diff --git a/proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit/remote/Server.java b/proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit/remote/Server.java index ed9769732..874718764 100644 --- a/proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit/remote/Server.java +++ b/proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit/remote/Server.java @@ -111,8 +111,8 @@ public class Server { } /** return whether there is a client running or not */ - public boolean isRunning() { - return client != null; + public synchronized boolean isRunning() { + return client != null && server != null && messenger != null; } /** start a server to the specified port */ @@ -122,7 +122,7 @@ public class Server { } /** cancel the connection to the client */ - public void cancel() { + public synchronized void cancel() { if (isRunning()) { TestRunEvent evt = new TestRunEvent(new Integer(-1), TestRunEvent.RUN_STOP); try { @@ -133,7 +133,7 @@ public class Server { } /** shutdown the server and any running client */ - public void shutdown() { + public synchronized void shutdown() { try { if (messenger != null) { messenger.close(); @@ -174,7 +174,6 @@ public class Server { } catch (Exception e) { //@fixme this stacktrace might be normal when closing // the socket. So decompose the above in distinct steps - e.printStackTrace(); } finally { cancel(); shutdown(); diff --git a/proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit/remote/TestRunEvent.java b/proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit/remote/TestRunEvent.java index df9b491fa..8f946f24a 100644 --- a/proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit/remote/TestRunEvent.java +++ b/proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit/remote/TestRunEvent.java @@ -153,7 +153,22 @@ public class TestRunEvent extends EventObject { return props; } + public boolean equals(Object o){ + if (o instanceof TestRunEvent){ + TestRunEvent other = (TestRunEvent)o; + return ( (type == other.type) && + (timestamp == other.timestamp) && + ( name == null ? other.name == null : name.equals(other.name) ) && + ( stacktrace == null ? other.stacktrace == null : stacktrace.equals(other.stacktrace) ) && + ( props == null ? other.props == null : props.equals(other.props) ) ) ; + } + return false; + } + public String toString(){ - return "Id: " + source + ", Type: " + type; + StringBuffer buf = new StringBuffer(); + buf.append("id: ").append(source); + buf.append("type: ").append(type); + return buf.toString(); } }