|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjunit.framework.Assert
junit.framework.TestCase
junit.extensions.jfcunit.JFCTestCase
Extend this class to create new tests for Swing based interfaces. This is a subclass of TestCase, and therefore provides all of the facilities that you would normally expect from TestCase. An important point to realize about coding with Swing classes is that most methods are single threaded. This means that once a component has been shown, its methods should normally only be accessed by the AWT thread. While JFCTestCase runs its tests, the AWT thread is temporarily blocked to prevent multi-threading issues. The effect of this is that any method calls that you make on Swing components during a test will have no impact on the GUI, until the AWT Thread is restarted. This can occur in one of two ways: (1) The test runs to completion (2) The method "awtSleep" defined within this class is called.
Nested Class Summary | |
(package private) class |
JFCTestCase.JFCSecurityManager
Security manager which proxies all calls to the original security manager. |
Field Summary | |
private static long |
DEFAULTLOCKWAIT
Time to wait between lock attempts. |
private static long |
DEFAULTSLEEP
Default time to sleep. |
private boolean |
m_assertExit
Assert Exit was called. |
private boolean |
m_cont
Continuation flag. |
private java.lang.Throwable |
m_err
Exception thrown by testcase. |
private boolean |
m_exited
True if exited. |
private boolean |
m_forcedWait
Forcibly wait for full time. |
private TestHelper |
m_helper
The test helper to be used in testing. |
private java.lang.Object |
m_lock
Lock instance. |
private long |
m_lockWait
Lock Wait time. |
private boolean |
m_pausingAWT
Run the AWTThread free from interruption. |
private boolean |
m_runBare
True if runBare has begun. |
private long |
m_sleepTime
Time to sleep. |
private boolean |
m_waiting
Waiting flag. |
Fields inherited from class junit.framework.TestCase |
|
Constructor Summary | |
protected |
JFCTestCase()
Constructs a new JFCTestCase (default Constructor if using JUnit ver 3.8). |
|
JFCTestCase(java.lang.String name)
Constructs a new JFCTestCase. |
Method Summary | |
private void |
acquire()
Acquire AWT Thread Control. |
void |
awtSleep()
Suspends the test for up to a maximum period of time, and allows the AWT Thread to resume temporarily. |
void |
awtSleep(long sleepTime)
Suspends the test for up to the specified (maximum) period of time, and allows the AWT Thread to resume temporarily. |
protected java.lang.SecurityManager |
createNoExitSecurityManager()
This method creates a replacement for the default system manager. |
void |
flushAWT()
Flush all events currently in the AWTEventQueue. |
boolean |
getAssertExit()
Get the current value of the assertExit property. |
private boolean |
getContinue()
Returns the cont. |
protected java.lang.Throwable |
getError()
Returns the error. |
TestHelper |
getHelper()
Get the test helper. |
protected long |
getLockWait()
Get the current duration between checking locks. |
private long |
getSleepTime()
Returns the value of sleepTime. |
protected boolean |
hasError()
Checks of the current test case has any errors. |
boolean |
isAWTRunning()
Get the AWT state. |
protected void |
pause()
Pause the test until the Option Pane is acknowleged. |
void |
pauseAWT()
Pause the awt event queue until it is released by releaseAWT() or the end of the test is reached. |
private void |
release()
Release the AWT Thread Control. |
protected void |
resetError()
Resets the err to the default value (null). |
protected void |
resetForcedWait()
Resets the forcedWait to the default value (false). |
void |
resetSleepTime()
Resets the sleepTime to the default value (DEFAULTSLEEP). |
void |
resumeAWT()
Resume the awt event queue. |
void |
runBare()
Sets up, executes and then tears down a test. |
protected void |
runCode(java.lang.Runnable code)
Run the code of the test case. |
protected void |
runTest()
Executes a test. |
void |
setAssertExit(boolean aValue)
Set the value of the assert exit property. |
private void |
setContinue(boolean c)
Sets the cont. |
protected void |
setError(java.lang.Throwable error)
Sets the err. |
protected void |
setForcedWait(boolean forced)
Sets the forcedWait. |
void |
setHelper(TestHelper helper)
Sets the helper. |
protected void |
setLockWait(long duration)
Set the duration between checking the lock. |
void |
setSleepTime(long time)
Sets the sleepTime. |
protected void |
setUp()
Default setUp which does nothing. |
void |
sleep(long delay)
Suspends the test for a period of time, and allows the AWT Thread to resume during this period if it has been paused. |
protected void |
tearDown()
Default tearDown which does nothing. |
Methods inherited from class junit.framework.TestCase |
countTestCases, createResult, getName, run, run, setName, toString |
Methods inherited from class junit.framework.Assert |
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
private static final long DEFAULTLOCKWAIT
private static final long DEFAULTSLEEP
private java.lang.Object m_lock
private java.lang.Throwable m_err
private transient boolean m_assertExit
private TestHelper m_helper
private boolean m_cont
private boolean m_exited
private boolean m_runBare
private boolean m_forcedWait
private volatile boolean m_pausingAWT
private volatile boolean m_waiting
private long m_lockWait
private long m_sleepTime
Constructor Detail |
protected JFCTestCase()
public JFCTestCase(java.lang.String name)
name
- The name of the test.Method Detail |
public final void setAssertExit(boolean aValue)
aValue
- true if System.exit() should be asserted,
to allow the test case to complete.public final boolean getAssertExit()
public final void setHelper(TestHelper helper)
helper
- TestHelper to be used.public final TestHelper getHelper()
public final void setSleepTime(long time)
time
- New value for sleepTimepublic final void awtSleep()
public final void awtSleep(long sleepTime)
sleepTime
- The number of ms to sleeppublic final void flushAWT()
public final void pauseAWT()
public final void resetSleepTime()
public final void resumeAWT()
public final void sleep(long delay)
delay
- The minimum amount of time the test case thread
should be delayed.public boolean isAWTRunning()
public void runBare() throws java.lang.Throwable
java.lang.Throwable
- exceptions thrown by code.protected final void setError(java.lang.Throwable error)
error
- New value for err.protected final java.lang.Throwable getError()
protected final void setForcedWait(boolean forced)
forced
- New value for forcedWait.protected final void setLockWait(long duration)
duration
- in milliseconds. A value less
than or equal to zero will reset the lockwait to the
default value.protected final long getLockWait()
protected void setUp() throws java.lang.Exception
java.lang.Exception
- An instance of java.lang.Exception can be thrownprotected final java.lang.SecurityManager createNoExitSecurityManager()
protected final boolean hasError()
protected final void resetError()
protected final void resetForcedWait()
protected void runCode(java.lang.Runnable code) throws java.lang.Throwable
code
- Code which is to be executed.
java.lang.Throwable
- exceptions thrown by code.protected void runTest() throws java.lang.Throwable
java.lang.Throwable
- exceptions thrown by code.protected void tearDown() throws java.lang.Exception
java.lang.Exception
- An instance of java.lang.Exception can be thrownprivate void setContinue(boolean c)
c
- New value for cont.private boolean getContinue()
private long getSleepTime()
private void acquire() throws java.lang.InterruptedException
java.lang.InterruptedException
- Thrown when a thread is waiting, sleeping, or otherwise paused
for a long time and another thread interrupts it using the
interrupt
method in class Thread
.private void release()
protected void pause()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |