@@ -67,16 +67,16 @@ import org.apache.tools.ant.types.FileSet;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.DirectoryScanner;
/**
/**
* Testcase for the Depend optional task.
*
* Testcase for the Depend optional task.
*
* @author Conor MacNeill
* @author Conor MacNeill
*/
*/
public class DependTest extends BuildFileTest {
public class DependTest extends BuildFileTest {
public static final String RESULT_FILESET = "result";
public static final String RESULT_FILESET = "result";
public static final String TEST_BUILD_FILE
public static final String TEST_BUILD_FILE
= "src/etc/testcases/taskdefs/optional/depend/depend.xml";
= "src/etc/testcases/taskdefs/optional/depend/depend.xml";
public DependTest(String name) {
public DependTest(String name) {
super(name);
super(name);
}
}
@@ -96,11 +96,11 @@ public class DependTest extends BuildFileTest {
Project project = getProject();
Project project = getProject();
executeTarget("testdirect");
executeTarget("testdirect");
Hashtable files = getResultFiles();
Hashtable files = getResultFiles();
assertEquals("Depend did not leave correct number of files", 2,
assertEquals("Depend did not leave correct number of files", 3,
files.size());
files.size());
assertTrue("Result did not contain A.class",
assertTrue("Result did not contain A.class",
files.containsKey("A.class"));
files.containsKey("A.class"));
assertTrue("Result did not contain D.class",
assertTrue("Result did not contain D.class",
files.containsKey("D.class"));
files.containsKey("D.class"));
}
}
@@ -111,9 +111,9 @@ public class DependTest extends BuildFileTest {
Project project = getProject();
Project project = getProject();
executeTarget("testclosure");
executeTarget("testclosure");
Hashtable files = getResultFiles();
Hashtable files = getResultFiles();
assertEquals("Depend did not leave correct number of files", 1,
assertEquals("Depend did not leave correct number of files", 2,
files.size());
files.size());
assertTrue("Result did not contain D.class",
assertTrue("Result did not contain D.class",
files.containsKey("D.class"));
files.containsKey("D.class"));
}
}
@@ -123,41 +123,41 @@ public class DependTest extends BuildFileTest {
public void testInner() {
public void testInner() {
Project project = getProject();
Project project = getProject();
executeTarget("testinner");
executeTarget("testinner");
assertEquals("Depend did not leave correct number of files", 0,
assertEquals("Depend did not leave correct number of files", 0,
getResultFiles().size());
getResultFiles().size());
}
}
/**
/**
* Test that multi-leve inner class dependencies trigger deletion of
* Test that multi-leve inner class dependencies trigger deletion of
* the outer class
* the outer class
*/
*/
public void testInnerInner() {
public void testInnerInner() {
Project project = getProject();
Project project = getProject();
executeTarget("testinnerinner");
executeTarget("testinnerinner");
assertEquals("Depend did not leave correct number of files", 0,
assertEquals("Depend did not leave correct number of files", 0,
getResultFiles().size());
getResultFiles().size());
}
}
/**
/**
* Test that an exception is thrown when there is no source
* Test that an exception is thrown when there is no source
*/
*/
public void testNoSource() {
public void testNoSource() {
expectBuildExceptionContaining("testnosource",
expectBuildExceptionContaining("testnosource",
"No source specified", "srcdir attribute must be set");
"No source specified", "srcdir attribute must be set");
}
}
/**
/**
* Test that an exception is thrown when the source attribute is empty
* Test that an exception is thrown when the source attribute is empty
*/
*/
public void testEmptySource() {
public void testEmptySource() {
expectBuildExceptionContaining("testemptysource",
expectBuildExceptionContaining("testemptysource",
"No source specified", "srcdir attribute must be non-empty");
"No source specified", "srcdir attribute must be non-empty");
}
}
/**
/**
* Read the result fileset into a Hashtable
* Read the result fileset into a Hashtable
*
* @return a Hashtable containing the names of the files in the result
*
* @return a Hashtable containing the names of the files in the result
* fileset
* fileset
*/
*/
private Hashtable getResultFiles() {
private Hashtable getResultFiles() {
@@ -170,8 +170,8 @@ public class DependTest extends BuildFileTest {
}
}
return files;
return files;
}
}
/**
/**
* Test mutual dependency between inner and outer do not cause both to be
* Test mutual dependency between inner and outer do not cause both to be
* deleted
* deleted
@@ -179,7 +179,7 @@ public class DependTest extends BuildFileTest {
public void testInnerClosure() {
public void testInnerClosure() {
Project project = getProject();
Project project = getProject();
executeTarget("testinnerclosure");
executeTarget("testinnerclosure");
assertEquals("Depend did not leave correct number of files", 2,
assertEquals("Depend did not leave correct number of files", 2,
getResultFiles().size());
getResultFiles().size());
}
}
@@ -196,10 +196,10 @@ public class DependTest extends BuildFileTest {
public void testNonPublic() {
public void testNonPublic() {
executeTarget("testnonpublic");
executeTarget("testnonpublic");
String log = getLog();
String log = getLog();
assertTrue("Expected warning about APrivate",
assertTrue("Expected warning about APrivate",
log.indexOf("The class APrivate in file") != -1);
log.indexOf("The class APrivate in file") != -1);
assertTrue("but has not been deleted because its source file "
+ "could not be determined",
assertTrue("but has not been deleted because its source file "
+ "could not be determined",
log.indexOf("The class APrivate in file") != -1);
log.indexOf("The class APrivate in file") != -1);
}
}