ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r292242 - in /ant/core/trunk: docs/manual/OptionalTasks/junit.html src/main/org/apache/tools/ant/taskdefs/optional/junit/BatchTest.java
Date Wed, 28 Sep 2005 18:32:15 GMT
Author: bodewig
Date: Wed Sep 28 11:32:08 2005
New Revision: 292242

URL: http://svn.apache.org/viewcvs?rev=292242&view=rev
Log:
ResourceCollection support for batchtest

Modified:
    ant/core/trunk/docs/manual/OptionalTasks/junit.html
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/BatchTest.java

Modified: ant/core/trunk/docs/manual/OptionalTasks/junit.html
URL: http://svn.apache.org/viewcvs/ant/core/trunk/docs/manual/OptionalTasks/junit.html?rev=292242&r1=292241&r2=292242&view=diff
==============================================================================
--- ant/core/trunk/docs/manual/OptionalTasks/junit.html (original)
+++ ant/core/trunk/docs/manual/OptionalTasks/junit.html Wed Sep 28 11:32:08 2005
@@ -448,11 +448,15 @@
 
 <p>Define a number of tests based on pattern matching.</p>
 
-<p><code>batchtest</code> collects the included files from any number
+<p><code>batchtest</code> collects the included <a href="../CoreTypes/resources.html">resources</a>
from any number
 of nested <a
-href="../CoreTypes/fileset.html"><code>&lt;fileset&gt;</code></a>s.
It then
-generates a test class name for each file that ends in
+href="../CoreTypes/resources.html#collection">Resource Collection</a>s. It then
+generates a test class name for each resource that ends in
 <code>.java</code> or <code>.class</code>.</p>
+
+<p>Any type of Resource Collection is supported as a nested element,
+prior to Ant 1.7 only <code>&lt;fileset&gt;</code> has been
+supported.</p>
 
 <table border="1" cellpadding="2" cellspacing="0">
 <tr>

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/BatchTest.java
URL: http://svn.apache.org/viewcvs/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/BatchTest.java?rev=292242&r1=292241&r2=292242&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/BatchTest.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/BatchTest.java Wed
Sep 28 11:32:08 2005
@@ -20,10 +20,14 @@
 
 import java.io.File;
 import java.util.Enumeration;
+import java.util.Iterator;
 import java.util.Vector;
 import org.apache.tools.ant.DirectoryScanner;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.types.FileSet;
+import org.apache.tools.ant.types.Resource;
+import org.apache.tools.ant.types.ResourceCollection;
+import org.apache.tools.ant.types.resources.Resources;
 
 /**
  * <p> Create then run <code>JUnitTest</code>'s based on the list of files
@@ -42,7 +46,7 @@
     private Project project;
 
     /** the list of filesets containing the testcase filename rules */
-    private Vector filesets = new Vector();
+    private Resources resources = new Resources();
 
     /**
      * create a new batchtest instance
@@ -59,7 +63,21 @@
      * @param     fs the new fileset containing the rules to get the testcases.
      */
     public void addFileSet(FileSet fs) {
-        filesets.addElement(fs);
+	add(fs);
+    }
+
+
+    /**
+     * Add a new ResourceCollection instance to this
+     * batchtest. Whatever the collection is, only names that are
+     * <tt>.java</tt> or <tt>.class</tt> will be considered as
+     * 'candidates'.
+     * @param rc the new ResourceCollection containing the rules to
+     * get the testcases.
+     * @since Ant 1.7
+     */
+    public void add(ResourceCollection rc) {
+        resources.add(rc);
     }
 
     /**
@@ -113,20 +131,17 @@
      */
     private String[] getFilenames() {
         Vector v = new Vector();
-        final int size = this.filesets.size();
-        for (int j = 0; j < size; j++) {
-            FileSet fs = (FileSet) filesets.elementAt(j);
-            DirectoryScanner ds = fs.getDirectoryScanner(project);
-            ds.scan();
-            String[] f = ds.getIncludedFiles();
-            for (int k = 0; k < f.length; k++) {
-                String pathname = f[k];
+	Iterator iter = resources.iterator();
+	while (iter.hasNext()) {
+	    Resource r = (Resource) iter.next();
+	    if (r.isExists()) {
+		String pathname = r.getName();
                 if (pathname.endsWith(".java")) {
                     v.addElement(pathname.substring(0, pathname.length() - ".java".length()));
                 } else if (pathname.endsWith(".class")) {
                     v.addElement(pathname.substring(0, pathname.length() - ".class".length()));
                 }
-            }
+	    }
         }
 
         String[] files = new String[v.size()];



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


Mime
View raw message