Browse Source

Checkstyle (whitespace, line length, etc)

master
Gintas Grigelionis 7 years ago
parent
commit
ab2d99a565
24 changed files with 134 additions and 165 deletions
  1. +1
    -1
      src/tests/junit/org/apache/tools/ant/IncludeTest.java
  2. +8
    -8
      src/tests/junit/org/apache/tools/ant/IntrospectionHelperTest.java
  3. +5
    -5
      src/tests/junit/org/apache/tools/ant/taskdefs/CVSPassTest.java
  4. +0
    -12
      src/tests/junit/org/apache/tools/ant/taskdefs/ConcatTest.java
  5. +27
    -32
      src/tests/junit/org/apache/tools/ant/taskdefs/CopyTest.java
  6. +1
    -1
      src/tests/junit/org/apache/tools/ant/taskdefs/DirnameTest.java
  7. +1
    -1
      src/tests/junit/org/apache/tools/ant/taskdefs/FailTest.java
  8. +1
    -1
      src/tests/junit/org/apache/tools/ant/taskdefs/JavaTest.java
  9. +16
    -8
      src/tests/junit/org/apache/tools/ant/taskdefs/RmicAdvancedTest.java
  10. +2
    -4
      src/tests/junit/org/apache/tools/ant/taskdefs/SignJarTest.java
  11. +3
    -3
      src/tests/junit/org/apache/tools/ant/taskdefs/TarTest.java
  12. +1
    -2
      src/tests/junit/org/apache/tools/ant/taskdefs/TouchTest.java
  13. +27
    -36
      src/tests/junit/org/apache/tools/ant/taskdefs/UnzipTest.java
  14. +1
    -4
      src/tests/junit/org/apache/tools/ant/taskdefs/WhichResourceTest.java
  15. +6
    -6
      src/tests/junit/org/apache/tools/ant/taskdefs/condition/ParserSupportsTest.java
  16. +1
    -2
      src/tests/junit/org/apache/tools/ant/taskdefs/optional/ANTLRTest.java
  17. +2
    -1
      src/tests/junit/org/apache/tools/ant/taskdefs/optional/JavahTest.java
  18. +2
    -2
      src/tests/junit/org/apache/tools/ant/taskdefs/optional/ReplaceRegExpTest.java
  19. +1
    -6
      src/tests/junit/org/apache/tools/ant/taskdefs/optional/XsltTest.java
  20. +7
    -5
      src/tests/junit/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTest.java
  21. +18
    -18
      src/tests/junit/org/apache/tools/ant/taskdefs/optional/sos/SOSTest.java
  22. +1
    -3
      src/tests/junit/org/apache/tools/ant/taskdefs/optional/unix/SymlinkTest.java
  23. +1
    -2
      src/tests/junit/org/apache/tools/ant/util/PackageNameMapperTest.java
  24. +1
    -2
      src/tests/junit/org/apache/tools/ant/util/UnPackageNameMapperTest.java

+ 1
- 1
src/tests/junit/org/apache/tools/ant/IncludeTest.java View File

@@ -81,7 +81,7 @@ public class IncludeTest {
thrown.expect(BuildException.class); thrown.expect(BuildException.class);
thrown.expect(hasProperty("location", hasProperty("fileName", thrown.expect(hasProperty("location", hasProperty("fileName",
containsString("build.xml")))); containsString("build.xml"))));
buildRule.configureProject("src/etc/testcases/core/include/including_file_parse_error/build.xml");
buildRule.configureProject("src/etc/testcases/core/include/including_file_parse_error/build.xml");
} }


@Test @Test


+ 8
- 8
src/tests/junit/org/apache/tools/ant/IntrospectionHelperTest.java View File

@@ -255,7 +255,7 @@ public class IntrospectionHelperTest {
Map<String, Class<?>> elemMap = getExpectedNestedElements(); Map<String, Class<?>> elemMap = getExpectedNestedElements();
for (String name : Collections.list(ih.getNestedElements())) { for (String name : Collections.list(ih.getNestedElements())) {
Class<?> expect = elemMap.get(name); Class<?> expect = elemMap.get(name);
assertNotNull("Support for " + name + " in IntrospectioNHelperTest?",
assertNotNull("Support for " + name + " in IntrospectionHelperTest?",
expect); expect);
assertEquals("Return type of " + name, expect, ih.getElementType(name)); assertEquals("Return type of " + name, expect, ih.getElementType(name));
elemMap.remove(name); elemMap.remove(name);
@@ -605,8 +605,7 @@ public class IntrospectionHelperTest {
@Test @Test
public void testGetAttributeMap() { public void testGetAttributeMap() {
Map<String, Class<?>> attrMap = getExpectedAttributes(); Map<String, Class<?>> attrMap = getExpectedAttributes();
Map<String, Class<?>> actualMap = ih.getAttributeMap();
actualMap.forEach((attrName, value) -> {
ih.getAttributeMap().forEach((attrName, value) -> {
Class<?> attrClass = attrMap.get(attrName); Class<?> attrClass = attrMap.get(attrName);
assertNotNull("Support for " + attrName + " in IntrospectionHelperTest?", attrClass); assertNotNull("Support for " + attrName + " in IntrospectionHelperTest?", attrClass);
assertEquals("Type of " + attrName, attrClass, value); assertEquals("Type of " + attrName, attrClass, value);
@@ -614,11 +613,14 @@ public class IntrospectionHelperTest {
}); });
attrMap.remove("name"); attrMap.remove("name");
assertTrue("Found all", attrMap.isEmpty()); assertTrue("Found all", attrMap.isEmpty());
}


@Test
public void testClearGetAttributeMap() {
thrown.expect(UnsupportedOperationException.class); thrown.expect(UnsupportedOperationException.class);
// TODO we should be asserting a value somewhere in here // TODO we should be asserting a value somewhere in here
// Check it's a read-only map. // Check it's a read-only map.
actualMap.clear();
ih.getAttributeMap().clear();
} }


@Test @Test
@@ -659,8 +661,7 @@ public class IntrospectionHelperTest {


private void assertAttrMethod(String attrName, String methodName, private void assertAttrMethod(String attrName, String methodName,
Class<?> methodArg, Object arg, Object badArg) { Class<?> methodArg, Object arg, Object badArg) {
Method m = ih.getAttributeMethod(attrName);
assertMethod(m, methodName, methodArg, arg, badArg);
assertMethod(ih.getAttributeMethod(attrName), methodName, methodArg, arg, badArg);
} }


public int setTwo(String s) { public int setTwo(String s) {
@@ -830,5 +831,4 @@ public class IntrospectionHelperTest {
return table; return table;
} }


} // IntrospectionHelperTest

}

+ 5
- 5
src/tests/junit/org/apache/tools/ant/taskdefs/CVSPassTest.java View File

@@ -56,6 +56,11 @@ public class CVSPassTest {
buildRule.configureProject("src/etc/testcases/taskdefs/cvspass.xml"); buildRule.configureProject("src/etc/testcases/taskdefs/cvspass.xml");
} }


@After
public void tearDown() {
buildRule.executeTarget("cleanup");
}

@Test @Test
public void testNoCVSRoot() { public void testNoCVSRoot() {
thrown.expect(BuildException.class); thrown.expect(BuildException.class);
@@ -70,11 +75,6 @@ public class CVSPassTest {
buildRule.executeTarget("test2"); buildRule.executeTarget("test2");
} }


@After
public void tearDown() {
buildRule.executeTarget("cleanup");
}

@Test @Test
public void testPassFile() throws Exception { public void testPassFile() throws Exception {
buildRule.executeTarget("test3"); buildRule.executeTarget("test3");


+ 0
- 12
src/tests/junit/org/apache/tools/ant/taskdefs/ConcatTest.java View File

@@ -275,16 +275,4 @@ public class ConcatTest {
FileUtilities.getFileContents(f1), FileUtilities.getFileContents(f2)); FileUtilities.getFileContents(f1), FileUtilities.getFileContents(f2));
} }


// ------------------------------------------------------
// Helper methods - should be in a utility class
// -----------------------------------------------------
@SuppressWarnings("unused")
private void expectFileContainsx(String target, String filename, String contains)
throws IOException {
buildRule.executeTarget(target);
String content = FileUtilities.getFileContents(buildRule.getProject(), filename);
assertThat("expecting file " + filename + " to contain " + contains + " but got " + content,
content, containsString(contains));
}

} }

+ 27
- 32
src/tests/junit/org/apache/tools/ant/taskdefs/CopyTest.java View File

@@ -79,17 +79,18 @@ public class CopyTest {
@Test @Test
public void test3() { public void test3() {
buildRule.executeTarget("test3"); buildRule.executeTarget("test3");
File file3 = new File(buildRule.getProject().getProperty("output"), "copytest3.tmp");
final String output = buildRule.getProject().getProperty("output");
final File file3 = new File(output, "copytest3.tmp");
// rollback file timestamp instead of delaying test // rollback file timestamp instead of delaying test
FileUtilities.rollbackTimestamps(file3, 3); FileUtilities.rollbackTimestamps(file3, 3);
buildRule.executeTarget("test3Part2"); buildRule.executeTarget("test3Part2");
assertTrue(file3.exists()); assertTrue(file3.exists());


File file3a = new File(buildRule.getProject().getProperty("output"), "copytest3a.tmp");
File file3a = new File(output, "copytest3a.tmp");
assertTrue(file3a.exists()); assertTrue(file3a.exists());
File file3b = new File(buildRule.getProject().getProperty("output"), "copytest3b.tmp");
File file3b = new File(output, "copytest3b.tmp");
assertTrue(file3b.exists()); assertTrue(file3b.exists());
File file3c = new File(buildRule.getProject().getProperty("output"), "copytest3c.tmp");
File file3c = new File(output, "copytest3c.tmp");
assertTrue(file3c.exists()); assertTrue(file3c.exists());


// file length checks rely on touch generating a zero byte file // file length checks rely on touch generating a zero byte file
@@ -118,8 +119,9 @@ public class CopyTest {
@Test @Test
public void testFilterSet() throws IOException { public void testFilterSet() throws IOException {
buildRule.executeTarget("testFilterSet"); buildRule.executeTarget("testFilterSet");
File tmp = new File(buildRule.getProject().getProperty("output"), "copy.filterset.tmp");
File check = new File(buildRule.getProject().getBaseDir(), "expected/copy.filterset.filtered");
File tmp = new File(buildRule.getProject().getProperty("output"), "copy.filterset.tmp");
File check = new File(buildRule.getProject().getBaseDir(),
"expected/copy.filterset.filtered");
assertTrue(tmp.exists()); assertTrue(tmp.exists());
assertEquals(FileUtilities.getFileContents(tmp), FileUtilities.getFileContents(check)); assertEquals(FileUtilities.getFileContents(tmp), FileUtilities.getFileContents(check));
} }
@@ -127,8 +129,9 @@ public class CopyTest {
@Test @Test
public void testFilterChain() throws IOException { public void testFilterChain() throws IOException {
buildRule.executeTarget("testFilterChain"); buildRule.executeTarget("testFilterChain");
File tmp = new File(buildRule.getProject().getProperty("output"), "copy.filterchain.tmp");
File check = new File(buildRule.getProject().getBaseDir(), "expected/copy.filterset.filtered");
File tmp = new File(buildRule.getProject().getProperty("output"), "copy.filterchain.tmp");
File check = new File(buildRule.getProject().getBaseDir(),
"expected/copy.filterset.filtered");
assertTrue(tmp.exists()); assertTrue(tmp.exists());
assertEquals(FileUtilities.getFileContents(tmp), FileUtilities.getFileContents(check)); assertEquals(FileUtilities.getFileContents(tmp), FileUtilities.getFileContents(check));
} }
@@ -186,24 +189,20 @@ public class CopyTest {
@Test @Test
public void testFileResourcePlain() { public void testFileResourcePlain() {
buildRule.executeTarget("testFileResourcePlain"); buildRule.executeTarget("testFileResourcePlain");
File file1 = new File(buildRule.getProject().getProperty("to.dir") + "/file1.txt");
File file2 = new File(buildRule.getProject().getProperty("to.dir") + "/file2.txt");
File file3 = new File(buildRule.getProject().getProperty("to.dir") + "/file3.txt");
assertTrue(file1.exists());
assertTrue(file2.exists());
assertTrue(file3.exists());
final String toDir = buildRule.getProject().getProperty("to.dir");
assertTrue(new File(toDir + "/file1.txt").exists());
assertTrue(new File(toDir + "/file2.txt").exists());
assertTrue(new File(toDir + "/file3.txt").exists());
} }


@Ignore("Previously ignored by naming convention") @Ignore("Previously ignored by naming convention")
@Test @Test
public void testFileResourceWithMapper() { public void testFileResourceWithMapper() {
buildRule.executeTarget("testFileResourceWithMapper"); buildRule.executeTarget("testFileResourceWithMapper");
File file1 = new File(buildRule.getProject().getProperty("to.dir") + "/file1.txt.bak");
File file2 = new File(buildRule.getProject().getProperty("to.dir") + "/file2.txt.bak");
File file3 = new File(buildRule.getProject().getProperty("to.dir") + "/file3.txt.bak");
assertTrue(file1.exists());
assertTrue(file2.exists());
assertTrue(file3.exists());
final String toDir = buildRule.getProject().getProperty("to.dir");
assertTrue(new File(toDir + "/file1.txt.bak").exists());
assertTrue(new File(toDir + "/file2.txt.bak").exists());
assertTrue(new File(toDir + "/file3.txt.bak").exists());
} }


@Test @Test
@@ -222,23 +221,19 @@ public class CopyTest {
@Test @Test
public void testPathAsResource() { public void testPathAsResource() {
buildRule.executeTarget("testPathAsResource"); buildRule.executeTarget("testPathAsResource");
File file1 = new File(buildRule.getProject().getProperty("to.dir") + "/file1.txt");
File file2 = new File(buildRule.getProject().getProperty("to.dir") + "/file2.txt");
File file3 = new File(buildRule.getProject().getProperty("to.dir") + "/file3.txt");
assertTrue(file1.exists());
assertTrue(file2.exists());
assertTrue(file3.exists());
final String toDir = buildRule.getProject().getProperty("to.dir");
assertTrue(new File(toDir + "/file1.txt").exists());
assertTrue(new File(toDir + "/file2.txt").exists());
assertTrue(new File(toDir + "/file3.txt").exists());
} }


@Test @Test
public void testZipfileset() { public void testZipfileset() {
buildRule.executeTarget("testZipfileset"); buildRule.executeTarget("testZipfileset");
File file1 = new File(buildRule.getProject().getProperty("to.dir") + "/file1.txt");
File file2 = new File(buildRule.getProject().getProperty("to.dir") + "/file2.txt");
File file3 = new File(buildRule.getProject().getProperty("to.dir") + "/file3.txt");
assertTrue(file1.exists());
assertTrue(file2.exists());
assertTrue(file3.exists());
final String toDir = buildRule.getProject().getProperty("to.dir");
assertTrue(new File(toDir + "/file1.txt").exists());
assertTrue(new File(toDir + "/file2.txt").exists());
assertTrue(new File(toDir + "/file3.txt").exists());
} }


@Test @Test


+ 1
- 1
src/tests/junit/org/apache/tools/ant/taskdefs/DirnameTest.java View File

@@ -69,7 +69,7 @@ public class DirnameTest {


@Test @Test
public void test4() { public void test4() {
assumeFalse("Test not possible on DOS or Netware family OS", Os.isFamily("netware") || Os.isFamily("dos"));
assumeFalse("Skip on DOS or Netware", Os.isFamily("netware") || Os.isFamily("dos"));
buildRule.executeTarget("test4"); buildRule.executeTarget("test4");
assertEquals("dirname failed", File.separator + "usr" + File.separator + "local", assertEquals("dirname failed", File.separator + "usr" + File.separator + "local",
buildRule.getProject().getProperty("local.dir")); buildRule.getProject().getProperty("local.dir"));


+ 1
- 1
src/tests/junit/org/apache/tools/ant/taskdefs/FailTest.java View File

@@ -75,7 +75,7 @@ public class FailTest {
public void testUnless() { public void testUnless() {
try { try {
buildRule.executeTarget("testUnless"); buildRule.executeTarget("testUnless");
//TODO assert rules
// TODO assert rules
} finally { } finally {
buildRule.getProject().setProperty("foo", ""); buildRule.getProject().setProperty("foo", "");
buildRule.executeTarget("testUnless"); buildRule.executeTarget("testUnless");


+ 1
- 1
src/tests/junit/org/apache/tools/ant/taskdefs/JavaTest.java View File

@@ -67,7 +67,7 @@ public class JavaTest {
/** Utilities used for file operations */ /** Utilities used for file operations */
private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();


private boolean runFatalTests=false;
private boolean runFatalTests = false;




/** /**


+ 16
- 8
src/tests/junit/org/apache/tools/ant/taskdefs/RmicAdvancedTest.java View File

@@ -327,7 +327,8 @@ public class RmicAdvancedTest {
*/ */
@Test @Test
public void testXnewForked() { public void testXnewForked() {
assumeFalse("Current system is Java 9 or newer", JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9));
assumeFalse("Current system is Java 9 or newer",
JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9));
buildRule.executeTarget("testXnewForked"); buildRule.executeTarget("testXnewForked");
} }


@@ -336,7 +337,8 @@ public class RmicAdvancedTest {
*/ */
@Test @Test
public void testXnewForkedJava9plus() { public void testXnewForkedJava9plus() {
assumeTrue("Current system is Java 8 or older", JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9));
assumeTrue("Current system is Java 8 or older",
JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9));
thrown.expect(BuildException.class); thrown.expect(BuildException.class);
thrown.expectMessage("JDK9 has removed support for -Xnew"); thrown.expectMessage("JDK9 has removed support for -Xnew");
buildRule.executeTarget("testXnewForked"); buildRule.executeTarget("testXnewForked");
@@ -347,7 +349,8 @@ public class RmicAdvancedTest {
*/ */
@Test @Test
public void testXnewForkedDest() { public void testXnewForkedDest() {
assumeFalse("Current system is Java 9 or newer", JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9));
assumeFalse("Current system is Java 9 or newer",
JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9));
buildRule.executeTarget("testXnewForkedDest"); buildRule.executeTarget("testXnewForkedDest");
} }


@@ -356,7 +359,8 @@ public class RmicAdvancedTest {
*/ */
@Test @Test
public void testXnewForkedDestJava9plus() { public void testXnewForkedDestJava9plus() {
assumeTrue("Current system is Java 8 or older", JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9));
assumeTrue("Current system is Java 8 or older",
JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9));
thrown.expect(BuildException.class); thrown.expect(BuildException.class);
thrown.expectMessage("JDK9 has removed support for -Xnew"); thrown.expectMessage("JDK9 has removed support for -Xnew");
buildRule.executeTarget("testXnewForkedDest"); buildRule.executeTarget("testXnewForkedDest");
@@ -367,7 +371,8 @@ public class RmicAdvancedTest {
*/ */
@Test @Test
public void testXnewCompiler() { public void testXnewCompiler() {
assumeFalse("Current system is Java 9 or newer", JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9));
assumeFalse("Current system is Java 9 or newer",
JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9));
buildRule.executeTarget("testXnewCompiler"); buildRule.executeTarget("testXnewCompiler");
} }


@@ -376,7 +381,8 @@ public class RmicAdvancedTest {
*/ */
@Test @Test
public void testXnewCompilerJava9plus() { public void testXnewCompilerJava9plus() {
assumeTrue("Current system is Java 8 or older", JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9));
assumeTrue("Current system is Java 8 or older",
JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9));
thrown.expect(BuildException.class); thrown.expect(BuildException.class);
thrown.expectMessage("JDK9 has removed support for -Xnew"); thrown.expectMessage("JDK9 has removed support for -Xnew");
buildRule.executeTarget("testXnewCompiler"); buildRule.executeTarget("testXnewCompiler");
@@ -387,7 +393,8 @@ public class RmicAdvancedTest {
*/ */
@Test @Test
public void testXnewCompilerDest() { public void testXnewCompilerDest() {
assumeFalse("Current system is Java 9 or newer", JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9));
assumeFalse("Current system is Java 9 or newer",
JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9));
buildRule.executeTarget("testXnewCompilerDest"); buildRule.executeTarget("testXnewCompilerDest");
} }


@@ -396,7 +403,8 @@ public class RmicAdvancedTest {
*/ */
@Test @Test
public void testXnewCompilerDestJava9plus() { public void testXnewCompilerDestJava9plus() {
assumeTrue("Current system is Java 8 or older", JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9));
assumeTrue("Current system is Java 8 or older",
JavaEnvUtils.isAtLeastJavaVersion(JavaEnvUtils.JAVA_9));
thrown.expect(BuildException.class); thrown.expect(BuildException.class);
thrown.expectMessage("JDK9 has removed support for -Xnew"); thrown.expectMessage("JDK9 has removed support for -Xnew");
buildRule.executeTarget("testXnewCompilerDest"); buildRule.executeTarget("testXnewCompilerDest");


+ 2
- 4
src/tests/junit/org/apache/tools/ant/taskdefs/SignJarTest.java View File

@@ -65,8 +65,7 @@ public class SignJarTest {
sj.setAlias("testonly"); sj.setAlias("testonly");
sj.setKeystore("testkeystore"); sj.setKeystore("testkeystore");
sj.setStorepass("apacheant"); sj.setStorepass("apacheant");
File jar = new File(buildRule.getProject().getProperty("test.jar"));
sj.setJar(jar);
sj.setJar(new File(buildRule.getProject().getProperty("test.jar")));
assertFalse("mustn't find signature without sigfile attribute", assertFalse("mustn't find signature without sigfile attribute",
sj.isSigned()); sj.isSigned());
sj.setSigfile("TEST"); sj.setSigfile("TEST");
@@ -81,8 +80,7 @@ public class SignJarTest {
sj.setAlias("test@nly"); sj.setAlias("test@nly");
sj.setKeystore("testkeystore"); sj.setKeystore("testkeystore");
sj.setStorepass("apacheant"); sj.setStorepass("apacheant");
File jar = new File(buildRule.getProject().getProperty("test.jar"));
sj.setJar(jar);
sj.setJar(new File(buildRule.getProject().getProperty("test.jar")));
assertTrue(sj.isSigned()); assertTrue(sj.isSigned());
} }




+ 3
- 3
src/tests/junit/org/apache/tools/ant/taskdefs/TarTest.java View File

@@ -111,10 +111,10 @@ public class TarTest {


private void test7(String target) { private void test7(String target) {
buildRule.executeTarget(target); buildRule.executeTarget(target);
File f1 = new File(buildRule.getProject().getProperty("output"), "untar/test7-prefix");
final String output = buildRule.getProject().getProperty("output");
File f1 = new File(output, "untar/test7-prefix");
assertTrue("The prefix attribute is not working properly.", f1.exists() && f1.isDirectory()); assertTrue("The prefix attribute is not working properly.", f1.exists() && f1.isDirectory());

File f2 = new File(buildRule.getProject().getProperty("output"), "untar/test7dir");
File f2 = new File(output, "untar/test7dir");
assertTrue("The prefix attribute is not working properly.", f2.exists() && f2.isDirectory()); assertTrue("The prefix attribute is not working properly.", f2.exists() && f2.isDirectory());
} }




+ 1
- 2
src/tests/junit/org/apache/tools/ant/taskdefs/TouchTest.java View File

@@ -94,8 +94,7 @@ public class TouchTest {
public void testNow() { public void testNow() {
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
buildRule.executeTarget("testNow"); buildRule.executeTarget("testNow");
long time = getTargetTime();
assertTimesNearlyMatch(time, now, 5000);
assertTimesNearlyMatch(getTargetTime(), now, 5000);
} }


/** /**


+ 27
- 36
src/tests/junit/org/apache/tools/ant/taskdefs/UnzipTest.java View File

@@ -103,10 +103,9 @@ public class UnzipTest {
@Test @Test
public void testPatternSetExcludeOnly() { public void testPatternSetExcludeOnly() {
buildRule.executeTarget("testPatternSetExcludeOnly"); buildRule.executeTarget("testPatternSetExcludeOnly");
assertFileMissing("1/foo is excluded",
buildRule.getProject().getProperty("output") + "/unziptestout/1/foo");
assertFileExists("2/bar is not excluded",
buildRule.getProject().getProperty("output") + "/unziptestout/2/bar");
final String output = buildRule.getProject().getProperty("output");
assertFileMissing("1/foo is excluded", output + "/unziptestout/1/foo");
assertFileExists("2/bar is not excluded", output + "/unziptestout/2/bar");
} }


/* /*
@@ -115,10 +114,9 @@ public class UnzipTest {
@Test @Test
public void testPatternSetIncludeOnly() { public void testPatternSetIncludeOnly() {
buildRule.executeTarget("testPatternSetIncludeOnly"); buildRule.executeTarget("testPatternSetIncludeOnly");
assertFileMissing("1/foo is not included",
buildRule.getProject().getProperty("output") + "/unziptestout/1/foo");
assertFileExists("2/bar is included",
buildRule.getProject().getProperty("output") + "/unziptestout/2/bar");
final String output = buildRule.getProject().getProperty("output");
assertFileMissing("1/foo is not included", output + "/unziptestout/1/foo");
assertFileExists("2/bar is included", output + "/unziptestout/2/bar");
} }


/* /*
@@ -127,10 +125,9 @@ public class UnzipTest {
@Test @Test
public void testPatternSetIncludeAndExclude() { public void testPatternSetIncludeAndExclude() {
buildRule.executeTarget("testPatternSetIncludeAndExclude"); buildRule.executeTarget("testPatternSetIncludeAndExclude");
assertFileMissing("1/foo is not included",
buildRule.getProject().getProperty("output") + "/unziptestout/1/foo");
assertFileMissing("2/bar is excluded",
buildRule.getProject().getProperty("output") + "/unziptestout/2/bar");
final String output = buildRule.getProject().getProperty("output");
assertFileMissing("1/foo is not included", output + "/unziptestout/1/foo");
assertFileMissing("2/bar is excluded", output + "/unziptestout/2/bar");
} }


/* /*
@@ -139,10 +136,9 @@ public class UnzipTest {
@Test @Test
public void testTwoPatternSets() { public void testTwoPatternSets() {
buildRule.executeTarget("testTwoPatternSets"); buildRule.executeTarget("testTwoPatternSets");
assertFileMissing("1/foo is not included",
buildRule.getProject().getProperty("output") + "/unziptestout/1/foo");
assertFileExists("2/bar is included",
buildRule.getProject().getProperty("output") + "/unziptestout/2/bar");
final String output = buildRule.getProject().getProperty("output");
assertFileMissing("1/foo is not included", output + "/unziptestout/1/foo");
assertFileExists("2/bar is included", output + "/unziptestout/2/bar");
} }


/* /*
@@ -151,10 +147,9 @@ public class UnzipTest {
@Test @Test
public void testTwoPatternSetsWithExcludes() { public void testTwoPatternSetsWithExcludes() {
buildRule.executeTarget("testTwoPatternSetsWithExcludes"); buildRule.executeTarget("testTwoPatternSetsWithExcludes");
assertFileMissing("1/foo is not included",
buildRule.getProject().getProperty("output") + "/unziptestout/1/foo");
assertFileMissing("2/bar is excluded",
buildRule.getProject().getProperty("output") + "/unziptestout/2/bar");
final String output = buildRule.getProject().getProperty("output");
assertFileMissing("1/foo is not included", output + "/unziptestout/1/foo");
assertFileMissing("2/bar is excluded", output + "/unziptestout/2/bar");
} }


/* /*
@@ -174,10 +169,9 @@ public class UnzipTest {
@Test @Test
public void testPatternSetSlashOnly() { public void testPatternSetSlashOnly() {
buildRule.executeTarget("testPatternSetSlashOnly"); buildRule.executeTarget("testPatternSetSlashOnly");
assertFileMissing("1/foo is not included",
buildRule.getProject().getProperty("output") + "/unziptestout/1/foo");
assertFileExists("\"2/bar is included",
buildRule.getProject().getProperty("output") + "/unziptestout/2/bar");
final String output = buildRule.getProject().getProperty("output");
assertFileMissing("1/foo is not included", output + "/unziptestout/1/foo");
assertFileExists("\"2/bar is included", output + "/unziptestout/2/bar");
} }


/* /*
@@ -196,10 +190,9 @@ public class UnzipTest {
@Test @Test
public void testFlattenMapper() { public void testFlattenMapper() {
buildRule.executeTarget("testFlattenMapper"); buildRule.executeTarget("testFlattenMapper");
assertFileMissing("1/foo is not flattened",
buildRule.getProject().getProperty("output") + "/unziptestout/1/foo");
assertFileExists("foo is flattened",
buildRule.getProject().getProperty("output") + "/unziptestout/foo");
final String output = buildRule.getProject().getProperty("output");
assertFileMissing("1/foo is not flattened", output + "/unziptestout/1/foo");
assertFileExists("foo is flattened", output + "/unziptestout/foo");
} }


/** /**
@@ -227,10 +220,9 @@ public class UnzipTest {
@Test @Test
public void testGlobMapper() { public void testGlobMapper() {
buildRule.executeTarget("testGlobMapper"); buildRule.executeTarget("testGlobMapper");
assertFileMissing("1/foo is not mapped",
buildRule.getProject().getProperty("output") + "/unziptestout/1/foo");
assertFileExists("1/foo is mapped",
buildRule.getProject().getProperty("output") + "/unziptestout/1/foo.txt");
final String output = buildRule.getProject().getProperty("output");
assertFileMissing("1/foo is not mapped", output + "/unziptestout/1/foo");
assertFileExists("1/foo is mapped", output + "/unziptestout/1/foo.txt");
} }


/** /**
@@ -252,9 +244,8 @@ public class UnzipTest {
@Test @Test
public void testDocumentationClaimsOnCopy() { public void testDocumentationClaimsOnCopy() {
buildRule.executeTarget("testDocumentationClaimsOnCopy"); buildRule.executeTarget("testDocumentationClaimsOnCopy");
assertFileMissing("1/foo is excluded",
buildRule.getProject().getProperty("output") + "/unziptestout/1/foo");
assertFileExists("2/bar is not excluded",
buildRule.getProject().getProperty("output") + "/unziptestout/2/bar");
final String output = buildRule.getProject().getProperty("output");
assertFileMissing("1/foo is excluded", output + "/unziptestout/1/foo");
assertFileExists("2/bar is not excluded", output + "/unziptestout/2/bar");
} }
} }

+ 1
- 4
src/tests/junit/org/apache/tools/ant/taskdefs/WhichResourceTest.java View File

@@ -26,16 +26,13 @@ import org.junit.Test;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;


public class WhichResourceTest { public class WhichResourceTest {
public static final String TEST_BUILD_FILE
= "src/etc/testcases/taskdefs/whichresource.xml";


@Rule @Rule
public BuildFileRule buildRule = new BuildFileRule(); public BuildFileRule buildRule = new BuildFileRule();



@Before @Before
public void setUp() { public void setUp() {
buildRule.configureProject(TEST_BUILD_FILE);
buildRule.configureProject("src/etc/testcases/taskdefs/whichresource.xml");
} }


@Test @Test


+ 6
- 6
src/tests/junit/org/apache/tools/ant/taskdefs/condition/ParserSupportsTest.java View File

@@ -44,15 +44,15 @@ public class ParserSupportsTest {


@Test @Test
public void testEmpty() { public void testEmpty() {
thrown.expect(BuildException .class) ;
thrown.expectMessage(ParserSupports.ERROR_NO_ATTRIBUTES);
thrown.expect(BuildException .class);
thrown.expectMessage(ParserSupports.ERROR_NO_ATTRIBUTES);
buildRule.executeTarget("testEmpty"); buildRule.executeTarget("testEmpty");
} }


@Test @Test
public void testBoth() { public void testBoth() {
thrown.expect(BuildException .class) ;
thrown.expectMessage(ParserSupports.ERROR_BOTH_ATTRIBUTES);
thrown.expect(BuildException .class);
thrown.expectMessage(ParserSupports.ERROR_BOTH_ATTRIBUTES);
buildRule.executeTarget("testBoth"); buildRule.executeTarget("testBoth");
} }


@@ -63,8 +63,8 @@ public class ParserSupportsTest {


@Test @Test
public void testPropertyNoValue() { public void testPropertyNoValue() {
thrown.expect(BuildException .class) ;
thrown.expectMessage(ParserSupports.ERROR_NO_VALUE);
thrown.expect(BuildException .class);
thrown.expectMessage(ParserSupports.ERROR_NO_VALUE);
buildRule.executeTarget("testPropertyNoValue"); buildRule.executeTarget("testPropertyNoValue");
} }




+ 1
- 2
src/tests/junit/org/apache/tools/ant/taskdefs/optional/ANTLRTest.java View File

@@ -134,8 +134,7 @@ public class ANTLRTest {
public void test10() { public void test10() {
buildRule.executeTarget("test10"); buildRule.executeTarget("test10");
File outputDirectory = new File(buildRule.getProject().getProperty("output")); File outputDirectory = new File(buildRule.getProject().getProperty("output"));
String[] calcFiles = outputDirectory.list(new HTMLFilter());
assertNotEquals(calcFiles.length, 0);
assertNotEquals(outputDirectory.list(new HTMLFilter()).length, 0);
} }


/** /**


+ 2
- 1
src/tests/junit/org/apache/tools/ant/taskdefs/optional/JavahTest.java View File

@@ -58,6 +58,7 @@ public class JavahTest {
public void testCompileFileset() { public void testCompileFileset() {
assumeFalse(JavaEnvUtils.isAtLeastJavaVersion("10")); assumeFalse(JavaEnvUtils.isAtLeastJavaVersion("10"));
buildRule.executeTarget("test-fileset"); buildRule.executeTarget("test-fileset");
assertTrue(new File(buildRule.getProject().getProperty("output"), "org_example_Foo.h").exists());
assertTrue(new File(buildRule.getProject().getProperty("output"), "org_example_Foo.h")
.exists());
} }
} }

+ 2
- 2
src/tests/junit/org/apache/tools/ant/taskdefs/optional/ReplaceRegExpTest.java View File

@@ -102,7 +102,7 @@ public class ReplaceRegExpTest {
buildRule.executeTarget("lastModifiedSetup"); buildRule.executeTarget("lastModifiedSetup");
File testFile = new File(buildRule.getOutputDir(), "test.txt"); File testFile = new File(buildRule.getOutputDir(), "test.txt");
assumeTrue(testFile.setLastModified(testFile.lastModified() assumeTrue(testFile.setLastModified(testFile.lastModified()
- (FileUtils.getFileUtils().getFileTimestampGranularity() * 3)));
- FileUtils.getFileUtils().getFileTimestampGranularity() * 3));
long ts1 = testFile.lastModified(); long ts1 = testFile.lastModified();
buildRule.executeTarget("testNoPreserve"); buildRule.executeTarget("testNoPreserve");
assertTrue(ts1 < testFile.lastModified()); assertTrue(ts1 < testFile.lastModified());
@@ -113,7 +113,7 @@ public class ReplaceRegExpTest {
buildRule.executeTarget("lastModifiedSetup"); buildRule.executeTarget("lastModifiedSetup");
File testFile = new File(buildRule.getOutputDir(), "test.txt"); File testFile = new File(buildRule.getOutputDir(), "test.txt");
assumeTrue(testFile.setLastModified(testFile.lastModified() assumeTrue(testFile.setLastModified(testFile.lastModified()
- (FileUtils.getFileUtils().getFileTimestampGranularity() * 3)));
- FileUtils.getFileUtils().getFileTimestampGranularity() * 3));
long ts1 = testFile.lastModified(); long ts1 = testFile.lastModified();
buildRule.executeTarget("testPreserve"); buildRule.executeTarget("testPreserve");
assertEquals(ts1, testFile.lastModified()); assertEquals(ts1, testFile.lastModified());


+ 1
- 6
src/tests/junit/org/apache/tools/ant/taskdefs/optional/XsltTest.java View File

@@ -34,17 +34,12 @@ import static org.junit.Assert.assertThat;
*/ */
public class XsltTest { public class XsltTest {


/**
* where tasks run
*/
private static final String TASKDEFS_DIR = "src/etc/testcases/taskdefs/optional/";

@Rule @Rule
public BuildFileRule buildRule = new BuildFileRule(); public BuildFileRule buildRule = new BuildFileRule();


@Before @Before
public void setUp() { public void setUp() {
buildRule.configureProject(TASKDEFS_DIR + "xslt.xml");
buildRule.configureProject("src/etc/testcases/taskdefs/optional/xslt.xml");
} }


/** /**


+ 7
- 5
src/tests/junit/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTest.java View File

@@ -37,8 +37,7 @@ public class JDependTest {


@Before @Before
public void setUp() { public void setUp() {
buildRule.configureProject(
"src/etc/testcases/taskdefs/optional/jdepend/jdepend.xml");
buildRule.configureProject("src/etc/testcases/taskdefs/optional/jdepend/jdepend.xml");
} }


/** /**
@@ -47,7 +46,8 @@ public class JDependTest {
@Test @Test
public void testSimple() { public void testSimple() {
buildRule.executeTarget("simple"); buildRule.executeTarget("simple");
assertThat(buildRule.getOutput(), containsString("Package: org.apache.tools.ant.util.facade"));
assertThat(buildRule.getOutput(),
containsString("Package: org.apache.tools.ant.util.facade"));
} }


/** /**
@@ -66,7 +66,8 @@ public class JDependTest {
@Test @Test
public void testFork() { public void testFork() {
buildRule.executeTarget("fork"); buildRule.executeTarget("fork");
assertThat(buildRule.getLog(), containsString("Package: org.apache.tools.ant.util.facade"));
assertThat(buildRule.getLog(),
containsString("Package: org.apache.tools.ant.util.facade"));
} }


/** /**
@@ -94,7 +95,8 @@ public class JDependTest {
@Test @Test
public void testTimeoutNot() { public void testTimeoutNot() {
buildRule.executeTarget("fork-timeout-not"); buildRule.executeTarget("fork-timeout-not");
assertThat(buildRule.getLog(), containsString("Package: org.apache.tools.ant.util.facade"));
assertThat(buildRule.getLog(),
containsString("Package: org.apache.tools.ant.util.facade"));
} }


} }

+ 18
- 18
src/tests/junit/org/apache/tools/ant/taskdefs/optional/sos/SOSTest.java View File

@@ -140,10 +140,10 @@ public class SOSTest {
@Test @Test
public void testGetExceptions() { public void testGetExceptions() {
buildRule.configureProject("src/etc/testcases/taskdefs/optional/sos/sos.xml"); buildRule.configureProject("src/etc/testcases/taskdefs/optional/sos/sos.xml");
expectSpecificBuildException("sosget.1", "some cause", "sosserverpath attribute must be set!");
expectSpecificBuildException("sosget.2", "some cause", "username attribute must be set!");
expectSpecificBuildException("sosget.3", "some cause", "vssserverpath attribute must be set!");
expectSpecificBuildException("sosget.4", "some cause", "projectpath attribute must be set!");
expectSpecificBuildException("sosget.1", "sosserverpath attribute must be set!");
expectSpecificBuildException("sosget.2", "username attribute must be set!");
expectSpecificBuildException("sosget.3", "vssserverpath attribute must be set!");
expectSpecificBuildException("sosget.4", "projectpath attribute must be set!");
} }


/** Test CheckInFile option flags */ /** Test CheckInFile option flags */
@@ -209,10 +209,10 @@ public class SOSTest {
@Test @Test
public void testCheckinExceptions() { public void testCheckinExceptions() {
buildRule.configureProject("src/etc/testcases/taskdefs/optional/sos/sos.xml"); buildRule.configureProject("src/etc/testcases/taskdefs/optional/sos/sos.xml");
expectSpecificBuildException("soscheckin.1", "some cause", "sosserverpath attribute must be set!");
expectSpecificBuildException("soscheckin.2", "some cause", "username attribute must be set!");
expectSpecificBuildException("soscheckin.3", "some cause", "vssserverpath attribute must be set!");
expectSpecificBuildException("soscheckin.4", "some cause", "projectpath attribute must be set!");
expectSpecificBuildException("soscheckin.1", "sosserverpath attribute must be set!");
expectSpecificBuildException("soscheckin.2", "username attribute must be set!");
expectSpecificBuildException("soscheckin.3", "vssserverpath attribute must be set!");
expectSpecificBuildException("soscheckin.4", "projectpath attribute must be set!");
} }


/** Test CheckOutFile option flags */ /** Test CheckOutFile option flags */
@@ -276,10 +276,10 @@ public class SOSTest {
@Test @Test
public void testCheckoutExceptions() { public void testCheckoutExceptions() {
buildRule.configureProject("src/etc/testcases/taskdefs/optional/sos/sos.xml"); buildRule.configureProject("src/etc/testcases/taskdefs/optional/sos/sos.xml");
expectSpecificBuildException("soscheckout.1", "some cause", "sosserverpath attribute must be set!");
expectSpecificBuildException("soscheckout.2", "some cause", "username attribute must be set!");
expectSpecificBuildException("soscheckout.3", "some cause", "vssserverpath attribute must be set!");
expectSpecificBuildException("soscheckout.4", "some cause", "projectpath attribute must be set!");
expectSpecificBuildException("soscheckout.1", "sosserverpath attribute must be set!");
expectSpecificBuildException("soscheckout.2", "username attribute must be set!");
expectSpecificBuildException("soscheckout.3", "vssserverpath attribute must be set!");
expectSpecificBuildException("soscheckout.4", "projectpath attribute must be set!");
} }


/** Test Label option flags */ /** Test Label option flags */
@@ -312,14 +312,14 @@ public class SOSTest {
@Test @Test
public void testLabelExceptions() { public void testLabelExceptions() {
buildRule.configureProject("src/etc/testcases/taskdefs/optional/sos/sos.xml"); buildRule.configureProject("src/etc/testcases/taskdefs/optional/sos/sos.xml");
expectSpecificBuildException("soslabel.1", "some cause", "sosserverpath attribute must be set!");
expectSpecificBuildException("soslabel.2", "some cause", "username attribute must be set!");
expectSpecificBuildException("soslabel.3", "some cause", "vssserverpath attribute must be set!");
expectSpecificBuildException("soslabel.4", "some cause", "projectpath attribute must be set!");
expectSpecificBuildException("soslabel.5", "some cause", "label attribute must be set!");
expectSpecificBuildException("soslabel.1", "sosserverpath attribute must be set!");
expectSpecificBuildException("soslabel.2", "username attribute must be set!");
expectSpecificBuildException("soslabel.3", "vssserverpath attribute must be set!");
expectSpecificBuildException("soslabel.4", "projectpath attribute must be set!");
expectSpecificBuildException("soslabel.5", "label attribute must be set!");
} }


private void expectSpecificBuildException(String target, String errorMessage,
private void expectSpecificBuildException(String target,
String exceptionMessage) { String exceptionMessage) {
thrown.expect(BuildException.class); thrown.expect(BuildException.class);
thrown.expectMessage(exceptionMessage); thrown.expectMessage(exceptionMessage);


+ 1
- 3
src/tests/junit/org/apache/tools/ant/taskdefs/optional/unix/SymlinkTest.java View File

@@ -65,11 +65,9 @@ public class SymlinkTest {
@Rule @Rule
public BuildFileRule buildRule = new BuildFileRule(); public BuildFileRule buildRule = new BuildFileRule();


private boolean supportsSymlinks = Os.isFamily("unix");

@Before @Before
public void setUp() { public void setUp() {
assumeTrue("Symlinks not supported on current operating system", supportsSymlinks);
assumeTrue("Symlinks not supported on current operating system", Os.isFamily("unix"));
buildRule.configureProject("src/etc/testcases/taskdefs/optional/unix/symlink.xml"); buildRule.configureProject("src/etc/testcases/taskdefs/optional/unix/symlink.xml");
buildRule.executeTarget("setUp"); buildRule.executeTarget("setUp");
} }


+ 1
- 2
src/tests/junit/org/apache/tools/ant/util/PackageNameMapperTest.java View File

@@ -31,10 +31,9 @@ public class PackageNameMapperTest {
mapper.setFrom("*.java"); mapper.setFrom("*.java");
mapper.setTo("TEST-*.xml"); mapper.setTo("TEST-*.xml");
String file = fixupPath("org/apache/tools/ant/util/PackageNameMapperTest.java"); String file = fixupPath("org/apache/tools/ant/util/PackageNameMapperTest.java");
String result = mapper.mapFileName(file)[0];


assertEquals("TEST-org.apache.tools.ant.util.PackageNameMapperTest.xml", assertEquals("TEST-org.apache.tools.ant.util.PackageNameMapperTest.xml",
result);
mapper.mapFileName(file)[0]);
} }


private String fixupPath(String file) { private String fixupPath(String file) {


+ 1
- 2
src/tests/junit/org/apache/tools/ant/util/UnPackageNameMapperTest.java View File

@@ -30,10 +30,9 @@ public class UnPackageNameMapperTest {
mapper.setFrom("TEST-*.xml"); mapper.setFrom("TEST-*.xml");
mapper.setTo("*.java"); mapper.setTo("*.java");
String file = "TEST-org.apache.tools.ant.util.UnPackageNameMapperTest.xml"; String file = "TEST-org.apache.tools.ant.util.UnPackageNameMapperTest.xml";
String result = mapper.mapFileName(file)[0];
String expected = fixupPath("org/apache/tools/ant/util/UnPackageNameMapperTest.java"); String expected = fixupPath("org/apache/tools/ant/util/UnPackageNameMapperTest.java");


assertEquals(expected, result);
assertEquals(expected, mapper.mapFileName(file)[0]);
} }


private String fixupPath(String file) { private String fixupPath(String file) {


Loading…
Cancel
Save