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:
DefinitionsPaneMemoryLeakTest, DefinitionsPaneTest, DrJavaPropertySetupTest, GlobalModelTestCase, LogTest, MainFrameTest, MultiThreadedTestCaseTest.Uncaught

public abstract class MultiThreadedTestCase
extends DrJavaTestCase

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

Version:
$Id: MultiThreadedTestCase.java 5175 2010-01-20 08:46:32Z mgricken $

Nested Class Summary
private static class MultiThreadedTestCase.ExceptionHandler
          Class that stores exceptions thrown in other threads so they can be rethrown in the main thread.
 
Nested classes/interfaces inherited from class junit.framework.TestCase
TestCase.WrappedException
 
Field Summary
protected static boolean _testFailed
          Flag to keep track of whether or not a test failed in another thread (not the testing thread).
 
Constructor Summary
MultiThreadedTestCase()
           
MultiThreadedTestCase(java.lang.String name)
           
 
Method Summary
static void join(java.lang.Thread t)
          Join with a thread, i.e.
protected static void listenerFail(java.lang.String s)
          This method prints the failure message to System.out and kills the JVM.
protected static void listenerFail(java.lang.Throwable t)
          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(java.lang.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(java.lang.String name)
Method Detail

setUp

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

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

tearDown

public void tearDown()
              throws java.lang.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:
java.lang.Exception

listenerFail

protected static void listenerFail(java.lang.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.


listenerFail

protected static void listenerFail(java.lang.Throwable t)
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(java.lang.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(java.lang.Object o)
Wait for a notify or notifyAll. If the wait is interrupted, an UnexpectedException is thrown.

Parameters:
o - object to wait for