Browse Source

- Add equals method to event.

- Fix server shutdown


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271040 13f79535-47bb-0310-9956-ffa450edef68
master
Stephane Bailliez 23 years ago
parent
commit
982958016a
2 changed files with 20 additions and 6 deletions
  1. +4
    -5
      proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit/remote/Server.java
  2. +16
    -1
      proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit/remote/TestRunEvent.java

+ 4
- 5
proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit/remote/Server.java View File

@@ -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();


+ 16
- 1
proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit/remote/TestRunEvent.java View File

@@ -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();
}
}

Loading…
Cancel
Save