You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by sb...@apache.org on 2002/02/01 22:39:14 UTC

cvs commit: jakarta-ant/proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit/remote Server.java TestRunEvent.java

sbailliez    02/02/01 13:39:14

  Modified:    proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit/remote
                        Server.java TestRunEvent.java
  Log:
  - Add equals method to event.
  - Fix server shutdown
  
  Revision  Changes    Path
  1.8       +4 -5      jakarta-ant/proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit/remote/Server.java
  
  Index: Server.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit/remote/Server.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Server.java	1 Feb 2002 19:55:48 -0000	1.7
  +++ Server.java	1 Feb 2002 21:39:13 -0000	1.8
  @@ -111,8 +111,8 @@
       }
   
       /** 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 @@
       }
   
       /** 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 @@
       }
   
       /** shutdown the server and any running client */
  -    public void shutdown() {
  +    public synchronized void shutdown() {
           try {
               if (messenger != null) {
                   messenger.close();
  @@ -174,7 +174,6 @@
               } 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();
  
  
  
  1.2       +16 -1     jakarta-ant/proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit/remote/TestRunEvent.java
  
  Index: TestRunEvent.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit/remote/TestRunEvent.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestRunEvent.java	30 Jan 2002 21:06:49 -0000	1.1
  +++ TestRunEvent.java	1 Feb 2002 21:39:13 -0000	1.2
  @@ -153,7 +153,22 @@
           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();
       }
   }
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>