edu.rice.cs.drjava.model.junit
Class JUnitEventNotifier

java.lang.Object
  extended by edu.rice.cs.drjava.model.EventNotifier<JUnitListener>
      extended by edu.rice.cs.drjava.model.junit.JUnitEventNotifier
All Implemented Interfaces:
JUnitListener

 class JUnitEventNotifier
extends EventNotifier<JUnitListener>
implements JUnitListener

Keeps track of all listeners to a JUnitModel, and has the ability to notify them of some event.

This class has a specific role of managing JUnitListeners. Other classes with similar names use similar code to perform the same function for other interfaces, e.g. InteractionsEventNotifier and GlobalEventNotifier. These classes implement the appropriate interface definition so that they can be used transparently as composite packaging for a particular listener interface.

Components which might otherwise manage their own list of listeners use EventNotifiers instead to simplify their internal implementation. Notifiers should therefore be considered a private implementation detail of the components, and should not be used directly outside of the "host" component.

All methods in this class must use the synchronization methods provided by ReaderWriterLock. This ensures that multiple notifications (reads) can occur simultaneously, but only one thread can be adding or removing listeners (writing) at a time, and no reads can occur during a write.

No methods on this class should be synchronized using traditional Java synchronization!

Version:
$Id: JUnitEventNotifier.java 5236 2010-04-27 01:43:36Z mgricken $

Field Summary
 
Fields inherited from class edu.rice.cs.drjava.model.EventNotifier
_listeners, _lock
 
Constructor Summary
JUnitEventNotifier()
           
 
Method Summary
 void addListener(JUnitListener jul)
          Adds a listener to the notifier.
 void classFileError(ClassFileError e)
          Called when JUnit encounters an illegal class file.
 void compileBeforeJUnit(CompilerListener cl, List<OpenDefinitionsDocument> outOfSync)
          Called before JUnit is started by the DefaultJUnitModel.
 void junitClassesStarted()
          Called after junitClasses is started by the GlobalModel.
 void junitEnded()
          Called after JUnit is finished running tests.
 void junitStarted()
          Called after junit/junitAll is started by the GlobalModel.
 void junitSuiteStarted(int numTests)
          Called to indicate that a suite of tests has started running.
 void junitTestEnded(String name, boolean wasSuccessful, boolean causedError)
          Called when a particular test has ended.
 void junitTestStarted(String name)
          Called when a particular test is started.
 void nonTestCase(boolean isTestAll, boolean didCompileFail)
          Called when trying to test a non-TestCase class.
 
Methods inherited from class edu.rice.cs.drjava.model.EventNotifier
removeAllListeners, removeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JUnitEventNotifier

JUnitEventNotifier()
Method Detail

addListener

public void addListener(JUnitListener jul)
Description copied from class: EventNotifier
Adds a listener to the notifier.

Overrides:
addListener in class EventNotifier<JUnitListener>
Parameters:
jul - a listener that reacts on events

nonTestCase

public void nonTestCase(boolean isTestAll,
                        boolean didCompileFail)
Called when trying to test a non-TestCase class.

Specified by:
nonTestCase in interface JUnitListener
Parameters:
isTestAll - whether or not it was a use of the test all button
didCompileFail - whether or not a compile before this JUnit attempt failed

classFileError

public void classFileError(ClassFileError e)
Description copied from interface: JUnitListener
Called when JUnit encounters an illegal class file.

Specified by:
classFileError in interface JUnitListener
Parameters:
e - the error or exception thrown by loading and resolving f.

compileBeforeJUnit

public void compileBeforeJUnit(CompilerListener cl,
                               List<OpenDefinitionsDocument> outOfSync)
Called before JUnit is started by the DefaultJUnitModel.

Specified by:
compileBeforeJUnit in interface JUnitListener

junitStarted

public void junitStarted()
Called after junit/junitAll is started by the GlobalModel.

Specified by:
junitStarted in interface JUnitListener

junitClassesStarted

public void junitClassesStarted()
Called after junitClasses is started by the GlobalModel.

Specified by:
junitClassesStarted in interface JUnitListener

junitSuiteStarted

public void junitSuiteStarted(int numTests)
Called to indicate that a suite of tests has started running.

Specified by:
junitSuiteStarted in interface JUnitListener
Parameters:
numTests - The number of tests in the suite to be run.

junitTestStarted

public void junitTestStarted(String name)
Called when a particular test is started.

Specified by:
junitTestStarted in interface JUnitListener
Parameters:
name - The name of the test being started.

junitTestEnded

public void junitTestEnded(String name,
                           boolean wasSuccessful,
                           boolean causedError)
Called when a particular test has ended.

Specified by:
junitTestEnded in interface JUnitListener
Parameters:
name - The name of the test that has ended.
wasSuccessful - Whether the test passed or not.
causedError - If not successful, whether the test caused an error or simply failed.

junitEnded

public void junitEnded()
Called after JUnit is finished running tests.

Specified by:
junitEnded in interface JUnitListener