edu.rice.cs.drjava.model.definitions
Class DefinitionsDocumentTest

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.definitions.DefinitionsDocumentTest
All Implemented Interfaces:
ReducedModelStates, Test

public final class DefinitionsDocumentTest
extends DrJavaTestCase
implements ReducedModelStates

Tests the functionality of the definitions document.

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

Field Summary
protected  String C_PUBLIC_EI_TEXT
           
protected  String C_PUBLIC_IE_TEXT
           
protected  String CEI_TEXT
           
protected  String CIE_TEXT
           
protected  String E_PUBLIC_CI_TEXT
           
protected  String E_PUBLIC_IC_TEXT
           
protected  String ECI_TEXT
           
protected  String EIC_TEXT
           
protected  String I_PUBLIC_CE_TEXT
           
protected  String I_PUBLIC_EC_TEXT
           
protected  String ICE_TEXT
           
protected  String IEC_TEXT
           
protected  String NESTED_CLASSES_TEXT
           
protected  String NEWLINE
           
protected  String PUBLIC_CEI_TEXT
           
protected  String PUBLIC_CIE_TEXT
           
protected  String PUBLIC_ECI_TEXT
           
protected  String PUBLIC_EIC_TEXT
           
protected  String PUBLIC_ICE_TEXT
           
protected  String PUBLIC_IEC_TEXT
           
 
Fields inherited from class edu.rice.cs.drjava.DrJavaTestCase
TEST_DRJAVA_CONFIG_PROPERTY
 
Fields inherited from interface edu.rice.cs.drjava.model.definitions.reducedmodel.ReducedModelStates
FREE, INSIDE_BLOCK_COMMENT, INSIDE_DOUBLE_QUOTE, INSIDE_LINE_COMMENT, INSIDE_SINGLE_QUOTE, STUTTER
 
Constructor Summary
DefinitionsDocumentTest(String name)
          Standard constructor.
 
Method Summary
protected  void setUp()
          Create a definitions document to work with.
static Test suite()
          Create a test suite for JUnit to run.
 void testAnonymousClassIndex()
          Test finding anonymous class index on document.
 void testExactClassName()
          Test exact class name-finding on document.
 void testgetMainClassName()
          Test getMainClassName.
 void textCompoundUndoManager()
          Test method for CompoundUndoManager.
 void textDeleteDoc()
          Test removal of text.
 void textGetColumn1()
          Tests returning the current column in the document.
 void textGetColumn2()
          Tests returning the current column in the document.
 void textGetLine1()
          Test returning second line in a two-line document.
 void textGetLine2()
          Test going to a specific line.
 void textGetLine3()
          Test going to the fourth line in a four line document.
 void textGetLine4()
          Test going to a line beyond the number of lines in a document just goes to the end of the file.
 void textGetLine5()
          Test going to the first line of an empty document doesn't do anything funny.
 void textGetLine6()
          Test going to a line that is greater than the line count of an empty document just keeps you in your current location.
 void textGetLine7()
          Test that going to a line within the document's line count sets the current position to the first character of the line.
 void textGetLineDeleteText()
          Tests line numbering output after deletion of a block
 void textGetLineDeleteText2()
          Tests line numbering output after deletion of a block
 void textGetPackageNameWithPackageStatementAfterImport()
          Puts an otherwise valid package statement after a valid import declaration.
 void textGotoLine1()
          Test going to the second line in a two-line document.
 void textGotoLine2()
          Test going to a specific line.
 void textGotoLine3()
          Test going to the fourth line in a four line document.
 void textGotoLine4()
          Test going to a line beyond the number of lines in a document just goes to the end of the file.
 void textGotoLine5()
          Test going to the first line of an empty document doesn't do anything funny.
 void textGotoLine6()
          Test going to a line that is greater than the line count of an empty document just keeps you in your current location.
 void textGotoLine7()
          Test that going to a line within the document's line count sets the current position to the first character of the line.
 void textHighlightKeywords1()
          Test that keywords are highlighted properly.
 void textHighlightKeywords2()
          This test case simulates what happens when some text is selected and there is a keyword around too.
 void textInsertSlashIntoStarSlash()
          Test inserting a slash between a star-slash combo.
 void textInsertStarIntoSlashStar()
          Test inserting a star between a slash-star combo.
 void textInsertStarIntoStarSlash()
          Test inserting a star between a star-slash combo.
 void textInsertToDoc()
          Test insertion.
 void textPackageNameEmpty()
          Test package-finding on empty document.
 void textPackageNameSimple()
          Test package-finding on simple document, with no funny comments.
 void textPackageNameWeird1()
          Test package-finding on document with a block comment between parts of package.
 void textPackageNameWeird2()
          Test package-finding on document with a line comment between parts of package.
 void textQualifiedClassNameWithoutPackage()
          Tests that the correct qualified class name is returned without a package.
 void textQualifiedClassNameWithPackage()
          Tests that the correct qualified class name is returned with a package.
 void textRemoveTabs1()
          Test whether removeTabs actually removes all tabs.
 void textRemoveTabs2()
          As of drjava-20020122-1534, files with tabs ended up garbled, with some of the text jumbled all around (bug #506630).
 void textTabRemovalOnInsertString()
          Test whether tabs are removed as appropriate on call to insertString.
 void textTabRemovalOnInsertString2()
          Test whether tabs are removed as appropriate on call to insertString.
 void textTopLevelClassName()
          Tests class name-finding on document.
 void textTopLevelClassNameMisleading()
          Tests class name-finding on document.
 void textTopLevelClassNameNoSpace()
          Tests that a keyword with no space following it does not cause a StringOutOfBoundsException (bug 742226).
 void textTopLevelClassNameWComments()
          Test class name-finding on document
 void textTopLevelClassNameWithClassloaderImport()
          Tests that the word class is not recognized if it is not followed by whitespace.
 void textTopLevelClassNameWithDelimiters()
          Tests class name-finding on document.
 void textTopLevelEnclosingClassName()
          Tests that the name of a top level enclosing class can be found.
 void textTopLevelInterfaceName()
          Test interface name-finding on document
 void textTopLevelInterfaceNameBeforeClassName()
          Tests class name-finding on document.
 void textTopLevelInterfaceNameMisleading()
          Tests class name-finding on document
 void textTopLevelInterfaceNameMisleading2()
          Tests class name-finding on document
 void textUndoAndRedoAfterMultipleLineCommentAndUncomment()
          Verify that undoing a multiple-line indent will be a single undo action
 void textUndoAndRedoAfterMultipleLineIndent()
          Verify that undoing a multiple-line indent will be a single undo action
 void textUndoOrRedoSetsUnmodifiedState()
          Verifies that the undo manager correctly determines if the document has been modified since the last save.
 
Methods inherited from class edu.rice.cs.drjava.DrJavaTestCase
setConfigSetting, setDocText, tearDown
 
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

NEWLINE

protected final String NEWLINE
See Also:
Constant Field Values

NESTED_CLASSES_TEXT

protected final String NESTED_CLASSES_TEXT
See Also:
Constant Field Values

PUBLIC_CIE_TEXT

protected final String PUBLIC_CIE_TEXT
See Also:
Constant Field Values

PUBLIC_CEI_TEXT

protected final String PUBLIC_CEI_TEXT
See Also:
Constant Field Values

PUBLIC_ICE_TEXT

protected final String PUBLIC_ICE_TEXT
See Also:
Constant Field Values

PUBLIC_IEC_TEXT

protected final String PUBLIC_IEC_TEXT
See Also:
Constant Field Values

PUBLIC_ECI_TEXT

protected final String PUBLIC_ECI_TEXT
See Also:
Constant Field Values

PUBLIC_EIC_TEXT

protected final String PUBLIC_EIC_TEXT
See Also:
Constant Field Values

I_PUBLIC_CE_TEXT

protected final String I_PUBLIC_CE_TEXT
See Also:
Constant Field Values

E_PUBLIC_CI_TEXT

protected final String E_PUBLIC_CI_TEXT
See Also:
Constant Field Values

C_PUBLIC_IE_TEXT

protected final String C_PUBLIC_IE_TEXT
See Also:
Constant Field Values

E_PUBLIC_IC_TEXT

protected final String E_PUBLIC_IC_TEXT
See Also:
Constant Field Values

C_PUBLIC_EI_TEXT

protected final String C_PUBLIC_EI_TEXT
See Also:
Constant Field Values

I_PUBLIC_EC_TEXT

protected final String I_PUBLIC_EC_TEXT
See Also:
Constant Field Values

CIE_TEXT

protected final String CIE_TEXT
See Also:
Constant Field Values

CEI_TEXT

protected final String CEI_TEXT
See Also:
Constant Field Values

ICE_TEXT

protected final String ICE_TEXT
See Also:
Constant Field Values

IEC_TEXT

protected final String IEC_TEXT
See Also:
Constant Field Values

ECI_TEXT

protected final String ECI_TEXT
See Also:
Constant Field Values

EIC_TEXT

protected final String EIC_TEXT
See Also:
Constant Field Values
Constructor Detail

DefinitionsDocumentTest

public DefinitionsDocumentTest(String name)
Standard constructor.

Parameters:
name - of the test
Method Detail

setUp

protected void setUp()
              throws Exception
Create a definitions document to work with.

Overrides:
setUp in class DrJavaTestCase
Throws:
Exception - This convention is mandated by JUnit.TestCase, the superclass of this class.

suite

public static Test suite()
Create a test suite for JUnit to run.

Returns:
a test suite based on this class

textInsertToDoc

public void textInsertToDoc()
                     throws BadLocationException
Test insertion.

Throws:
BadLocationException

textInsertStarIntoStarSlash

public void textInsertStarIntoStarSlash()
                                 throws BadLocationException
Test inserting a star between a star-slash combo.

Throws:
BadLocationException

textInsertSlashIntoStarSlash

public void textInsertSlashIntoStarSlash()
                                  throws BadLocationException
Test inserting a slash between a star-slash combo.

Throws:
BadLocationException

textInsertStarIntoSlashStar

public void textInsertStarIntoSlashStar()
                                 throws BadLocationException
Test inserting a star between a slash-star combo.

Throws:
BadLocationException

textDeleteDoc

public void textDeleteDoc()
                   throws BadLocationException
Test removal of text.

Throws:
BadLocationException

textHighlightKeywords1

public void textHighlightKeywords1()
                            throws BadLocationException
Test that keywords are highlighted properly.

Throws:
BadLocationException

textHighlightKeywords2

public void textHighlightKeywords2()
                            throws BadLocationException
This test case simulates what happens when some text is selected and there is a keyword around too. In drjava-20010720-1712 there is a bug that if you enter "int Y" and then try to select "t Y", it throws an exception. This is a test for that bug. The important thing about the selection process is that it asks for only the first two chars in the call to getHighlightStatus even though it wants to render the last three chars selected.

Throws:
BadLocationException

textGotoLine1

public void textGotoLine1()
                   throws BadLocationException
Test going to the second line in a two-line document.

Throws:
BadLocationException

textGotoLine2

public void textGotoLine2()
                   throws BadLocationException
Test going to a specific line.

Throws:
BadLocationException

textGotoLine3

public void textGotoLine3()
                   throws BadLocationException
Test going to the fourth line in a four line document.

Throws:
BadLocationException

textGotoLine4

public void textGotoLine4()
                   throws BadLocationException
Test going to a line beyond the number of lines in a document just goes to the end of the file.

Throws:
BadLocationException

textGotoLine5

public void textGotoLine5()
Test going to the first line of an empty document doesn't do anything funny. It should stay in the same location.


textGotoLine6

public void textGotoLine6()
Test going to a line that is greater than the line count of an empty document just keeps you in your current location.


textGotoLine7

public void textGotoLine7()
                   throws BadLocationException
Test that going to a line within the document's line count sets the current position to the first character of the line.

Throws:
BadLocationException

textGetColumn1

public void textGetColumn1()
                    throws BadLocationException
Tests returning the current column in the document.

Throws:
BadLocationException

textGetColumn2

public void textGetColumn2()
                    throws BadLocationException
Tests returning the current column in the document.

Throws:
BadLocationException

textGetLine1

public void textGetLine1()
                  throws BadLocationException
Test returning second line in a two-line document.

Throws:
BadLocationException

textGetLine2

public void textGetLine2()
                  throws BadLocationException
Test going to a specific line.

Throws:
BadLocationException

textGetLine3

public void textGetLine3()
                  throws BadLocationException
Test going to the fourth line in a four line document.

Throws:
BadLocationException

textGetLine4

public void textGetLine4()
                  throws BadLocationException
Test going to a line beyond the number of lines in a document just goes to the end of the file.

Throws:
BadLocationException

textGetLine5

public void textGetLine5()
Test going to the first line of an empty document doesn't do anything funny. It should stay in the same location.


textGetLine6

public void textGetLine6()
Test going to a line that is greater than the line count of an empty document just keeps you in your current location.


textGetLine7

public void textGetLine7()
                  throws BadLocationException
Test that going to a line within the document's line count sets the current position to the first character of the line.

Throws:
BadLocationException

textGetLineDeleteText

public void textGetLineDeleteText()
                           throws BadLocationException
Tests line numbering output after deletion of a block

Throws:
BadLocationException

textGetLineDeleteText2

public void textGetLineDeleteText2()
                            throws BadLocationException
Tests line numbering output after deletion of a block

Throws:
BadLocationException

textRemoveTabs1

public void textRemoveTabs1()
Test whether removeTabs actually removes all tabs.


textRemoveTabs2

public void textRemoveTabs2()
As of drjava-20020122-1534, files with tabs ended up garbled, with some of the text jumbled all around (bug #506630). This test aims to replicate the problem.


textTabRemovalOnInsertString2

public void textTabRemovalOnInsertString2()
                                   throws BadLocationException
Test whether tabs are removed as appropriate on call to insertString.

Throws:
BadLocationException

textTabRemovalOnInsertString

public void textTabRemovalOnInsertString()
                                  throws BadLocationException
Test whether tabs are removed as appropriate on call to insertString.

Throws:
BadLocationException

textPackageNameEmpty

public void textPackageNameEmpty()
                          throws InvalidPackageException
Test package-finding on empty document.

Throws:
InvalidPackageException

textPackageNameSimple

public void textPackageNameSimple()
                           throws Exception
Test package-finding on simple document, with no funny comments.

Throws:
Exception

textPackageNameWeird1

public void textPackageNameWeird1()
                           throws BadLocationException,
                                  InvalidPackageException
Test package-finding on document with a block comment between parts of package.

Throws:
BadLocationException
InvalidPackageException

textPackageNameWeird2

public void textPackageNameWeird2()
                           throws BadLocationException,
                                  InvalidPackageException
Test package-finding on document with a line comment between parts of package.

Throws:
BadLocationException
InvalidPackageException

textGetPackageNameWithPackageStatementAfterImport

public void textGetPackageNameWithPackageStatementAfterImport()
                                                       throws BadLocationException,
                                                              InvalidPackageException
Puts an otherwise valid package statement after a valid import declaration. This should result in seeing no package statement (for the purposes of getSourceRoot), so the resulting package name should be "".

Throws:
BadLocationException
InvalidPackageException

textTopLevelClassName

public void textTopLevelClassName()
                           throws BadLocationException,
                                  ClassNameNotFoundException
Tests class name-finding on document.

Throws:
BadLocationException
ClassNameNotFoundException

textTopLevelInterfaceName

public void textTopLevelInterfaceName()
                               throws BadLocationException,
                                      ClassNameNotFoundException
Test interface name-finding on document

Throws:
BadLocationException
ClassNameNotFoundException

textTopLevelClassNameWComments

public void textTopLevelClassNameWComments()
                                    throws BadLocationException,
                                           ClassNameNotFoundException
Test class name-finding on document

Throws:
BadLocationException
ClassNameNotFoundException

textTopLevelClassNameNoSpace

public void textTopLevelClassNameNoSpace()
                                  throws BadLocationException
Tests that a keyword with no space following it does not cause a StringOutOfBoundsException (bug 742226).

Throws:
BadLocationException

textTopLevelClassNameWithClassloaderImport

public void textTopLevelClassNameWithClassloaderImport()
                                                throws BadLocationException,
                                                       ClassNameNotFoundException
Tests that the word class is not recognized if it is not followed by whitespace.

Throws:
BadLocationException
ClassNameNotFoundException

textTopLevelClassNameMisleading

public void textTopLevelClassNameMisleading()
                                     throws BadLocationException,
                                            ClassNameNotFoundException
Tests class name-finding on document.

Throws:
BadLocationException
ClassNameNotFoundException

textTopLevelInterfaceNameMisleading

public void textTopLevelInterfaceNameMisleading()
                                         throws BadLocationException,
                                                ClassNameNotFoundException
Tests class name-finding on document

Throws:
BadLocationException
ClassNameNotFoundException

textTopLevelInterfaceNameMisleading2

public void textTopLevelInterfaceNameMisleading2()
                                          throws BadLocationException,
                                                 ClassNameNotFoundException
Tests class name-finding on document

Throws:
BadLocationException
ClassNameNotFoundException

textTopLevelInterfaceNameBeforeClassName

public void textTopLevelInterfaceNameBeforeClassName()
                                              throws BadLocationException,
                                                     ClassNameNotFoundException
Tests class name-finding on document.

Throws:
BadLocationException
ClassNameNotFoundException

textTopLevelClassNameWithDelimiters

public void textTopLevelClassNameWithDelimiters()
                                         throws BadLocationException,
                                                ClassNameNotFoundException
Tests class name-finding on document.

Throws:
BadLocationException
ClassNameNotFoundException

textTopLevelEnclosingClassName

public void textTopLevelEnclosingClassName()
                                    throws BadLocationException,
                                           ClassNameNotFoundException
Tests that the name of a top level enclosing class can be found.

Throws:
BadLocationException
ClassNameNotFoundException

textQualifiedClassNameWithPackage

public void textQualifiedClassNameWithPackage()
                                       throws BadLocationException,
                                              ClassNameNotFoundException
Tests that the correct qualified class name is returned with a package.

Throws:
BadLocationException
ClassNameNotFoundException

textQualifiedClassNameWithoutPackage

public void textQualifiedClassNameWithoutPackage()
                                          throws BadLocationException,
                                                 ClassNameNotFoundException
Tests that the correct qualified class name is returned without a package.

Throws:
BadLocationException
ClassNameNotFoundException

textUndoAndRedoAfterMultipleLineIndent

public void textUndoAndRedoAfterMultipleLineIndent()
                                            throws BadLocationException
Verify that undoing a multiple-line indent will be a single undo action

Throws:
BadLocationException

textUndoAndRedoAfterMultipleLineCommentAndUncomment

public void textUndoAndRedoAfterMultipleLineCommentAndUncomment()
                                                         throws BadLocationException
Verify that undoing a multiple-line indent will be a single undo action

Throws:
BadLocationException

textCompoundUndoManager

public void textCompoundUndoManager()
                             throws BadLocationException
Test method for CompoundUndoManager. Tests that the nested compound edit functionality works correctly.

Throws:
BadLocationException

textUndoOrRedoSetsUnmodifiedState

public void textUndoOrRedoSetsUnmodifiedState()
                                       throws BadLocationException
Verifies that the undo manager correctly determines if the document has been modified since the last save.

Throws:
BadLocationException

testAnonymousClassIndex

public void testAnonymousClassIndex()
                             throws BadLocationException,
                                    ClassNameNotFoundException
Test finding anonymous class index on document.

Throws:
BadLocationException
ClassNameNotFoundException

testExactClassName

public void testExactClassName()
                        throws BadLocationException,
                               ClassNameNotFoundException
Test exact class name-finding on document.

Throws:
BadLocationException
ClassNameNotFoundException

testgetMainClassName

public void testgetMainClassName()
                          throws BadLocationException,
                                 ClassNameNotFoundException
Test getMainClassName.

Throws:
BadLocationException
ClassNameNotFoundException