edu.rice.cs.drjava.model.repl
Class InteractionsModelTest

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.repl.InteractionsModelTest
All Implemented Interfaces:
Test

public final class InteractionsModelTest
extends DrJavaTestCase

Tests the functionality of an InteractionsModel. The synchronization in this class is abominable; many interactions document locking and "event queue only" invariants are violated. The ubiquitous workaround is to call Utilities.clearEventQueue(). TODO: completely revise this class.

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

Nested Class Summary
static class InteractionsModelTest.TestInteractionsModel
          A generic InteractionsModel for testing purposes.
 
Field Summary
protected  InteractionsDJDocument _adapter
           
protected  InteractionsModel _model
           
 
Fields inherited from class edu.rice.cs.drjava.DrJavaTestCase
TEST_DRJAVA_CONFIG_PROPERTY
 
Constructor Summary
InteractionsModelTest(String name)
           
 
Method Summary
protected  void _assertMainTransformation(String typed, String expected)
          Asserts that the given string typed by the user of the form "java classname" is transformed to the given expected main method invocation.
protected  void _assertProcessedContents(String typed, String expected)
          Asserts that the given string typed by the user is processed to become the given expected string for an interpretation.
protected  void assertReplThrewContinuationException(String code)
          Not a test method, Assumes that _model is an IncompleteInputInteractionsModel.
protected  void assertReplThrewSyntaxException(String code)
          Not a test method, Assumes that _model is an IncompleteInputInteractionsModel.
 void tearDown()
          Clean up for every test case.
 void testDebugPort()
          Tests that a debug port can be generated.
 void testInteractionsHistoryStoredCorrectly()
          Tests that the interactions history is stored correctly.
 void testInterpretCurrentInteraction()
          Tests that the correct text is returned when interpreting.
 void testInterpretCurrentInteractionWithIncompleteInput()
           
 void testInterpretJavaArguments()
          Tests that "java Classname [args]" runs the class's main method, with simple delimited arguments.
 void testInterpretJavaEscapedArgs()
          Tests that escaped characters just return the character itself.
 void testInterpretJavaQuotedEscapedArgs()
          Tests that within a quote, everything is correctly escaped.
 void testInterpretJavaSingleQuotedArgs()
          Tests that single quotes can be used as argument delimiters.
 void testScriptLoading()
          Tests that an interactions history can be loaded in as a script.
 void testSetChangeInputListener()
          Tests that setting and changing an input listener works correctly.
 
Methods inherited from class edu.rice.cs.drjava.DrJavaTestCase
setConfigSetting, setDocText, setUp
 
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

_adapter

protected InteractionsDJDocument _adapter

_model

protected InteractionsModel _model
Constructor Detail

InteractionsModelTest

public InteractionsModelTest(String name)
Method Detail

tearDown

public void tearDown()
              throws Exception
Description copied from class: DrJavaTestCase
Clean up for every test case. Only used in unit tests. Added because Windows would intermittently throw a java.util.concurrent.RejectedExecutionException during cleanup.

Overrides:
tearDown in class DrJavaTestCase
Throws:
Exception

_assertProcessedContents

protected void _assertProcessedContents(String typed,
                                        String expected)
                                 throws Exception
Asserts that the given string typed by the user is processed to become the given expected string for an interpretation.

Parameters:
typed - A string typed by the user
expected - What the processor should return
Throws:
Exception

_assertMainTransformation

protected void _assertMainTransformation(String typed,
                                         String expected)
Asserts that the given string typed by the user of the form "java classname" is transformed to the given expected main method invocation.

Parameters:
typed - the "java classname args ..." typed by the user
expected - the expected main class call

testInterpretCurrentInteraction

public void testInterpretCurrentInteraction()
                                     throws Exception
Tests that the correct text is returned when interpreting.

Throws:
Exception

testInterpretCurrentInteractionWithIncompleteInput

public void testInterpretCurrentInteractionWithIncompleteInput()
                                                        throws EditDocumentException,
                                                               InterruptedException,
                                                               RemoteException
Throws:
EditDocumentException
InterruptedException
RemoteException

assertReplThrewContinuationException

protected void assertReplThrewContinuationException(String code)
                                             throws EditDocumentException,
                                                    InterruptedException
Not a test method, Assumes that _model is an IncompleteInputInteractionsModel.

Throws:
EditDocumentException
InterruptedException

assertReplThrewSyntaxException

protected void assertReplThrewSyntaxException(String code)
                                       throws EditDocumentException,
                                              InterruptedException
Not a test method, Assumes that _model is an IncompleteInputInteractionsModel.

Throws:
EditDocumentException
InterruptedException

testInterpretJavaArguments

public void testInterpretJavaArguments()
Tests that "java Classname [args]" runs the class's main method, with simple delimited arguments.


testInterpretJavaEscapedArgs

public void testInterpretJavaEscapedArgs()
Tests that escaped characters just return the character itself. Escaped whitespace is considered a character, not a delimiter. (This is how Unix behaves.) not currently enforcing any behavior for a simple implementation using a StreamTokenizer


testInterpretJavaQuotedEscapedArgs

public void testInterpretJavaQuotedEscapedArgs()
Tests that within a quote, everything is correctly escaped. (Special characters are passed to the program correctly.)


testInterpretJavaSingleQuotedArgs

public void testInterpretJavaSingleQuotedArgs()
Tests that single quotes can be used as argument delimiters.


testDebugPort

public void testDebugPort()
                   throws IOException
Tests that a debug port can be generated.

Throws:
IOException

testScriptLoading

public void testScriptLoading()
                       throws Exception
Tests that an interactions history can be loaded in as a script.

Throws:
Exception

testSetChangeInputListener

public void testSetChangeInputListener()
Tests that setting and changing an input listener works correctly.


testInteractionsHistoryStoredCorrectly

public void testInteractionsHistoryStoredCorrectly()
                                            throws Exception
Tests that the interactions history is stored correctly. See bug # 992455

Throws:
Exception