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/testcases/org/apache/tools/ant/taskdefs/optional/junit TestRunRecorder.java
Date Fri, 01 Feb 2002 21:39:29 GMT
sbailliez    02/02/01 13:39:29

  Modified:    proposal/sandbox/junit/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/remote
                        MessageReaderTest.java TestRunnerTest.java
               proposal/sandbox/junit/src/testcases/org/apache/tools/ant/taskdefs/optional/junit
                        TestRunRecorder.java
  Log:
  Fix tests
  
  Revision  Changes    Path
  1.2       +30 -42    jakarta-ant/proposal/sandbox/junit/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/remote/MessageReaderTest.java
  
  Index: MessageReaderTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/sandbox/junit/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/remote/MessageReaderTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MessageReaderTest.java	5 Jan 2002 23:50:53 -0000	1.1
  +++ MessageReaderTest.java	1 Feb 2002 21:39:29 -0000	1.2
  @@ -62,7 +62,7 @@
   
   import junit.framework.TestCase;
   
  -import org.apache.tools.ant.taskdefs.optional.junit.TestRunListener;
  +import org.apache.tools.ant.taskdefs.optional.junit.remote.TestRunListener;
   import org.apache.tools.ant.taskdefs.optional.junit.TestRunRecorder;
   
   /**
  @@ -72,11 +72,7 @@
    */
   public class MessageReaderTest extends TestCase {
   
  -    protected ByteArrayOutputStream out;
  -
  -    protected MessageReader reader;
  -
  -    protected MessageWriter writer;
  +    private EventDispatcher dispatcher;
   
       protected TestRunRecorder recorder;
   
  @@ -85,65 +81,57 @@
       }
   
       protected void setUp() {
  -        out = new ByteArrayOutputStream();
  -        writer = new MessageWriter(out);
  -        reader = new MessageReader();
  +        dispatcher = new EventDispatcher();
           recorder = new TestRunRecorder();
  -        reader.addListener( recorder );
  +        dispatcher.addListener( recorder );
       }
   
       public void testTestRunStarted() throws Exception {
  -        writer.notifyTestRunStarted(9999);
  -        reader.process( new ByteArrayInputStream(out.toByteArray()) );
  -        assertEquals(new Integer(9999), recorder.runStarted.elementAt(0));
  +        TestRunEvent evt = new TestRunEvent(new Integer(99), TestRunEvent.RUN_STARTED);
  +        dispatcher.fireRunStarted( evt );
  +        assertEquals(evt, recorder.runStarted.elementAt(0));
       }
   
       public void testTestStarted() throws Exception {
  -        writer.notifyTestStarted("xxxxxx");
  -        reader.process( new ByteArrayInputStream(out.toByteArray()) );
  -        assertEquals("xxxxxx", recorder.testStarted.elementAt(0));
  +        TestRunEvent evt = new TestRunEvent(new Integer(99), TestRunEvent.TEST_STARTED,
"xxxx");
  +        dispatcher.fireTestStarted( evt );
  +        assertEquals(evt, recorder.testStarted.elementAt(0));
       }
   
       public void testTestEnded() throws Exception {
  -        writer.notifyTestEnded("xxxxxx");
  -        reader.process( new ByteArrayInputStream(out.toByteArray()) );
  -        assertEquals("xxxxxx", recorder.testEnded.elementAt(0));
  +        TestRunEvent evt = new TestRunEvent(new Integer(99), TestRunEvent.TEST_ENDED, "xxxx");
  +        dispatcher.fireTestEnded( evt );
  +        assertEquals(evt, recorder.testEnded.elementAt(0));
       }
   
       public void testTestFailedError() throws Exception {
  -        writer.notifyTestFailed(TestRunListener.STATUS_ERROR, "xxxxxx", "1\n2\n3\n4\n5");
  -        reader.process( new ByteArrayInputStream(out.toByteArray()) );
  -        TestRunRecorder.TestFailedInfo info = (TestRunRecorder.TestFailedInfo)recorder.testFailed.elementAt(0);
  -        assertEquals("xxxxxx", info.testname);
  -        assertEquals(TestRunListener.STATUS_ERROR, info.status);
  -        assertEquals("1\n2\n3\n4\n5", info.trace);
  +        Exception e = new Exception("error");
  +        e.fillInStackTrace();
  +        TestRunEvent evt = new TestRunEvent(new Integer(99), TestRunEvent.TEST_ERROR, "xxxx",
e);
  +        dispatcher.fireTestError( evt );
  +        assertEquals(evt, recorder.testError.elementAt(0));
       }
   
       public void testTestFailedFailure() throws Exception {
  -        writer.notifyTestFailed(TestRunListener.STATUS_FAILURE, "xxxxxx", "1\n2\n3\n4\n5");
  -        reader.process( new ByteArrayInputStream(out.toByteArray()) );
  -        TestRunRecorder.TestFailedInfo info = (TestRunRecorder.TestFailedInfo)recorder.testFailed.elementAt(0);
  -        assertEquals("xxxxxx", info.testname);
  -        assertEquals(TestRunListener.STATUS_FAILURE, info.status);
  -        assertEquals("1\n2\n3\n4\n5", info.trace);
  +        Exception e = new Exception("error");
  +        e.fillInStackTrace();
  +        TestRunEvent evt = new TestRunEvent(new Integer(99), TestRunEvent.TEST_FAILURE,
"xxxx", e);
  +        dispatcher.fireTestFailure( evt );
  +        assertEquals(evt, recorder.testFailed.elementAt(0));
       }
   
       public void testTestRunEnded() throws Exception {
  -        writer.notifyTestRunEnded(999999);
  -        reader.process( new ByteArrayInputStream(out.toByteArray()) );
  -        assertEquals(new Long(999999), recorder.runEnded.elementAt(0));
  +        TestRunEvent evt = new TestRunEvent(new Integer(99), TestRunEvent.RUN_ENDED);
  +        dispatcher.fireRunEnded( evt );
  +        assertEquals(evt, recorder.runEnded.elementAt(0));
       }
   
       public void testTestRunStopped() throws Exception {
  -        writer.notifyTestRunStopped(999999);
  -        reader.process( new ByteArrayInputStream(out.toByteArray()) );
  -        assertEquals(new Long(999999), recorder.runStopped.elementAt(0));
  +        TestRunEvent evt = new TestRunEvent(new Integer(99), TestRunEvent.RUN_STOPPED);
  +        dispatcher.fireRunStopped( evt );
  +        assertEquals(evt, recorder.runStopped.elementAt(0));
       }
   
  -    public void testTestRunSystemProperties() throws Exception {
  -        writer.notifySystemProperties();
  -        reader.process( new ByteArrayInputStream(out.toByteArray()) );
  -        assertEquals(System.getProperties(), recorder.sysprops.elementAt(0));
  -    }
  +
   
   }
  
  
  
  1.4       +12 -11    jakarta-ant/proposal/sandbox/junit/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/remote/TestRunnerTest.java
  
  Index: TestRunnerTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/sandbox/junit/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/remote/TestRunnerTest.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TestRunnerTest.java	27 Jan 2002 14:10:27 -0000	1.3
  +++ TestRunnerTest.java	1 Feb 2002 21:39:29 -0000	1.4
  @@ -61,7 +61,7 @@
   import junit.framework.TestListener;
   
   import org.apache.tools.ant.taskdefs.optional.junit.formatter.PlainFormatter;
  -import org.apache.tools.ant.taskdefs.optional.junit.TestRunListener;
  +import org.apache.tools.ant.taskdefs.optional.junit.remote.TestRunListener;
   import org.apache.tools.ant.taskdefs.optional.junit.TestRunRecorder;
   
   /**
  @@ -117,7 +117,7 @@
   //        server.addListener( new PlainFormatter() );
           runner.run();
           synchronized(this){ while (!done){ wait(); } }
  -        assertEquals(new Integer(3), recorder.runStarted.elementAt(0));
  +        assertEquals(1, recorder.runStarted.size());
           /*
           assertTrue(recorder.runStarted.elementAt(0).toSt("testSuccess"));
           assertTrue(started.contains("testFailure"));
  @@ -148,32 +148,33 @@
       }
   
   // TestRunListener implementation
  -    public void onTestStarted(String testname) {
  +    public void onTestStarted(TestRunEvent evt) {
       }
  -    public void onTestEnded(String testname) {
  +    public void onTestEnded(TestRunEvent evt) {
       }
  -    public void onTestFailed(int status, String testname, String trace) {
  +    public void onTestFailure(TestRunEvent evt) {
       }
  -    public void onTestRunStarted(int count) {
  +    public void onRunStarted(TestRunEvent count) {
       }
  -    public void onTestRunEnded(long elapsedtime) {
  +    public void onRunEnded(TestRunEvent evt) {
           synchronized(this){
               done = true;
               notify();
           }
       }
  -    public void onTestRunStopped(long elapsedtime) {
  +    public void onRunStopped(TestRunEvent evt) {
           synchronized(this){
               done = true;
               notify();
           }
       }
  -    public void onTestRunSystemProperties(Properties props) {
  +
  +    public void onSuiteStarted(TestRunEvent evt) {
       }
   
  -    public void onTestStdOutLine(String testname, String line) {
  +    public void onSuiteEnded(TestRunEvent evt) {
       }
   
  -    public void onTestStdErrLine(String testname, String line) {
  +    public void onTestError(TestRunEvent evt) {
       }
   }
  
  
  
  1.2       +20 -44    jakarta-ant/proposal/sandbox/junit/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/TestRunRecorder.java
  
  Index: TestRunRecorder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/sandbox/junit/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/TestRunRecorder.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestRunRecorder.java	5 Jan 2002 23:12:47 -0000	1.1
  +++ TestRunRecorder.java	1 Feb 2002 21:39:29 -0000	1.2
  @@ -56,6 +56,9 @@
   import java.util.Properties;
   import java.util.Vector;
   
  +import org.apache.tools.ant.taskdefs.optional.junit.remote.TestRunEvent;
  +import org.apache.tools.ant.taskdefs.optional.junit.remote.TestRunListener;
  +
   /**
    * A TestRunListener that stores all events for later check.
    *
  @@ -68,73 +71,46 @@
    */
   public class TestRunRecorder implements TestRunListener {
   
  -    /** wrapper around failure info */
  -    public static class TestFailedInfo {
  -        public int status;
  -        public String testname;
  -        public String trace;
  -    }
  -
  -    /** wrapper around output info */
  -    public static class TestOutputInfo {
  -        public String testname;
  -        public String line;
  -    }
  -
   // all these are public in order for testcases to have access quickly
       public Vector testStarted = new Vector();
       public Vector testEnded = new Vector();
       public Vector testFailed = new Vector();
  -    public Vector testStdout = new Vector();
  -    public Vector testStderr = new Vector();
  -    public Vector sysprops = new Vector();
  +    public Vector testError = new Vector();
       public Vector runStarted = new Vector();
       public Vector runEnded = new Vector();
       public Vector runStopped = new Vector();
   
  -    public void onTestStarted(String testname) {
  -        testStarted.addElement(testname);
  +    public void onTestStarted(TestRunEvent evt) {
  +        testStarted.addElement(evt);
       }
   
  -    public void onTestEnded(String testname) {
  -        testEnded.addElement(testname);
  +    public void onTestEnded(TestRunEvent evt) {
  +        testEnded.addElement(evt);
       }
   
  -    public void onTestFailed(int status, String testname, String trace) {
  -        TestFailedInfo info = new TestFailedInfo();
  -        info.status = status;
  -        info.testname = testname;
  -        info.trace = trace;
  -        testFailed.addElement(info);
  +    public void onTestFailure(TestRunEvent evt) {
  +        testFailed.addElement(evt);
       }
   
  -    public void onTestStdOutLine(String testname, String line) {
  -        TestOutputInfo info = new TestOutputInfo();
  -        info.testname = testname;
  -        info.line = line;
  -        testStdout.addElement(info);
  +    public void onRunStarted(TestRunEvent evt) {
  +        runStarted.addElement(evt);
       }
   
  -    public void onTestStdErrLine(String testname, String line) {
  -        TestOutputInfo info = new TestOutputInfo();
  -        info.testname = testname;
  -        info.line = line;
  -        testStderr.addElement(info);
  +    public void onRunEnded(TestRunEvent evt) {
  +        runEnded.addElement(evt);
       }
   
  -    public void onTestRunSystemProperties(Properties props) {
  -        sysprops.addElement(props);
  +    public void onRunStopped(TestRunEvent evt) {
  +        runStopped.addElement(evt);
       }
   
  -    public void onTestRunStarted(int testcount) {
  -        runStarted.addElement(new Integer(testcount));
  +    public void onSuiteStarted(TestRunEvent evt) {
       }
   
  -    public void onTestRunEnded(long elapsedtime) {
  -        runEnded.addElement(new Long(elapsedtime));
  +    public void onSuiteEnded(TestRunEvent evt) {
       }
   
  -    public void onTestRunStopped(long elapsedtime) {
  -        runStopped.addElement(new Long(elapsedtime));
  +    public void onTestError(TestRunEvent evt) {
  +        testError.addElement( evt );
       }
   }
  
  
  

--
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