net.groboclown.junit.jpda.v1
Class AsyncTest

java.lang.Object
  |
  +--junit.framework.Assert
        |
        +--net.groboclown.junit.jpda.v1.AsyncTest
Direct Known Subclasses:
MainTest.Test1

public abstract class AsyncTest
extends junit.framework.Assert

Specifies the test method to test the asynchronous methods against, and the options to support it.

The series of steps are as follows:

  1. The test() method is invoked in two separate threads on the remote VM.
  2. The method is stepped through until the isTestReady() method returns true.
  3. At this point, the method is continued to be stepped through until a method is invoked which is outside this class.
  4. When both threads are at this point, the methods are evaluated for thread safety.
  5. After the method returns, the test should repeat the method invokation until finishedTest() is invoked.
  6. The test() method should then shut down and exit.

Note that there is tight coupling between this class, and the AsyncTestWatcher class.


Inner Class Summary
 class AsyncTest.AsyncRunner
           
 
Field Summary
static String DEBUG_VM_ARG
           
private  Vector errors
           
private  boolean isTestReady1
           
private  boolean isTestReady2
           
private  boolean isTestRunning
           
private  AsyncTest.AsyncRunner r1
           
private  AsyncTest.AsyncRunner r2
           
private  Object sync
           
private  Thread t1
           
private  Thread t2
           
static String TEST_1_THREAD
           
static String TEST_2_THREAD
           
 
Constructor Summary
AsyncTest()
           
 
Method Summary
 void finishedTest()
           
 boolean isTestReady()
           
static void main(String[] args)
          Called from the command line.
abstract  void runTest()
           
 void setupTest()
           
 void shutdownTest()
           
 void startTest()
           
 void test()
          Only invoked by AsyncRunner.
 
Methods inherited from class junit.framework.Assert
assert, assert, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertNotNull, assertNotNull, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

TEST_1_THREAD

public static final String TEST_1_THREAD

TEST_2_THREAD

public static final String TEST_2_THREAD

DEBUG_VM_ARG

public static final String DEBUG_VM_ARG

sync

private Object sync

isTestRunning

private volatile boolean isTestRunning

isTestReady1

private volatile boolean isTestReady1

isTestReady2

private volatile boolean isTestReady2

errors

private Vector errors

r1

private AsyncTest.AsyncRunner r1

r2

private AsyncTest.AsyncRunner r2

t1

private Thread t1

t2

private Thread t2
Constructor Detail

AsyncTest

public AsyncTest()
Method Detail

main

public static void main(String[] args)
                 throws Exception
Called from the command line.
Parameters:
args - the command line arguments

startTest

public final void startTest()

finishedTest

public final void finishedTest()

isTestReady

public final boolean isTestReady()

test

public final void test()
Only invoked by AsyncRunner.

setupTest

public void setupTest()

shutdownTest

public void shutdownTest()

runTest

public abstract void runTest()


Written under the LGPL