hbedi       2002/10/20 07:08:11

  Modified:    tests/src/java/org/apache/james/testing
                        ProtocolSimulator.java
  Log:
  minor fix. Line numbers were not right if there is a failure.
  line numbers for empty and comment lines were ignored.
  
  Revision  Changes    Path
  1.5       +24 -15    
jakarta-james/tests/src/java/org/apache/james/testing/ProtocolSimulator.java
  
  Index: ProtocolSimulator.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-james/tests/src/java/org/apache/james/testing/ProtocolSimulator.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ProtocolSimulator.java    19 Oct 2002 19:58:17 -0000      1.4
  +++ ProtocolSimulator.java    20 Oct 2002 14:08:11 -0000      1.5
  @@ -96,16 +96,6 @@
           runSimulation(simulation);
       }
       
  -    /** represents a single protocol interaction */
  -    private static interface Command {
  -        /** 
  -         * do something. Either write to or read from and validate 
  -         * @param reader Input from protocol server
  -         * @param writer Output to protocol Server 
  -         */
  -        public void execute(BufferedReader reader,PrintWriter writer) throws 
Throwable;
  -    }
  -    
       // ---- methods to fire off simulation ---------
   
       /** Starts simulation threads. Blocks till simulation threads are done. */
  @@ -178,10 +168,10 @@
                   break;
               // ignore empty lines.
               if ( templateLine.trim().length() == 0 )
  -                continue;
  -            if ( templateLine.startsWith(COMMENT_TAG) )
  -                continue;
  -            if ( templateLine.startsWith(CLIENT_TAG) ) {
  +                list.add(new NOOPCmd());
  +            else if ( templateLine.startsWith(COMMENT_TAG) )
  +                list.add(new NOOPCmd());
  +            else if ( templateLine.startsWith(CLIENT_TAG) ) {
                   list.add(new Command() {
                           // just send the client data
                           public void execute(BufferedReader reader,PrintWriter 
writer) 
  @@ -215,8 +205,9 @@
                       throws Throwable 
                   {
                       for ( int i = 0 ; i < list.size() ; i++ ) {
  +                        Command cmd = (Command)list.get(i);
                           try {
  -                            ((Command)list.get(i)).execute(reader,writer);
  +                            cmd.execute(reader,writer);
                           } catch(Throwable t) {
                               System.out.println("Failed on line: "+i);
                               throw t;
  @@ -225,5 +216,23 @@
                   }
               };
           return simulation;
  +    }
  +
  +    // ----- helper abstractions -------
  +
  +    /** represents a single protocol interaction */
  +    private interface Command {
  +        /** 
  +         * do something. Either write to or read from and validate 
  +         * @param reader Input from protocol server
  +         * @param writer Output to protocol Server 
  +         */
  +        public abstract void execute(BufferedReader reader,PrintWriter writer) 
throws Throwable;
  +    }
  +
  +    /** do nothing */
  +    private static class NOOPCmd implements Command {
  +        public void execute(BufferedReader reader,PrintWriter writer) 
  +            throws Throwable { }
       }
   }
  
  
  

--
To unsubscribe, e-mail:   <mailto:james-dev-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:james-dev-help@;jakarta.apache.org>

Reply via email to