You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by sb...@apache.org on 2002/02/02 02:38:21 UTC

cvs commit: jakarta-ant/proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/rjunit/remote Base64.java

sbailliez    02/02/01 17:38:21

  Modified:    proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/rjunit
                        BatchTestElement.java ClasspathTestCollector.java
                        ClientElement.java JUnitHelper.java
  Removed:     proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/rjunit/remote
                        Base64.java
  Log:
  Make sure that it collects testcases correctly inside directories.
  
  Revision  Changes    Path
  1.2       +12 -1     jakarta-ant/proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/rjunit/BatchTestElement.java
  
  Index: BatchTestElement.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/rjunit/BatchTestElement.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BatchTestElement.java	1 Feb 2002 23:53:22 -0000	1.1
  +++ BatchTestElement.java	2 Feb 2002 01:38:21 -0000	1.2
  @@ -59,6 +59,8 @@
   
   import org.apache.tools.ant.types.Path;
   import org.apache.tools.ant.types.PatternSet;
  +import org.apache.tools.ant.Project;
  +import org.apache.tools.ant.ProjectComponent;
   
   /**
    * A test element where tests files are specified by include/exclude
  @@ -72,10 +74,15 @@
    *
    * @author <a href="mailto:sbailliez@apache.org">Stephane Bailliez</a>
    */
  -public class BatchTestElement implements TestCollector {
  +public class BatchTestElement extends ProjectComponent implements TestCollector {
   
       private ClasspathTestCollector collector = new ClasspathTestCollector();
   
  +    public void setProject(Project p){
  +        collector.setProject(p);
  +        super.setProject(p);
  +    }
  +
   // Test collector implementation
   
       public Enumeration collectTests() {
  @@ -86,6 +93,10 @@
   
       public void setPath(Path path) {
           collector.setPath(path);
  +    }
  +
  +    public Path getPath(){
  +        return collector.getPath();
       }
   
       public PatternSet.NameEntry createInclude() {
  
  
  
  1.2       +11 -5     jakarta-ant/proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/rjunit/ClasspathTestCollector.java
  
  Index: ClasspathTestCollector.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/rjunit/ClasspathTestCollector.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ClasspathTestCollector.java	1 Feb 2002 23:53:22 -0000	1.1
  +++ ClasspathTestCollector.java	2 Feb 2002 01:38:21 -0000	1.2
  @@ -73,12 +73,12 @@
    *
    * @author <a href="mailto:sbailliez@apache.org">Stephane Bailliez</a>
    */
  -public class ClasspathTestCollector extends ProjectComponent
  +public final class ClasspathTestCollector extends ProjectComponent
           implements TestCollector {
   
       private final static int SUFFIX_LENGTH = ".class".length();
   
  -    private PatternSet patterns = new PatternSet();
  +    private final PatternSet patterns = new PatternSet();
   
       private Path path = null;
   
  @@ -101,11 +101,13 @@
               }
               // add tests to the already collected one
               final int includedCount = included.size();
  +            log("Adding " + includedCount + " testcases from " + f, Project.MSG_VERBOSE);
               for (int j = 0; j < includedCount; j++) {
  -                String testname = (String) included.elementAt(i);
  +                String testname = (String) included.elementAt(j);
                   collected.put(testname, "");
               }
           }
  +        log("Collected " + collected.size() + " testcases from " + paths.length + " paths.");
           return collected.keys();
       }
   
  @@ -114,8 +116,8 @@
           Project project = getProject();
           DirectoryScanner ds = new DirectoryScanner();
           ds.setBasedir(dir);
  -        ds.setIncludes(patterns.getIncludePatterns(project));
  -        ds.setExcludes(patterns.getExcludePatterns(project));
  +        ds.setIncludes(patterns.getIncludePatterns(getProject()));
  +        ds.setExcludes(patterns.getExcludePatterns(getProject()));
           ds.scan();
           String[] included = ds.getIncludedFiles();
           return testClassNameFromFile(included);
  @@ -161,6 +163,10 @@
   
       public void setPath(Path path) {
           this.path = path;
  +    }
  +
  +    public Path getPath(){
  +        return this.path;
       }
   
       public PatternSet.NameEntry createInclude() {
  
  
  
  1.2       +14 -3     jakarta-ant/proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/rjunit/ClientElement.java
  
  Index: ClientElement.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/rjunit/ClientElement.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ClientElement.java	1 Feb 2002 23:53:22 -0000	1.1
  +++ ClientElement.java	2 Feb 2002 01:38:21 -0000	1.2
  @@ -58,6 +58,7 @@
   import java.io.FileOutputStream;
   import java.io.IOException;
   import java.io.OutputStream;
  +import java.io.ByteArrayOutputStream;
   import java.util.Enumeration;
   import java.util.Properties;
   import java.util.Vector;
  @@ -110,7 +111,7 @@
       /** create a new client */
       public ClientElement(RJUnitTask value) {
           parent = value;
  -        cmd.setClassname("org.apache.tools.ant.taskdefs.optional.junit.remote.TestRunner");
  +        cmd.setClassname("org.apache.tools.ant.taskdefs.optional.rjunit.remote.TestRunner");
       }
   
       /** core entry point */
  @@ -127,7 +128,7 @@
           // must appended to classpath to avoid conflicts.
           JUnitHelper.addClasspathEntry(createClasspath(), "/junit/framework/TestCase.class");
           JUnitHelper.addClasspathEntry(createClasspath(), "/org/apache/tools/ant/Task.class");
  -        JUnitHelper.addClasspathEntry(createClasspath(), "/org/apache/tools/ant/taskdefs/optional/junit/remote/TestRunner.class");
  +        JUnitHelper.addClasspathEntry(createClasspath(), "/org/apache/tools/ant/taskdefs/optional/rjunit/remote/TestRunner.class");
       }
   
       protected void doExecute() throws BuildException {
  @@ -162,6 +163,13 @@
           Enumeration[] tests = new Enumeration[testCollectors.size()];
           for (int i = 0; i < testCollectors.size(); i++) {
               TestCollector te = (TestCollector) testCollectors.elementAt(i);
  +            //@fixme I'm forced to append the classpath from batchtests
  +            // here to make sure it will be included as part of the
  +            // testrunner classpath. Need a better design ?
  +            if (te instanceof BatchTestElement){
  +                Path path = ((BatchTestElement)te).getPath();
  +                cmd.getClasspath().append(path);
  +            }
               tests[i] = te.collectTests();
           }
           return new CompoundEnumeration(tests);
  @@ -191,8 +199,11 @@
           File f = futils.createTempFile("junit-antrunner", "tmp", new File("."));
           OutputStream os = null;
           try {
  +            ByteArrayOutputStream baos = new ByteArrayOutputStream();
               os = new BufferedOutputStream(new FileOutputStream(f));
  -            props.store(os, "JUnit Ant Runner configuration file");
  +            props.store(baos, "JUnit Ant Runner configuration file");
  +            log(baos.toString(), Project.MSG_VERBOSE);
  +            os.write(baos.toByteArray());
           } catch (IOException e) {
               throw new BuildException(e);
           } finally {
  
  
  
  1.2       +1 -1      jakarta-ant/proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/rjunit/JUnitHelper.java
  
  Index: JUnitHelper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/rjunit/JUnitHelper.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JUnitHelper.java	1 Feb 2002 23:53:22 -0000	1.1
  +++ JUnitHelper.java	2 Feb 2002 01:38:21 -0000	1.2
  @@ -144,7 +144,7 @@
        */
       public static File getResourceEntry(String resource) {
           URL url = JUnitHelper.class.getResource(resource);
  -        if (url != null) {
  +        if (url == null) {
               // can't find the resource...
               return null;
           }
  
  
  

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