AbstractFileSetTestpublic abstract class AbstractFileSetTest extends TestCase Base class for FileSetTest and DirSetTest.
This doesn't actually test much, mainly reference handling. |
Fields Summary |
---|
private org.apache.tools.ant.Project | project |
Constructors Summary |
---|
public AbstractFileSetTest(String name)
super(name);
|
Methods Summary |
---|
protected abstract AbstractFileSet | getInstance()
| protected final org.apache.tools.ant.Project | getProject()
return project;
| public void | setUp()
project = new Project();
project.setBasedir(".");
| public void | testCircularReferenceCheck()
AbstractFileSet f = getInstance();
project.addReference("dummy", f);
f.setRefid(new Reference("dummy"));
try {
f.getDir(project);
fail("Can make " + f.getDataTypeName()
+ " a Reference to itself.");
} catch (BuildException be) {
assertEquals("This data type contains a circular reference.",
be.getMessage());
}
try {
f.getDirectoryScanner(project);
fail("Can make " + f.getDataTypeName()
+ " a Reference to itself.");
} catch (BuildException be) {
assertEquals("This data type contains a circular reference.",
be.getMessage());
}
// dummy1 --> dummy2 --> dummy3 --> dummy1
AbstractFileSet f1 = getInstance();
project.addReference("dummy1", f1);
f1.setRefid(new Reference("dummy2"));
AbstractFileSet f2 = getInstance();
project.addReference("dummy2", f2);
f2.setRefid(new Reference("dummy3"));
AbstractFileSet f3 = getInstance();
project.addReference("dummy3", f3);
f3.setRefid(new Reference("dummy1"));
try {
f1.getDir(project);
fail("Can make circular reference.");
} catch (BuildException be) {
assertEquals("This data type contains a circular reference.",
be.getMessage());
}
try {
f1.getDirectoryScanner(project);
fail("Can make circular reference.");
} catch (BuildException be) {
assertEquals("This data type contains a circular reference.",
be.getMessage());
}
// dummy1 --> dummy2 --> dummy3
// (which has the Project's basedir as root).
f1 = getInstance();
project.addReference("dummy1", f1);
f1.setRefid(new Reference("dummy2"));
f2 = getInstance();
project.addReference("dummy2", f2);
f2.setRefid(new Reference("dummy3"));
f3 = getInstance();
project.addReference("dummy3", f3);
f3.setDir(project.resolveFile("."));
File dir = f1.getDir(project);
assertEquals("Dir is basedir", dir, project.getBaseDir());
| public final void | testEmptyElementIfIsReference()
AbstractFileSet f = getInstance();
f.setIncludes("**/*.java");
try {
f.setRefid(new Reference("dummyref"));
fail("Can add reference to "
+ f.getDataTypeName()
+ " with elements from setIncludes");
} catch (BuildException be) {
assertEquals("You must not specify more than one attribute "
+ "when using refid", be.getMessage());
}
f = getInstance();
f.createPatternSet();
try {
f.setRefid(new Reference("dummyref"));
fail("Can add reference to "
+ f.getDataTypeName()
+ " with nested patternset element.");
} catch (BuildException be) {
assertEquals("You must not specify nested elements when "
+ "using refid", be.getMessage());
}
f = getInstance();
f.createInclude();
try {
f.setRefid(new Reference("dummyref"));
fail("Can add reference to "
+ f.getDataTypeName()
+ " with nested include element.");
} catch (BuildException be) {
assertEquals("You must not specify more than one attribute "
+ "when using refid", be.getMessage());
}
f = getInstance();
f.setRefid(new Reference("dummyref"));
try {
f.setIncludes("**/*.java");
fail("Can set includes in "
+ f.getDataTypeName()
+ " that is a reference.");
} catch (BuildException be) {
assertEquals("You must not specify more than one attribute "
+ "when using refid", be.getMessage());
}
try {
f.setIncludesfile(new File("/a"));
fail("Can set includesfile in "
+ f.getDataTypeName()
+ " that is a reference.");
} catch (BuildException be) {
assertEquals("You must not specify more than one attribute "
+ "when using refid", be.getMessage());
}
try {
f.setExcludes("**/*.java");
fail("Can set excludes in "
+ f.getDataTypeName()
+ " that is a reference.");
} catch (BuildException be) {
assertEquals("You must not specify more than one attribute "
+ "when using refid", be.getMessage());
}
try {
f.setExcludesfile(new File("/a"));
fail("Can set excludesfile in "
+ f.getDataTypeName()
+ " that is a reference.");
} catch (BuildException be) {
assertEquals("You must not specify more than one attribute "
+ "when using refid", be.getMessage());
}
try {
f.setDir(project.resolveFile("."));
fail("Can set dir in "
+ f.getDataTypeName()
+ " that is a reference.");
} catch (BuildException be) {
assertEquals("You must not specify more than one attribute "
+ "when using refid", be.getMessage());
}
try {
f.createInclude();
fail("Can add nested include in "
+ f.getDataTypeName()
+ " that is a reference.");
} catch (BuildException be) {
assertEquals("You must not specify nested elements when using "
+ "refid", be.getMessage());
}
try {
f.createExclude();
fail("Can add nested exclude in "
+ f.getDataTypeName()
+ " that is a reference.");
} catch (BuildException be) {
assertEquals("You must not specify nested elements when using "
+ "refid", be.getMessage());
}
try {
f.createIncludesFile();
fail("Can add nested includesfile in "
+ f.getDataTypeName()
+ " that is a reference.");
} catch (BuildException be) {
assertEquals("You must not specify nested elements when using "
+ "refid", be.getMessage());
}
try {
f.createExcludesFile();
fail("Can add nested excludesfile in "
+ f.getDataTypeName()
+ " that is a reference.");
} catch (BuildException be) {
assertEquals("You must not specify nested elements when using "
+ "refid", be.getMessage());
}
try {
f.createPatternSet();
fail("Can add nested patternset in "
+ f.getDataTypeName()
+ " that is a reference.");
} catch (BuildException be) {
assertEquals("You must not specify nested elements when using "
+ "refid", be.getMessage());
}
|
|