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/rjunit/remote MessageReaderTest.java TestCases.java TestRunnerTest.java
Date Sat, 02 Feb 2002 00:04:32 GMT
sbailliez    02/02/01 16:04:32

  Added:       proposal/sandbox/junit/src/testcases/org/apache/tools/ant/taskdefs/optional/rjunit
                        RJUnitTaskTest.java TestRunRecorder.java
                        ZipScannerTest.java
               proposal/sandbox/junit/src/testcases/org/apache/tools/ant/taskdefs/optional/rjunit/data
                        Test1.java build-test.xml
               proposal/sandbox/junit/src/testcases/org/apache/tools/ant/taskdefs/optional/rjunit/formatter
                        FilterStackFormatterTest.java
                        FormatterRecorder.java
               proposal/sandbox/junit/src/testcases/org/apache/tools/ant/taskdefs/optional/rjunit/remote
                        MessageReaderTest.java TestCases.java
                        TestRunnerTest.java
  Removed:     proposal/sandbox/junit/src/testcases/org/apache/tools/ant/taskdefs/optional/junit
                        RJUnitTaskTest.java TestRunRecorder.java
                        ZipScannerTest.java
               proposal/sandbox/junit/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/data
                        Test1.java build-test.xml
               proposal/sandbox/junit/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/formatter
                        FilterStackFormatterTest.java
                        FormatterRecorder.java
               proposal/sandbox/junit/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/remote
                        MessageReaderTest.java TestCases.java
                        TestRunnerTest.java
  Log:
  Moving to rjunit package
  
  Revision  Changes    Path
  1.1                  jakarta-ant/proposal/sandbox/junit/src/testcases/org/apache/tools/ant/taskdefs/optional/rjunit/RJUnitTaskTest.java
  
  Index: RJUnitTaskTest.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Ant", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.tools.ant.taskdefs.optional.rjunit;
  
  import java.io.File;
  import java.net.URL;
  
  import org.apache.tools.ant.BuildFileTest;
  import org.apache.tools.ant.Project;
  import org.apache.tools.ant.ProjectHelper;
  
  /**
   *
   * @author <a href="mailto:sbailliez@apache.org">Stephane Bailliez</a>
   */
  public class RJUnitTaskTest extends BuildFileTest {
      public RJUnitTaskTest(String name) {
          super(name);
      }
  
      protected void setUp() throws Exception {
          configureProject("data/build-test.xml");
      }
  
      protected void configureProject(String resource){
          URL url = getClass().getResource(resource);
          assertNotNull("Could not find resource :" + resource, url);
          super.configureProject(url.getFile());
      }
  
      public void testServerAndClient(){
          executeTarget("server-and-client");
          System.out.println(getFullLog());
      }
      public void testServerAndClient2(){
          executeTarget("server-and-client");
          System.out.println(getFullLog());
      }
      /*
      public void testStandalone() throws Exception {
          // run server first..
          Thread thread = new Thread(){
              public void run(){
                  executeTarget("server-only");
              }
          };
          thread.start();
  
          executeTarget("client-only");
          System.out.println(getFullLog());
          thread.join();
      }
  */
  
  }
  
  
  
  1.1                  jakarta-ant/proposal/sandbox/junit/src/testcases/org/apache/tools/ant/taskdefs/optional/rjunit/TestRunRecorder.java
  
  Index: TestRunRecorder.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Ant", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.tools.ant.taskdefs.optional.rjunit;
  
  import java.util.Properties;
  import java.util.Vector;
  
  import org.apache.tools.ant.taskdefs.optional.rjunit.remote.TestRunEvent;
  import org.apache.tools.ant.taskdefs.optional.rjunit.remote.TestRunListener;
  
  /**
   * A TestRunListener that stores all events for later check.
   *
   * <p>
   * All the events are stored chronologically in distinct vectors
   * and are made available as public instances
   * </p>
   *
   * @author <a href="mailto:sbailliez@apache.org">Stephane Bailliez</a>
   */
  public class TestRunRecorder implements TestRunListener {
  
  // 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 testError = new Vector();
      public Vector runStarted = new Vector();
      public Vector runEnded = new Vector();
      public Vector runStopped = new Vector();
  
      public void onTestStarted(TestRunEvent evt) {
          testStarted.addElement(evt);
      }
  
      public void onTestEnded(TestRunEvent evt) {
          testEnded.addElement(evt);
      }
  
      public void onTestFailure(TestRunEvent evt) {
          testFailed.addElement(evt);
      }
  
      public void onRunStarted(TestRunEvent evt) {
          runStarted.addElement(evt);
      }
  
      public void onRunEnded(TestRunEvent evt) {
          runEnded.addElement(evt);
      }
  
      public void onRunStopped(TestRunEvent evt) {
          runStopped.addElement(evt);
      }
  
      public void onSuiteStarted(TestRunEvent evt) {
      }
  
      public void onSuiteEnded(TestRunEvent evt) {
      }
  
      public void onTestError(TestRunEvent evt) {
          testError.addElement( evt );
      }
  }
  
  
  
  1.1                  jakarta-ant/proposal/sandbox/junit/src/testcases/org/apache/tools/ant/taskdefs/optional/rjunit/ZipScannerTest.java
  
  Index: ZipScannerTest.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Ant", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.tools.ant.taskdefs.optional.rjunit;
  
  import java.io.File;
  
  import junit.framework.TestCase;
  
  /**
   * Basic test to ensure that the collector is working.
   *
   * @author <a href="mailto:sbailliez@apache.org">Stephane Bailliez</a>
   */
  public class ZipScannerTest extends TestCase {
      public ZipScannerTest(String s) {
          super(s);
      }
  
      protected ZipScanner _scanner;
  
      protected void setUp() throws Exception {
          _scanner = new ZipScanner();
          String path = System.getProperty("java.home") + "/lib/rt.jar";
          _scanner.setBasedir(path);
      }
  
      public void testScan() throws Exception {
          _scanner.scan();
          String[] files = _scanner.getIncludedFiles();
          assertContains(files, "java/lang/Exception.class");
          String[] dirs = _scanner.getIncludedDirectories();
          assertContains(dirs, "java/lang/");
      }
  
      public void testIncludes() throws Exception {
          _scanner.setIncludes( new String[]{ "**/Exception.class" });
          _scanner.scan();
          String[] files = _scanner.getIncludedFiles();
          assertEquals(1, files.length);
          assertEquals(files[0], "java/lang/Exception.class");
      }
  
  
  
      public void assertContains(Object[] lists, Object o){
          for (int i = 0; i < lists.length; i++){
              if (lists[i].equals(o)){
                  return;
              }
          }
          fail("Should contain " + o);
      }
  
  }
  
  
  
  1.1                  jakarta-ant/proposal/sandbox/junit/src/testcases/org/apache/tools/ant/taskdefs/optional/rjunit/data/Test1.java
  
  Index: Test1.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Ant", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.tools.ant.taskdefs.optional.rjunit.data;
  
  import junit.framework.TestCase;
  
  /**
   * Provide a common set of test reporting.
   *
   * @author <a href="mailto:sbailliez@apache.org">Stephane Bailliez</a>
   */
  public class Test1 extends TestCase {
      public Test1(String s) {
          super(s);
      }
  
      public void testSuccess(){
      }
  
      public void testFailure(){
          fail("failure on purpose");
      }
  
      public void testError(){
          throw new RuntimeException("error on purpose");
      }
  }
  
  
  
  1.1                  jakarta-ant/proposal/sandbox/junit/src/testcases/org/apache/tools/ant/taskdefs/optional/rjunit/data/build-test.xml
  
  Index: build-test.xml
  ===================================================================
  <project name="rjunit-tests" basedir="." default="server-and-client">
  
      <taskdef name="rjunit" classname="org.apache.tools.ant.taskdefs.optional.junit.RJUnitTask"/>
  
      <target name="server-and-client">
          <echo message="java.class.path: ${java.class.path}"/>
          <rjunit>
              <server port="1234">
                  <formatter type="plain">
                      <param name="file" location="junit-test-log.txt"/>
                  </formatter>
              </server>
              <client host="127.0.0.1"  port="1234">
                  <classpath path="${java.class.path}"/>
                  <test name="org.apache.tools.ant.taskdefs.optional.junit.data.Test1"/>
              </client>
          </rjunit>
      </target>
  
      <target name="server-only">
          <rjunit>
              <server port="1234">
                  <formatter type="plain">
                      <param name="file" location="junit-test-log.txt"/>
                  </formatter>
                  <formatter type="xml">
                      <param name="file" location="junit-test-log.xml"/>
                  </formatter>
              </server>
          </rjunit>
      </target>
  
      <target name="client-only">
          <rjunit>
              <client host="127.0.0.1"  port="1234">
                  <classpath path="${java.class.path}"/>
                  <test name="org.apache.tools.ant.taskdefs.optional.junit.data.Test1"/>
              </client>
          </rjunit>
      </target>
  
  </project>
  
  
  1.1                  jakarta-ant/proposal/sandbox/junit/src/testcases/org/apache/tools/ant/taskdefs/optional/rjunit/formatter/FilterStackFormatterTest.java
  
  Index: FilterStackFormatterTest.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Ant", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.tools.ant.taskdefs.optional.rjunit.formatter;
  
  import java.io.OutputStream;
  import java.io.PrintWriter;
  import java.io.StringWriter;
  import java.util.Properties;
  
  import junit.framework.TestCase;
  
  import org.apache.tools.ant.BuildException;
  import org.apache.tools.ant.util.StringUtils;
  import org.apache.tools.ant.taskdefs.optional.rjunit.remote.TestRunEvent;
  
  /**
   * Not exactly rocket science test.. dooh !
   *
   * @author <a href="mailto:sbailliez@apache.org">Stephane Bailliez</a>
   */
  public class FilterStackFormatterTest extends TestCase
          implements Formatter {
  
      public FilterStackFormatterTest(String s) {
          super(s);
      }
  
      protected String trace;
      protected String expected;
  
      protected void setUp() {
          StringWriter sw = new StringWriter();
          PrintWriter pw = new PrintWriter(sw, true);
          pw.println("org.apache.test.ClassName.method(ClassName.java:125)");
          pw.println("\tat org.apache.test.C1.m1(C1.java:125)");
          pw.println("\tat junit.framework.TestCase.m0(TestCase.java:999)");
          pw.println("\tat org.apache.test.C2.m1(C2.java:125)");
          pw.println("\tat junit.framework.TestResult.m1(TestResult.java:999)");
          pw.println("\tat org.apache.test.C3.m1(C3.java:125)");
          pw.println("\tat junit.framework.TestSuite.m2(TestSuite.java:999)");
          pw.println("\tat org.apache.test.C4.m1(C4.java:125)");
          pw.println("\tat junit.framework.Assert.m3(Assert.java:999)");
          pw.println("\tat junit.swingui.TestRunner.m3(TestRunner.java:999)");
          pw.println("\tat junit.awtui.TestRunner.m3(TestRunner.java:999)");
          pw.println("\tat org.apache.test.C5.m1(C5.java:125)");
          pw.println("\tat junit.textui.TestRunner.m3(TestRunner.java:999)");
          pw.println("\tat java.lang.reflect.Method.invoke(Method.java:999)");
          pw.println("\tat org.apache.tools.ant.C.m(C.java:999)");
          pw.println("\tat org.apache.test.C6.m1(C6.java:125)");
          trace = sw.toString();
          sw.getBuffer().setLength(0);
  
          pw.println("org.apache.test.ClassName.method(ClassName.java:125)");
          pw.println("\tat org.apache.test.C1.m1(C1.java:125)");
          pw.println("\tat org.apache.test.C2.m1(C2.java:125)");
          pw.println("\tat org.apache.test.C3.m1(C3.java:125)");
          pw.println("\tat org.apache.test.C4.m1(C4.java:125)");
          pw.println("\tat org.apache.test.C5.m1(C5.java:125)");
          pw.println("\tat org.apache.test.C6.m1(C6.java:125)");
          expected = sw.toString();
      }
  
      public void testFiltering() {
          /*
          FilterStackFormatter wrapper = new FilterStackFormatter(this);
          Exception e = new Exception("xx");
          e.fillInStackTrace();
          TestRunEvent evt = new TestRunEvent(new Integer(1), TestRunEvent.TEST_ERROR, "xx");
          wrapper.onTestFailure(evt);
          StringUtils.getStackTrace()
          assertEquals(expected, filteredTrace);
          */
      }
  
  
  // --- formatter implementation
      protected String filteredTrace;
  
      public void onTestStarted(TestRunEvent evt) {
      }
  
      public void onTestEnded(TestRunEvent evt) {
      }
  
      public void init(Properties props) throws BuildException {
      }
  
      public void onTestFailure(TestRunEvent evt) {
          filteredTrace = trace;
      }
  
      public void onSuiteStarted(TestRunEvent evt) {
      }
  
      public void onSuiteEnded(TestRunEvent evt) {
      }
  
      public void onTestError(TestRunEvent evt) {
      }
  
      public void onRunStarted(TestRunEvent evt) {
      }
  
      public void onRunEnded(TestRunEvent evt) {
      }
  
      public void onRunStopped(TestRunEvent evt) {
      }
  }
  
  
  
  1.1                  jakarta-ant/proposal/sandbox/junit/src/testcases/org/apache/tools/ant/taskdefs/optional/rjunit/formatter/FormatterRecorder.java
  
  Index: FormatterRecorder.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Ant", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.tools.ant.taskdefs.optional.rjunit.formatter;
  
  import java.io.OutputStream;
  import java.util.Properties;
  
  import org.apache.tools.ant.taskdefs.optional.rjunit.TestRunRecorder;
  import org.apache.tools.ant.BuildException;
  
  /**
   * A formatter recorder that serves the same purpose as
   * a <tt>TestRunRecorder</tt>
   *
   *
   * @see TestRunRecorder
   * @author <a href="mailto:sbailliez@apache.org">Stephane Bailliez</a>
   */
  public class FormatterRecorder extends TestRunRecorder
          implements Formatter {
      public void init(Properties props) throws BuildException {
      }
  }
  
  
  
  1.1                  jakarta-ant/proposal/sandbox/junit/src/testcases/org/apache/tools/ant/taskdefs/optional/rjunit/remote/MessageReaderTest.java
  
  Index: MessageReaderTest.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Ant", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.tools.ant.taskdefs.optional.rjunit.remote;
  
  import java.io.PrintWriter;
  import java.io.PipedOutputStream;
  import java.io.PipedInputStream;
  import java.io.ByteArrayOutputStream;
  import java.io.ByteArrayInputStream;
  import java.util.Properties;
  
  import junit.framework.TestCase;
  
  import org.apache.tools.ant.taskdefs.optional.rjunit.remote.TestRunListener;
  import org.apache.tools.ant.taskdefs.optional.rjunit.TestRunRecorder;
  
  /**
   * Ensure that the Reader/Writer works fine.
   *
   * @author <a href="mailto:sbailliez@apache.org">Stephane Bailliez</a>
   */
  public class MessageReaderTest extends TestCase {
  
      private EventDispatcher dispatcher;
  
      protected TestRunRecorder recorder;
  
      public MessageReaderTest(String s) {
          super(s);
      }
  
      protected void setUp() {
          dispatcher = new EventDispatcher();
          recorder = new TestRunRecorder();
          dispatcher.addListener( recorder );
      }
  
      public void testTestRunStarted() throws Exception {
          TestRunEvent evt = new TestRunEvent(new Integer(99), TestRunEvent.RUN_STARTED);
          dispatcher.fireRunStarted( evt );
          assertEquals(evt, recorder.runStarted.elementAt(0));
      }
  
      public void testTestStarted() throws Exception {
          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 {
          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 {
          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 {
          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 {
          TestRunEvent evt = new TestRunEvent(new Integer(99), TestRunEvent.RUN_ENDED);
          dispatcher.fireRunEnded( evt );
          assertEquals(evt, recorder.runEnded.elementAt(0));
      }
  
      public void testTestRunStopped() throws Exception {
          TestRunEvent evt = new TestRunEvent(new Integer(99), TestRunEvent.RUN_STOPPED);
          dispatcher.fireRunStopped( evt );
          assertEquals(evt, recorder.runStopped.elementAt(0));
      }
  
  
  
  }
  
  
  
  1.1                  jakarta-ant/proposal/sandbox/junit/src/testcases/org/apache/tools/ant/taskdefs/optional/rjunit/remote/TestCases.java
  
  Index: TestCases.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Ant", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.tools.ant.taskdefs.optional.rjunit.remote;
  
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  import junit.framework.Test;
  import junit.extensions.TestSetup;
  
  /**
   *
   * @author <a href="mailto:sbailliez@apache.org">Stephane Bailliez</a>
   */
  public class TestCases {
  
      /** null testcase w/ 3 tests */
      public static class NullTestCase extends TestCase {
          public NullTestCase(String s) {
              super(s);
          }
          public void testSuccess(){}
          public void testFailure(){ assertTrue(false); }
          public void testError(){ throw new RuntimeException("on purpose"); }
      }
  
      /** testcase w/ a static suite method */
      public static class NullTestSuite extends TestCase {
          public NullTestSuite(String s) {
              super(s);
          }
          public static Test suite(){
              return new TestSuite(NullTestCase.class);
          }
      }
  
      public static class SimpleTestCase extends TestCase {
          public SimpleTestCase(String s) {
              super(s);
          }
          public void testSuccess(){}
      }
  
      public static class FailSetupTestSuite extends TestCase {
          public FailSetupTestSuite(String s) {
              super(s);
          }
          public static Test suite(){
              return new FailTestSetup( new TestSuite(SimpleTestCase.class) );
          }
      }
  
      public static class FailTestSetup extends TestSetup {
          public FailTestSetup(Test test) {
              super(test);
          }
          protected void setUp(){
              throw new IllegalArgumentException("on purpose");
          }
      }
  }
  
  
  
  1.1                  jakarta-ant/proposal/sandbox/junit/src/testcases/org/apache/tools/ant/taskdefs/optional/rjunit/remote/TestRunnerTest.java
  
  Index: TestRunnerTest.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Ant", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.tools.ant.taskdefs.optional.rjunit.remote;
  
  import java.util.Vector;
  import java.util.Properties;
  
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  import junit.framework.TestListener;
  
  import org.apache.tools.ant.taskdefs.optional.rjunit.formatter.PlainFormatter;
  import org.apache.tools.ant.taskdefs.optional.rjunit.remote.TestRunListener;
  import org.apache.tools.ant.taskdefs.optional.rjunit.TestRunRecorder;
  
  /**
   * TestCase for the test runner.
   *
   * @author <a href="mailto:sbailliez@apache.org">Stephane Bailliez</a>
   */
  public class TestRunnerTest extends TestCase
          implements TestRunListener {
  
      public final static int PORT = 1234;
  
      protected Server server;
  
      protected TestRunner runner;
  
      protected TestRunRecorder recorder;
  
      protected boolean done;
  
      public TestRunnerTest(String s) {
          super(s);
      }
  
      protected void setUp() throws Exception {
          server = createServer();
          server.start();
          runner = createClient();
          recorder = new TestRunRecorder();
          server.addListener( recorder );
          server.addListener( this );
      }
  
      protected void tearDown() throws Exception {
          server.shutdown();
          runner.stop();
      }
  
      protected Server createServer() throws Exception {
          return new Server(PORT);
      }
  
      protected TestRunner createClient() throws Exception {
          TestRunner client = new TestRunner();
          client.setDebug(true);
          client.setHost("127.0.0.1");
          client.setPort(PORT);
          return client;
      }
  
      public void testNullTestCase() throws Exception {
          runner.addTestClassName(TestCases.NullTestCase.class.getName());
  //        server.addListener( new PlainFormatter() );
          runner.run();
          synchronized(this){ while (!done){ wait(); } }
          assertEquals(1, recorder.runStarted.size());
          /*
          assertTrue(recorder.runStarted.elementAt(0).toSt("testSuccess"));
          assertTrue(started.contains("testFailure"));
          assertTrue(started.contains("testError"));*/
  
      }
  
      public void testFailSetupTestCase() throws Exception {
          runner.addTestClassName(TestCases.FailSetupTestSuite.class.getName());
          runner.run();
          synchronized(this){ while (!done){ wait(); } }
  
          assertEquals(1, recorder.runStarted.size());
          assertEquals(1, recorder.runEnded.size());
      }
  
      public void testFailSetupTestSuite() throws Exception {
          runner.addTestClassName(TestCases.FailSetupTestSuite.class.getName());
          runner.run();
          synchronized(this){ while (!done){ wait(); } }
          assertEquals(1, recorder.runStarted.size());
          assertEquals(1, recorder.runEnded.size());
      }
  
      public static void main(String[] args){
          TestSuite suite = new TestSuite(TestRunnerTest.class);
          junit.textui.TestRunner.run(suite);
      }
  
  // TestRunListener implementation
      public void onTestStarted(TestRunEvent evt) {
      }
      public void onTestEnded(TestRunEvent evt) {
      }
      public void onTestFailure(TestRunEvent evt) {
      }
      public void onRunStarted(TestRunEvent count) {
      }
      public void onRunEnded(TestRunEvent evt) {
          synchronized(this){
              done = true;
              notify();
          }
      }
      public void onRunStopped(TestRunEvent evt) {
          synchronized(this){
              done = true;
              notify();
          }
      }
  
      public void onSuiteStarted(TestRunEvent evt) {
      }
  
      public void onSuiteEnded(TestRunEvent evt) {
      }
  
      public void onTestError(TestRunEvent 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