edu.rice.cs.drjava.model.debug
Class DebugTestCase

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
                  extended by edu.rice.cs.drjava.model.GlobalModelTestCase
                      extended by edu.rice.cs.drjava.model.debug.DebugTestCase
All Implemented Interfaces:
junit.framework.Test
Direct Known Subclasses:
JPDADebugTestCase

public abstract class DebugTestCase
extends GlobalModelTestCase

This class contains the basic fields and methods that are necessary for any test file that needs to use the JPDADebugger.

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

Nested Class Summary
protected  class DebugTestCase.BreakpointTestListener
          DebugTestListener for all tests setting breakpoints.
protected  class DebugTestCase.DebugStartAndStopListener
          DebugTestListener for all tests starting the debugger.
protected  class DebugTestCase.DebugTestListener
          Listens to events from the debugger to ensure that they happen at the correct times.
protected  class DebugTestCase.InterpretListener
          TestListener that listens for an interpretation to end, and then notifies anyone waiting on it.
protected  class DebugTestCase.StepTestListener
          DebugTestListener for all tests using the stepper.
 
Nested classes/interfaces inherited from class edu.rice.cs.drjava.model.GlobalModelTestCase
GlobalModelTestCase.CancelingSelector, GlobalModelTestCase.CompileShouldFailListener, GlobalModelTestCase.CompileShouldSucceedListener, GlobalModelTestCase.FileMovedWarningException, GlobalModelTestCase.FileSelector, GlobalModelTestCase.InteractionListener, GlobalModelTestCase.JUnitNonTestListener, GlobalModelTestCase.JUnitTestListener, GlobalModelTestCase.OpenWarningException, GlobalModelTestCase.OverwriteException, GlobalModelTestCase.SaveCopyFileSelector, GlobalModelTestCase.TestGlobalModel, GlobalModelTestCase.TestListener, GlobalModelTestCase.WarningFileSelector
 
Nested classes/interfaces inherited from class junit.framework.TestCase
junit.framework.TestCase.WrappedException
 
Field Summary
protected  Debugger _debugger
           
protected  Object _notifierLock
           
protected  int _pendingNotifies
           
protected static String CLASS_WITH_STATIC_FIELD
           
protected static String DEBUG_CLASS
           
protected static String DEBUG_CLASS_WITH_PACKAGE
           
protected static String INNER_CLASS_WITH_LOCAL_VARS
           
protected static String MONKEY_CLASS
           
protected static String MONKEY_STATIC_STUFF
           
protected static String MONKEY_WITH_INNER_CLASS
           
protected static String SUSPEND_CLASS
           
protected static String THREAD_DEATH_CLASS
           
 
Fields inherited from class edu.rice.cs.drjava.model.GlobalModelTestCase
_doc, _interactionsController, _log, _model, _tempDir, BAR_TEXT, BAZ_TEXT, FOO_MISSING_CLOSE_TEXT, FOO_PACKAGE_AFTER_IMPORT, FOO_PACKAGE_AS_FIELD, FOO_PACKAGE_AS_FIELD_2, FOO_PACKAGE_AS_PART_OF_FIELD, FOO_PACKAGE_INSIDE_CLASS, FOO_TEXT
 
Fields inherited from class edu.rice.cs.drjava.model.MultiThreadedTestCase
_testFailed
 
Constructor Summary
DebugTestCase()
           
 
Method Summary
protected  void _asyncDoSetCurrentThread(DebugThreadData th)
          Sets the current thread in a new thread to avoid being notified of events before we start waiting for them.
protected  void _asyncResume()
          Resumes the debugger asynchronously so as to aovid getting notified before we start waiting for notifies
protected  void _asyncStep(Debugger.StepType type)
          Resumes the debugger asynchronously so as to avoid getting notified before we start waiting for notifies.
protected  void _doSetCurrentThread(DebugThreadData t)
          Sets the current debugger thread to the specified thread t.
protected  void _notifyLock()
          Notifies _notifierLock if the after the notify count has expired.
protected  void _setPendingNotifies(int n)
          Ensures that the given object will wait for n notifications.
protected  void _shutdownAndWaitForInteractionEnded()
          Cleanly shuts down the debugger, waiting for a suspended interaction to complete.
protected  void _shutdownWithoutSuspendedInteraction()
          Cleanly shuts down the debugger, without having to wait for a suspended interaction to complete.
protected  OpenDefinitionsDocument _startupDebugger(File file, String classText)
          Cleanly starts the debugger with a newly compiled file saved in a temporary directory.
protected  OpenDefinitionsDocument _startupDebugger(String fileName, String classText)
          Cleanly starts the debugger with a newly compiled file saved in a temporary directory.
 void setUp()
          Sets up the debugger for each test.
 void tearDown()
          Cleans up the debugger after each test.
 
Methods inherited from class edu.rice.cs.drjava.model.GlobalModelTestCase
assertCompileErrorsPresent, assertCompileErrorsPresent, assertContents, assertInteractionsContains, assertInteractionsDoesNotContain, assertInteractionsDoesNotMatch, assertInteractionsMatches, assertLength, assertModified, assertNumOpenDocs, changeDocumentText, classForJava, createFile, doCompile, doCompile, getCompilerErrorString, getInteractionsText, interpret, interpretIgnoreResult, safeLoadHistory, safeSaveHistory, saveAllFiles, saveFile, saveFileAs, saveFileCopy, setupDocument, tempDirectory, tempFile, tempFile, testStartCompile, writeToNewTempFile
 
Methods inherited from class edu.rice.cs.drjava.model.MultiThreadedTestCase
join, listenerFail, listenerFail, wait
 
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

_pendingNotifies

protected volatile int _pendingNotifies

_notifierLock

protected final Object _notifierLock

_debugger

protected volatile Debugger _debugger

DEBUG_CLASS

protected static final String DEBUG_CLASS
See Also:
Constant Field Values

DEBUG_CLASS_WITH_PACKAGE

protected static final String DEBUG_CLASS_WITH_PACKAGE
See Also:
Constant Field Values

SUSPEND_CLASS

protected static final String SUSPEND_CLASS
See Also:
Constant Field Values

MONKEY_CLASS

protected static final String MONKEY_CLASS
See Also:
Constant Field Values

MONKEY_WITH_INNER_CLASS

protected static final String MONKEY_WITH_INNER_CLASS
See Also:
Constant Field Values

INNER_CLASS_WITH_LOCAL_VARS

protected static final String INNER_CLASS_WITH_LOCAL_VARS
See Also:
Constant Field Values

CLASS_WITH_STATIC_FIELD

protected static final String CLASS_WITH_STATIC_FIELD
See Also:
Constant Field Values

MONKEY_STATIC_STUFF

protected static final String MONKEY_STATIC_STUFF
See Also:
Constant Field Values

THREAD_DEATH_CLASS

protected static final String THREAD_DEATH_CLASS
See Also:
Constant Field Values
Constructor Detail

DebugTestCase

public DebugTestCase()
Method Detail

setUp

public void setUp()
           throws Exception
Sets up the debugger for each test.

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

tearDown

public void tearDown()
              throws Exception
Cleans up the debugger after each test.

Overrides:
tearDown in class GlobalModelTestCase
Throws:
Exception

_setPendingNotifies

protected void _setPendingNotifies(int n)
                            throws InterruptedException
Ensures that the given object will wait for n notifications. Callers must call o.wait() AFTER this is called. Use _notifyLock instead of o.notify() when using this method. Only one object (o) can use this synchronization protocol at a time, since it uses a field to store the number of pending notifications.

Parameters:
n - The number of times to be "notified" through _notifyLock
Throws:
InterruptedException

_notifyLock

protected void _notifyLock()
Notifies _notifierLock if the after the notify count has expired. See _setPendingNotifies.


_startupDebugger

protected OpenDefinitionsDocument _startupDebugger(String fileName,
                                                   String classText)
                                            throws Exception
Cleanly starts the debugger with a newly compiled file saved in a temporary directory. Assumes that the file will compile successfully.

Parameters:
fileName - Name of the file to save in a temp directory
classText - String containing the code for the class to compile
Returns:
OpenDefinitionsDocument containing the compiled source file
Throws:
Exception

_startupDebugger

protected OpenDefinitionsDocument _startupDebugger(File file,
                                                   String classText)
                                            throws Exception
Cleanly starts the debugger with a newly compiled file saved in a temporary directory. Assumes that the file will compile successfully.

Parameters:
file - File to save the class in
classText - String containing the code for the class to compile
Returns:
OpenDefinitionsDocument containing the compiled source file
Throws:
Exception

_shutdownWithoutSuspendedInteraction

protected void _shutdownWithoutSuspendedInteraction()
                                             throws Exception
Cleanly shuts down the debugger, without having to wait for a suspended interaction to complete.

Throws:
Exception

_shutdownAndWaitForInteractionEnded

protected void _shutdownAndWaitForInteractionEnded()
                                            throws Exception
Cleanly shuts down the debugger, waiting for a suspended interaction to complete.

Throws:
Exception

_doSetCurrentThread

protected void _doSetCurrentThread(DebugThreadData t)
                            throws DebugException
Sets the current debugger thread to the specified thread t.

Throws:
DebugException

_asyncStep

protected void _asyncStep(Debugger.StepType type)
Resumes the debugger asynchronously so as to avoid getting notified before we start waiting for notifies.


_asyncResume

protected void _asyncResume()
Resumes the debugger asynchronously so as to aovid getting notified before we start waiting for notifies


_asyncDoSetCurrentThread

protected void _asyncDoSetCurrentThread(DebugThreadData th)
Sets the current thread in a new thread to avoid being notified of events before we start waiting for them.