edu.rice.cs.drjava.model
Class MultiThreadedTestCase

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by edu.rice.cs.drjava.DrJavaTestCase
              extended by edu.rice.cs.drjava.model.MultiThreadedTestCase
All Implemented Interfaces:
Test
Direct Known Subclasses:
DefinitionsPaneTest, GlobalModelTestCase, LogTest, MainFrameTest, MultiThreadedTestCaseTest.Uncaught, ProjectMenuTest

public abstract class MultiThreadedTestCase
extends DrJavaTestCase

TestCase which can fail if another thread causes an error or failure.

Version:
$Id: MultiThreadedTestCase.java 4691 2008-12-02 23:33:27Z dlsmith $

Field Summary
protected static boolean _testFailed
          Flag to keep track of whether or not a test failed in another thread (not the testing thread).
 
Fields inherited from class edu.rice.cs.drjava.DrJavaTestCase
TEST_DRJAVA_CONFIG_PROPERTY
 
Constructor Summary
MultiThreadedTestCase()
           
MultiThreadedTestCase(String name)
           
 
Method Summary
static void join(Thread t)
          Join with a thread, i.e.
protected static void listenerFail(String s)
          This method prints the failure message to System.out and kills the JVM.
 void setUp()
          Initialize test state to not failed.
 void tearDown()
          If any test failed, print a message saying that some test failed in another thread (not the testing thread).
static void wait(Object o)
          Wait for a notify or notifyAll.
 
Methods inherited from class edu.rice.cs.drjava.DrJavaTestCase
setConfigSetting, setDocText
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, 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, failNotEquals, failNotSame, failSame, format
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_testFailed

protected static volatile boolean _testFailed
Flag to keep track of whether or not a test failed in another thread (not the testing thread).

Constructor Detail

MultiThreadedTestCase

public MultiThreadedTestCase()

MultiThreadedTestCase

public MultiThreadedTestCase(String name)
Method Detail

setUp

public void setUp()
           throws Exception
Initialize test state to not failed.

Overrides:
setUp in class DrJavaTestCase
Throws:
Exception - This convention is mandated by the JUnit TestCase class which is an ancestor of this class.

tearDown

public void tearDown()
              throws Exception
If any test failed, print a message saying that some test failed in another thread (not the testing thread).

Overrides:
tearDown in class DrJavaTestCase
Throws:
Exception

listenerFail

protected static void listenerFail(String s)
This method prints the failure message to System.out and kills the JVM. Just calling fail() doesn't always cause the test to fail, because the listener is often called from another thread.


join

public static void join(Thread t)
Join with a thread, i.e. continue only after that thread has terminated. If the join is interrupted, an UnexpectedException is thrown.

Parameters:
t - thread to join with

wait

public static void wait(Object o)
Wait for a notify or notifyAll. If the wait is interrupted, an UnexpectedException is thrown.

Parameters:
o - object to wait for