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

java.lang.Object
  |
  +--junit.framework.Assert
        |
        +--junit.framework.TestCase
              |
              +--edu.rice.cs.drjava.model.GlobalModelTestCase
                    |
                    +--edu.rice.cs.drjava.model.debug.DebugTest
All Implemented Interfaces:
OptionConstants, Test

public class DebugTest
extends GlobalModelTestCase
implements OptionConstants

Tests the JPDA-based debugger.

Version:
$Id: DebugTest.java,v 1.9 2002/09/13 22:55:34 csreis Exp $

Inner Class Summary
(package private)  class DebugTest.BreakpointTestListener
          Test Listener for all tests setting breakpoints.
(package private)  class DebugTest.DebugStartAndStopListener
          Test Listener for all tests starting the debugger.
(package private)  class DebugTest.DebugTestListener
          Listens to events from the debugger to ensure that they happen at the correct times.
(package private)  class DebugTest.StepTestListener
          TestListener for all tests using the stepper.
 
Inner classes inherited from class edu.rice.cs.drjava.model.GlobalModelTestCase
GlobalModelTestCase.CancelingSelector, GlobalModelTestCase.CompileShouldFailListener, GlobalModelTestCase.CompileShouldSucceedListener, GlobalModelTestCase.FileSelector, GlobalModelTestCase.OpenWarningException, GlobalModelTestCase.OverwriteException, GlobalModelTestCase.TestListener, GlobalModelTestCase.WarningFileSelector
 
Field Summary
protected  DebugManager _debugManager
           
private  Object _notifierLock
           
private  int _pendingNotifies
           
private  gj.util.Vector _userSourcePath
           
private  Boolean _userStepDrJava
           
private  Boolean _userStepInterpreter
           
private  Boolean _userStepJava
           
protected static String DEBUG_CLASS
           
protected static String DEBUG_CLASS_WITH_PACKAGE
           
(package private)  boolean printEvents
           
(package private)  boolean printMessages
           
 
Fields inherited from class edu.rice.cs.drjava.model.GlobalModelTestCase
_model, _originalModel, _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 junit.framework.TestCase
fName
 
Fields inherited from interface edu.rice.cs.drjava.config.OptionConstants
COMPILER_ERROR_COLOR, DEBUG_BREAKPOINT_COLOR, DEBUG_SHOW_THREADS, DEBUG_SOURCEPATH, DEBUG_STEP_DRJAVA, DEBUG_STEP_INTERPRETER, DEBUG_STEP_JAVA, DEBUG_THREAD_COLOR, DEFINITIONS_BACKGROUND_COLOR, DEFINITIONS_COMMENT_COLOR, DEFINITIONS_DOUBLE_QUOTED_COLOR, DEFINITIONS_KEYWORD_COLOR, DEFINITIONS_MATCH_COLOR, DEFINITIONS_NORMAL_COLOR, DEFINITIONS_NUMBER_COLOR, DEFINITIONS_SINGLE_QUOTED_COLOR, DEFINITIONS_TYPE_COLOR, EXTRA_CLASSPATH, FONT_DOCLIST, FONT_MAIN, FONT_TOOLBAR, HISTORY_MAX_SIZE, INDENT_LEVEL, INTERACTIONS_EXIT_PROMPT, JAVAC_ALLOW_ASSERT, JAVAC_LOCATION, JSR14_COLLECTIONSPATH, JSR14_LOCATION, KEY_BACKWARD, KEY_BEGIN_DOCUMENT, KEY_BEGIN_LINE, KEY_CLOSE_FILE, KEY_COMPILE, KEY_COMPILE_ALL, KEY_COPY, KEY_CUT, KEY_CUT_LINE, KEY_DEBUG_BREAKPOINT_TOGGLE, KEY_DEBUG_MODE_TOGGLE, KEY_DEBUG_RESUME, KEY_DEBUG_STEP_INTO, KEY_DEBUG_STEP_OUT, KEY_DEBUG_STEP_OVER, KEY_DELETE_NEXT, KEY_DELETE_PREVIOUS, KEY_DOWN, KEY_END_DOCUMENT, KEY_END_LINE, KEY_FIND_NEXT, KEY_FIND_REPLACE, KEY_FORWARD, KEY_GOTO_LINE, KEY_NEW_FILE, KEY_NEXT_DOCUMENT, KEY_NEXT_WORD, KEY_OPEN_FILE, KEY_PAGE_DOWN, KEY_PAGE_UP, KEY_PASTE, KEY_PREVIOUS_DOCUMENT, KEY_PREVIOUS_WORD, KEY_PRINT, KEY_PRINT_PREVIEW, KEY_QUIT, KEY_REDO, KEY_SAVE_FILE, KEY_SAVE_FILE_AS, KEY_SELECT_ALL, KEY_UNDO, KEY_UP, LINEENUM_ENABLED, mask, QUIT_PROMPT, RECENT_FILES, RECENT_FILES_MAX_SIZE, TOOLBAR_ICONS_ENABLED, TOOLBAR_TEXT_ENABLED, WORKING_DIRECTORY
 
Constructor Summary
DebugTest(String name)
          Constructor.
 
Method Summary
private  void _assertInteractionContainsHelper(String text, boolean shouldContain)
           
protected  OpenDefinitionsDocument _doCompile(String text, File file)
          Compiles a new file with the given text.
protected  void _notifyObject(Object o)
          Notifies the given object if the notify count has expired.
protected  void _waitForNotifies(int n)
          Ensures that the given object will wait for n notifications.
protected  void assertInteractionsContains(String text)
          Asserts that the given string exists in the Interactions Document.
protected  void assertInteractionsDoesNotContain(String text)
          Asserts that the given string does not exist in the Interactions Document.
protected  String getInteractionsText()
          Returns the current contents of the interactions document
 void setUp()
          Setup for each test case, which does the following.
static Test suite()
          Creates a test suite for JUnit to run.
 void tearDown()
          Teardown for each test case, which recursively deletes the temporary directory created in setUp.
 void testBreakpoints()
          Tests that breakpoints behave correctly.
 void testBreakpointsAndStepsInNonPublicClasses()
          Tests that breakpoints behave correctly.
 void testDebugSourcepath()
          Tests that the sourcepath config option properly adds files to the search directories.
 void testGetPackageDir()
          Tests the utility function to get a relative directory for a package.
 void testStepInto()
          Tests that breakpoints and steps behave correctly.
 void testStepOut()
          Tests that stepping out of a method behaves correctly.
 void testStepOverWithPackage()
          Tests that stepping works in a public class with a package
 
Methods inherited from class edu.rice.cs.drjava.model.GlobalModelTestCase
assertCompileErrorsPresent, assertCompileErrorsPresent, assertContents, assertLength, assertModified, assertNumOpenDocs, changeDocumentText, classForJava, createFile, createModel, interpret, interpretIgnoreResult, setupDocument, tempDirectory, tempFile, tempFile, writeToNewTempFile
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, name, run, run, runBare, runTest, setName, toString
 
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, wait, wait, wait
 

Field Detail

printEvents

final boolean printEvents

printMessages

final boolean printMessages

_pendingNotifies

private int _pendingNotifies

_notifierLock

private Object _notifierLock

_userSourcePath

private gj.util.Vector _userSourcePath

_userStepJava

private Boolean _userStepJava

_userStepInterpreter

private Boolean _userStepInterpreter

_userStepDrJava

private Boolean _userStepDrJava

DEBUG_CLASS

protected static final String DEBUG_CLASS

DEBUG_CLASS_WITH_PACKAGE

protected static final String DEBUG_CLASS_WITH_PACKAGE

_debugManager

protected DebugManager _debugManager
Constructor Detail

DebugTest

public DebugTest(String name)
Constructor.
Parameters:
String - name
Method Detail

suite

public static Test suite()
Creates a test suite for JUnit to run.
Returns:
a test suite based on the methods in this class

setUp

public void setUp()
           throws IOException
Description copied from class: GlobalModelTestCase
Setup for each test case, which does the following.
  1. Creates a new GlobalModel in GlobalModelTestCase._model for each test case run.
  2. Creates a new temporary directory in GlobalModelTestCase._tempDir.
Overrides:
setUp in class GlobalModelTestCase

tearDown

public void tearDown()
              throws IOException
Description copied from class: GlobalModelTestCase
Teardown for each test case, which recursively deletes the temporary directory created in setUp.
Overrides:
tearDown in class GlobalModelTestCase

_waitForNotifies

protected void _waitForNotifies(int n)
                         throws InterruptedException
Ensures that the given object will wait for n notifications. Callers must call o.wait() AFTER this is called. (We can't call it here, because then the synchronized _notifyObject method can never be entered.) Use _notifyObject instead of o.notify() when using this method. Only one object (o) can use this 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 _notifyObject

_notifyObject

protected void _notifyObject(Object o)
Notifies the given object if the notify count has expired. See _waitForNotifies

_doCompile

protected OpenDefinitionsDocument _doCompile(String text,
                                             File file)
                                      throws IOException,
                                             BadLocationException,
                                             InterruptedException
Compiles a new file with the given text.

assertInteractionsContains

protected void assertInteractionsContains(String text)
                                   throws BadLocationException
Asserts that the given string exists in the Interactions Document.

assertInteractionsDoesNotContain

protected void assertInteractionsDoesNotContain(String text)
                                         throws BadLocationException
Asserts that the given string does not exist in the Interactions Document.

_assertInteractionContainsHelper

private void _assertInteractionContainsHelper(String text,
                                              boolean shouldContain)
                                       throws BadLocationException

getInteractionsText

protected String getInteractionsText()
                              throws BadLocationException
Returns the current contents of the interactions document

testBreakpoints

public void testBreakpoints()
                     throws DebugException,
                            BadLocationException,
                            IOException,
                            InterruptedException
Tests that breakpoints behave correctly.

testStepInto

public void testStepInto()
                  throws DebugException,
                         BadLocationException,
                         IOException,
                         InterruptedException
Tests that breakpoints and steps behave correctly.

testStepOut

public void testStepOut()
                 throws DebugException,
                        BadLocationException,
                        IOException,
                        InterruptedException
Tests that stepping out of a method behaves correctly.

testStepOverWithPackage

public void testStepOverWithPackage()
                             throws DebugException,
                                    BadLocationException,
                                    IOException,
                                    InterruptedException
Tests that stepping works in a public class with a package

testDebugSourcepath

public void testDebugSourcepath()
                         throws DebugException,
                                BadLocationException,
                                IOException,
                                InterruptedException
Tests that the sourcepath config option properly adds files to the search directories.

testBreakpointsAndStepsInNonPublicClasses

public void testBreakpointsAndStepsInNonPublicClasses()
                                               throws DebugException,
                                                      BadLocationException,
                                                      IOException,
                                                      InterruptedException
Tests that breakpoints behave correctly.

testGetPackageDir

public void testGetPackageDir()
Tests the utility function to get a relative directory for a package.