From ab2d99a565162500aadbaea9a0ebd7cc9183f8aa Mon Sep 17 00:00:00 2001 From: Gintas Grigelionis Date: Sun, 29 Apr 2018 22:42:22 +0200 Subject: [PATCH] Checkstyle (whitespace, line length, etc) --- .../org/apache/tools/ant/IncludeTest.java | 2 +- .../tools/ant/IntrospectionHelperTest.java | 16 ++--- .../tools/ant/taskdefs/CVSPassTest.java | 10 +-- .../apache/tools/ant/taskdefs/ConcatTest.java | 12 ---- .../apache/tools/ant/taskdefs/CopyTest.java | 59 ++++++++--------- .../tools/ant/taskdefs/DirnameTest.java | 2 +- .../apache/tools/ant/taskdefs/FailTest.java | 2 +- .../apache/tools/ant/taskdefs/JavaTest.java | 2 +- .../tools/ant/taskdefs/RmicAdvancedTest.java | 24 ++++--- .../tools/ant/taskdefs/SignJarTest.java | 6 +- .../apache/tools/ant/taskdefs/TarTest.java | 6 +- .../apache/tools/ant/taskdefs/TouchTest.java | 3 +- .../apache/tools/ant/taskdefs/UnzipTest.java | 63 ++++++++----------- .../tools/ant/taskdefs/WhichResourceTest.java | 5 +- .../condition/ParserSupportsTest.java | 12 ++-- .../ant/taskdefs/optional/ANTLRTest.java | 3 +- .../ant/taskdefs/optional/JavahTest.java | 3 +- .../taskdefs/optional/ReplaceRegExpTest.java | 4 +- .../tools/ant/taskdefs/optional/XsltTest.java | 7 +-- .../optional/jdepend/JDependTest.java | 12 ++-- .../ant/taskdefs/optional/sos/SOSTest.java | 36 +++++------ .../taskdefs/optional/unix/SymlinkTest.java | 4 +- .../tools/ant/util/PackageNameMapperTest.java | 3 +- .../ant/util/UnPackageNameMapperTest.java | 3 +- 24 files changed, 134 insertions(+), 165 deletions(-) diff --git a/src/tests/junit/org/apache/tools/ant/IncludeTest.java b/src/tests/junit/org/apache/tools/ant/IncludeTest.java index 17141db37..4603023bc 100644 --- a/src/tests/junit/org/apache/tools/ant/IncludeTest.java +++ b/src/tests/junit/org/apache/tools/ant/IncludeTest.java @@ -81,7 +81,7 @@ public class IncludeTest { thrown.expect(BuildException.class); thrown.expect(hasProperty("location", hasProperty("fileName", 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 diff --git a/src/tests/junit/org/apache/tools/ant/IntrospectionHelperTest.java b/src/tests/junit/org/apache/tools/ant/IntrospectionHelperTest.java index 8f746aa72..e512a3b96 100644 --- a/src/tests/junit/org/apache/tools/ant/IntrospectionHelperTest.java +++ b/src/tests/junit/org/apache/tools/ant/IntrospectionHelperTest.java @@ -255,7 +255,7 @@ public class IntrospectionHelperTest { Map> elemMap = getExpectedNestedElements(); for (String name : Collections.list(ih.getNestedElements())) { Class expect = elemMap.get(name); - assertNotNull("Support for " + name + " in IntrospectioNHelperTest?", + assertNotNull("Support for " + name + " in IntrospectionHelperTest?", expect); assertEquals("Return type of " + name, expect, ih.getElementType(name)); elemMap.remove(name); @@ -605,8 +605,7 @@ public class IntrospectionHelperTest { @Test public void testGetAttributeMap() { Map> attrMap = getExpectedAttributes(); - Map> actualMap = ih.getAttributeMap(); - actualMap.forEach((attrName, value) -> { + ih.getAttributeMap().forEach((attrName, value) -> { Class attrClass = attrMap.get(attrName); assertNotNull("Support for " + attrName + " in IntrospectionHelperTest?", attrClass); assertEquals("Type of " + attrName, attrClass, value); @@ -614,11 +613,14 @@ public class IntrospectionHelperTest { }); attrMap.remove("name"); assertTrue("Found all", attrMap.isEmpty()); + } + @Test + public void testClearGetAttributeMap() { thrown.expect(UnsupportedOperationException.class); // TODO we should be asserting a value somewhere in here // Check it's a read-only map. - actualMap.clear(); + ih.getAttributeMap().clear(); } @Test @@ -659,8 +661,7 @@ public class IntrospectionHelperTest { private void assertAttrMethod(String attrName, String methodName, 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) { @@ -830,5 +831,4 @@ public class IntrospectionHelperTest { return table; } -} // IntrospectionHelperTest - +} diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/CVSPassTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/CVSPassTest.java index 22329d280..66dc18ca9 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/CVSPassTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/CVSPassTest.java @@ -56,6 +56,11 @@ public class CVSPassTest { buildRule.configureProject("src/etc/testcases/taskdefs/cvspass.xml"); } + @After + public void tearDown() { + buildRule.executeTarget("cleanup"); + } + @Test public void testNoCVSRoot() { thrown.expect(BuildException.class); @@ -70,11 +75,6 @@ public class CVSPassTest { buildRule.executeTarget("test2"); } - @After - public void tearDown() { - buildRule.executeTarget("cleanup"); - } - @Test public void testPassFile() throws Exception { buildRule.executeTarget("test3"); diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/ConcatTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/ConcatTest.java index 0e8f4ccf2..45d62025a 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/ConcatTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/ConcatTest.java @@ -275,16 +275,4 @@ public class ConcatTest { 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)); - } - } diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/CopyTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/CopyTest.java index 64bb09c92..e8b419198 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/CopyTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/CopyTest.java @@ -79,17 +79,18 @@ public class CopyTest { @Test public void 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 FileUtilities.rollbackTimestamps(file3, 3); buildRule.executeTarget("test3Part2"); assertTrue(file3.exists()); - File file3a = new File(buildRule.getProject().getProperty("output"), "copytest3a.tmp"); + File file3a = new File(output, "copytest3a.tmp"); assertTrue(file3a.exists()); - File file3b = new File(buildRule.getProject().getProperty("output"), "copytest3b.tmp"); + File file3b = new File(output, "copytest3b.tmp"); assertTrue(file3b.exists()); - File file3c = new File(buildRule.getProject().getProperty("output"), "copytest3c.tmp"); + File file3c = new File(output, "copytest3c.tmp"); assertTrue(file3c.exists()); // file length checks rely on touch generating a zero byte file @@ -118,8 +119,9 @@ public class CopyTest { @Test public void testFilterSet() throws IOException { 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()); assertEquals(FileUtilities.getFileContents(tmp), FileUtilities.getFileContents(check)); } @@ -127,8 +129,9 @@ public class CopyTest { @Test public void testFilterChain() throws IOException { 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()); assertEquals(FileUtilities.getFileContents(tmp), FileUtilities.getFileContents(check)); } @@ -186,24 +189,20 @@ public class CopyTest { @Test public void 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") @Test public void 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 @@ -222,23 +221,19 @@ public class CopyTest { @Test public void 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 public void 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 diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/DirnameTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/DirnameTest.java index 82d4bc928..72e1a992e 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/DirnameTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/DirnameTest.java @@ -69,7 +69,7 @@ public class DirnameTest { @Test 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"); assertEquals("dirname failed", File.separator + "usr" + File.separator + "local", buildRule.getProject().getProperty("local.dir")); diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/FailTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/FailTest.java index 41ad81c54..bb82aaf3b 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/FailTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/FailTest.java @@ -75,7 +75,7 @@ public class FailTest { public void testUnless() { try { buildRule.executeTarget("testUnless"); - //TODO assert rules + // TODO assert rules } finally { buildRule.getProject().setProperty("foo", ""); buildRule.executeTarget("testUnless"); diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/JavaTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/JavaTest.java index 31b7ef9aa..07025d0e7 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/JavaTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/JavaTest.java @@ -67,7 +67,7 @@ public class JavaTest { /** Utilities used for file operations */ private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); - private boolean runFatalTests=false; + private boolean runFatalTests = false; /** diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/RmicAdvancedTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/RmicAdvancedTest.java index 5de5f2d41..f162b2fe1 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/RmicAdvancedTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/RmicAdvancedTest.java @@ -327,7 +327,8 @@ public class RmicAdvancedTest { */ @Test 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"); } @@ -336,7 +337,8 @@ public class RmicAdvancedTest { */ @Test 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.expectMessage("JDK9 has removed support for -Xnew"); buildRule.executeTarget("testXnewForked"); @@ -347,7 +349,8 @@ public class RmicAdvancedTest { */ @Test 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"); } @@ -356,7 +359,8 @@ public class RmicAdvancedTest { */ @Test 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.expectMessage("JDK9 has removed support for -Xnew"); buildRule.executeTarget("testXnewForkedDest"); @@ -367,7 +371,8 @@ public class RmicAdvancedTest { */ @Test 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"); } @@ -376,7 +381,8 @@ public class RmicAdvancedTest { */ @Test 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.expectMessage("JDK9 has removed support for -Xnew"); buildRule.executeTarget("testXnewCompiler"); @@ -387,7 +393,8 @@ public class RmicAdvancedTest { */ @Test 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"); } @@ -396,7 +403,8 @@ public class RmicAdvancedTest { */ @Test 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.expectMessage("JDK9 has removed support for -Xnew"); buildRule.executeTarget("testXnewCompilerDest"); diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/SignJarTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/SignJarTest.java index e8f54f8bd..536645f26 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/SignJarTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/SignJarTest.java @@ -65,8 +65,7 @@ public class SignJarTest { sj.setAlias("testonly"); sj.setKeystore("testkeystore"); 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", sj.isSigned()); sj.setSigfile("TEST"); @@ -81,8 +80,7 @@ public class SignJarTest { sj.setAlias("test@nly"); sj.setKeystore("testkeystore"); 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()); } diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/TarTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/TarTest.java index 5b9815fa0..e31aab654 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/TarTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/TarTest.java @@ -111,10 +111,10 @@ public class TarTest { private void test7(String 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()); - - 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()); } diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/TouchTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/TouchTest.java index fc845d903..1924530b2 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/TouchTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/TouchTest.java @@ -94,8 +94,7 @@ public class TouchTest { public void testNow() { long now = System.currentTimeMillis(); buildRule.executeTarget("testNow"); - long time = getTargetTime(); - assertTimesNearlyMatch(time, now, 5000); + assertTimesNearlyMatch(getTargetTime(), now, 5000); } /** diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/UnzipTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/UnzipTest.java index e719271f7..355fe9c71 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/UnzipTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/UnzipTest.java @@ -103,10 +103,9 @@ public class UnzipTest { @Test public void 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 public void 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 public void 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 public void 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 public void 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 public void 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 public void 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 public void 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 public void 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"); } } diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/WhichResourceTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/WhichResourceTest.java index 8e282b3a0..697f12ae4 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/WhichResourceTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/WhichResourceTest.java @@ -26,16 +26,13 @@ import org.junit.Test; import static org.junit.Assert.assertNotNull; public class WhichResourceTest { - public static final String TEST_BUILD_FILE - = "src/etc/testcases/taskdefs/whichresource.xml"; @Rule public BuildFileRule buildRule = new BuildFileRule(); - @Before public void setUp() { - buildRule.configureProject(TEST_BUILD_FILE); + buildRule.configureProject("src/etc/testcases/taskdefs/whichresource.xml"); } @Test diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/condition/ParserSupportsTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/condition/ParserSupportsTest.java index 9f1c3cf9c..06d0c51b4 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/condition/ParserSupportsTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/condition/ParserSupportsTest.java @@ -44,15 +44,15 @@ public class ParserSupportsTest { @Test 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"); } @Test 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"); } @@ -63,8 +63,8 @@ public class ParserSupportsTest { @Test 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"); } diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ANTLRTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ANTLRTest.java index ea063c0d6..895617f5c 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ANTLRTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ANTLRTest.java @@ -134,8 +134,7 @@ public class ANTLRTest { public void test10() { buildRule.executeTarget("test10"); 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); } /** diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/JavahTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/JavahTest.java index f9283028e..d58c0804f 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/JavahTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/JavahTest.java @@ -58,6 +58,7 @@ public class JavahTest { public void testCompileFileset() { assumeFalse(JavaEnvUtils.isAtLeastJavaVersion("10")); 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()); } } diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ReplaceRegExpTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ReplaceRegExpTest.java index 1dc7b01ce..cbf278aa9 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ReplaceRegExpTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ReplaceRegExpTest.java @@ -102,7 +102,7 @@ public class ReplaceRegExpTest { buildRule.executeTarget("lastModifiedSetup"); File testFile = new File(buildRule.getOutputDir(), "test.txt"); assumeTrue(testFile.setLastModified(testFile.lastModified() - - (FileUtils.getFileUtils().getFileTimestampGranularity() * 3))); + - FileUtils.getFileUtils().getFileTimestampGranularity() * 3)); long ts1 = testFile.lastModified(); buildRule.executeTarget("testNoPreserve"); assertTrue(ts1 < testFile.lastModified()); @@ -113,7 +113,7 @@ public class ReplaceRegExpTest { buildRule.executeTarget("lastModifiedSetup"); File testFile = new File(buildRule.getOutputDir(), "test.txt"); assumeTrue(testFile.setLastModified(testFile.lastModified() - - (FileUtils.getFileUtils().getFileTimestampGranularity() * 3))); + - FileUtils.getFileUtils().getFileTimestampGranularity() * 3)); long ts1 = testFile.lastModified(); buildRule.executeTarget("testPreserve"); assertEquals(ts1, testFile.lastModified()); diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XsltTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XsltTest.java index 64499c1c8..4bcfa5a43 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XsltTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XsltTest.java @@ -34,17 +34,12 @@ import static org.junit.Assert.assertThat; */ public class XsltTest { - /** - * where tasks run - */ - private static final String TASKDEFS_DIR = "src/etc/testcases/taskdefs/optional/"; - @Rule public BuildFileRule buildRule = new BuildFileRule(); @Before public void setUp() { - buildRule.configureProject(TASKDEFS_DIR + "xslt.xml"); + buildRule.configureProject("src/etc/testcases/taskdefs/optional/xslt.xml"); } /** diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTest.java index 55d4b0760..d0110e98b 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTest.java @@ -37,8 +37,7 @@ public class JDependTest { @Before 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 public void testSimple() { 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 public void testFork() { 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 public void testTimeoutNot() { 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")); } } diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/sos/SOSTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/sos/SOSTest.java index 7d2376e99..30c777ac7 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/sos/SOSTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/sos/SOSTest.java @@ -140,10 +140,10 @@ public class SOSTest { @Test public void testGetExceptions() { 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 */ @@ -209,10 +209,10 @@ public class SOSTest { @Test public void testCheckinExceptions() { 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 */ @@ -276,10 +276,10 @@ public class SOSTest { @Test public void testCheckoutExceptions() { 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 */ @@ -312,14 +312,14 @@ public class SOSTest { @Test public void testLabelExceptions() { 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) { thrown.expect(BuildException.class); thrown.expectMessage(exceptionMessage); diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/unix/SymlinkTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/unix/SymlinkTest.java index 0bc3f6b1c..c5127929e 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/unix/SymlinkTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/unix/SymlinkTest.java @@ -65,11 +65,9 @@ public class SymlinkTest { @Rule public BuildFileRule buildRule = new BuildFileRule(); - private boolean supportsSymlinks = Os.isFamily("unix"); - @Before 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.executeTarget("setUp"); } diff --git a/src/tests/junit/org/apache/tools/ant/util/PackageNameMapperTest.java b/src/tests/junit/org/apache/tools/ant/util/PackageNameMapperTest.java index fdf739315..3bf1e02f1 100644 --- a/src/tests/junit/org/apache/tools/ant/util/PackageNameMapperTest.java +++ b/src/tests/junit/org/apache/tools/ant/util/PackageNameMapperTest.java @@ -31,10 +31,9 @@ public class PackageNameMapperTest { mapper.setFrom("*.java"); mapper.setTo("TEST-*.xml"); 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", - result); + mapper.mapFileName(file)[0]); } private String fixupPath(String file) { diff --git a/src/tests/junit/org/apache/tools/ant/util/UnPackageNameMapperTest.java b/src/tests/junit/org/apache/tools/ant/util/UnPackageNameMapperTest.java index c59154d52..ecb8db23a 100644 --- a/src/tests/junit/org/apache/tools/ant/util/UnPackageNameMapperTest.java +++ b/src/tests/junit/org/apache/tools/ant/util/UnPackageNameMapperTest.java @@ -30,10 +30,9 @@ public class UnPackageNameMapperTest { mapper.setFrom("TEST-*.xml"); mapper.setTo("*.java"); 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"); - assertEquals(expected, result); + assertEquals(expected, mapper.mapFileName(file)[0]); } private String fixupPath(String file) {