ClassFileSetTestpublic class ClassFileSetTest extends org.apache.tools.ant.BuildFileTest Testcase for the Classfileset optional type. |
Fields Summary |
---|
public static final String | RESULT_FILESET |
Constructors Summary |
---|
public ClassFileSetTest(String name)
super(name);
|
Methods Summary |
---|
public void | setUp()
// share the setup for testing the depend task
configureProject("src/etc/testcases/taskdefs/optional/depend/depend.xml");
| public void | tearDown()
executeTarget("clean");
| public void | testBasicSet()Test basic classfileset
Project p = getProject();
executeTarget("testbasicset");
FileSet resultFileSet = (FileSet)p.getReference(RESULT_FILESET);
DirectoryScanner scanner = resultFileSet.getDirectoryScanner(p);
String[] scannedFiles = scanner.getIncludedFiles();
Hashtable files = new Hashtable();
for (int i = 0; i < scannedFiles.length; ++i) {
files.put(scannedFiles[i], scannedFiles[i]);
}
assertEquals("Classfileset did not pick up expected number of "
+ "class files", 4, files.size());
assertTrue("Result did not contain A.class",
files.containsKey("A.class"));
assertTrue("Result did not contain B.class",
files.containsKey("B.class"));
assertTrue("Result did not contain C.class",
files.containsKey("C.class"));
assertTrue("Result did not contain D.class",
files.containsKey("D.class"));
| public void | testByReference()Test that you can pass a classfileset by reference to a fileset.
executeTarget("testbyreference");
| public void | testComboSet()Test combo classfileset
Project p = getProject();
executeTarget("testcomboset");
FileSet resultFileSet = (FileSet)p.getReference(RESULT_FILESET);
DirectoryScanner scanner = resultFileSet.getDirectoryScanner(p);
String[] scannedFiles = scanner.getIncludedFiles();
Hashtable files = new Hashtable();
for (int i = 0; i < scannedFiles.length; ++i) {
files.put(scannedFiles[i], scannedFiles[i]);
}
assertEquals("Classfileset did not pick up expected number of "
+ "class files", 1, files.size());
assertTrue("Result did not contain C.class",
files.containsKey("C.class"));
| public void | testMethodParam()Test that classes included in a method "System.out.println(MyClass.class)" are included.
Project p = getProject();
executeTarget("testmethodparam");
FileSet resultFileSet = (FileSet)p.getReference(RESULT_FILESET);
DirectoryScanner scanner = resultFileSet.getDirectoryScanner(p);
String[] scannedFiles = scanner.getIncludedFiles();
Hashtable files = new Hashtable();
for (int i = 0; i < scannedFiles.length; ++i) {
files.put(scannedFiles[i], scannedFiles[i]);
}
assertEquals("Classfileset did not pick up expected number of "
+ "class files", 5, files.size());
assertTrue("Result did not contain A.class",
files.containsKey("A.class"));
assertTrue("Result did not contain B.class",
files.containsKey("B.class"));
assertTrue("Result did not contain C.class",
files.containsKey("C.class"));
assertTrue("Result did not contain D.class",
files.containsKey("D.class"));
assertTrue("Result did not contain E.class",
files.containsKey("E.class"));
| public void | testMethodParamInner()Test that classes included in a method "System.out.println(Outer.Inner.class)" are included.
Project p = getProject();
executeTarget("testmethodparaminner");
FileSet resultFileSet = (FileSet)p.getReference(RESULT_FILESET);
DirectoryScanner scanner = resultFileSet.getDirectoryScanner(p);
String[] scannedFiles = scanner.getIncludedFiles();
Hashtable files = new Hashtable();
for (int i = 0; i < scannedFiles.length; ++i) {
files.put(scannedFiles[i], scannedFiles[i]);
}
assertEquals("Classfileset did not pick up expected number of "
+ "class files", 4, files.size());
assertTrue("Result did not contain test" + File.separator + "Outer$Inner.class",
files.containsKey("test" + File.separator + "Outer$Inner.class"));
assertTrue("Result did not contain test" + File.separator + "Outer.class",
files.containsKey("test" + File.separator + "Outer.class"));
assertTrue("Result did not contain test" + File.separator + "ContainsOnlyInner.class",
files.containsKey("test" + File.separator + "ContainsOnlyInner.class"));
assertTrue("Result did not contain test" + File.separator + "ContainsOnlyInner.class",
files.containsKey("test" + File.separator + "MethodParam.class"));
| public void | testResourceCollection()
executeTarget("testresourcecollection");
| public void | testSmallSet()Test small classfileset
Project p = getProject();
executeTarget("testsmallset");
FileSet resultFileSet = (FileSet)p.getReference(RESULT_FILESET);
DirectoryScanner scanner = resultFileSet.getDirectoryScanner(p);
String[] scannedFiles = scanner.getIncludedFiles();
Hashtable files = new Hashtable();
for (int i = 0; i < scannedFiles.length; ++i) {
files.put(scannedFiles[i], scannedFiles[i]);
}
assertEquals("Classfileset did not pick up expected number of "
+ "class files", 2, files.size());
assertTrue("Result did not contain B.class",
files.containsKey("B.class"));
assertTrue("Result did not contain C.class",
files.containsKey("C.class"));
|
|