Methods Summary |
---|
public void | add(org.apache.tools.ant.types.ResourceCollection rc)Add a new ResourceCollection instance to this
batchtest. Whatever the collection is, only names that are
.java or .class will be considered as
'candidates'.
resources.add(rc);
|
public void | addFileSet(org.apache.tools.ant.types.FileSet fs)Add a new fileset instance to this batchtest. Whatever the fileset is,
only filename that are .java or .class will be
considered as 'candidates'.
add(fs);
// this one is here because the changes to support ResourceCollections
// have broken Magic's JUnitTestTask.
//
// The task adds a FileSet to a BatchTest instance using the
// Java API and without telling the FileSet about its project
// instance. The original code would pass in project on the
// call to getDirectoryScanner - which is now hidden deep into
// Resources.iterator() and not reachable.
if (fs.getProject() == null) {
fs.setProject(project);
}
|
void | addTestsTo(java.util.Vector v)Convenient method to merge the JUnitTests of this batchtest
to a Vector.
JUnitTest[] tests = createAllJUnitTest();
v.ensureCapacity(v.size() + tests.length);
for (int i = 0; i < tests.length; i++) {
v.addElement(tests[i]);
}
|
private JUnitTest[] | createAllJUnitTest()Create all JUnitTests based on the filesets. Each instance
is configured to match this instance properties.
String[] filenames = getFilenames();
JUnitTest[] tests = new JUnitTest[filenames.length];
for (int i = 0; i < tests.length; i++) {
String classname = javaToClass(filenames[i]);
tests[i] = createJUnitTest(classname);
}
return tests;
|
private JUnitTest | createJUnitTest(java.lang.String classname)Create a JUnitTest that has the same property as this
BatchTest instance.
JUnitTest test = new JUnitTest();
test.setName(classname);
test.setHaltonerror(this.haltOnError);
test.setHaltonfailure(this.haltOnFail);
test.setFiltertrace(this.filtertrace);
test.setFork(this.fork);
test.setIf(this.ifProperty);
test.setUnless(this.unlessProperty);
test.setTodir(this.destDir);
test.setFailureProperty(failureProperty);
test.setErrorProperty(errorProperty);
Enumeration list = this.formatters.elements();
while (list.hasMoreElements()) {
test.addFormatter((FormatterElement) list.nextElement());
}
return test;
|
public java.util.Enumeration | elements()Return all JUnitTest instances obtain by applying the fileset rules.
JUnitTest[] tests = createAllJUnitTest();
return Enumerations.fromArray(tests);
|
private java.lang.String[] | getFilenames()Iterate over all filesets and return the filename of all files
that end with .java or .class. This is to avoid
wrapping a JUnitTest over an xml file for example. A Testcase
is obviously a java file (compiled or not).
Vector v = new Vector();
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()];
v.copyInto(files);
return files;
|
public static java.lang.String | javaToClass(java.lang.String filename)Convenient method to convert a pathname without extension to a
fully qualified classname. For example org/apache/Whatever will
be converted to org.apache.Whatever
return filename.replace(File.separatorChar, '.").replace('/", '.")
.replace('\\", '.");
|