ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@locus.apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/junit BaseTest.java BatchTest.java JUnitTask.java JUnitTest.java
Date Thu, 14 Sep 2000 08:49:41 GMT
bodewig     00/09/14 01:49:41

  Modified:    .        build.xml
               src/main/org/apache/tools/ant/taskdefs/optional/junit
                        BatchTest.java JUnitTask.java JUnitTest.java
  Added:       src/main/org/apache/tools/ant/taskdefs/optional/junit
                        BaseTest.java
  Log:
  <junit> now works again as it did before tasks started to be
  configured at runtime.
  
  Revision  Changes    Path
  1.72      +1 -1      jakarta-ant/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/build.xml,v
  retrieving revision 1.71
  retrieving revision 1.72
  diff -u -r1.71 -r1.72
  --- build.xml	2000/09/14 08:13:04	1.71
  +++ build.xml	2000/09/14 08:49:37	1.72
  @@ -317,7 +317,7 @@
   
         <formatter type="plain" usefile="false" />
   
  -      <batchtest fork="yes">
  +      <batchtest>
           <fileset dir="${src.tests.dir}">
             <include name="**/*Test*" />
             <exclude name="**/All*" />
  
  
  
  1.3       +5 -31     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/BatchTest.java
  
  Index: BatchTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/BatchTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- BatchTest.java	2000/09/07 09:50:58	1.2
  +++ BatchTest.java	2000/09/14 08:49:39	1.3
  @@ -68,16 +68,10 @@
    * @author <a href="mailto:jeff.martin@synamic.co.uk">Jeff Martin</a>
    * @author <a href="mailto:stefan.bodewig@megabit.net">Stefan Bodewig</a> 
    */
  -public final class BatchTest {
  -    private boolean fork=false;
  -    private boolean haltOnError=false;
  -    private boolean haltOnFailure=false;
  +public final class BatchTest extends BaseTest {
       private Project project;
  -    private String ifCond = null;
  -    private String unlessCond = null;
   
       private Vector filesets = new Vector();
  -    private Vector formatters = new Vector();
   
       public BatchTest(Project project){
           this.project = project;
  @@ -87,30 +81,10 @@
           filesets.addElement(fs);
       }
   
  -    public void addFormatter(FormatterElement elem) {
  -        formatters.addElement(elem);
  -    }
  -
  -    public void setIf(String propertyName) {
  -        ifCond = propertyName;
  -    }
  -
  -    public void setUnless(String propertyName) {
  -        unlessCond = propertyName;
  -    }
  -
  -    public final void setFork(boolean value) {
  -        this.fork = value;
  -    }
  -    public final void setHaltonerror(boolean value) {
  -        this.haltOnError = value;
  -    }
  -    public final void setHaltonfailure(boolean value) {
  -        this.haltOnFailure = value;
  -    }
       public final Enumeration elements(){
           return new FileList();
       }
  +
       public class FileList implements Enumeration{
           private String files[]=null;
           private int i=0;
  @@ -142,10 +116,10 @@
               if(hasMoreElements()){
                   JUnitTest test = new JUnitTest(javaToClass(files[i]));
                   test.setHaltonerror(haltOnError);
  -                test.setHaltonfailure(haltOnFailure);
  +                test.setHaltonfailure(haltOnFail);
                   test.setFork(fork);
  -                test.setIf(ifCond);
  -                test.setUnless(unlessCond);
  +                test.setIf(ifProperty);
  +                test.setUnless(unlessProperty);
                   Enumeration list = formatters.elements();
                   while (list.hasMoreElements()) {
                       test.addFormatter((FormatterElement)list.nextElement());
  
  
  
  1.9       +39 -15    jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
  
  Index: JUnitTask.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- JUnitTask.java	2000/09/14 08:13:06	1.8
  +++ JUnitTask.java	2000/09/14 08:49:39	1.9
  @@ -92,16 +92,23 @@
       private Vector batchTests = new Vector();
       private Vector formatters = new Vector();
   
  -    private JUnitTest defaults = new JUnitTest();
       private Integer timeout = null;
       private boolean summary = false;
   
       public void setHaltonerror(boolean value) {
  -        defaults.setHaltonerror(value);
  +        Enumeration enum = allTests();
  +        while (enum.hasMoreElements()) {
  +            BaseTest test = (BaseTest) enum.nextElement();
  +            test.setHaltonerror(value);
  +        }
       }
   
       public void setHaltonfailure(boolean value) {
  -        defaults.setHaltonfailure(value);
  +        Enumeration enum = allTests();
  +        while (enum.hasMoreElements()) {
  +            BaseTest test = (BaseTest) enum.nextElement();
  +            test.setHaltonfailure(value);
  +        }
       }
   
       public void setPrintsummary(boolean value) {
  @@ -114,7 +121,6 @@
           } else {
               createJvmarg().setValue("-Xmx"+max);
           }
  -        
       }
   
       public void setTimeout(Integer value) {
  @@ -122,7 +128,11 @@
       }
   
       public void setFork(boolean value) {
  -        defaults.setFork(value);
  +        Enumeration enum = allTests();
  +        while (enum.hasMoreElements()) {
  +            BaseTest test = (BaseTest) enum.nextElement();
  +            test.setFork(value);
  +        }
       }
   
       public void setJvm(String value) {
  @@ -138,17 +148,11 @@
       }
   
       public void addTest(JUnitTest test) {
  -        test.setHaltonerror(defaults.getHaltonerror());
  -        test.setHaltonfailure(defaults.getHaltonfailure());
  -        test.setFork(defaults.getFork());
           tests.addElement(test);
       }
   
       public BatchTest createBatchTest() {
           BatchTest test = new BatchTest(project);
  -        test.setHaltonerror(defaults.getHaltonerror());
  -        test.setHaltonfailure(defaults.getHaltonfailure());
  -        test.setFork(defaults.getFork());
           batchTests.addElement(test);
           return test;
       }
  @@ -171,16 +175,18 @@
           boolean errorOccurred = false;
           boolean failureOccurred = false;
   
  +        Vector runTests = (Vector) tests.clone();
  +
           Enumeration list = batchTests.elements();
           while (list.hasMoreElements()) {
               BatchTest test = (BatchTest)list.nextElement();
               Enumeration list2 = test.elements();
               while (list2.hasMoreElements()) {
  -                tests.addElement(list2.nextElement());
  +                runTests.addElement(list2.nextElement());
               }
           }
   
  -        list = tests.elements();
  +        list = runTests.elements();
           while (list.hasMoreElements()) {
               JUnitTest test = (JUnitTest)list.nextElement();
   
  @@ -194,8 +200,6 @@
   
               int exitValue = JUnitTestRunner.ERRORS;
               
  -            System.err.println(test.getFork());
  -
               if (!test.getFork()) {
                   JUnitTestRunner runner = 
                       new JUnitTestRunner(test, test.getHaltonerror(),
  @@ -311,5 +315,25 @@
   
           if (dest.exists()) dest.delete();
           src.renameTo(dest);
  +    }
  +
  +    protected Enumeration allTests() {
  +
  +        return new Enumeration() {
  +                private Enumeration testEnum = tests.elements();
  +                private Enumeration batchEnum = batchTests.elements();
  +                
  +                public boolean hasMoreElements() {
  +                    return testEnum.hasMoreElements() ||
  +                        batchEnum.hasMoreElements();
  +                }
  +                
  +                public Object nextElement() {
  +                    if (testEnum.hasMoreElements()) {
  +                        return testEnum.nextElement();
  +                    }
  +                    return batchEnum.nextElement();
  +                }
  +            };
       }
   }
  
  
  
  1.3       +1 -45     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTest.java
  
  Index: JUnitTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JUnitTest.java	2000/08/09 13:12:13	1.2
  +++ JUnitTest.java	2000/09/14 08:49:39	1.3
  @@ -65,18 +65,13 @@
    * @author Thomas Haas
    * @author <a href="mailto:stefan.bodewig@megabit.net">Stefan Bodewig</a> 
    */
  -public class JUnitTest {
  -    private boolean haltOnError = false;
  -    private boolean haltOnFail = false;
  +public class JUnitTest extends BaseTest {
       private String name = null;
       private File outfile = null;
  -    private boolean fork = false;
   
       private long runs, failures, errors;
       private long runTime;
   
  -    private Vector formatters = new Vector();
  -
       public JUnitTest() {
       }
   
  @@ -90,22 +85,6 @@
           this.haltOnFail = haltOnFail;
       }
   
  -    public void setFork(boolean value) {
  -        fork = value;
  -    }
  -
  -    public boolean getFork() {
  -        return fork;
  -    }
  -
  -    public void setHaltonerror(boolean value) {
  -        haltOnError = value;
  -    }
  -
  -    public void setHaltonfailure(boolean value) {
  -        haltOnFail = value;
  -    }
  -
       public void setName(String value) {
           name = value;
       }
  @@ -114,14 +93,6 @@
           outfile = value;
       }
   
  -    public boolean getHaltonerror() {
  -        return haltOnError;
  -    }
  -
  -    public boolean getHaltonfailure() {
  -        return haltOnFail;
  -    }
  -
       public String getName() {
           return name;
       }
  @@ -148,17 +119,6 @@
       public long errorCount() {return errors;}
       public long getRunTime() {return runTime;}
   
  -    private String ifProperty = null;
  -    private String unlessProperty = null;
  -
  -    public void setIf(String propertyName) {
  -        ifProperty = propertyName;
  -    }
  -
  -    public void setUnless(String propertyName) {
  -        unlessProperty = propertyName;
  -    }
  -
       public boolean shouldRun(Project p) {
           if (ifProperty != null && p.getProperty(ifProperty) == null) {
               return false;
  @@ -167,10 +127,6 @@
               return false;
           }
           return true;
  -    }
  -
  -    public void addFormatter(FormatterElement elem) {
  -        formatters.addElement(elem);
       }
   
       public FormatterElement[] getFormatters() {
  
  
  
  1.1                  jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/BaseTest.java
  
  Index: BaseTest.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000 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", "Tomcat", 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.junit;
  
  import java.util.Vector;
  
  /**
   * Baseclass for BatchTest and JUnitTest.
   *
   * @author <a href="mailto:stefan.bodewig@megabit.net">Stefan Bodewig</a> 
   */
  public abstract class BaseTest {
      protected boolean haltOnError = false;
      protected boolean haltOnFail = false;
      protected boolean fork = false;
      protected String ifProperty = null;
      protected String unlessProperty = null;
      protected Vector formatters = new Vector();
  
      public void setFork(boolean value) {
          fork = value;
      }
  
      public boolean getFork() {
          return fork;
      }
  
      public void setHaltonerror(boolean value) {
          haltOnError = value;
      }
  
      public void setHaltonfailure(boolean value) {
          haltOnFail = value;
      }
  
      public boolean getHaltonerror() {
          return haltOnError;
      }
  
      public boolean getHaltonfailure() {
          return haltOnFail;
      }
  
      public void setIf(String propertyName) {
          ifProperty = propertyName;
      }
  
      public void setUnless(String propertyName) {
          unlessProperty = propertyName;
      }
  
      public void addFormatter(FormatterElement elem) {
          formatters.addElement(elem);
      }
  }
  
  
  

Mime
View raw message