KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > edu > rice > cs > drjava > model > GlobalModelTestCase


1 /*BEGIN_COPYRIGHT_BLOCK
2  *
3  * This file is part of DrJava. Download the current version of this project from http://www.drjava.org/
4  * or http://sourceforge.net/projects/drjava/
5  *
6  * DrJava Open Source License
7  *
8  * Copyright (C) 2001-2005 JavaPLT group at Rice University (javaplt@rice.edu). All rights reserved.
9  *
10  * Developed by: Java Programming Languages Team, Rice University, http://www.cs.rice.edu/~javaplt/
11  *
12  * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
13  * documentation files (the "Software"), to deal with the Software without restriction, including without limitation
14  * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
15  * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
16  *
17  * - Redistributions of source code must retain the above copyright notice, this list of conditions and the
18  * following disclaimers.
19  * - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
20  * following disclaimers in the documentation and/or other materials provided with the distribution.
21  * - Neither the names of DrJava, the JavaPLT, Rice University, nor the names of its contributors may be used to
22  * endorse or promote products derived from this Software without specific prior written permission.
23  * - Products derived from this software may not be called "DrJava" nor use the term "DrJava" as part of their
24  * names without prior written permission from the JavaPLT group. For permission, write to javaplt@rice.edu.
25  *
26  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
27  * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28  * CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
29  * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
30  * WITH THE SOFTWARE.
31  *
32 END_COPYRIGHT_BLOCK*/

33
34 package edu.rice.cs.drjava.model;
35
36 import edu.rice.cs.drjava.DrJava;
37 import edu.rice.cs.drjava.model.compiler.CompilerListener;
38 import edu.rice.cs.drjava.model.repl.InteractionsDocument;
39 import edu.rice.cs.drjava.model.junit.JUnitModel;
40 import edu.rice.cs.util.FileOpenSelector;
41 import edu.rice.cs.plt.io.IOUtil;
42 import edu.rice.cs.util.Log;
43 import edu.rice.cs.util.OperationCanceledException;
44 import edu.rice.cs.util.StringOps;
45 import edu.rice.cs.util.UnexpectedException;
46 import edu.rice.cs.util.classloader.ClassFileError;
47 import edu.rice.cs.util.swing.Utilities;
48 import edu.rice.cs.util.swing.AsyncTask;
49 import edu.rice.cs.util.text.EditDocumentException;
50 import edu.rice.cs.util.text.EditDocumentInterface;
51
52 import javax.swing.text.BadLocationException JavaDoc;
53 import java.io.File JavaDoc;
54 import java.io.IOException JavaDoc;
55 import java.util.regex.*;
56 import java.util.List JavaDoc;
57
58 /** Base class for tests over the {@link GlobalModel}.
59  *
60  * This class provides a number of convenience methods for testing the GlobalModel. It also contains a model instance
61  * (reset in {@link #setUp} and a temporary directory that's created per test invocation (and subsequently cleaned in
62  * {@link #tearDown}. This reduces the burden for such file management stuff in the test cases themselves.
63  *
64  * @version $Id: GlobalModelTestCase.java 4075 2007-01-19 21:35:50Z dlsmith $
65  */

66 public abstract class GlobalModelTestCase extends MultiThreadedTestCase {
67   
68   protected static final Log _log = new Log("GlobalModel.txt", false);
69
70   protected volatile DefaultGlobalModel _model;
71   protected volatile File JavaDoc _tempDir;
72   protected volatile OpenDefinitionsDocument _doc; // the working document in some shared set up routines
73

74   protected static final String JavaDoc FOO_TEXT = "class DrJavaTestFoo {}";
75   protected static final String JavaDoc BAR_TEXT = "class DrJavaTestBar {}";
76   protected static final String JavaDoc BAZ_TEXT = "class DrJavaTestBaz extends DrJavaTestFoo { public static int x = 3; }";
77   protected static final String JavaDoc FOO_MISSING_CLOSE_TEXT = "class DrJavaTestFoo {";
78   protected static final String JavaDoc FOO_PACKAGE_AFTER_IMPORT = "import java.util.*;\npackage a;\n" + FOO_TEXT;
79   protected static final String JavaDoc FOO_PACKAGE_INSIDE_CLASS = "class DrJavaTestFoo { package a; }";
80   protected static final String JavaDoc FOO_PACKAGE_AS_FIELD = "class DrJavaTestFoo { int package; }";
81   protected static final String JavaDoc FOO_PACKAGE_AS_FIELD_2 = "class DrJavaTestFoo { int package = 5; }";
82   protected static final String JavaDoc FOO_PACKAGE_AS_PART_OF_FIELD = "class DrJavaTestFoo { int cur_package = 5; }";
83   
84   public GlobalModelTestCase() { _log.log("Constructing a " + this); }
85
86   /** Setup for each test case, which does the following.
87    * <OL>
88    * <LI>
89    * Creates a new GlobalModel in {@link #_model} for each test case run.
90    * </LI>
91    * <LI>
92    * Creates a new temporary directory in {@link #_tempDir}.
93    * </LI>
94    * </OL>
95    */

96   public void setUp() throws Exception JavaDoc {
97     _log.log("Setting up " + this);
98     super.setUp();
99     _model = new TestGlobalModel();
100     _log.log("Global model created for " + this);
101     DrJava.getConfig().resetToDefaults();
102     String JavaDoc user = System.getProperty("user.name");
103     _tempDir = IOUtil.createAndMarkTempDirectory("DrJava-test-" + user, "");
104     // Wait until model has connected to slave JVM
105
_log.log("Ensuring that interpreter is connected in " + this);
106     _model._jvm.ensureInterpreterConnected();
107     _log.log("Ensured that intepreter is connected in " + this);
108     _model.setResetAfterCompile(false);
109     _log.log("Completed (GlobalModelTestCase) set up of " + this);
110
111 // _model.getOpenDefinitionsDocuments().get(0).saveFile(new FileSelector(new File(_tempDir, "blank document")));
112
// super.setUp();
113
}
114
115   /** Teardown for each test case, which recursively deletes the temporary directory created in setUp. */
116   public void tearDown() throws Exception JavaDoc {
117     _log.log("Tearing down " + this);
118     boolean ret = IOUtil.deleteRecursively(_tempDir);
119     assertTrue("delete temp directory " + _tempDir, ret);
120
121     _model.dispose();
122     _tempDir = null;
123     _model = null;
124
125     super.tearDown();
126     _log.log("Completed tear down of " + this);
127   }
128
129   /** Clear all old text and insert the given text. */
130   protected void changeDocumentText(String JavaDoc s, OpenDefinitionsDocument doc) throws BadLocationException JavaDoc {
131     doc.clear();
132     assertLength(0, doc);
133     doc.append(s, null);
134     assertModified(true, doc);
135     assertContents(s, doc);
136   }
137
138   /** Create a new temporary file in _tempDir. */
139   protected File JavaDoc tempFile() throws IOException JavaDoc {
140     File JavaDoc f = File.createTempFile("DrJava-test", ".java", _tempDir).getCanonicalFile();
141 // System.err.println("temp file created with name " + f);
142
return f;
143   }
144
145   /** Create a new temporary file in _tempDir. Calls with the same int will return the same filename, while calls
146    * with different ints will return different filenames.
147    */

148   protected File JavaDoc tempFile(int i) throws IOException JavaDoc {
149     return File.createTempFile("DrJava-test" + i, ".java", _tempDir).getCanonicalFile();
150   }
151
152   /** Create a new temporary directory in _tempDir. */
153   protected File JavaDoc tempDirectory() throws IOException JavaDoc {
154     return IOUtil.createAndMarkTempDirectory("DrJava-test", "", _tempDir);
155   }
156
157   protected File JavaDoc createFile(String JavaDoc name) { return new File JavaDoc(_tempDir, name); }
158
159   /** Given a .java file and a class file name, returns the corresponding .class file. */
160   protected File JavaDoc classForJava(File JavaDoc sourceFile, String JavaDoc className) {
161     assertTrue(sourceFile.getName().endsWith(".java"));
162     String JavaDoc cname = className + ".class";
163     return new File JavaDoc(sourceFile.getParent(), cname);
164   }
165
166   /** Creates a new temporary file and writes the given text to it.
167    * The File object for the new file is returned.
168    */

169   protected File JavaDoc writeToNewTempFile(String JavaDoc text) throws IOException JavaDoc {
170     File JavaDoc temp = tempFile();
171     IOUtil.writeStringToFile(temp, text);
172     return temp;
173   }
174
175   /** Creates and returns a new document, makes sure newFile is fired, and then adds some text. When this method is
176    * done newCount is reset to 0.
177    * @return the new modified document
178    */

179   protected OpenDefinitionsDocument setupDocument(String JavaDoc text) throws BadLocationException JavaDoc {
180     TestListener listener = new TestListener() {
181       public synchronized void newFileCreated(OpenDefinitionsDocument doc) { newCount++; }
182     };
183
184     _model.addListener(listener);
185
186     // Open a new document
187
int numOpen = _model.getOpenDefinitionsDocuments().size();
188     Utilities.invokeAndWait(new Runnable JavaDoc() { public void run () { _doc = _model.newFile(); } });
189     
190     assertNumOpenDocs(numOpen + 1);
191
192     listener.assertNewCount(1);
193     assertLength(0, _doc);
194     assertModified(false, _doc);
195
196     changeDocumentText(text, _doc);
197     assertModified(true, _doc);
198     _model.removeListener(listener);
199
200     return _doc;
201   }
202
203   /** Compiles a new file with the given text. The compile is expected to succeed and it is checked to make sure it
204    * worked reasonably. This method does not return until the Interactions JVM has reset and is ready to use.
205    * @param text Code for the class to be compiled
206    * @param file File to save the class in
207    * @return Document after it has been saved and compiled
208    */

209   protected synchronized OpenDefinitionsDocument doCompile(String JavaDoc text, File JavaDoc file) throws IOException JavaDoc,
210     BadLocationException JavaDoc, InterruptedException JavaDoc {
211     
212     OpenDefinitionsDocument doc = setupDocument(text);
213     doCompile(doc, file);
214     return doc;
215   }
216
217   /** Saves to the given file, and then compiles the given document. The compile is expected to succeed and it is
218    * checked to make sure it worked reasonably. This method does not return until the Interactions JVM has reset
219    * and is ready to use.
220    * @param doc Document containing the code to be compiled
221    * @param file File to save the class in
222    */

223   protected void doCompile(OpenDefinitionsDocument doc, File JavaDoc file) throws IOException JavaDoc, InterruptedException JavaDoc {
224     doc.saveFile(new FileSelector(file));
225
226     // Perform a mindless interpretation to force interactions to reset (only to simplify this method)
227
try { interpret("0"); }
228     catch (EditDocumentException e) { throw new UnexpectedException(e); }
229     Utilities.clearEventQueue();
230     
231     _model.setResetAfterCompile(true);
232     CompileShouldSucceedListener listener = new CompileShouldSucceedListener(true);
233     _model.addListener(listener);
234     
235     listener.logCompileStart();
236
237     doc.startCompile();
238     Utilities.clearEventQueue();
239     
240     if (_model.getCompilerModel().getNumErrors() > 0) fail("compile failed: " + getCompilerErrorString());
241
242     listener.waitCompileDone();
243
244     listener.checkCompileOccurred();
245     assertCompileErrorsPresent(false);
246     
247     listener.waitResetDone();
248     Utilities.clearEventQueue();
249     _model.removeListener(listener);
250   }
251
252   /** Returns a string with all compiler errors. */
253   protected String JavaDoc getCompilerErrorString() {
254     final StringBuilder JavaDoc buf = new StringBuilder JavaDoc();
255     buf.append(" compiler error(s):\n");
256     buf.append(_model.getCompilerModel().getCompilerErrorModel().toString());
257     return buf.toString();
258   }
259
260   /** Puts the given input into the interactions document and then interprets it, returning the result that was put
261    * into the interactions document. This assumes the interactions document is in a state with no text after the
262    * prompt. To be sure this is the case, you can reset interactions first. This method provides its own listener
263    * to synchronized with the completion of the interaction.
264    *
265    * @param input text to interpret
266    * @return The output from this interpretation, in String form, as it was printed to the interactions document.
267    */

268   protected String JavaDoc interpret(String JavaDoc input) throws EditDocumentException {
269     
270     InteractionsDocument interactionsDoc = _model.getInteractionsDocument();
271     Utilities.clearEventQueue();
272     
273     interactionsDoc.setInProgress(false); // for some reason, the inProgress state can be true when interpret is invoked
274
interactionsDoc.append(input, InteractionsDocument.DEFAULT_STYLE);
275     
276     Utilities.clearEventQueue();
277
278     // skip the right length for the newline
279
final int newLineLen = System.getProperty("line.separator").length();
280     final int resultsStartLocation = interactionsDoc.getLength() + newLineLen;
281
282     InteractionListener listener = new InteractionListener();
283
284     _model.addListener(listener);
285     listener.logInteractionStart();
286     try {
287       _model.interpretCurrentInteraction();
288       listener.waitInteractionDone();
289     }
290     catch (InterruptedException JavaDoc ie) { throw new UnexpectedException(ie); }
291     Utilities.clearEventQueue();
292     _model.removeListener(listener);
293     
294     listener.assertInteractionStartCount(1);
295     listener.assertInteractionEndCount(1);
296
297     // skip the right length for the newline
298
interactionsDoc.acquireReadLock();
299     try {
300       final int resultsEndLocation = interactionsDoc.getLength() - newLineLen - interactionsDoc.getPrompt().length();
301       
302       final int resultsLen = resultsEndLocation - resultsStartLocation;
303       //System.out.println("resultsStartLoc = " + resultsStartLocation + " resultsEndLocation = " + resultsEndLocation);
304
// There was no output from this interaction
305
if (resultsLen <= 0) return "";
306       return interactionsDoc.getDocText(resultsStartLocation, resultsLen);
307     }
308     finally { interactionsDoc.releaseReadLock(); }
309   }
310
311   /** Appends the input string to the interactions pane and interprets it. */
312   protected void interpretIgnoreResult(String JavaDoc input) throws EditDocumentException {
313     InteractionsDocument interactionsDoc = _model.getInteractionsDocument();
314     interactionsDoc.append(input, InteractionsDocument.DEFAULT_STYLE);
315     _model.interpretCurrentInteraction();
316   }
317
318   /** Asserts that the given string exists in the Interactions Document. */
319   protected void assertInteractionsContains(String JavaDoc text) throws EditDocumentException {
320     _assertInteractionContainsHelper(text, true);
321   }
322
323   /** Asserts that the given string does not exist in the Interactions Document. */
324   protected void assertInteractionsDoesNotContain(String JavaDoc text) throws EditDocumentException {
325     _assertInteractionContainsHelper(text, false);
326   }
327
328   private void _assertInteractionContainsHelper(String JavaDoc text, boolean shouldContain) throws EditDocumentException {
329
330     String JavaDoc interactText = getInteractionsText();
331     int contains = interactText.lastIndexOf(text);
332     assertTrue("Interactions document should " +
333                (shouldContain ? "" : "not ")
334                  + "contain:\n"
335                  + text
336                  + "\nActual contents of Interactions document:\n"
337                  + interactText,
338                (contains != -1) == shouldContain);
339   }
340
341   /** Asserts that the text in the Interactions Document matches the given regex. */
342   protected void assertInteractionsMatches(String JavaDoc regex) throws EditDocumentException {
343     _assertInteractionMatchesHelper(regex, true);
344   }
345
346   /** Asserts that the text in the Interactions Document does NOT match the given regex. */
347   protected void assertInteractionsDoesNotMatch(String JavaDoc regex)
348     throws EditDocumentException {
349     _assertInteractionMatchesHelper(regex, false);
350   }
351   
352   private void _assertInteractionMatchesHelper(String JavaDoc regex, boolean shouldMatch) throws EditDocumentException {
353
354     String JavaDoc interactText = getInteractionsText();
355     boolean matches = Pattern.compile(regex, Pattern.MULTILINE|Pattern.DOTALL).matcher(interactText).matches();
356     assertTrue("Interactions document should " +
357                (shouldMatch ? "" : "not ")
358                  + "match:\n"
359                  + regex
360                  + "\nActual contents of Interactions document:\n"
361                  + interactText,
362                matches == shouldMatch);
363   }
364
365   /** Returns the current contents of the interactions document */
366   protected String JavaDoc getInteractionsText() throws EditDocumentException {
367     InteractionsDocument doc = _model.getInteractionsDocument();
368     return doc.getText();
369   }
370
371   protected void assertNumOpenDocs(int num) {
372     assertEquals("number of open documents", num, _model.getOpenDefinitionsDocuments().size());
373   }
374
375   protected void assertModified(boolean b, OpenDefinitionsDocument doc) {
376     assertEquals("document isModifiedSinceSave", b, doc.isModifiedSinceSave());
377   }
378
379
380   protected void assertLength(int len, OpenDefinitionsDocument doc) {
381     assertEquals("document length", len, doc.getLength());
382   }
383
384   protected void assertContents(String JavaDoc s, OpenDefinitionsDocument doc) throws BadLocationException JavaDoc {
385     assertEquals("document contents", s, doc.getText());
386   }
387
388   protected void assertCompileErrorsPresent(boolean b) { assertCompileErrorsPresent("", b); }
389
390   protected void assertCompileErrorsPresent(String JavaDoc name, boolean b) {
391     //CompilerError[] errors = _model.getCompileErrors();
392
int numErrors = _model.getCompilerModel().getNumErrors();
393
394     if (name.length() > 0) name += ": ";
395
396     //StringBuffer buf = new StringBuffer();
397
//for (int i = 0; i < errors.length; i++) {
398
// buf.append("\nerror #" + i + ": " + errors[i]);
399
//}
400

401     assertEquals(name + "compile errors > 0? numErrors =" + numErrors, b, numErrors > 0);
402   }
403
404     // These exceptions are specially used only in this test case.
405
// They are used to verify that the code blocks
406
public static class OverwriteException extends RuntimeException JavaDoc{ }
407   public static class OpenWarningException extends RuntimeException JavaDoc{ }
408   public static class FileMovedWarningException extends RuntimeException JavaDoc{ }
409
410   public static class WarningFileSelector implements FileOpenSelector, FileSaveSelector {
411     private volatile File JavaDoc _file;
412     public WarningFileSelector(File JavaDoc f) { _file = f; }
413     public File JavaDoc getFile() throws OperationCanceledException { return _file; }
414     public File JavaDoc[] getFiles() throws OperationCanceledException { return new File JavaDoc[] {_file}; }
415     public boolean warnFileOpen(File JavaDoc f) { throw new OpenWarningException(); }
416     public boolean verifyOverwrite() { throw new OverwriteException(); }
417     public boolean shouldSaveAfterFileMoved(OpenDefinitionsDocument doc, File JavaDoc oldFile) {
418       throw new FileMovedWarningException();
419     }
420   }
421
422   /** This class is used by several test cases in Compile Tests that expect incorrect behavior concerning the saving
423    * of files. This special FileSelector is included to ensure compliance with these test cases, for which the
424    * intricacies of saving files are unimportant. The only FileSelector that honest-to-supreme-deity matters is
425    * is DefaultGlobalModel.ConcreteOpenDefDoc, which is much more like WarningFileSelector
426    */

427
428   public static class FileSelector implements FileOpenSelector, FileSaveSelector {
429     private volatile File JavaDoc _file1, _file2;
430     public FileSelector(File JavaDoc f) { _file1 = f; }
431     public FileSelector(File JavaDoc f1, File JavaDoc f2) {
432       _file1 = f1;
433       _file2 = f2;
434     }
435
436     public File JavaDoc getFile() throws OperationCanceledException { return _file1; }
437     
438     public File JavaDoc[] getFiles() throws OperationCanceledException {
439       if (_file2 != null) return new File JavaDoc[] {_file1, _file2};
440       else return new File JavaDoc[] {_file1};
441     }
442     public boolean warnFileOpen(File JavaDoc f) { return true; }
443     public boolean verifyOverwrite() { return true; }
444     public boolean shouldSaveAfterFileMoved(OpenDefinitionsDocument doc, File JavaDoc oldFile) { return true; }
445   }
446
447   public static class CancelingSelector implements FileOpenSelector, FileSaveSelector {
448     public File JavaDoc getFile() throws OperationCanceledException { throw new OperationCanceledException(); }
449     public File JavaDoc[] getFiles() throws OperationCanceledException { throw new OperationCanceledException(); }
450     public boolean warnFileOpen(File JavaDoc f) { return true; }
451     public boolean verifyOverwrite() {return true; }
452     public boolean shouldSaveAfterFileMoved(OpenDefinitionsDocument doc, File JavaDoc oldFile) { return true; }
453   }
454
455   /** A GlobalModelListener for testing. By default it expects no events to be fired. To customize,
456    * subclass and override one or more methods.
457    */

458   public static class TestListener implements GlobalModelListener {
459     /** Remembers when this listener was created. */
460     protected volatile Exception JavaDoc _startupTrace;
461     
462     protected volatile int fileNotFoundCount;
463     protected volatile int newCount;
464     protected volatile int openCount;
465     protected volatile int closeCount;
466     protected volatile int saveCount;
467     protected volatile int canAbandonCount;
468     protected volatile int quitFileCount;
469     protected volatile int classFileErrorCount;
470     protected volatile int compileStartCount;
471     protected volatile int compileEndCount;
472     protected volatile int runStartCount;
473     protected volatile int junitStartCount;
474     protected volatile int junitSuiteStartedCount;
475     protected volatile int junitTestStartedCount;
476     protected volatile int junitTestEndedCount;
477     protected volatile int junitEndCount;
478     protected volatile int interactionStartCount;
479     protected volatile int interactionEndCount;
480     protected volatile int interactionErrorCount;
481     protected volatile int interpreterResettingCount;
482     protected volatile int interpreterReadyCount;
483     protected volatile int interpreterExitedCount;
484     protected volatile int interpreterResetFailedCount;
485     protected volatile int interpreterChangedCount;
486     //protected int interactionCaretPositionChangedCount;
487
protected volatile int consoleResetCount;
488     protected volatile int saveBeforeCompileCount;
489     //protected int saveBeforeRunCount;
490
protected volatile int compileBeforeJUnitCount;
491     protected volatile int saveBeforeJavadocCount;
492     //protected int saveBeforeDebugCount;
493
protected volatile int nonTestCaseCount;
494     protected volatile int lastExitStatus;
495     protected volatile int fileRevertedCount;
496     protected volatile int shouldRevertFileCount;
497     protected volatile int undoableEditCount;
498     protected volatile int interactionIncompleteCount;
499     protected volatile int filePathContainsPoundCount;
500
501     public TestListener() {
502       _startupTrace = new Exception JavaDoc();
503       resetCounts();
504     }
505
506     public synchronized void resetCounts() {
507       fileNotFoundCount = 0;
508       newCount = 0;
509       openCount = 0;
510       closeCount = 0;
511       saveCount = 0;
512       canAbandonCount = 0;
513       quitFileCount = 0;
514       classFileErrorCount = 0;
515       compileStartCount = 0;
516       compileEndCount = 0;
517       runStartCount = 0;
518       junitStartCount = 0;
519       junitSuiteStartedCount = 0;
520       junitTestStartedCount = 0;
521       junitTestEndedCount = 0;
522       junitEndCount = 0;
523       interactionStartCount = 0;
524       interactionEndCount = 0;
525       interactionErrorCount = 0;
526       interpreterChangedCount = 0;
527       //interactionCaretPositionChangedCount = 0;
528
consoleResetCount = 0;
529       interpreterResettingCount = 0;
530       interpreterReadyCount = 0;
531       interpreterExitedCount = 0;
532       interpreterResetFailedCount = 0;
533       saveBeforeCompileCount = 0;
534       //saveBeforeRunCount = 0;
535
compileBeforeJUnitCount = 0;
536       saveBeforeJavadocCount = 0;
537       //saveBeforeDebugCount = 0;
538
nonTestCaseCount = 0;
539       lastExitStatus = 0;
540       fileRevertedCount = 0;
541       shouldRevertFileCount = 0;
542       undoableEditCount = 0;
543       interactionIncompleteCount = 0;
544       filePathContainsPoundCount = 0;
545     }
546
547     public void projectModified() { }
548     public void projectOpened(File JavaDoc pfile, FileOpenSelector files) { }
549     public void projectClosed() { }
550     public void projectBuildDirChanged() { }
551     public void projectWorkDirChanged() { }
552     public void projectRunnableChanged() { }
553     
554     public void currentDirectoryChanged(File JavaDoc dir) { }
555     
556     /** Appends the stack trace from the listener's creation to the end of the given failure message. */
557     public void listenerFail(String JavaDoc message) {
558       String JavaDoc header = "\nTestListener creation stack trace:\n" + StringOps.getStackTrace(_startupTrace);
559       MultiThreadedTestCase.listenerFail(message + header);
560     }
561
562     public void assertFileNotFoundCount(int i) {
563       assertEquals("number of times fileNotFound fired", i, fileNotFoundCount);
564     }
565
566     public void assertAbandonCount(int i) {
567       assertEquals("number of times canAbandon fired", i, canAbandonCount);
568     }
569
570     public void assertQuitFileCount(int i) {
571       assertEquals("number of times quitFile fired", i, quitFileCount);
572     }
573      public void assertClassFileErrorCount(int i) {
574       assertEquals("number of times classFileError fired", i, classFileErrorCount);
575     }
576     public void assertNewCount(int i) {
577       assertEquals("number of times newFile fired", i, newCount);
578     }
579
580     public void assertOpenCount(int i) {
581       assertEquals("number of times openFile fired", i, openCount);
582     }
583
584     public void assertCloseCount(int i) {
585       assertEquals("number of times closeFile fired", i, closeCount);
586     }
587
588     public void assertSaveCount(int i) {
589       assertEquals("number of times saveFile fired", i, saveCount);
590     }
591
592     public void assertJUnitStartCount(int i) {
593       assertEquals("number of times junitStarted fired", i, junitStartCount);
594     }
595
596     public void assertJUnitSuiteStartedCount(int i) {
597       assertEquals("number of times junitSuiteStarted fired", i, junitSuiteStartedCount);
598     }
599
600     public void assertJUnitTestStartedCount(int i) {
601       assertEquals("number of times junitTestStarted fired", i, junitTestStartedCount);
602     }
603
604     public void assertJUnitTestEndedCount(int i) {
605       assertEquals("number of times junitTestEnded fired", i, junitTestEndedCount);
606     }
607
608     public void assertJUnitEndCount(int i) {
609       assertEquals("number of times junitEnded fired", i, junitEndCount);
610     }
611
612     public void assertInteractionStartCount(int i) {
613       assertEquals("number of times interactionStarted fired", i, interactionStartCount);
614     }
615
616     public void assertInteractionEndCount(int i) {
617       assertEquals("number of times interactionEnded fired", i, interactionEndCount);
618     }
619
620     public void assertInteractionErrorCount(int i) {
621       assertEquals("number of times interactionError fired", i, interactionErrorCount );
622     }
623
624     public void assertInterpreterChangedCount(int i) {
625       assertEquals("number of times interpreterChanged fired", i, interpreterChangedCount);
626     }
627
628 // /** Not used */
629
// public void assertInteractionCaretPositionChangedCount(int i) {
630
// assertEquals("number of times interactionCaretPositionChanged fired", i, interactionCaretPositionChangedCount);
631
// }
632

633     public void assertCompileStartCount(int i) {
634       assertEquals("number of times compileStarted fired", i, compileStartCount);
635     }
636
637     public void assertCompileEndCount(int i) {
638       assertEquals("number of times compileEnded fired", i, compileEndCount);
639     }
640
641     public void assertRunStartCount(int i) {
642       assertEquals("number of times runStarted fired", i, runStartCount);
643     }
644
645     public void assertInterpreterResettingCount(int i) {
646       assertEquals("number of times interpreterResetting fired", i, interpreterResettingCount);
647     }
648
649     public void assertInterpreterReadyCount(int i) {
650       assertEquals("number of times interpreterReady fired", i, interpreterReadyCount);
651     }
652
653     public void assertInterpreterResetFailedCount(int i) {
654       assertEquals("number of times interpreterResetFailed fired", i, interpreterResetFailedCount);
655     }
656
657     public void assertInterpreterExitedCount(int i) {
658       assertEquals("number of times interpreterExited fired", i, interpreterExitedCount);
659     }
660
661     public void assertInteractionsErrorCount(int i) {
662       assertEquals("number of times interactionsError fired", i, interactionErrorCount);
663     }
664
665     public void assertConsoleResetCount(int i) {
666       assertEquals("number of times consoleReset fired", i, consoleResetCount);
667     }
668
669     public void assertSaveBeforeCompileCount(int i) {
670       assertEquals("number of times saveBeforeCompile fired", i, saveBeforeCompileCount);
671     }
672
673 // /** Not used.*/
674
// public void assertSaveBeforeRunCount(int i) {
675
// assertEquals("number of times saveBeforeRun fired", i, saveBeforeRunCount);
676
// }
677
//
678
public void assertCompileBeforeJUnitCount(int i) {
679       assertEquals("number of times compileBeforeJUnit fired", i, compileBeforeJUnitCount);
680     }
681
682     public void assertSaveBeforeJavadocCount(int i) {
683       assertEquals("number of times saveBeforeJavadoc fired", i, saveBeforeJavadocCount);
684     }
685
686 // /** Not used. */
687
// public void assertSaveBeforeDebugCount(int i) {
688
// assertEquals("number of times saveBeforeDebug fired",
689
// i,
690
// saveBeforeDebugCount);
691
// }
692

693     public void assertNonTestCaseCount(int i) {
694       assertEquals("number of times nonTestCase fired", i, nonTestCaseCount);
695     }
696
697     public void assertFileRevertedCount(int i) {
698       assertEquals("number of times fileReverted fired", i, fileRevertedCount);
699     }
700
701     public void assertUndoableEditCount(int i) {
702       assertEquals("number of times undoableEditHappened fired", i, undoableEditCount);
703     }
704
705     public void assertShouldRevertFileCount(int i) {
706       assertEquals("number of times shouldRevertFile fired", i, shouldRevertFileCount);
707     }
708
709     public void assertInteractionIncompleteCount(int i) {
710       assertEquals("number of times interactionIncomplete fired", i, interactionIncompleteCount);
711     }
712
713     public <P,R> void executeAsyncTask(AsyncTask<P,R> task, P param, boolean showProgress, boolean lockUI) {
714       listenerFail("executeAswyncTask fired unexpectedly");
715     }
716        
717     public void handleAlreadyOpenDocument(OpenDefinitionsDocument doc) {
718       listenerFail("handleAlreadyOpenDocument fired unexpectedly");
719     }
720       
721     public void newFileCreated(OpenDefinitionsDocument doc) { listenerFail("newFileCreated fired unexpectedly"); }
722     public void fileNotFound(File JavaDoc f) { listenerFail("fileNotFound fired unexpectedly"); }
723     // Recent revision defers opening files until the document for a file is requested forcing the following comment out
724
public void fileOpened(OpenDefinitionsDocument doc) { /* listenerFail("fileOpened fired unexpectedly"); */ }
725     public void fileClosed(OpenDefinitionsDocument doc) { listenerFail("fileClosed fired unexpectedly"); }
726     public void fileSaved(OpenDefinitionsDocument doc) { listenerFail("fileSaved fired unexpectedly"); }
727     public void fileReverted(OpenDefinitionsDocument doc) { listenerFail("fileReverted fired unexpectedly"); }
728     public void undoableEditHappened() { listenerFail("undoableEditHappened fired unexpectedly"); }
729     public void saveBeforeCompile() { listenerFail("saveBeforeCompile fired unexpectedly"); }
730     
731     public void junitStarted() { listenerFail("junitStarted fired unexpectedly"); }
732     public void junitClassesStarted() { listenerFail("junitAllStarted fired unexpectedly"); }
733     public void junitSuiteStarted(int numTests) { listenerFail("junitSuiteStarted fired unexpectedly"); }
734     public void junitTestStarted(String JavaDoc name) { listenerFail("junitTestStarted fired unexpectedly"); }
735     public void junitTestEnded(String JavaDoc name, boolean wasSuccessful, boolean causedError) {
736       listenerFail("junitTestEnded fired unexpectedly");
737     }
738     public void junitEnded() { listenerFail("junitEnded fired unexpectedly"); }
739     
740     public void javadocStarted() { listenerFail("javadocStarted fired unexpectedly"); }
741     public void javadocEnded(boolean success, File JavaDoc destDir, boolean allDocs) {
742       listenerFail("javadocEnded fired unexpectedly");
743     }
744
745     public void interactionStarted() { listenerFail("interactionStarted fired unexpectedly"); }
746     public void interactionEnded() { listenerFail("interactionEnded fired unexpectedly"); }
747     public void interactionErrorOccurred(int offset, int length) {
748       listenerFail("interpreterErrorOccurred fired unexpectedly");
749     }
750
751     public void interpreterChanged(boolean inProgress) { listenerFail("interpreterChanged fired unexpectedly"); }
752
753 // /**Not used */
754
// public void interactionCaretPositionChanged(int pos) {
755
// listenerFail("interactionCaretPosition fired unexpectedly");
756
// }
757

758     public void compileStarted() { listenerFail("compileStarted fired unexpectedly"); }
759     public void compileEnded(File JavaDoc workDir, List JavaDoc<? extends File JavaDoc> excludedFiles) { listenerFail("compileEnded fired unexpectedly"); }
760     
761     public void runStarted(OpenDefinitionsDocument doc) { listenerFail("runStarted fired unexpectedly"); }
762     
763     public void interpreterResetting() { listenerFail("interpreterResetting fired unexpectedly"); }
764
765     public void interpreterReady(File JavaDoc wd) { listenerFail("interpreterReady fired unexpectedly"); }
766     public void interpreterExited(int status) {
767       listenerFail("interpreterExited(" + status + ") fired unexpectedly");
768     }
769     public void interpreterResetFailed(Throwable JavaDoc t) { listenerFail("interpreterResetFailed fired unexpectedly"); }
770     public void slaveJVMUsed() { /* not directly tested; ignore it */ }
771     public void consoleReset() { listenerFail("consoleReset fired unexpectedly"); }
772     public void saveUntitled() { listenerFail("saveUntitled fired unexpectedly"); }
773     
774     public void compileBeforeJUnit(CompilerListener cl) { compileBeforeJUnitCount++; }
775
776     public void saveBeforeJavadoc() { listenerFail("saveBeforeJavadoc fired unexpectedly"); }
777     public void nonTestCase(boolean isTestAll) { listenerFail("nonTestCase fired unexpectedly"); }
778
779     public boolean canAbandonFile(OpenDefinitionsDocument doc) {
780       listenerFail("canAbandonFile fired unexpectedly");
781       throw new UnexpectedException();
782     }
783     
784     public boolean quitFile(OpenDefinitionsDocument doc) {
785       listenerFail("quitFile fired unexpectedly");
786       throw new UnexpectedException();
787     }
788     
789     public void classFileError(ClassFileError e) {
790       listenerFail("classFileError fired unexpectedly");
791     }
792     
793     public boolean shouldRevertFile(OpenDefinitionsDocument doc) {
794       listenerFail("shouldRevertfile fired unexpectedly");
795       throw new UnexpectedException();
796     }
797
798     public void interactionIncomplete() { listenerFail("interactionIncomplete fired unexpectedly"); }
799     public void filePathContainsPound() { listenerFail("filePathContainsPound fired unexpectedly"); }
800     
801     public void documentNotFound(OpenDefinitionsDocument d, File JavaDoc f) {
802       listenerFail("documentNotFound fired unexpectedly");
803     }
804     
805     public void activeDocumentChanged(OpenDefinitionsDocument active) {
806       /* this event is not dircectly tested */
807     }
808     
809     public void focusOnDefinitionsPane() { /* this event is not dircectly tested */ }
810   }
811   
812   public static class InteractionListener extends TestListener {
813     private volatile boolean _interactionDone = false; // records when the interaction is done
814
private final Object JavaDoc _interactionLock = new Object JavaDoc(); // lock for _interactionDone
815

816     private volatile boolean _resetDone = false; // records when the interaction is done
817
private final Object JavaDoc _resetLock = new Object JavaDoc(); // lock for _interactionDone
818

819     private volatile int _lastExitStatus = -1;
820     
821     /** Relying on the default constructor. */
822     
823     public synchronized void interactionStarted() { interactionStartCount++; }
824     
825     public void interactionEnded() {
826 // assertInteractionStartCount(1);
827

828       synchronized(this) { interactionEndCount++; }
829       synchronized(_interactionLock) {
830         _interactionDone = true;
831         _interactionLock.notify();
832       }
833     }
834     
835     public void interpreterExited(int status) {
836 // Utilities.showDebug("GlobalModelOtherTest: interpreterExited");
837
// assertInteractionStartCount(1);
838
// assertInterpreterResettingCount(0);
839
synchronized(this) {
840         interpreterExitedCount++;
841         _lastExitStatus = status;
842       }
843       synchronized(_interactionLock) {
844         _interactionDone = true;
845         _interactionLock.notify();
846       }
847     }
848     
849     public void interpreterResetting() {
850       assertInterpreterResettingCount(0);
851       assertInterpreterReadyCount(0);
852       synchronized(this) { interpreterResettingCount++; }
853     }
854     
855     public void interpreterReady(File JavaDoc wd) {
856 // Utilities.showDebug("GlobalModelOtherTest: interpreterReady");
857
synchronized(this) { interpreterReadyCount++; }
858       synchronized(_resetLock) {
859 // assertInteractionStartCount(1);
860
// assertInterpreterExitedCount(1);
861
// assertInterpreterResettingCount(1);
862
// Utilities.showDebug("GlobalModelOtherTest: notifying resetDone");
863
_resetDone = true;
864         _resetLock.notify();
865       }
866     }
867     
868     public void consoleReset() {
869       assertConsoleResetCount(0);
870 // assertCompileStartCount(1);
871
// assertCompileEndCount(1);
872
// don't care whether interactions or console are reset first
873
synchronized(this) { consoleResetCount++; }
874     }
875     
876     public void resetConsoleResetCount() { consoleResetCount = 0; }
877     
878     public void logInteractionStart() {
879       _interactionDone = false;
880       _resetDone = false;
881     }
882     
883     public void waitInteractionDone() throws InterruptedException JavaDoc {
884       synchronized(_interactionLock) { while (! _interactionDone) _interactionLock.wait(); }
885     }
886     
887     public void waitResetDone() throws InterruptedException JavaDoc {
888       synchronized(_resetLock) { while (! _resetDone) _resetLock.wait(); }
889     }
890     
891     public int getLastExitStatus() { return _lastExitStatus; }
892   };
893   
894   
895   /** A model listener for situations expecting a compilation to fail. The _expectReset flag determines if interactions
896    * are reset after a compilation. The interactionsReset() method notifies when reset has occurred.
897    */

898   public static class CompileShouldSucceedListener extends InteractionListener {
899     private volatile boolean _expectReset;
900     
901     private volatile boolean _compileDone = false; // records when compilaton is done
902
private final Object JavaDoc _compileLock = new Object JavaDoc(); // lock for _compileDone
903

904     public void logCompileStart() {
905       logInteractionStart();
906       _compileDone = false;
907     }
908     
909     public void compile(OpenDefinitionsDocument doc) throws IOException JavaDoc, InterruptedException JavaDoc {
910       logCompileStart();
911       doc.startCompile();
912       waitCompileDone();
913     }
914     
915     public void waitCompileDone() throws InterruptedException JavaDoc {
916       synchronized(_compileLock) {
917         while (! _compileDone) {
918 // System.err.println("Waiting for JUnit to complete");
919
_compileLock.wait();
920         }
921       }
922     }
923   
924     private void _notifyCompileDone() {
925       synchronized(_compileLock) {
926         _compileDone = true;
927         _compileLock.notify();
928       }
929     }
930     
931     /** Standard constructor.
932      * @param expectReset Whether to listen for interactions being
933      */

934     public CompileShouldSucceedListener(boolean expectReset) { _expectReset = expectReset; }
935     
936     public CompileShouldSucceedListener() { this(false); }
937     
938 // public boolean notDone() { return ! _interactionsReset; }
939

940     @Override JavaDoc public void newFileCreated(OpenDefinitionsDocument doc) { /* ingore this operation */ }
941     
942     @Override JavaDoc public void compileStarted() {
943 // Utilities.showDebug("compileStarted called in CSSListener");
944
assertCompileStartCount(0);
945       assertCompileEndCount(0);
946       assertInterpreterResettingCount(0);
947       assertInterpreterReadyCount(0);
948       assertConsoleResetCount(0);
949       synchronized(this) { compileStartCount++; }
950     }
951     
952     @Override JavaDoc public void compileEnded(File JavaDoc workDir, List JavaDoc<? extends File JavaDoc> excludedFiles) {
953 // Utilities.showDebug("compileEnded called in CSSListener");
954
assertCompileEndCount(0);
955       assertCompileStartCount(1);
956       assertInterpreterResettingCount(0);
957       assertInterpreterReadyCount(0);
958       assertConsoleResetCount(0);
959       synchronized(this) { compileEndCount++; }
960       _notifyCompileDone();
961     }
962     
963     public void checkCompileOccurred() {
964       assertCompileEndCount(1);
965       assertCompileStartCount(1);
966 // if (_expectReset) {
967
// assertInterpreterResettingCount(1);
968
// assertInterpreterReadyCount(1);
969
// }
970
// else {
971
// assertInterpreterResettingCount(0);
972
// assertInterpreterReadyCount(0);
973
// }
974

975       // Note: console is no longer reset after a compile
976
//assertConsoleResetCount(1);
977
}
978   }
979     
980   /** A model listener for situations expecting a compilation to fail. */
981   public static class CompileShouldFailListener extends TestListener {
982     
983     private volatile boolean _compileDone = false; // records when compilaton is done
984
private final Object JavaDoc _compileLock = new Object JavaDoc(); // lock for _compileDone
985

986     public void logCompileStart() { _compileDone = false; }
987     
988     public void waitCompileDone() throws InterruptedException JavaDoc {
989       synchronized(_compileLock) {
990         while (! _compileDone) {
991 // System.err.println("Waiting for JUnit to complete");
992
_compileLock.wait();
993         }
994       }
995     }
996     
997     public void compile(OpenDefinitionsDocument doc) throws IOException JavaDoc, InterruptedException JavaDoc {
998       logCompileStart();
999       doc.startCompile();
1000      waitCompileDone();
1001    }
1002    
1003    private void _notifyCompileDone() {
1004      synchronized(_compileLock) {
1005        _compileDone = true;
1006        _compileLock.notify();
1007      }
1008    }
1009    
1010    @Override JavaDoc public void compileStarted() {
1011      assertCompileStartCount(0);
1012      assertCompileEndCount(0);
1013      synchronized(this) { compileStartCount++; }
1014    }
1015    
1016    @Override JavaDoc public void compileEnded(File JavaDoc workDir, List JavaDoc<? extends File JavaDoc> excludedFiles) {
1017// Utilities.showDebug("compileEnded called in CSSListener");
1018
assertCompileEndCount(0);
1019      assertCompileStartCount(1);
1020      assertInterpreterResettingCount(0);
1021      assertInterpreterReadyCount(0);
1022      assertConsoleResetCount(0);
1023      synchronized(this) { compileEndCount++; }
1024      _notifyCompileDone();
1025    }
1026    
1027    public void checkCompileOccurred() {
1028      assertCompileEndCount(1);
1029      assertCompileStartCount(1);
1030    }
1031    
1032  }
1033  
1034  public static class JUnitTestListener extends CompileShouldSucceedListener {
1035    
1036    protected volatile boolean _junitDone = false;
1037    protected final Object JavaDoc _junitLock = new Object JavaDoc();
1038    
1039    // handle System.out's separately but default to outer class's printMessage value
1040
protected volatile boolean printMessages = GlobalModelJUnitTest.printMessages;
1041    
1042    public void logJUnitStart() {
1043      logCompileStart();
1044      _junitDone = false;
1045    }
1046    
1047    /** Runs JUnit on doc to completion. */
1048    public void runJUnit(OpenDefinitionsDocument doc) throws IOException JavaDoc, ClassNotFoundException JavaDoc,
1049      InterruptedException JavaDoc {
1050      logJUnitStart();
1051// System.err.println("Starting JUnit on " + doc);
1052
doc.startJUnit();
1053// System.err.println("JUnit Started on " + doc);
1054
waitJUnitDone();
1055    }
1056    
1057    public void runJUnit(JUnitModel jm) throws IOException JavaDoc, ClassNotFoundException JavaDoc, InterruptedException JavaDoc {
1058      logJUnitStart();
1059// System.err.println("Starting JUnit");
1060
jm.junitAll();
1061      waitJUnitDone();
1062    }
1063    
1064    public void waitJUnitDone() throws InterruptedException JavaDoc {
1065      synchronized(_junitLock) { while (! _junitDone) { _junitLock.wait(); } }
1066    }
1067    
1068    private void _notifyJUnitDone() {
1069      synchronized(_junitLock) {
1070        _junitDone = true;
1071        _junitLock.notify();
1072      }
1073    }
1074    
1075    /** Construct JUnitTestListener without resetting interactions */
1076    public JUnitTestListener() { this(false, false); }
1077    public JUnitTestListener(boolean shouldResetAfterCompile) { this(shouldResetAfterCompile, false); }
1078    public JUnitTestListener(boolean shouldResetAfterCompile, boolean printListenerMessages) {
1079      super(shouldResetAfterCompile);
1080      this.printMessages = printListenerMessages;
1081    }
1082    public void resetCompileCounts() {
1083      compileStartCount = 0;
1084      compileEndCount = 0;
1085    }
1086    @Override JavaDoc public void junitStarted() {
1087      if (printMessages) System.out.println("listener.junitStarted");
1088      synchronized(this) { junitStartCount++; }
1089    }
1090    @Override JavaDoc public void junitSuiteStarted(int numTests) {
1091      if (printMessages) System.out.println("listener.junitSuiteStarted, numTests = "+numTests);
1092      assertJUnitStartCount(1);
1093      synchronized(this) { junitSuiteStartedCount++; }
1094    }
1095    @Override JavaDoc public void junitTestStarted(String JavaDoc name) {
1096      if (printMessages) System.out.println(" listener.junitTestStarted, " + name);
1097      synchronized(this) { junitTestStartedCount++; }
1098    }
1099    @Override JavaDoc public void junitTestEnded(String JavaDoc name, boolean wasSuccessful, boolean causedError) {
1100      if (printMessages) System.out.println(" listener.junitTestEnded, name = " + name + " succ = " + wasSuccessful +
1101                                            " err = " + causedError);
1102      synchronized(this) { junitTestEndedCount++; }
1103      assertEquals("junitTestEndedCount should be same as junitTestStartedCount", junitTestEndedCount,
1104                   junitTestStartedCount);
1105    }
1106    @Override JavaDoc public void nonTestCase(boolean isTestAll) {
1107      if (printMessages) System.out.println("listener.nonTestCase, isTestAll=" + isTestAll);
1108      synchronized(this) { nonTestCaseCount++; }
1109      _notifyJUnitDone();
1110    }
1111    @Override JavaDoc public void classFileError(ClassFileError e) {
1112      if (printMessages) System.out.println("listener.classFileError, e="+e);
1113      synchronized(this) { classFileErrorCount++; }
1114      _notifyJUnitDone();
1115    }
1116    @Override JavaDoc public void junitEnded() {
1117      //assertJUnitSuiteStartedCount(1);
1118
if (printMessages) System.out.println("junitEnded event!");
1119      synchronized(this) { junitEndCount++; }
1120      _notifyJUnitDone();
1121    }
1122  }
1123  
1124  /** Listener class for failing JUnit invocation. */
1125  public static class JUnitNonTestListener extends JUnitTestListener {
1126    private volatile boolean _shouldBeTestAll;
1127    public JUnitNonTestListener() { this(false); }
1128    public JUnitNonTestListener(boolean shouldBeTestAll) { _shouldBeTestAll = shouldBeTestAll; }
1129    public void nonTestCase(boolean isTestAll) {
1130      synchronized(this) { nonTestCaseCount++; }
1131      assertEquals("Non test case heard the wrong value for test current/test all", _shouldBeTestAll, isTestAll);
1132// Utilities.show("synchronizing on _junitLock");
1133
synchronized(_junitLock) {
1134// System.err.println("JUnit aborted as nonTestCase");
1135
_junitDone = true;
1136        _junitLock.notify();
1137      }
1138    }
1139  }
1140  
1141  /* A variant of DefaultGlobalModel used only for testing purposes. This variant
1142   * does not change the working directory when resetting interactions. This test class and its
1143   * descendants were written before the distinction between getWorkingDirectory and getMasterDirectory.
1144   * This method override restores the old semantics for getWorkingDirectory. The new definition breaks
1145   * some unit tests because the slave JVM keeps its working directory open until it shuts down.
1146   */

1147   public class TestGlobalModel extends DefaultGlobalModel {
1148    public File JavaDoc getWorkingDirectory() { return getMasterWorkingDirectory(); }
1149  }
1150}
1151
Popular Tags