Skip to content

Commit 2331c79

Browse files
committed
Streamlined MultiThreadedTestCase and DrJavaTestCase because of failing test in ProjectMenuTest.java. The setUp method in DrJavaTestCase appeared broken when assert checking was enabled.
Changes to be committed: modified: ../../drjava/DrJavaTestCase.java modified: ../../drjava/model/MultiThreadedTestCase.java modified: ../../drjava/ui/ProjectMenuTest.java modified: AbstractMasterJVM.java
1 parent 458e0a2 commit 2331c79

File tree

4 files changed

+31
-37
lines changed

4 files changed

+31
-37
lines changed

drjava/src/edu/rice/cs/drjava/DrJavaTestCase.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,20 @@ public class DrJavaTestCase extends TestCase {
6161
protected void setUp() throws Exception {
6262
super.setUp(); // declared to throw Exception, forcing throws clause on preceding line
6363
Utilities.TEST_MODE = true;
64-
final String newName = System.getProperty("drjava.test.config");
65-
assert newName != null;
66-
64+
// final String newName = System.getProperty("drjava.test.config");
65+
// assert newName != null; // The preceding property is never set in main drjava code base, so this assert will fail
66+
6767
// Utilities.show("newName = '" + newName + "'");
6868

69-
if (newName != null) { // in deployed code, assertion checking may be turned off
70-
Utilities.invokeAndWait(new Runnable() {
71-
public void run() {
72-
DrJava.setPropertiesFile(newName); // spawns change updates which should run in event thread
73-
// Utilities.clearEventQueue();
74-
DrJava._initConfig(); // spawns change updates which should run in event thread
75-
}
76-
});
77-
}
69+
// if (newName != null) { // in deployed code, assertion checking may be turned off
70+
// Utilities.invokeAndWait(new Runnable() {
71+
// public void run() {
72+
// DrJava.setPropertiesFile(newName); // spawns change updates which should run in event thread
73+
//// Utilities.clearEventQueue();
74+
// DrJava._initConfig(); // spawns change updates which should run in event thread
75+
// }
76+
// });
77+
// }
7878
}
7979

8080
/** Clean up for every test case. Only used in unit tests. Added because Windows would intermittently throw

drjava/src/edu/rice/cs/drjava/model/MultiThreadedTestCase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public void uncaughtException(java.lang.Thread t, Throwable e) {
129129
_t = t;
130130
_e = e;
131131
if (_mainThread != null) {
132-
// System.err.println("***Uncaught Exception in spawned thread within a MultiThreadedTestCase:");
132+
System.err.println("***Uncaught Exception in spawned thread within a MultiThreadedTestCase:");
133133
e.printStackTrace(System.out);
134134
_mainThread.interrupt();
135135
}

drjava/src/edu/rice/cs/drjava/ui/ProjectMenuTest.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,12 @@ public final class ProjectMenuTest extends MultiThreadedTestCase {
6969

7070
private volatile String _projFileText = null;
7171

72-
/** Invokes setUp() in DrJavaTestCase. This superclass is accessible from anonymous inner classes.
73-
* @throws Exception if something goes wrong
74-
*/
75-
private void superSetUp() throws Exception { super.setUp(); }
76-
7772
/** Setup method for each JUnit test case in this Test class.
7873
* @throws Exception This convention is mandated by the JUnit TestClass which is an ancestor of this class.
7974
*/
8075
public void setUp() throws Exception {
8176
// Perform Swing setup in event thread because the event thread is ALREADY running
82-
superSetUp(); // super.setUp() should be called first; contains an embedded invokeAndWait
77+
super.setUp(); // contains an embedded invokeAndWait in DrJavaTestCase
8378

8479
Utilities.invokeAndWait(new Runnable() {
8580
public void run() {
@@ -113,7 +108,6 @@ public void run() {
113108
_frame.pack();
114109
_model = _frame.getModel();
115110
_model.ensureJVMStarterFinished();
116-
// superSetUp();
117111
}
118112
// Exception e is either an IOException from a file operation or an Exception thrown by superSetUp().
119113
catch(Exception e) { throw new UnexpectedException(e); }

drjava/src/edu/rice/cs/util/newjvm/AbstractMasterJVM.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,17 @@
5050
import static edu.rice.cs.plt.debug.DebugUtil.debug;
5151
import static edu.rice.cs.plt.debug.DebugUtil.error;
5252

53-
/** * An abstract class implementing the logic to invoke and control, via RMI, a second Java virtual
54-
* machine. This class is used by subclassing it. (See package documentation for more details.)
55-
* The state-changing methods of this class consistently block until a precondition for the state
56-
* change is satisfied — for example, {@link #quitSlave} cannot complete until a slave is
57-
* running. Only one thread may change the state at a time. Thus, clients should be careful
58-
* to only invoke state-changing methods when they are guaranteed to succeed (only invoking
59-
* {@code quitSlave()}, for example, when it is known to have been matched by a successful
60-
* {@code invokeSlave} invocation).
61-
*
62-
* @version $Id$
63-
*/
53+
/** An abstract class implementing the logic to invoke and control, via RMI, a second Java virtual
54+
* machine. This class is used by subclassing it. (See package documentation for more details.)
55+
* The state-changing methods of this class consistently block until a precondition for the state
56+
* change is satisfied — for example, {@link #quitSlave} cannot complete until a slave is
57+
* running. Only one thread may change the state at a time. Thus, clients should be careful
58+
* to only invoke state-changing methods when they are guaranteed to succeed (only invoking
59+
* {@code quitSlave()}, for example, when it is known to have been matched by a successful
60+
* {@code invokeSlave} invocation).
61+
*
62+
* @version $Id$
63+
*/
6464
public abstract class AbstractMasterJVM implements MasterRemote {
6565

6666
/** Debugging log. */
@@ -194,25 +194,25 @@ public void run(Process p) {
194194
* @throws IllegalStateException If this object has been disposed.
195195
*/
196196
protected final void quitSlave() {
197-
transition(State.RUNNING, State.QUITTING);
197+
transition(State.RUNNING, State.QUITTING); // may throw IllegalStateException
198198
attemptQuit(_slave);
199199
_slave = null;
200200
_monitor.set(State.FRESH);
201201
//debug.log("Entered state " + State.FRESH);
202202
}
203203

204204
/** Make a best attempt to invoke {@code slave.quit()}. Log an error if it fails.
205-
* @param slave link to the slave JVM
206-
*/
205+
* @param slave link to the slave JVM
206+
*/
207207
private static void attemptQuit(SlaveRemote slave) {
208208
try { slave.quit(); }
209209
catch (RemoteException e) { error.log("Unable to complete slave.quit()", e); }
210210
}
211211

212212
/** Free the resources required for this object to respond to RMI invocations (useful for applications -- such as
213-
* testing -- that produce a large number of MasterJVMs as a program runs). Requires the slave to have
214-
* quit; blocks until that occurs. After an object has been disposed, it is no longer useful.
215-
*/
213+
* testing -- that produce a large number of MasterJVMs as a program runs). Requires the slave to have
214+
* quit; blocks until that occurs. After an object has been disposed, it is no longer useful.
215+
*/
216216
protected void dispose() {
217217
transition(State.FRESH, State.DISPOSED);
218218
if (_masterStub.isResolved()) {

0 commit comments

Comments
 (0)