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

java.lang.Object
  |
  +--junit.framework.Assert
        |
        +--junit.framework.TestCase
              |
              +--edu.rice.cs.drjava.model.definitions.DefinitionsDocumentTest
All Implemented Interfaces:
ReducedModelStates, Test

public class DefinitionsDocumentTest
extends TestCase
implements ReducedModelStates

Tests the functionality of the definitions document.

Version:
$Id: DefinitionsDocumentTest.java,v 1.36 2002/09/10 02:27:07 csreis Exp $

Field Summary
protected  DefinitionsDocument defModel
           
 
Fields inherited from class junit.framework.TestCase
fName
 
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)
          Constructor.
 
Method Summary
private  void _checkHighlightStatusConsistent(gj.util.Vector v, int start, int end)
          Make sure the vector is consistent: all elements immediately adjoin one another (no overlap), and make sure all indices between start and end are in the vector.
private  String _getAllText()
           
protected  void setUp()
          Create a definitions document to work with.
static Test suite()
          Create a test suite for JUnit to run.
 void testDeleteDoc()
          Test removal of text.
 void testGetColumn1()
          Tests returning the current column in the document.
 void testGetColumn2()
          Tests returning the current column in the document.
 void testGetLine1()
          Test returning second line in a two-line document.
 void testGetLine2()
          Test going to a specific line.
 void testGetLine3()
          Test going to the fourth line in a four line document.
 void testGetLine4()
          Test going to a line beyond the number of lines in a document just goes to the end of the file.
 void testGetLine5()
          Test going to the first line of an empty document doesn't do anything funny.
 void testGetLine6()
          Test going to a line that is greater than the line count of an empty document just keeps you in your current location.
 void testGetLine7()
          Test that going to a line within the document's line count sets the current position to the first character of the line.
 void testGetLineDeleteText()
           
 void testGetPackageNameWithPackageStatementAfterImport()
          Puts an otherwise valid package statement after a valid import declaration.
 void testGotoLine1()
          Test going to the second line in a two-line document.
 void testGotoLine2()
          Test going to a specific line.
 void testGotoLine3()
          Test going to the fourth line in a four line document.
 void testGotoLine4()
          Test going to a line beyond the number of lines in a document just goes to the end of the file.
 void testGotoLine5()
          Test going to the first line of an empty document doesn't do anything funny.
 void testGotoLine6()
          Test going to a line that is greater than the line count of an empty document just keeps you in your current location.
 void testGotoLine7()
          Test that going to a line within the document's line count sets the current position to the first character of the line.
 void testHighlightKeywords1()
          Test that keywords are highlighted properly.
 void testHighlightKeywords2()
          This test case simulates what happens when some text is selected and there is a keyword around too.
 void testInsertSlashIntoStarSlash()
          Test inserting a slash between a star-slash combo.
 void testInsertStarIntoSlashStar()
          Test inserting a star between a slash-star combo.
 void testInsertStarIntoStarSlash()
          Test inserting a star between a star-slash combo.
 void testInsertToDoc()
          Test insertion.
 void testPackageNameEmpty()
          Test package-finding on empty document.
 void testPackageNameSimple()
          Test package-finding on simple document, with no funny comments.
 void testPackageNameWeird1()
          Test package-finding on document with a block comment between parts of package.
 void testPackageNameWeird2()
          Test package-finding on document with a line comment between parts of package.
 void testQualifiedClassNameWithoutPackage()
          Tests that the correct qualified class name is returned without a package.
 void testQualifiedClassNameWithPackage()
          Tests that the correct qualified class name is returned with a package.
 void testRemoveTabs1()
          Test whether removeTabs actually removes all tabs.
 void testRemoveTabs2()
          As of drjava-20020122-1534, files with tabs ended up garbled, with some of the text jumbled all around (bug #506630).
 void testTabRemovalOnInsertString()
          Test whether tabs are removed as appropriate on call to insertString.
 void testTabRemovalOnInsertString2()
          Test whether tabs are removed as appropriate on call to insertString.
 void testTopLevelClassName()
          Test class name-finding on document
 void testTopLevelClassNameMisleading()
          Test class name-finding on document
 void testTopLevelClassNameWComments()
          Test class name-finding on document
 void testTopLevelClassNameWithClassloaderImport()
          Tests that the word class is not recognized if it is not followed by whitespace.
 void testTopLevelClassNameWithDelimiters()
          Test class name-finding on document
 void testTopLevelEnclosingClassName()
          Tests that the name of a top level enclosing class can be found.
 void testTopLevelInterfaceName()
          Test interface name-finding on document
 void testTopLevelInterfaceNameBeforeClassName()
          Test class name-finding on document
 void testTopLevelInterfaceNameMisleading()
          Test class name-finding on document
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, name, run, run, runBare, runTest, setName, tearDown, 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

defModel

protected DefinitionsDocument defModel
Constructor Detail

DefinitionsDocumentTest

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

setUp

protected void setUp()
Create a definitions document to work with.
Overrides:
setUp in class TestCase

suite

public static Test suite()
Create a test suite for JUnit to run.
Returns:
a test suite based on this class

testInsertToDoc

public void testInsertToDoc()
                     throws BadLocationException
Test insertion.

testInsertStarIntoStarSlash

public void testInsertStarIntoStarSlash()
                                 throws BadLocationException
Test inserting a star between a star-slash combo.
Throws:
BadLocationException -  

testInsertSlashIntoStarSlash

public void testInsertSlashIntoStarSlash()
                                  throws BadLocationException
Test inserting a slash between a star-slash combo.
Throws:
BadLocationException -  

testInsertStarIntoSlashStar

public void testInsertStarIntoSlashStar()
                                 throws BadLocationException
Test inserting a star between a slash-star combo.
Throws:
BadLocationException -  

testDeleteDoc

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

_checkHighlightStatusConsistent

private void _checkHighlightStatusConsistent(gj.util.Vector v,
                                             int start,
                                             int end)
Make sure the vector is consistent: all elements immediately adjoin one another (no overlap), and make sure all indices between start and end are in the vector. Vector is guaranteed to not have size zero.

testHighlightKeywords1

public void testHighlightKeywords1()
                            throws BadLocationException
Test that keywords are highlighted properly.
Throws:
BadLocationException -  

testHighlightKeywords2

public void testHighlightKeywords2()
                            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 exceptions. This is a test for that case. The important thing about the selecting thing is that because it wants to render the last three chars selected, it asks for the first two only in the call to getHighlightStatus.
Throws:
BadLocationException -  

testGotoLine1

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

testGotoLine2

public void testGotoLine2()
                   throws BadLocationException
Test going to a specific line.
Throws:
BadLocationException -  

testGotoLine3

public void testGotoLine3()
                   throws BadLocationException
Test going to the fourth line in a four line document.
Throws:
BadLocationException -  

testGotoLine4

public void testGotoLine4()
                   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 -  

testGotoLine5

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

testGotoLine6

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

testGotoLine7

public void testGotoLine7()
                   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 -  

testGetColumn1

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

testGetColumn2

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

testGetLine1

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

testGetLine2

public void testGetLine2()
                  throws BadLocationException
Test going to a specific line.
Throws:
BadLocationException -  

testGetLine3

public void testGetLine3()
                  throws BadLocationException
Test going to the fourth line in a four line document.
Throws:
BadLocationException -  

testGetLine4

public void testGetLine4()
                  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 -  

testGetLine5

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

testGetLine6

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

testGetLine7

public void testGetLine7()
                  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 -  

testGetLineDeleteText

public void testGetLineDeleteText()
                           throws BadLocationException

testRemoveTabs1

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

testRemoveTabs2

public void testRemoveTabs2()
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.

testTabRemovalOnInsertString2

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

testTabRemovalOnInsertString

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

testPackageNameEmpty

public void testPackageNameEmpty()
                          throws BadLocationException,
                                 InvalidPackageException
Test package-finding on empty document.

testPackageNameSimple

public void testPackageNameSimple()
                           throws BadLocationException,
                                  InvalidPackageException
Test package-finding on simple document, with no funny comments.

testPackageNameWeird1

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

testPackageNameWeird2

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

testGetPackageNameWithPackageStatementAfterImport

public void testGetPackageNameWithPackageStatementAfterImport()
                                                       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 "".

_getAllText

private String _getAllText()
                    throws BadLocationException

testTopLevelClassName

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

testTopLevelInterfaceName

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

testTopLevelClassNameWComments

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

testTopLevelClassNameWithClassloaderImport

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

testTopLevelClassNameMisleading

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

testTopLevelInterfaceNameMisleading

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

testTopLevelInterfaceNameBeforeClassName

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

testTopLevelClassNameWithDelimiters

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

testTopLevelEnclosingClassName

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

testQualifiedClassNameWithPackage

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

testQualifiedClassNameWithoutPackage

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