|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjunit.framework.Assert
junit.framework.TestCase
edu.rice.cs.drjava.DrJavaTestCase
edu.rice.cs.drjava.model.MultiThreadedTestCase
edu.rice.cs.drjava.model.GlobalModelTestCase
public abstract class GlobalModelTestCase
Base class for tests over the GlobalModel
.
This class provides a number of convenience methods for testing the GlobalModel. It also contains a model instance
(reset in setUp()
and a temporary directory that's created per test invocation (and subsequently cleaned in
tearDown()
. This reduces the burden for such file management stuff in the test cases themselves.
Nested Class Summary | |
---|---|
static class |
GlobalModelTestCase.CancelingSelector
|
static class |
GlobalModelTestCase.CompileShouldFailListener
A model listener for situations expecting a compilation to fail. |
static class |
GlobalModelTestCase.CompileShouldSucceedListener
A model listener for situations expecting a compilation to succeed. |
static class |
GlobalModelTestCase.FileMovedWarningException
|
static class |
GlobalModelTestCase.FileSelector
This class is used by several test cases in Compile Tests that expect incorrect behavior concerning the saving of files. |
static class |
GlobalModelTestCase.InteractionListener
|
static class |
GlobalModelTestCase.JUnitNonTestListener
Listener class for failing JUnit invocation. |
static class |
GlobalModelTestCase.JUnitTestListener
|
static class |
GlobalModelTestCase.OpenWarningException
|
static class |
GlobalModelTestCase.OverwriteException
|
class |
GlobalModelTestCase.TestGlobalModel
|
static class |
GlobalModelTestCase.TestListener
A GlobalModelListener for testing. |
static class |
GlobalModelTestCase.WarningFileSelector
|
Field Summary | |
---|---|
protected OpenDefinitionsDocument |
_doc
|
protected InteractionsController |
_interactionsController
|
static Log |
_log
|
protected DefaultGlobalModel |
_model
|
protected File |
_tempDir
|
protected static String |
BAR_TEXT
|
protected static String |
BAZ_TEXT
|
protected static String |
FOO_MISSING_CLOSE_TEXT
|
protected static String |
FOO_PACKAGE_AFTER_IMPORT
|
protected static String |
FOO_PACKAGE_AS_FIELD
|
protected static String |
FOO_PACKAGE_AS_FIELD_2
|
protected static String |
FOO_PACKAGE_AS_PART_OF_FIELD
|
protected static String |
FOO_PACKAGE_INSIDE_CLASS
|
protected static String |
FOO_TEXT
|
Fields inherited from class edu.rice.cs.drjava.model.MultiThreadedTestCase |
---|
_testFailed |
Fields inherited from class edu.rice.cs.drjava.DrJavaTestCase |
---|
TEST_DRJAVA_CONFIG_PROPERTY |
Constructor Summary | |
---|---|
GlobalModelTestCase()
|
Method Summary | |
---|---|
protected void |
assertCompileErrorsPresent(boolean b)
|
protected void |
assertCompileErrorsPresent(String name,
boolean b)
|
protected void |
assertContents(String s,
OpenDefinitionsDocument doc)
|
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 void |
assertInteractionsDoesNotMatch(String regex)
Asserts that the text in the Interactions Document does NOT match the given regex. |
protected void |
assertInteractionsMatches(String regex)
Asserts that the text in the Interactions Document matches the given regex. |
protected void |
assertLength(int len,
OpenDefinitionsDocument doc)
|
protected void |
assertModified(boolean b,
OpenDefinitionsDocument doc)
|
protected void |
assertNumOpenDocs(int num)
|
protected void |
changeDocumentText(String s,
OpenDefinitionsDocument doc)
Clear all old text and insert the given text. |
protected File |
classForJava(File sourceFile,
String className)
Given a .java file and a class file name, returns the corresponding .class file. |
protected File |
createFile(String name)
|
protected void |
doCompile(OpenDefinitionsDocument doc,
File file)
Saves to the given file, and then compiles the given document. |
protected OpenDefinitionsDocument |
doCompile(String text,
File file)
Compiles a new file with the given text. |
protected String |
getCompilerErrorString()
Returns a string with all compiler errors. |
protected String |
getInteractionsText()
Returns the current contents of the interactions document |
protected String |
interpret(String input)
Puts the given input into the interactions document and then interprets it, returning the result that was put into the interactions document. |
protected void |
interpretIgnoreResult(String input)
Appends the input string to the interactions pane and interprets it. |
protected void |
safeLoadHistory(GlobalModelTestCase.FileSelector fs)
|
protected void |
safeSaveHistory(GlobalModelTestCase.FileSelector fs)
|
protected void |
saveAllFiles(GlobalModel model,
FileSaveSelector fs)
|
protected void |
saveFile(OpenDefinitionsDocument doc,
FileSaveSelector fss)
Invokes doc.saveFile from within the event thread. |
protected void |
saveFileAs(OpenDefinitionsDocument doc,
FileSaveSelector fss)
Invokes doc.saveFileAs from within the event thread. |
void |
setUp()
Setup for each test case, which does the following. |
protected OpenDefinitionsDocument |
setupDocument(String text)
Creates and returns a new document, makes sure newFile is fired, and then adds some text. |
void |
tearDown()
Teardown for each test case, which recursively deletes the temporary directory created in setUp. |
protected File |
tempDirectory()
Create a new temporary directory in _tempDir. |
protected File |
tempFile()
Create a new temporary file in _tempDir. |
protected File |
tempFile(int i)
Create a new temporary file in _tempDir. |
protected static void |
testStartCompile(OpenDefinitionsDocument doc)
Invokes startCompile on the given document in the event thread. |
protected File |
writeToNewTempFile(String text)
Creates a new temporary file and writes the given text to it. |
Methods inherited from class edu.rice.cs.drjava.model.MultiThreadedTestCase |
---|
join, 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 |
---|
public static final Log _log
protected volatile DefaultGlobalModel _model
protected volatile InteractionsController _interactionsController
protected volatile File _tempDir
protected volatile OpenDefinitionsDocument _doc
protected static final String FOO_TEXT
protected static final String BAR_TEXT
protected static final String BAZ_TEXT
protected static final String FOO_MISSING_CLOSE_TEXT
protected static final String FOO_PACKAGE_AFTER_IMPORT
protected static final String FOO_PACKAGE_INSIDE_CLASS
protected static final String FOO_PACKAGE_AS_FIELD
protected static final String FOO_PACKAGE_AS_FIELD_2
protected static final String FOO_PACKAGE_AS_PART_OF_FIELD
Constructor Detail |
---|
public GlobalModelTestCase()
Method Detail |
---|
public void setUp() throws Exception
_model
for each test case run.
_tempDir
.
setUp
in class MultiThreadedTestCase
Exception
- This convention is mandated by the JUnit TestCase class which is an ancestor of this class.public void tearDown() throws Exception
tearDown
in class MultiThreadedTestCase
Exception
protected void changeDocumentText(String s, OpenDefinitionsDocument doc)
protected File tempFile() throws IOException
IOException
protected File tempFile(int i) throws IOException
IOException
protected File tempDirectory() throws IOException
IOException
protected File createFile(String name)
protected File classForJava(File sourceFile, String className)
protected File writeToNewTempFile(String text) throws IOException
IOException
protected OpenDefinitionsDocument setupDocument(String text) throws BadLocationException
BadLocationException
protected void safeLoadHistory(GlobalModelTestCase.FileSelector fs)
protected void safeSaveHistory(GlobalModelTestCase.FileSelector fs)
protected static void testStartCompile(OpenDefinitionsDocument doc)
protected OpenDefinitionsDocument doCompile(String text, File file) throws IOException, BadLocationException, InterruptedException
text
- Code for the class to be compiledfile
- File to save the class in
IOException
BadLocationException
InterruptedException
protected void doCompile(OpenDefinitionsDocument doc, File file) throws IOException, InterruptedException
doc
- Document containing the code to be compiledfile
- File to save the class in
IOException
InterruptedException
protected String getCompilerErrorString()
protected String interpret(String input) throws EditDocumentException
input
- text to interpret
EditDocumentException
protected void interpretIgnoreResult(String input) throws EditDocumentException
EditDocumentException
protected void assertInteractionsContains(String text) throws EditDocumentException
EditDocumentException
protected void assertInteractionsDoesNotContain(String text) throws EditDocumentException
EditDocumentException
protected void assertInteractionsMatches(String regex) throws EditDocumentException
EditDocumentException
protected void assertInteractionsDoesNotMatch(String regex) throws EditDocumentException
EditDocumentException
protected String getInteractionsText() throws EditDocumentException
EditDocumentException
protected void assertNumOpenDocs(int num)
protected void assertModified(boolean b, OpenDefinitionsDocument doc)
protected void assertLength(int len, OpenDefinitionsDocument doc)
protected void assertContents(String s, OpenDefinitionsDocument doc) throws BadLocationException
BadLocationException
protected void saveFile(OpenDefinitionsDocument doc, FileSaveSelector fss)
protected void saveFileAs(OpenDefinitionsDocument doc, FileSaveSelector fss)
protected void saveAllFiles(GlobalModel model, FileSaveSelector fs)
protected void assertCompileErrorsPresent(boolean b)
protected void assertCompileErrorsPresent(String name, boolean b)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |