edu.rice.cs.drjava.model
Class GlobalModelCompileErrorsTest

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

public final class GlobalModelCompileErrorsTest
extends GlobalModelTestCase

Tests to ensure that compilation fails when expected, and that the errors are reported correctly. Every test in this class is run for *each* of the compilers that is available.

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

Nested Class Summary
 
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
TestCase.WrappedException
 
Field Summary
private static java.lang.String BAR_MISSING_SEMI_TEXT
           
private static java.lang.String BAR_MISSING_SEMI_TEXT_MULTIPLE_LINES
           
protected static java.lang.String COMPILER_ERRORS_2872797_TEXT
           
private static java.lang.String FOO_MISSING_CLOSE_TEXT
           
private static java.lang.String FOO_PACKAGE_AFTER_IMPORT
           
private static java.lang.String FOO_PACKAGE_AS_FIELD
           
private static java.lang.String FOO_PACKAGE_AS_FIELD_2
           
private static java.lang.String FOO_PACKAGE_INSIDE_CLASS
           
 
Fields inherited from class edu.rice.cs.drjava.model.GlobalModelTestCase
_doc, _interactionsController, _log, _model, _tempDir, BAR_TEXT, BAZ_TEXT, FOO_PACKAGE_AS_PART_OF_FIELD, FOO_TEXT
 
Fields inherited from class edu.rice.cs.drjava.model.MultiThreadedTestCase
_testFailed
 
Constructor Summary
GlobalModelCompileErrorsTest()
           
 
Method Summary
private  java.lang.String _name()
          Gets the name of the compiler.
 void testCompileAllFailsDifferentSourceRoots()
          Tests calling compileAll with different source roots works if the files have errors in them.
 void testCompileEndWhileParsing()
          Tests compiling an invalid file and checks to make sure the class file was not created.
 void testCompileFailsCorrectLineNumbers()
          Tests the compiler errors have the correct line numbers.
 void testCompileMissingCloseCurly()
          Tests compiling an invalid file and checks to make sure the class file was not created.
 void testCompilePackageAsField()
          Creates a source file with "package" as a field name and ensures that compile starts but fails due to the invalid field name.
 void testCompilePackageAsField2()
          Creates a source file with "package" as a field name and ensures that compile starts but fails due to the invalid field name.
 void testCompileWithPackageStatementInsideClass()
          Puts an otherwise valid package statement inside a class declaration.
 
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, setUp, setupDocument, tearDown, 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

FOO_MISSING_CLOSE_TEXT

private static final java.lang.String FOO_MISSING_CLOSE_TEXT
See Also:
Constant Field Values

BAR_MISSING_SEMI_TEXT

private static final java.lang.String BAR_MISSING_SEMI_TEXT
See Also:
Constant Field Values

FOO_PACKAGE_AFTER_IMPORT

private static final java.lang.String FOO_PACKAGE_AFTER_IMPORT
See Also:
Constant Field Values

FOO_PACKAGE_INSIDE_CLASS

private static final java.lang.String FOO_PACKAGE_INSIDE_CLASS
See Also:
Constant Field Values

FOO_PACKAGE_AS_FIELD

private static final java.lang.String FOO_PACKAGE_AS_FIELD
See Also:
Constant Field Values

FOO_PACKAGE_AS_FIELD_2

private static final java.lang.String FOO_PACKAGE_AS_FIELD_2
See Also:
Constant Field Values

BAR_MISSING_SEMI_TEXT_MULTIPLE_LINES

private static final java.lang.String BAR_MISSING_SEMI_TEXT_MULTIPLE_LINES
See Also:
Constant Field Values

COMPILER_ERRORS_2872797_TEXT

protected static final java.lang.String COMPILER_ERRORS_2872797_TEXT
See Also:
Constant Field Values
Constructor Detail

GlobalModelCompileErrorsTest

public GlobalModelCompileErrorsTest()
Method Detail

_name

private java.lang.String _name()
Gets the name of the compiler.

Returns:
the string representation of the active compiler

testCompileAllFailsDifferentSourceRoots

public void testCompileAllFailsDifferentSourceRoots()
                                             throws javax.swing.text.BadLocationException,
                                                    java.io.IOException,
                                                    java.lang.InterruptedException
Tests calling compileAll with different source roots works if the files have errors in them. (Each file has 1 error.) Note that this testcase will fail if several compilers can be found through the .drjava file. As the test is then run one time per compiler it can find.

Throws:
javax.swing.text.BadLocationException
java.io.IOException
java.lang.InterruptedException

testCompilePackageAsField

public void testCompilePackageAsField()
                               throws javax.swing.text.BadLocationException,
                                      java.io.IOException,
                                      java.lang.InterruptedException
Creates a source file with "package" as a field name and ensures that compile starts but fails due to the invalid field name.

Throws:
javax.swing.text.BadLocationException
java.io.IOException
java.lang.InterruptedException

testCompilePackageAsField2

public void testCompilePackageAsField2()
                                throws javax.swing.text.BadLocationException,
                                       java.io.IOException,
                                       java.lang.InterruptedException
Creates a source file with "package" as a field name and ensures that compile starts but fails due to the invalid field name. This is different from testCompilePackageAsField() as it initializes the field.

Throws:
javax.swing.text.BadLocationException
java.io.IOException
java.lang.InterruptedException

testCompileMissingCloseCurly

public void testCompileMissingCloseCurly()
                                  throws javax.swing.text.BadLocationException,
                                         java.io.IOException,
                                         java.lang.InterruptedException
Tests compiling an invalid file and checks to make sure the class file was not created.

Throws:
javax.swing.text.BadLocationException
java.io.IOException
java.lang.InterruptedException

testCompileWithPackageStatementInsideClass

public void testCompileWithPackageStatementInsideClass()
                                                throws javax.swing.text.BadLocationException,
                                                       java.io.IOException,
                                                       java.lang.InterruptedException
Puts an otherwise valid package statement inside a class declaration. This better not work!

Throws:
javax.swing.text.BadLocationException
java.io.IOException
java.lang.InterruptedException

testCompileFailsCorrectLineNumbers

public void testCompileFailsCorrectLineNumbers()
                                        throws javax.swing.text.BadLocationException,
                                               java.io.IOException,
                                               java.lang.InterruptedException
Tests the compiler errors have the correct line numbers. TODO: rewrite this test for the new error model interface

Throws:
javax.swing.text.BadLocationException
java.io.IOException
java.lang.InterruptedException

testCompileEndWhileParsing

public void testCompileEndWhileParsing()
                                throws javax.swing.text.BadLocationException,
                                       java.io.IOException,
                                       java.lang.InterruptedException
Tests compiling an invalid file and checks to make sure the class file was not created.

Throws:
javax.swing.text.BadLocationException
java.io.IOException
java.lang.InterruptedException