ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sbaill...@apache.org
Subject cvs commit: jakarta-ant/proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit TestRunListener.java
Date Sat, 05 Jan 2002 22:08:44 GMT
sbailliez    02/01/05 14:08:44

  Modified:    proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit/formatter
                        BaseFormatter.java BriefFormatter.java
                        DefaultTestRunListener.java FilterFormatter.java
                        FilterStackFormatter.java SummaryFormatter.java
                        XMLFormatter.java
               proposal/sandbox/junit/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/formatter
                        FilterStackFormatterTest.java
               proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit/remote
                        MessageReader.java
               proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit
                        TestRunListener.java
  Log:
  Rename the listener methods to onXXX(). It is more meaningful in this case
  since otherwise it conflitcts somewhat with the testXXX methods in a testcase.
  
  It leads to terrible code in testcase since we cannot then say that the testcase
  is a testrunlistener (or a formatter) because of the method naming guidelines.
  
  Revision  Changes    Path
  1.2       +9 -9      jakarta-ant/proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit/formatter/BaseFormatter.java
  
  Index: BaseFormatter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit/formatter/BaseFormatter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BaseFormatter.java	5 Jan 2002 19:06:44 -0000	1.1
  +++ BaseFormatter.java	5 Jan 2002 22:08:44 -0000	1.2
  @@ -100,22 +100,22 @@
       public void setSystemError(String err) {
       }
   
  -    public void testStdOutLine(String testname, String line) {
  +    public void onTestStdOutLine(String testname, String line) {
       }
   
  -    public void testStdErrLine(String testname, String line) {
  +    public void onTestStdErrLine(String testname, String line) {
       }
   
  -    public void testRunSystemProperties(Properties props) {
  +    public void onTestRunSystemProperties(Properties props) {
       }
   
  -    public void testStarted(String testname) {
  +    public void onTestStarted(String testname) {
       }
   
  -    public void testEnded(String testname) {
  +    public void onTestEnded(String testname) {
       }
   
  -    public void testFailed(int status, String testname, String trace) {
  +    public void onTestFailed(int status, String testname, String trace) {
           if (status == STATUS_ERROR) {
               errorCount++;
           } else if (status == STATUS_FAILURE) {
  @@ -123,15 +123,15 @@
           }
       }
   
  -    public void testRunStarted(int testcount) {
  +    public void onTestRunStarted(int testcount) {
           runCount = testcount;
       }
   
  -    public void testRunEnded(long elapsedtime) {
  +    public void onTestRunEnded(long elapsedtime) {
           finished(elapsedtime);
       }
   
  -    public void testRunStopped(long elapsedtime) {
  +    public void onTestRunStopped(long elapsedtime) {
           finished(elapsedtime);
       }
   
  
  
  
  1.2       +2 -2      jakarta-ant/proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit/formatter/BriefFormatter.java
  
  Index: BriefFormatter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit/formatter/BriefFormatter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BriefFormatter.java	5 Jan 2002 19:06:44 -0000	1.1
  +++ BriefFormatter.java	5 Jan 2002 22:08:44 -0000	1.2
  @@ -62,7 +62,7 @@
    */
   public class BriefFormatter extends SummaryFormatter {
   
  -    public void testFailed(int status, String testname, String trace) {
  +    public void onTestFailed(int status, String testname, String trace) {
           writer.print("TestCase: ");
           writer.print(testname);
           if (status == STATUS_ERROR) {
  @@ -74,7 +74,7 @@
           writer.print(trace);
           writer.println();
           writer.println();
  -        super.testFailed(status, testname, trace);
  +        super.onTestFailed(status, testname, trace);
       }
   
   }
  
  
  
  1.2       +13 -7     jakarta-ant/proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit/formatter/DefaultTestRunListener.java
  
  Index: DefaultTestRunListener.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit/formatter/DefaultTestRunListener.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultTestRunListener.java	5 Jan 2002 19:06:44 -0000	1.1
  +++ DefaultTestRunListener.java	5 Jan 2002 22:08:44 -0000	1.2
  @@ -63,32 +63,38 @@
    */
   public class DefaultTestRunListener implements TestRunListener {
   
  -    public void testStarted(String testname) {
  +    public void onTestStarted(String testname) {
           System.out.println("Started " + testname);
       }
   
  -    public void testEnded(String testname) {
  +    public void onTestEnded(String testname) {
           System.out.println("Ended " + testname);
       }
   
  -    public void testFailed(int status, String testname, String trace) {
  +    public void onTestFailed(int status, String testname, String trace) {
           System.out.println(testname + " failed with status " + status);
           System.out.println(trace);
       }
   
  -    public void testRunSystemProperties(Properties props) {
  +    public void onTestRunSystemProperties(Properties props) {
           System.out.println("properties: " + props);
       }
   
  -    public void testRunStarted(int testcount) {
  +    public void onTestRunStarted(int testcount) {
           System.out.println("testsuite:  " + testcount);
       }
   
  -    public void testRunEnded(long elapsedtime) {
  +    public void onTestStdOutLine(String testname, String line) {
  +    }
  +
  +    public void onTestStdErrLine(String testname, String line) {
  +    }
  +
  +    public void onTestRunEnded(long elapsedtime) {
           System.out.println("testsuite ended after: " + elapsedtime);
       }
   
  -    public void testRunStopped(long elapsedtime) {
  +    public void onTestRunStopped(long elapsedtime) {
           System.out.println("testsuite stopped after: " + elapsedtime);
       }
   }
  
  
  
  1.2       +22 -14    jakarta-ant/proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit/formatter/FilterFormatter.java
  
  Index: FilterFormatter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit/formatter/FilterFormatter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FilterFormatter.java	5 Jan 2002 19:06:44 -0000	1.1
  +++ FilterFormatter.java	5 Jan 2002 22:08:44 -0000	1.2
  @@ -73,39 +73,47 @@
           formatter.setOutput(out);
       }
   
  -    public void testStarted(String testname) {
  -        formatter.testStarted(testname);
  +    public void onTestStdOutLine(String testname, String line) {
  +        formatter.onTestStdOutLine(testname, line);
  +    }
  +
  +    public void onTestStdErrLine(String testname, String line) {
  +        formatter.onTestStdErrLine(testname, line);
  +    }
  +
  +    public void onTestStarted(String testname) {
  +        formatter.onTestStarted(testname);
       }
   
       public void setSystemOutput(String out) {
           formatter.setSystemOutput(out);
       }
   
  -    public void testEnded(String testname) {
  -        formatter.testEnded(testname);
  +    public void onTestEnded(String testname) {
  +        formatter.onTestEnded(testname);
       }
   
       public void setSystemError(String err) {
           formatter.setSystemError(err);
       }
   
  -    public void testFailed(int status, String testname, String trace) {
  -        formatter.testFailed(status, testname, trace);
  +    public void onTestFailed(int status, String testname, String trace) {
  +        formatter.onTestFailed(status, testname, trace);
       }
   
  -    public void testRunSystemProperties(Properties props) {
  -        formatter.testRunSystemProperties(props);
  +    public void onTestRunSystemProperties(Properties props) {
  +        formatter.onTestRunSystemProperties(props);
       }
   
  -    public void testRunStarted(int testcount) {
  -        formatter.testRunStarted(testcount);
  +    public void onTestRunStarted(int testcount) {
  +        formatter.onTestRunStarted(testcount);
       }
   
  -    public void testRunEnded(long elapsedtime) {
  -        formatter.testRunEnded(elapsedtime);
  +    public void onTestRunEnded(long elapsedtime) {
  +        formatter.onTestRunEnded(elapsedtime);
       }
   
  -    public void testRunStopped(long elapsedtime) {
  -        formatter.testRunEnded(elapsedtime);
  +    public void onTestRunStopped(long elapsedtime) {
  +        formatter.onTestRunEnded(elapsedtime);
       }
   }
  
  
  
  1.2       +2 -2      jakarta-ant/proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit/formatter/FilterStackFormatter.java
  
  Index: FilterStackFormatter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit/formatter/FilterStackFormatter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FilterStackFormatter.java	5 Jan 2002 19:06:44 -0000	1.1
  +++ FilterStackFormatter.java	5 Jan 2002 22:08:44 -0000	1.2
  @@ -103,7 +103,7 @@
           super(formatter);
       }
   
  -    public void testFailed(int status, String testname, String trace) {
  +    public void onTestFailed(int status, String testname, String trace) {
           StringTokenizer st = new StringTokenizer(trace,"\r\n");
           StringBuffer buf = new StringBuffer(trace.length());
           while ( st.hasMoreTokens() ){
  @@ -112,7 +112,7 @@
                   buf.append(line).append(StringUtils.LINE_SEP);
               }
           }
  -        super.testFailed(status, testname, buf.toString());
  +        super.onTestFailed(status, testname, buf.toString());
       }
   
       /**
  
  
  
  1.2       +1 -0      jakarta-ant/proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit/formatter/SummaryFormatter.java
  
  Index: SummaryFormatter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit/formatter/SummaryFormatter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SummaryFormatter.java	5 Jan 2002 19:06:44 -0000	1.1
  +++ SummaryFormatter.java	5 Jan 2002 22:08:44 -0000	1.2
  @@ -54,6 +54,7 @@
   package org.apache.tools.ant.taskdefs.optional.junit.formatter;
   
   import java.text.MessageFormat;
  +import java.util.ResourceBundle;
   
   /**
    * Display a summary message at the end of a testsuite stating
  
  
  
  1.2       +14 -14    jakarta-ant/proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit/formatter/XMLFormatter.java
  
  Index: XMLFormatter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit/formatter/XMLFormatter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XMLFormatter.java	5 Jan 2002 19:06:44 -0000	1.1
  +++ XMLFormatter.java	5 Jan 2002 22:08:44 -0000	1.2
  @@ -135,35 +135,35 @@
       /** Timing helper. */
       private Hashtable testStarts = new Hashtable();
   
  -    public void testStarted(String testname) {
  +    public void onTestStarted(String testname) {
           //@fixme, eh, a testname only can obviouslly be a duplicate...
           testStarts.put(testname, new Long(System.currentTimeMillis()));
           Element currentTest = doc.createElement(TESTCASE);
           currentTest.setAttribute(ATTR_NAME, testname);
           rootElement.appendChild(currentTest);
           testElements.put(testname, currentTest);
  -        super.testStarted(testname);
  +        super.onTestStarted(testname);
       }
   
  -    public void testEnded(String testname) {
  +    public void onTestEnded(String testname) {
           Element currentTest = (Element) testElements.get(testname);
           // with a TestSetup, startTest and endTest are not called.
           if (currentTest == null){
  -            testStarted(testname);
  +            onTestStarted(testname);
               currentTest = (Element) testElements.get(testname);
           }
           Long l = (Long) testStarts.get(testname);
           float time = ((System.currentTimeMillis()-l.longValue()) / 1000.0f);
           currentTest.setAttribute(ATTR_TIME, Float.toString(time));
  -        super.testEnded(testname);
  +        super.onTestEnded(testname);
           // remove the test objects
           testStarts.remove(testname);
           testElements.remove(testname);
       }
   
  -    public void testFailed(int status, String testname, String trace) {
  +    public void onTestFailed(int status, String testname, String trace) {
           if (testname != null) {
  -            testEnded(testname);
  +            onTestEnded(testname);
           }
           String type = status == STATUS_FAILURE ? FAILURE : ERROR;
           Element nested = doc.createElement(type);
  @@ -183,19 +183,19 @@
           nested.setAttribute(ATTR_TYPE, args[0]);
           Text text = doc.createTextNode(trace);
           nested.appendChild(text);
  -        super.testFailed(status, testname, trace);
  +        super.onTestFailed(status, testname, trace);
       }
   
  -    public void testRunStarted(int testcount) {
  -        super.testRunStarted(testcount);
  +    public void onTestRunStarted(int testcount) {
  +        super.onTestRunStarted(testcount);
       }
   
  -    public void testRunEnded(long elapsedtime) {
  -        super.testRunEnded(elapsedtime);
  +    public void onTestRunEnded(long elapsedtime) {
  +        super.onTestRunEnded(elapsedtime);
       }
   
  -    public void testRunStopped(long elapsedtime) {
  -        super.testRunStopped(elapsedtime);
  +    public void onTestRunStopped(long elapsedtime) {
  +        super.onTestRunStopped(elapsedtime);
       }
   
       private static DocumentBuilder getDocumentBuilder() {
  
  
  
  1.2       +10 -10    jakarta-ant/proposal/sandbox/junit/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/formatter/FilterStackFormatterTest.java
  
  Index: FilterStackFormatterTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/sandbox/junit/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/formatter/FilterStackFormatterTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FilterStackFormatterTest.java	5 Jan 2002 22:01:19 -0000	1.1
  +++ FilterStackFormatterTest.java	5 Jan 2002 22:08:44 -0000	1.2
  @@ -111,7 +111,7 @@
   
       public void testFiltering() {
           FilterStackFormatter wrapper = new FilterStackFormatter(wrapped);
  -        wrapper.testFailed(0, "", trace);
  +        wrapper.onTestFailed(0, "", trace);
           assertEquals(expected, wrapped.trace);
       }
   
  @@ -121,38 +121,38 @@
           public void setOutput(OutputStream out) {
           }
   
  -        public void testStarted(String testname) {
  +        public void onTestStarted(String testname) {
           }
   
           public void setSystemOutput(String out) {
           }
   
  -        public void testEnded(String testname) {
  +        public void onTestEnded(String testname) {
           }
   
           public void setSystemError(String err) {
           }
   
  -        public void testFailed(int status, String testname, String trace) {
  +        public void onTestFailed(int status, String testname, String trace) {
               this.trace = trace;
           }
   
  -        public void testStdOutLine(String testname, String line) {
  +        public void onTestStdOutLine(String testname, String line) {
           }
   
  -        public void testStdErrLine(String testname, String line) {
  +        public void onTestStdErrLine(String testname, String line) {
           }
   
  -        public void testRunSystemProperties(Properties props) {
  +        public void onTestRunSystemProperties(Properties props) {
           }
   
  -        public void testRunStarted(int testcount) {
  +        public void onTestRunStarted(int testcount) {
           }
   
  -        public void testRunEnded(long elapsedtime) {
  +        public void onTestRunEnded(long elapsedtime) {
           }
   
  -        public void testRunStopped(long elapsedtime) {
  +        public void onTestRunStopped(long elapsedtime) {
           }
       }
   }
  
  
  
  1.2       +7 -7      jakarta-ant/proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit/remote/MessageReader.java
  
  Index: MessageReader.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit/remote/MessageReader.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MessageReader.java	5 Jan 2002 20:18:34 -0000	1.1
  +++ MessageReader.java	5 Jan 2002 22:08:44 -0000	1.2
  @@ -190,7 +190,7 @@
       protected void notifyTestStarted(String testname) {
           synchronized (listeners) {
               for (int i = 0; i < listeners.size(); i++) {
  -                ((TestRunListener) listeners.elementAt(i)).testStarted(testname);
  +                ((TestRunListener) listeners.elementAt(i)).onTestStarted(testname);
               }
           }
       }
  @@ -198,7 +198,7 @@
       protected void notifyTestEnded(String testname) {
           synchronized (listeners) {
               for (int i = 0; i < listeners.size(); i++) {
  -                ((TestRunListener) listeners.elementAt(i)).testEnded(testname);
  +                ((TestRunListener) listeners.elementAt(i)).onTestEnded(testname);
               }
           }
       }
  @@ -206,7 +206,7 @@
       protected void notifyTestFailed(int kind, String testname, String trace) {
           synchronized (listeners) {
               for (int i = 0; i < listeners.size(); i++) {
  -                ((TestRunListener) listeners.elementAt(i)).testFailed(kind, testname, trace);
  +                ((TestRunListener) listeners.elementAt(i)).onTestFailed(kind, testname,
trace);
               }
           }
       }
  @@ -214,7 +214,7 @@
       protected void notifyTestSuiteStarted(int count) {
           synchronized (listeners) {
               for (int i = 0; i < listeners.size(); i++) {
  -                ((TestRunListener) listeners.elementAt(i)).testRunStarted(count);
  +                ((TestRunListener) listeners.elementAt(i)).onTestRunStarted(count);
               }
           }
       }
  @@ -222,7 +222,7 @@
       protected void notifyTestSuiteEnded(long elapsedtime) {
           synchronized (listeners) {
               for (int i = 0; i < listeners.size(); i++) {
  -                ((TestRunListener) listeners.elementAt(i)).testRunEnded(elapsedtime);
  +                ((TestRunListener) listeners.elementAt(i)).onTestRunEnded(elapsedtime);
               }
           }
       }
  @@ -230,7 +230,7 @@
       protected void notifyTestSuiteStopped(long elapsedtime) {
           synchronized (listeners) {
               for (int i = 0; i < listeners.size(); i++) {
  -                ((TestRunListener) listeners.elementAt(i)).testRunStopped(elapsedtime);
  +                ((TestRunListener) listeners.elementAt(i)).onTestRunStopped(elapsedtime);
               }
           }
       }
  @@ -238,7 +238,7 @@
       protected void notifyTestSystemProperties(Properties props) {
           synchronized (listeners) {
               for (int i = 0; i < listeners.size(); i++) {
  -                ((TestRunListener) listeners.elementAt(i)).testRunSystemProperties(props);
  +                ((TestRunListener) listeners.elementAt(i)).onTestRunSystemProperties(props);
               }
           }
       }
  
  
  
  1.2       +9 -9      jakarta-ant/proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit/TestRunListener.java
  
  Index: TestRunListener.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit/TestRunListener.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestRunListener.java	5 Jan 2002 19:06:44 -0000	1.1
  +++ TestRunListener.java	5 Jan 2002 22:08:44 -0000	1.2
  @@ -80,14 +80,14 @@
        * @param a testname made of the testname and testcase classname.
        * in the following format: <tt>&lt;testname&gt;(&lt;testcase&gt;)</tt>
        */
  -    public void testStarted(String testname);
  +    public void onTestStarted(String testname);
   
       /**
        * A test ended.
        * @param a testname made of the testname and testcase classname.
        * in the following format: <tt>&lt;testname&gt;(&lt;testcase&gt;)</tt>
        */
  -    public void testEnded(String testname);
  +    public void onTestEnded(String testname);
   
       /**
        * A test has failed.
  @@ -97,24 +97,24 @@
        * @param trace the error/failure stacktrace.
        * @todo change this to a testFailure / testError ?
        */
  -    public void testFailed(int status, String testname, String trace);
  +    public void onTestFailed(int status, String testname, String trace);
   
       /** test logged this line on stdout */
  -    public void testStdOutLine(String testname, String line);
  +    public void onTestStdOutLine(String testname, String line);
   
       /** test logged this line on sterr */
  -    public void testStdErrLine(String testname, String line);
  +    public void onTestStdErrLine(String testname, String line);
   
       /** these system properties are used on the remote client */
  -    public void testRunSystemProperties(Properties props);
  +    public void onTestRunSystemProperties(Properties props);
   
       /** starting a sequence of <tt>testcount</tt> tests. */
  -    public void testRunStarted(int testcount);
  +    public void onTestRunStarted(int testcount);
   
       /** ending gracefully the sequence after <tt>elapsedtime</tt> ms. */
  -    public void testRunEnded(long elapsedtime);
  +    public void onTestRunEnded(long elapsedtime);
   
       /** stopping the sequence after <tt>elapsedtime</tt> ms. */
  -    public void testRunStopped(long elapsedtime);
  +    public void onTestRunStopped(long elapsedtime);
   
   }
  
  
  

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


Mime
View raw message