DirSetTestpublic class DirSetTest extends AbstractFileSetTest JUnit 3 testcases for org.apache.tools.ant.types.DirSet. |
Constructors Summary |
---|
public DirSetTest(String name)
super(name);
|
Methods Summary |
---|
protected AbstractFileSet | getInstance()
return new DirSet();
| public void | testFileSetIsNoDirSet()
DirSet ds = (DirSet) getInstance();
ds.setProject(getProject());
FileSet fs = new FileSet();
fs.setProject(getProject());
getProject().addReference("dummy", fs);
ds.setRefid(new Reference(getProject(), "dummy"));
try {
ds.getDir(getProject());
fail("DirSet created from FileSet reference");
} catch (BuildException e) {
assertEquals("dummy doesn\'t denote a DirSet", e.getMessage());
}
ds = (DirSet) getInstance();
ds.setProject(getProject());
getProject().addReference("dummy2", ds);
fs.setRefid(new Reference(getProject(), "dummy2"));
try {
fs.getDir(getProject());
fail("FileSet created from DirSet reference");
} catch (BuildException e) {
assertEquals("dummy2 doesn\'t denote a FileSet", e.getMessage());
}
| public void | testToString()
File tmp = File.createTempFile("DirSetTest", "");
tmp.delete();
File a = new File(tmp, "a");
a.mkdirs();
File b = new File(tmp, "b");
File bc = new File(b, "c");
bc.mkdirs();
new FileOutputStream(new File(a, "x")).close();
new FileOutputStream(new File(b, "x")).close();
new FileOutputStream(new File(bc, "x")).close();
DirSet ds = new DirSet();
ds.setProject(getProject());
ds.setDir(tmp);
ds.setIncludes("b/");
assertEquals("b;b" + File.separator + "c", ds.toString());
|
|