You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by da...@apache.org on 2002/10/14 18:14:56 UTC

cvs commit: jakarta-james/tests/src/java/org/apache/james/testing EndToEnd.java SMTPDeliveryWorker.java

danny       2002/10/14 09:14:55

  Modified:    tests/src/java/org/apache/james/testing EndToEnd.java
                        SMTPDeliveryWorker.java
  Log:
  tidying up, and adding run of second admin script
  
  Revision  Changes    Path
  1.3       +41 -19    jakarta-james/tests/src/java/org/apache/james/testing/EndToEnd.java
  
  Index: EndToEnd.java
  ===================================================================
  RCS file: /home/cvs/jakarta-james/tests/src/java/org/apache/james/testing/EndToEnd.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- EndToEnd.java	14 Oct 2002 06:44:22 -0000	1.2
  +++ EndToEnd.java	14 Oct 2002 16:14:54 -0000	1.3
  @@ -105,18 +105,15 @@
           try {
               client.setDefaultTimeout(500);
               client.connect("127.0.0.1", 4555);
  -            in = new BufferedReader(new InputStreamReader(client.getInputStream()));
  -            OutputStream oo = client.getOutputStream();
  -            out = new OutputStreamWriter(oo);
  -            print(in, System.out);
  -            for (int i = 0; i < script1.length; i++) {
  -                out.write(script1[i] + "\n");
  -                System.out.println(" " + script1[i] + " \n");
  -                out.flush();
  -                print(in, System.out);
  -            }
  -            mailTest();
  +            runTelnetScript(client, script1);
  +            client.disconnect();
  +            SMTPTest();
  +            POP3Test();
  +            client.connect("127.0.0.1", 4555);
  +            runTelnetScript(client, script2);
               client.disconnect();
  +                        
  +            
           } catch (SocketException e) {
               e.printStackTrace();
               assertTrue(false);
  @@ -126,6 +123,21 @@
           }
       }
   
  +    private void runTelnetScript(TelnetClient client, String[] script) throws IOException {
  +        BufferedReader in;
  +        OutputStreamWriter out;
  +        in = new BufferedReader(new InputStreamReader(client.getInputStream()));
  +        OutputStream oo = client.getOutputStream();
  +        out = new OutputStreamWriter(oo);
  +        print(in, System.out);
  +        for (int i = 0; i < script.length; i++) {
  +            out.write(script[i] + "\n");
  +            System.out.println(" " + script[i] + " \n");
  +            out.flush();
  +            print(in, System.out);
  +        }
  +    }
  +
       private void echo(OutputStreamWriter out) {
       }
   
  @@ -153,10 +165,10 @@
       }
   
       /**
  -     * Carries out the "mail" aspects of the tests, spawning the appropriate
  +     * Carries out theSMTPmail" aspects of the tests, spawning the appropriate
        * worker threads.
        */
  -    private void mailTest() {
  +    private void SMTPTest() {
           start = new Date();
           StringBuffer mail1 = new StringBuffer();
           mail1.append(
  @@ -181,7 +193,16 @@
               // TODO: Shouldn't this busy loop be replaced with an
               //       appropriate timed wait?
           }
  -        try {
  +        
  +        long time = (new Date()).getTime() - start.getTime();
  +        System.err.println("time total " + (int) time);
  +    }
  +
  +    /**
  +     *  End to end test of POP3 functionality.
  +     */
  +    private void POP3Test() {
  +       try {
               POP3Client pclient = new POP3Client();
               pclient.connect("127.0.0.1", 110);
               System.out.println(pclient.getReplyString());
  @@ -193,13 +214,14 @@
               pclient.disconnect();
               System.out.println(pclient.getReplyString());
           } catch (SocketException e) {
  -            //TODO: This should be recorded
  +            e.printStackTrace();
  +            assertTrue(false);
           } catch (IOException e) {
  -            //TODO: This should be recorded
  +            e.printStackTrace();
  +            assertTrue(false);
           }
  -        long time = (new Date()).getTime() - start.getTime();
  -        System.err.println("time total " + (int) time);
       }
  +
   
       /**
        * Record that a particular worker thread has finished.
  
  
  
  1.3       +6 -13     jakarta-james/tests/src/java/org/apache/james/testing/SMTPDeliveryWorker.java
  
  Index: SMTPDeliveryWorker.java
  ===================================================================
  RCS file: /home/cvs/jakarta-james/tests/src/java/org/apache/james/testing/SMTPDeliveryWorker.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SMTPDeliveryWorker.java	14 Oct 2002 06:44:22 -0000	1.2
  +++ SMTPDeliveryWorker.java	14 Oct 2002 16:14:55 -0000	1.3
  @@ -19,23 +19,19 @@
    */
   public class SMTPDeliveryWorker implements Runnable {
       private SMTPClient client;
  -
       /**
        * The test of the mail message to send.
        */
       private String mail;
  -
       /**
        * The worker id.  Primarily used for identification by the class
        * managing the threads.
        */
       private int workerid;
  -
       /**
        * The EndToEnd test case that spawned this thread.
        */
       EndToEnd boss;
  -
       /**
        * Constructor for SMTPDeliveryWorker.
        *
  @@ -51,25 +47,23 @@
        */
       public void run() {
           try {
  -            
  -            //move the connect and disconnect into the loop to make a new connection for every mail
  -            client.connect("127.0.0.1", 25);
               for (int run = 0; run < 100; run++) {
  -                //System.out.println(client.getReplyString());
  +                //move the connect and disconnect out of the loop to reuse 
  +                // the connection for all mail
  +                client.connect("127.0.0.1", 25);
                   client.sendSimpleMessage("postmaster@localhost", "test@localhost", mail);
                   boss.delivered();
  +                client.disconnect();
               }
  -            client.disconnect();
               String[] outs = client.getReplyStrings();
               for (int i = 0; i < outs.length; i++) {
                   System.out.println(outs[i]);
               }
           } catch (IOException e) {
  -            System.err.println("argh! "+workerid+" "+e.getMessage());
  +            System.err.println("argh! " + workerid + " " + e.getMessage());
           }
           boss.finished(workerid);
       }
  -
       /**
        * Set the worker id for this worker thread.
        *
  @@ -78,7 +72,6 @@
       public void setWorkerid(int workerid) {
           this.workerid = workerid;
       }
  -
       /**
        * Get the worker id for this worker thread.
        *
  
  
  

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