http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/taskdefs/ConditionTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/ConditionTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/ConditionTest.java index 1b6c103..9329512 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/ConditionTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/ConditionTest.java @@ -72,7 +72,7 @@ public class ConditionTest { try { buildRule.executeTarget("condition-empty"); fail("BuildException should have been thrown - no conditions"); - } catch(BuildException ex) { + } catch (BuildException ex) { assertEquals("You must nest a condition into <condition>", ex.getMessage()); } } @@ -255,7 +255,7 @@ public class ConditionTest { try { buildRule.executeTarget("contains-incomplete1"); fail("BuildException should have been thrown - Missing contains attribute"); - } catch(BuildException ex) { + } catch (BuildException ex) { assertEquals("both string and substring are required in contains", ex.getMessage()); } } @@ -265,7 +265,7 @@ public class ConditionTest { try { buildRule.executeTarget("contains-incomplete2"); fail("BuildException should have been thrown - Missing contains attribute"); - } catch(BuildException ex) { + } catch (BuildException ex) { assertEquals("both string and substring are required in contains", ex.getMessage()); } } @@ -293,7 +293,7 @@ public class ConditionTest { try { buildRule.executeTarget("istrue-incomplete"); fail("BuildException should have been thrown - Missing attribute"); - } catch(BuildException ex) { + } catch (BuildException ex) { assertEquals("Nothing to test for truth", ex.getMessage()); } } @@ -322,7 +322,7 @@ public class ConditionTest { try { buildRule.executeTarget("isfalse-incomplete"); fail("BuildException should have been thrown - Missing attribute"); - } catch(BuildException ex) { + } catch (BuildException ex) { assertEquals("Nothing to test for falsehood", ex.getMessage()); } }
http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/taskdefs/CopyTest.java ---------------------------------------------------------------------- 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 719bc44..fc03f28 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/CopyTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/CopyTest.java @@ -60,7 +60,7 @@ public class CopyTest { public void test1() { buildRule.executeTarget("test1"); File f = new File(buildRule.getProject().getProperty("output"), "copytest1.tmp"); - if ( !f.exists()) { + if (!f.exists()) { fail("Copy failed"); } } @@ -69,7 +69,7 @@ public class CopyTest { public void test2() { buildRule.executeTarget("test2"); File f = new File(buildRule.getProject().getProperty("output"), "copytest1dir/copy.xml"); - if ( !f.exists()) { + if (!f.exists()) { fail("Copy failed"); } } @@ -79,7 +79,7 @@ public class CopyTest { buildRule.executeTarget("test3"); File file3 = new File(buildRule.getProject().getProperty("output"), "copytest3.tmp"); //rollback file timestamp instead of delaying test - FileUtilities.rollbackTimetamps(file3, 3); + FileUtilities.rollbackTimestamps(file3, 3); buildRule.executeTarget("test3Part2"); assertTrue(file3.exists()); @@ -91,19 +91,19 @@ public class CopyTest { assertTrue(file3c.exists()); //file length checks rely on touch generating a zero byte file - if(file3.length()==0) { + if (file3.length()==0) { fail("could not overwrite an existing, older file"); } - if(file3c.length()!=0) { + if (file3c.length()!=0) { fail("could not force overwrite an existing, newer file"); } - if(file3b.length()==0) { + if (file3b.length()==0) { fail("unexpectedly overwrote an existing, newer file"); } //file time checks for java1.2+ - assertTrue(file3a.lastModified()==file3.lastModified()); - assertTrue(file3c.lastModified()<file3a.lastModified()); + assertTrue(file3a.lastModified() == file3.lastModified()); + assertTrue(file3c.lastModified() < file3a.lastModified()); } @@ -197,9 +197,9 @@ 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"); + 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()); @@ -209,9 +209,9 @@ public class CopyTest { @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"); + 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()); @@ -220,7 +220,7 @@ public class CopyTest { @Test public void testFileResourceWithFilter() { buildRule.executeTarget("testFileResourceWithFilter"); - File file1 = new File(buildRule.getProject().getProperty("to.dir")+"/fileNR.txt"); + File file1 = new File(buildRule.getProject().getProperty("to.dir") + "/fileNR.txt"); assertTrue(file1.exists()); try { String file1Content = FileUtils.readFully(new FileReader(file1)); @@ -233,9 +233,9 @@ 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"); + 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()); @@ -244,9 +244,9 @@ public class CopyTest { @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"); + 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()); @@ -285,7 +285,7 @@ public class CopyTest { * Tests that the {@code copy} task doesn't corrupt the source file, if the target of the copy operation is a symlink * to the source file being copied * - * @throws Exception + * @throws Exception if something goes wrong * @see <a href="https://bz.apache.org/bugzilla/show_bug.cgi?id=60644">issue 60644</a> */ @Test http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/taskdefs/CopydirTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/CopydirTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/CopydirTest.java index a7fdd5c..adad994 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/CopydirTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/CopydirTest.java @@ -79,7 +79,7 @@ public class CopydirTest { @Test public void test5() { buildRule.executeTarget("test5"); - java.io.File f = new java.io.File(new File(buildRule.getProject().getProperty("output")), "taskdefs.tmp"); + File f = new File(new File(buildRule.getProject().getProperty("output")), "taskdefs.tmp"); if (!f.exists() || !f.isDirectory()) { fail("Copy failed"); http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/taskdefs/DefaultExcludesTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/DefaultExcludesTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/DefaultExcludesTest.java index e093d4f..06ca3a2 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/DefaultExcludesTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/DefaultExcludesTest.java @@ -157,13 +157,13 @@ public class DefaultExcludesTest { private void assertArrayContentsEquals(String message, String[] expected, String[] actual) { // check that both arrays have the same size assertEquals(message + " : string array length match", expected.length, actual.length); - for (int counter=0; counter < expected.length; counter++) { + for (String element : expected) { boolean found = false; for (int i = 0; !found && i < actual.length; i++) { - found |= expected[counter].equals(actual[i]); + found |= element.equals(actual[i]); } assertTrue(message + " : didn't find element " - + expected[counter] + " in array match", found); + + element + " in array match", found); } } http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/taskdefs/DirnameTest.java ---------------------------------------------------------------------- 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 8db1c5f..d870348 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/DirnameTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/DirnameTest.java @@ -46,7 +46,7 @@ public class DirnameTest { try { buildRule.executeTarget("test1"); fail("Build exception should have been thrown as property attribute is required"); - } catch(BuildException ex) { + } catch (BuildException ex) { assertEquals("property attribute required", ex.getMessage()); } } @@ -56,7 +56,7 @@ public class DirnameTest { try { buildRule.executeTarget("test2"); fail("Build exception should have been thrown as file attribute is required"); - } catch(BuildException ex) { + } catch (BuildException ex) { assertEquals("file attribute required", ex.getMessage()); } } @@ -66,7 +66,7 @@ public class DirnameTest { try { buildRule.executeTarget("test3"); fail("Build exception should have been thrown as property attribute is required"); - } catch(BuildException ex) { + } catch (BuildException ex) { assertEquals("property attribute required", ex.getMessage()); } } http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/taskdefs/EchoTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/EchoTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/EchoTest.java index 5c2ae28..8f88ff1 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/EchoTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/EchoTest.java @@ -50,7 +50,7 @@ public class EchoTest { echo.setProject(p); echo.setTaskName("testLogBlankEcho"); echo.execute(); - assertEquals("[testLogBlankEcho] ", logger.lastLoggedMessage ); + assertEquals("[testLogBlankEcho] ", logger.lastLoggedMessage); } @Test @@ -67,15 +67,14 @@ public class EchoTest { echo.setFile(removeThis); echo.setEncoding("UTF-8"); echo.execute(); - String x = FileUtils.readFully(new InputStreamReader(new FileInputStream(removeThis), "UTF-8" )); + String x = FileUtils.readFully(new InputStreamReader(new FileInputStream(removeThis), "UTF-8")); assertEquals(x,"\u00e4\u00a9"); } @After public void tearDown() { if (removeThis != null && removeThis.exists()) { - if (!removeThis.delete()) - { + if (!removeThis.delete()) { removeThis.deleteOnExit(); } } http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/taskdefs/ExecuteJavaTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/ExecuteJavaTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/ExecuteJavaTest.java index 069645b..9e87af0 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/ExecuteJavaTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/ExecuteJavaTest.java @@ -37,15 +37,15 @@ public class ExecuteJavaTest { private final static int TIME_OUT = 5000; - private final static int CLOCK_ERROR=200; - private final static int TIME_OUT_TEST=TIME_OUT-CLOCK_ERROR; + private final static int CLOCK_ERROR = 200; + private final static int TIME_OUT_TEST = TIME_OUT - CLOCK_ERROR; private ExecuteJava ej; private Project project; private Path cp; @Before - public void setUp(){ + public void setUp() { ej = new ExecuteJava(); ej.setTimeout((long)TIME_OUT); project = new Project(); @@ -64,7 +64,7 @@ public class ExecuteJavaTest { @Test public void testNoTimeOut() throws Exception { - Commandline cmd = getCommandline(TIME_OUT/2); + Commandline cmd = getCommandline(TIME_OUT / 2); ej.setJavaCommand(cmd); ej.execute(project); assertTrue("process should not have been killed", !ej.killedProcess()); @@ -73,24 +73,24 @@ public class ExecuteJavaTest { // test that the watchdog ends the process @Test public void testTimeOut() throws Exception { - Commandline cmd = getCommandline(TIME_OUT*2); + Commandline cmd = getCommandline(TIME_OUT * 2); ej.setJavaCommand(cmd); long now = System.currentTimeMillis(); ej.execute(project); long elapsed = System.currentTimeMillis() - now; assertTrue("process should have been killed", ej.killedProcess()); - assertTrue("elapse time of "+elapsed - +" ms is less than timeout value of "+TIME_OUT_TEST+" ms", + assertTrue("elapse time of " + elapsed + + " ms is less than timeout value of " + TIME_OUT_TEST + " ms", elapsed >= TIME_OUT_TEST); - assertTrue("elapse time of "+elapsed - +" ms is greater than run value of "+(TIME_OUT*2)+" ms", - elapsed < TIME_OUT*2); + assertTrue("elapse time of " + elapsed + + " ms is greater than run value of " + (TIME_OUT * 2) + " ms", + elapsed < TIME_OUT * 2); } @Test public void testNoTimeOutForked() throws Exception { - Commandline cmd = getCommandline(TIME_OUT/2); + Commandline cmd = getCommandline(TIME_OUT / 2); ej.setJavaCommand(cmd); ej.fork(cp); assertTrue("process should not have been killed", !ej.killedProcess()); @@ -99,26 +99,26 @@ public class ExecuteJavaTest { // test that the watchdog ends the process @Test public void testTimeOutForked() throws Exception { - Commandline cmd = getCommandline(TIME_OUT*2); + Commandline cmd = getCommandline(TIME_OUT * 2); ej.setJavaCommand(cmd); long now = System.currentTimeMillis(); ej.fork(cp); long elapsed = System.currentTimeMillis() - now; assertTrue("process should have been killed", ej.killedProcess()); - assertTrue("elapse time of "+elapsed - +" ms is less than timeout value of "+TIME_OUT_TEST+" ms", + assertTrue("elapse time of " + elapsed + + " ms is less than timeout value of " + TIME_OUT_TEST + " ms", elapsed >= TIME_OUT_TEST); - assertTrue("elapse time of "+elapsed - +" ms is greater than run value of "+(TIME_OUT*2)+" ms", - elapsed < TIME_OUT*2); + assertTrue("elapse time of " + elapsed + + " ms is greater than run value of " + (TIME_OUT * 2) + " ms", + elapsed < TIME_OUT * 2); } /** * Dangerous method to obtain the classpath for the test. This is * severely tighted to the build.xml properties. */ - private static String getTestClassPath(){ + private static String getTestClassPath() { String classpath = System.getProperty("build.tests"); if (classpath == null) { System.err.println("WARNING: 'build.tests' property is not available !"); http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/taskdefs/ExecuteWatchdogTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/ExecuteWatchdogTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/ExecuteWatchdogTest.java index 1834d5e..f23ea3b 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/ExecuteWatchdogTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/ExecuteWatchdogTest.java @@ -40,13 +40,13 @@ public class ExecuteWatchdogTest { private final static String TEST_CLASSPATH = getTestClassPath(); - private final static int CLOCK_ERROR=200; - private final static long TIME_OUT_TEST=TIME_OUT-CLOCK_ERROR; + private final static int CLOCK_ERROR = 200; + private final static long TIME_OUT_TEST = TIME_OUT - CLOCK_ERROR; private ExecuteWatchdog watchdog; @Before - public void setUp(){ + public void setUp() { watchdog = new ExecuteWatchdog(TIME_OUT); } @@ -54,7 +54,7 @@ public class ExecuteWatchdogTest { * Dangerous method to obtain the classpath for the test. This is * severely tied to the build.xml properties. */ - private static String getTestClassPath(){ + private static String getTestClassPath() { String classpath = System.getProperty("build.tests"); if (classpath == null) { System.err.println("WARNING: 'build.tests' property is not available !"); @@ -74,10 +74,10 @@ public class ExecuteWatchdogTest { } private String getErrorOutput(Process p) throws Exception { - BufferedReader err = new BufferedReader( new InputStreamReader(p.getErrorStream()) ); - StringBuffer buf = new StringBuffer(); + BufferedReader err = new BufferedReader(new InputStreamReader(p.getErrorStream())); + StringBuilder buf = new StringBuilder(); String line; - while ( (line = err.readLine()) != null){ + while ((line = err.readLine()) != null) { buf.append(line); } return buf.toString(); @@ -85,9 +85,9 @@ public class ExecuteWatchdogTest { private int waitForEnd(Process p) throws Exception { int retcode = p.waitFor(); - if (retcode != 0){ + if (retcode != 0) { String err = getErrorOutput(p); - if (err.length() > 0){ + if (err.length() > 0) { System.err.println("ERROR:"); System.err.println(err); } @@ -97,25 +97,28 @@ public class ExecuteWatchdogTest { @Test public void testNoTimeOut() throws Exception { - Process process = getProcess(TIME_OUT/2); + Process process = getProcess(TIME_OUT / 2); watchdog.start(process); int retCode = waitForEnd(process); - assertTrue("process should not have been killed", !watchdog.killedProcess()); + assertFalse("process should not have been killed", watchdog.killedProcess()); assertFalse(Execute.isFailure(retCode)); } // test that the watchdog ends the process @Test public void testTimeOut() throws Exception { - Process process = getProcess(TIME_OUT*2); + Process process = getProcess(TIME_OUT * 2); long now = System.currentTimeMillis(); watchdog.start(process); - int retCode = process.waitFor(); + @SuppressWarnings("unused") + int retCode = process.waitFor(); long elapsed = System.currentTimeMillis() - now; assertTrue("process should have been killed", watchdog.killedProcess()); - // assertTrue("return code is invalid: " + retCode, retCode!=0); - assertTrue("elapse time of "+elapsed+" ms is less than timeout value of "+TIME_OUT_TEST+" ms", elapsed >= TIME_OUT_TEST); - assertTrue("elapse time of "+elapsed+" ms is greater than run value of "+(TIME_OUT*2)+" ms", elapsed < TIME_OUT*2); + // assertNotEquals("return code is invalid: " + retCode, retCode, 0); + assertTrue("elapse time of " + elapsed + " ms is less than timeout value of " + TIME_OUT_TEST + " ms", + elapsed >= TIME_OUT_TEST); + assertTrue("elapse time of " + elapsed + " ms is greater than run value of " + (TIME_OUT * 2) + " ms", + elapsed < TIME_OUT * 2); } // test a process that runs and failed @@ -130,7 +133,7 @@ public class ExecuteWatchdogTest { @Test public void testManualStop() throws Exception { - final Process process = getProcess(TIME_OUT*2); + final Process process = getProcess(TIME_OUT * 2); watchdog.start(process); // I assume that starting this takes less than TIME_OUT/2 ms... @@ -146,8 +149,8 @@ public class ExecuteWatchdogTest { }; thread.start(); - // wait for TIME_OUT/2, there should be about TIME_OUT/2 ms remaining before timeout - thread.join(TIME_OUT/2); + // wait for TIME_OUT / 2, there should be about TIME_OUT / 2 ms remaining before timeout + thread.join(TIME_OUT / 2); // now stop the watchdog. watchdog.stop(); http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/taskdefs/FailTest.java ---------------------------------------------------------------------- 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 8883558..5bcc169 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/FailTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/FailTest.java @@ -43,7 +43,7 @@ public class FailTest { public void test1() { try { buildRule.executeTarget("test1"); - fail("it is required to fail :-)") ; + fail("it is required to fail :-)"); } catch (BuildException ex) { assertEquals("No message", ex.getMessage()); } @@ -53,7 +53,7 @@ public class FailTest { public void test2() { try { buildRule.executeTarget("test2"); - fail("it is required to fail :-)") ; + fail("it is required to fail :-)"); } catch (BuildException ex) { assertEquals("test2", ex.getMessage()); } @@ -63,7 +63,7 @@ public class FailTest { public void testText() { try { buildRule.executeTarget("testText"); - fail("it is required to fail :-)") ; + fail("it is required to fail :-)"); } catch (BuildException ex) { assertEquals("testText", ex.getMessage()); } @@ -75,7 +75,7 @@ public class FailTest { buildRule.getProject().setProperty("foo", ""); try { buildRule.executeTarget("testIf"); - fail("testIf must fail if foo has been set") ; + fail("testIf must fail if foo has been set"); } catch (BuildException ex) { //TODO assert result } @@ -85,7 +85,7 @@ public class FailTest { public void testUnless() { try { buildRule.executeTarget("testUnless"); - fail("testUnless must fail unless foo has been set") ; + fail("testUnless must fail unless foo has been set"); } catch (BuildException ex) { //TODO assert rules } @@ -106,7 +106,7 @@ public class FailTest { buildRule.getProject().setProperty("if", ""); try { buildRule.executeTarget("testIfAndUnless"); - fail("expect fail on defined(if)") ; + fail("expect fail on defined(if)"); } catch (BuildException ex) { assertEquals("if=if and unless=unless", ex.getMessage()); } @@ -129,7 +129,7 @@ public class FailTest { public void testNested1() { try { buildRule.executeTarget("testNested1"); - fail("it is required to fail :-)") ; + fail("it is required to fail :-)"); } catch (BuildException ex) { assertEquals("condition satisfied", ex.getMessage()); } @@ -144,7 +144,7 @@ public class FailTest { public void testNested3() { try { buildRule.executeTarget("testNested3"); - fail("it is required to fail :-)") ; + fail("it is required to fail :-)"); } catch (BuildException ex) { assertEquals("testNested3", ex.getMessage()); } @@ -156,13 +156,13 @@ public class FailTest { + "not permitted in conjunction with if/unless attributes"; char[] c = {'a', 'b', 'c'}; - StringBuffer target = new StringBuffer("testNested4x"); + StringBuilder target = new StringBuilder("testNested4x"); for (int i = 0; i < c.length; i++) { target.setCharAt(target.length() - 1, c[i]); try { buildRule.executeTarget(target.toString()); - fail("it is required to fail :-)") ; + fail("it is required to fail :-)"); } catch (BuildException ex) { assertEquals(specificMessage, ex.getMessage()); } @@ -173,7 +173,7 @@ public class FailTest { public void testNested5() { try { buildRule.executeTarget("testNested5"); - fail("it is required to fail :-)") ; + fail("it is required to fail :-)"); } catch (BuildException ex) { assertEquals("Only one nested condition is allowed.", ex.getMessage()); } @@ -183,7 +183,7 @@ public class FailTest { public void testNested6() { try { buildRule.executeTarget("testNested6"); - fail("it is required to fail :-)") ; + fail("it is required to fail :-)"); } catch (BuildException ex) { assertEquals("testNested6\ntestNested6\ntestNested6", ex.getMessage()); } @@ -194,13 +194,13 @@ public class FailTest { String specificMessage = "A single nested condition is required."; char[] c = {'a', 'b'}; - StringBuffer target = new StringBuffer("testNested7x"); + StringBuilder target = new StringBuilder("testNested7x"); for (int i = 0; i < c.length; i++) { target.setCharAt(target.length() - 1, c[i]); try { buildRule.executeTarget(target.toString()); - fail("it is required to fail :-)") ; + fail("it is required to fail :-)"); } catch (BuildException ex) { assertEquals(specificMessage, ex.getMessage()); } http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/taskdefs/FilterTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/FilterTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/FilterTest.java index fdbec6e..0e40ad8 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/FilterTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/FilterTest.java @@ -126,19 +126,19 @@ public class FilterTest { String line = null; File f = new File(buildRule.getProject().getBaseDir(), filteredFile); if (!f.exists()) { - fail("filter test"+testNumber+" failed"); + fail("filter test" + testNumber + " failed"); } else { BufferedReader in = null; try { in = new BufferedReader(new FileReader(f)); } catch (FileNotFoundException fnfe) { - fail("filter test"+testNumber+" failed, filtered file: " + f.toString() + " not found"); + fail("filter test" + testNumber + " failed, filtered file: " + f.toString() + " not found"); } try { line = in.readLine(); in.close(); } catch (IOException ioe) { - fail("filter test"+testNumber+" failed. IOException while reading filtered file: " + ioe); + fail("filter test" + testNumber + " failed. IOException while reading filtered file: " + ioe); } } f.delete(); http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/taskdefs/FixCrLfTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/FixCrLfTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/FixCrLfTest.java index 06a18cc..258688d 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/FixCrLfTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/FixCrLfTest.java @@ -234,7 +234,7 @@ public class FixCrLfTest { public void assertEqualContent(File expect, File result) throws AssertionFailedError, IOException { if (!result.exists()) { - fail("Expected file "+result+" doesn\'t exist"); + fail("Expected file " + result + " doesn\'t exist"); } InputStream inExpect = null; http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/taskdefs/GUnzipTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/GUnzipTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/GUnzipTest.java index fc731f7..a7aac5d 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/GUnzipTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/GUnzipTest.java @@ -17,6 +17,8 @@ */ package org.apache.tools.ant.taskdefs; +import java.io.IOException; + import org.apache.tools.ant.BuildException; import org.apache.tools.ant.BuildFileRule; import org.apache.tools.ant.FileUtilities; @@ -64,28 +66,28 @@ public class GUnzipTest { } @Test - public void testRealTest() throws java.io.IOException { + public void testRealTest() throws IOException { testRealTest("realTest"); } @Test - public void testRealTestWithResource() throws java.io.IOException { + public void testRealTestWithResource() throws IOException { testRealTest("realTestWithResource"); } - private void testRealTest(String target) throws java.io.IOException { + private void testRealTest(String target) throws IOException { buildRule.executeTarget(target); assertEquals(FileUtilities.getFileContents(buildRule.getProject().resolveFile("../asf-logo.gif")), FileUtilities.getFileContents(buildRule.getProject().resolveFile("asf-logo.gif"))); } @Test - public void testTestGzipTask() throws java.io.IOException { + public void testTestGzipTask() throws IOException { testRealTest("testGzipTask"); } @Test - public void testDocumentationClaimsOnCopy() throws java.io.IOException { + public void testDocumentationClaimsOnCopy() throws IOException { testRealTest("testDocumentationClaimsOnCopy"); } } http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/taskdefs/GzipTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/GzipTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/GzipTest.java index 6319317..76342b8 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/GzipTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/GzipTest.java @@ -82,7 +82,7 @@ public class GzipTest { } @Test - public void testGZip(){ + public void testGZip() { buildRule.executeTarget("realTest"); String log = buildRule.getLog(); assertTrue("Expecting message starting with 'Building:' but got '" @@ -92,12 +92,12 @@ public class GzipTest { } @Test - public void testResource(){ + public void testResource() { buildRule.executeTarget("realTestWithResource"); } @Test - public void testDateCheck(){ + public void testDateCheck() { buildRule.executeTarget("testDateCheck"); String log = buildRule.getLog(); assertTrue( @@ -106,7 +106,7 @@ public class GzipTest { } @After - public void tearDown(){ + public void tearDown() { buildRule.executeTarget("cleanup"); } http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/taskdefs/ImportTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/ImportTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/ImportTest.java index 5fdf8a4..40a52cd 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/ImportTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/ImportTest.java @@ -90,8 +90,9 @@ public class ImportTest { try { buildRule.executeTarget("do-import"); fail("Build exception should have been thrown as import only allowed in top level task"); - } catch(BuildException ex) { - assertContains( "not a top level task", "import only allowed as a top-level task", ex.getMessage()); + } catch (BuildException ex) { + assertContains("not a top level task", "import only allowed as a top-level task", + ex.getMessage()); } } @@ -111,7 +112,8 @@ public class ImportTest { "src/etc/testcases/taskdefs/import/same_target.xml"); fail("Expected build exception"); } catch (BuildException ex) { - assertContains("Message did not contain expected contents", "Duplicate target", ex.getMessage()); + assertContains("Message did not contain expected contents", "Duplicate target", + ex.getMessage()); } } http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/taskdefs/JarTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/JarTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/JarTest.java index 1c6fa94..0a26606 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/JarTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/JarTest.java @@ -137,7 +137,7 @@ public class JarTest { // move the modified date back a couple of seconds rather than delay the test on each run Assume.assumeTrue(jarFile.setLastModified(jarFile.lastModified() - - (FileUtils.getFileUtils().getFileTimestampGranularity() * 3))); + - FileUtils.getFileUtils().getFileTimestampGranularity() * 3)); long jarModifiedDate = jarFile.lastModified(); buildRule.executeTarget(secondTarget); @@ -169,13 +169,13 @@ public class JarTest { private void testRecreate(String firstTarget, String secondTarget) { //Move the modified date on all input back a couple of seconds rather then delay the test to achieve a similar effect - FileUtilities.rollbackTimetamps(buildRule.getProject().getBaseDir(), 5); + FileUtilities.rollbackTimestamps(buildRule.getProject().getBaseDir(), 5); buildRule.executeTarget(firstTarget); File jarFile = new File(getOutputDir(), tempJar); //Move the modified date back a couple of seconds rather then delay the test to achieve a similar effect - FileUtilities.rollbackTimetamps(buildRule.getOutputDir(), 5); + FileUtilities.rollbackTimestamps(buildRule.getOutputDir(), 5); long jarModifiedDate = jarFile.lastModified(); buildRule.executeTarget(secondTarget); @@ -334,7 +334,7 @@ public class JarTest { public void testNoVersionInfoFail() { try { buildRule.executeTarget("testNoVersionInfoFail"); - fail("BuildException expected: Manifest Implemention information missing."); + fail("BuildException expected: Manifest Implementation information missing."); } catch (BuildException ex) { assertContains("No Implementation-Title set.", ex.getMessage()); } @@ -343,33 +343,33 @@ public class JarTest { @Test public void testNoVersionInfoIgnore() { buildRule.executeTarget("testNoVersionInfoIgnore"); - assertTrue(buildRule.getFullLog().indexOf("No Implementation-Title set.") > -1 ); - assertTrue(buildRule.getFullLog().indexOf("No Implementation-Version set.") > -1 ); - assertTrue(buildRule.getFullLog().indexOf("No Implementation-Vendor set.") > -1 ); + assertTrue(buildRule.getFullLog().indexOf("No Implementation-Title set.") > -1); + assertTrue(buildRule.getFullLog().indexOf("No Implementation-Version set.") > -1); + assertTrue(buildRule.getFullLog().indexOf("No Implementation-Vendor set.") > -1); } @Test public void testNoVersionInfoWarn() { buildRule.executeTarget("testNoVersionInfoWarn"); - assertTrue(buildRule.getLog().indexOf("No Implementation-Title set.") > -1 ); - assertTrue(buildRule.getLog().indexOf("No Implementation-Version set.") > -1 ); - assertTrue(buildRule.getLog().indexOf("No Implementation-Vendor set.") > -1 ); + assertTrue(buildRule.getLog().indexOf("No Implementation-Title set.") > -1); + assertTrue(buildRule.getLog().indexOf("No Implementation-Version set.") > -1); + assertTrue(buildRule.getLog().indexOf("No Implementation-Vendor set.") > -1); } @Test public void testNoVersionInfoNoStrict() { buildRule.executeTarget("testNoVersionInfoNoStrict"); - assertFalse(buildRule.getLog().indexOf("No Implementation-Title set.") > -1 ); - assertFalse(buildRule.getLog().indexOf("No Implementation-Version set.") > -1 ); - assertFalse(buildRule.getLog().indexOf("No Implementation-Vendor set.") > -1 ); + assertFalse(buildRule.getLog().indexOf("No Implementation-Title set.") > -1); + assertFalse(buildRule.getLog().indexOf("No Implementation-Version set.") > -1); + assertFalse(buildRule.getLog().indexOf("No Implementation-Vendor set.") > -1); } @Test public void testHasVersionInfo() { buildRule.executeTarget("testHasVersionInfo"); - assertFalse(buildRule.getLog().indexOf("No Implementation-Title set.") > -1 ); - assertFalse(buildRule.getLog().indexOf("No Implementation-Version set.") > -1 ); - assertFalse(buildRule.getLog().indexOf("No Implementation-Vendor set.") > -1 ); + assertFalse(buildRule.getLog().indexOf("No Implementation-Title set.") > -1); + assertFalse(buildRule.getLog().indexOf("No Implementation-Version set.") > -1); + assertFalse(buildRule.getLog().indexOf("No Implementation-Vendor set.") > -1); } } http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/taskdefs/JavaTest.java ---------------------------------------------------------------------- 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 8d99571..ea1bdbf 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/JavaTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/JavaTest.java @@ -78,14 +78,15 @@ public class JavaTest { //final String propname="tests-classpath.value"; //String testClasspath=System.getProperty(propname); - //System.out.println("Test cp="+testClasspath); - String runFatal=System.getProperty("junit.run.fatal.tests"); - if(runFatal!=null) - runFatalTests=true; + //System.out.println("Test cp=" + testClasspath); + String runFatal = System.getProperty("junit.run.fatal.tests"); + if (runFatal != null) { + runFatalTests = true; + } } @Test - public void testNoJarNoClassname(){ + public void testNoJarNoClassname() { try { buildRule.executeTarget("testNoJarNoClassname"); fail("Build exception should have been thrown - parameter validation"); @@ -173,20 +174,20 @@ public class JavaTest { assertEquals("Command line should have 5 elements", 5, cmdLine.length); assertEquals("Last command line element should be java argument: " + arg, arg, - cmdLine[cmdLine.length-1]); + cmdLine[cmdLine.length - 1]); assertEquals("The command line element at index 3 should be module name: " + moduleName, moduleName, - cmdLine[cmdLine.length-2]); + cmdLine[cmdLine.length - 2]); assertEquals("The command line element at index 2 should be -m", "-m", - cmdLine[cmdLine.length-3]); + cmdLine[cmdLine.length - 3]); } @Test public void testModuleAndClassnameCommandLine() { final String moduleName = "TestModule"; //NOI18N final String className = "org.apache.Test"; //NOI18N - final String moduleClassPair= String.format("%s/%s", moduleName, className); + final String moduleClassPair = String.format("%s/%s", moduleName, className); final String arg = "appArg"; //NOI18N final Java java = new Java(); java.setFork(true); @@ -199,13 +200,13 @@ public class JavaTest { assertEquals("Command line should have 5 elements", 5, cmdLine.length); assertEquals("Last command line element should be java argument: " + arg, arg, - cmdLine[cmdLine.length-1]); + cmdLine[cmdLine.length - 1]); assertEquals("The command line element at index 3 should be module class pair: " + moduleClassPair, moduleClassPair, - cmdLine[cmdLine.length-2]); + cmdLine[cmdLine.length - 2]); assertEquals("The command line element at index 2 should be -m", "-m", - cmdLine[cmdLine.length-3]); + cmdLine[cmdLine.length - 3]); } @Test @@ -395,7 +396,7 @@ public class JavaTest { // wait a little bit for the task to wait for input Thread.sleep(100); - // write some stuff in the input stream to be catched by the input task + // write some stuff in the input stream to be caught by the input task out.write("foo\n".getBytes()); out.flush(); try { @@ -459,21 +460,21 @@ public class JavaTest { * argv[1] = string to print to System.err (optional) */ public static void main(String[] argv) { - int exitCode=0; - if(argv.length>0) { + int exitCode = 0; + if (argv.length > 0) { try { - exitCode=Integer.parseInt(argv[0]); - } catch(NumberFormatException nfe) { - exitCode=-1; + exitCode = Integer.parseInt(argv[0]); + } catch (NumberFormatException nfe) { + exitCode = -1; } } - if(argv.length>1) { + if (argv.length > 1) { System.out.println(argv[1]); } - if(argv.length>2) { + if (argv.length > 2) { System.err.println(argv[2]); } - if(exitCode!=0) { + if (exitCode != 0) { System.exit(exitCode); } } @@ -503,8 +504,7 @@ public class JavaTest { if (argv.length >= 1) { sleepTime = Integer.parseInt(argv[0]); } - if (argv.length >= 2) - { + if (argv.length >= 2) { logFile = argv[1]; } OutputStreamWriter out = null; @@ -515,9 +515,13 @@ public class JavaTest { FileOutputStream fos = new FileOutputStream(dest); out = new OutputStreamWriter(fos); out.write("bye bye\n"); - } catch (Exception ex) {} - finally { - try {out.close();} catch (IOException ioe) {}} + } catch (Exception ex) { + } finally { + try { + out.close(); + } catch (IOException ioe) { + } + } } } http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/taskdefs/JavacTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/JavacTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/JavacTest.java index 364a50e..ce302dc 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/JavacTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/JavacTest.java @@ -288,7 +288,7 @@ public class JavacTest { final File tmp = new File(System.getProperty("java.io.tmpdir")); //NOI18N final File destDir = new File(tmp, String.format("%stestMP%d", getClass().getName(), - System.currentTimeMillis()/1000)); + System.currentTimeMillis() / 1000)); destDir.mkdirs(); try { final Path p = new Path(project); http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/taskdefs/LoadFileTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/LoadFileTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/LoadFileTest.java index ce166d9..48f47b8 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/LoadFileTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/LoadFileTest.java @@ -38,19 +38,16 @@ public class LoadFileTest { @Rule public final BuildFileRule buildRule = new BuildFileRule(); - @Before public void setUp() { buildRule.configureProject("src/etc/testcases/taskdefs/loadfile.xml"); } - @After public void tearDown() { buildRule.executeTarget("cleanup"); } - /** * A unit test for JUnit */ @@ -64,7 +61,6 @@ public class LoadFileTest { } } - /** * A unit test for JUnit */ @@ -78,7 +74,6 @@ public class LoadFileTest { } } - /** * A unit test for JUnit */ @@ -96,32 +91,27 @@ public class LoadFileTest { * A unit test for JUnit */ @Test - public void testFailOnError() - throws BuildException { + public void testFailOnError() throws BuildException { buildRule.executeTarget("testFailOnError"); assertNull(buildRule.getProject().getProperty("testFailOnError")); } - /** * A unit test for JUnit */ @Test - public void testLoadAFile() - throws BuildException { + public void testLoadAFile() throws BuildException { buildRule.executeTarget("testLoadAFile"); if(buildRule.getProject().getProperty("testLoadAFile").indexOf("eh?")<0) { fail("property is not all in the file"); } } - /** * A unit test for JUnit */ @Test - public void testLoadAFileEnc() - throws BuildException { + public void testLoadAFileEnc() throws BuildException { buildRule.executeTarget("testLoadAFileEnc"); assertNotNull("file load files", buildRule.getProject().getProperty("testLoadAFileEnc")); } @@ -130,8 +120,7 @@ public class LoadFileTest { * A unit test for JUnit */ @Test - public void testEvalProps() - throws BuildException { + public void testEvalProps() throws BuildException { buildRule.executeTarget("testEvalProps"); if(buildRule.getProject().getProperty("testEvalProps").indexOf("rain")<0) { fail("property eval broken"); @@ -142,8 +131,7 @@ public class LoadFileTest { * Test FilterChain and FilterReaders */ @Test - public void testFilterChain() - throws BuildException { + public void testFilterChain() throws BuildException { buildRule.executeTarget("testFilterChain"); if(buildRule.getProject().getProperty("testFilterChain").indexOf("World!")<0) { fail("Filter Chain broken"); @@ -154,8 +142,7 @@ public class LoadFileTest { * Test StripJavaComments filterreader functionality. */ @Test - public final void testStripJavaComments() - throws BuildException { + public final void testStripJavaComments() throws BuildException { buildRule.executeTarget("testStripJavaComments"); final String expected = buildRule.getProject().getProperty("expected"); final String generated = buildRule.getProject().getProperty("testStripJavaComments"); http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/taskdefs/MakeUrlTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/MakeUrlTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/MakeUrlTest.java index 07e53fd..592f1d7 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/MakeUrlTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/MakeUrlTest.java @@ -100,7 +100,7 @@ public class MakeUrlTest { /** * test that we can round trip by opening a url that exists * - * @throws IOException + * @throws IOException if something goes wrong */ @Test public void testRoundTrip() throws IOException { @@ -142,8 +142,8 @@ public class MakeUrlTest { /** * assert that a property ends with * - * @param property - * @param ending + * @param property String + * @param ending String */ private void assertPropertyEndsWith(String property, String ending) { String result = getProperty(property); @@ -167,8 +167,8 @@ public class MakeUrlTest { /** * get a property from the project * - * @param property - * @return + * @param property String + * @return String */ protected String getProperty(String property) { return buildRule.getProject().getProperty(property); http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestClassPathTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestClassPathTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestClassPathTest.java index 695d45c..6fb3d13 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestClassPathTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestClassPathTest.java @@ -17,7 +17,6 @@ */ package org.apache.tools.ant.taskdefs; - import static org.apache.tools.ant.AntAssert.assertContains; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; @@ -231,8 +230,8 @@ public class ManifestClassPathTest { } else { altDriveLetter = "C"; } - new java.io.File(altDriveLetter + ":/foo.txt").getCanonicalPath(); - } catch (java.io.IOException e) { + new File(altDriveLetter + ":/foo.txt").getCanonicalPath(); + } catch (IOException e) { Assume.assumeNoException("Drive " + altDriveLetter + ": doesn't exist or is not ready", e); } buildRule.getProject().setProperty("altDriveLetter", altDriveLetter); http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestTest.java index 6e79432..a4a1e47 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestTest.java @@ -134,9 +134,8 @@ public class ManifestTest { @Test public void test5() { buildRule.executeTarget("test5"); - String output = buildRule.getLog(); - boolean hasWarning = output.indexOf("Manifest warning: \"Name\" attributes should not occur in the main section") != -1; - assertTrue("Expected warning about Name in main section", hasWarning); + assertTrue("Expected warning about Name in main section", buildRule.getLog() + .contains("Manifest warning: \"Name\" attributes should not occur in the main section")); } /** @@ -150,9 +149,8 @@ public class ManifestTest { } catch (BuildException ex) { assertContains("Invalid Manifest", ex.getMessage()); } - String output = buildRule.getLog(); - boolean hasWarning = output.indexOf("Manifest sections should start with a \"Name\" attribute") != -1; - assertTrue("Expected warning about section not starting with Name: attribute", hasWarning); + assertTrue("Expected warning about section not starting with Name: attribute", buildRule.getLog() + .contains("Manifest sections should start with a \"Name\" attribute")); } @@ -162,9 +160,8 @@ public class ManifestTest { @Test public void test7() { buildRule.executeTarget("test7"); - - boolean hasWarning = buildRule.getLog().indexOf(Manifest.ERROR_FROM_FORBIDDEN) != -1; - assertTrue("Expected warning about From: attribute", hasWarning); + assertTrue("Expected warning about From: attribute", buildRule.getLog() + .contains(Manifest.ERROR_FROM_FORBIDDEN)); } /** @@ -245,7 +242,8 @@ public class ManifestTest { buildRule.executeTarget("test13"); fail("BuildException expected: Duplicate Attribute"); } catch (BuildException ex) { - assertContains("The attribute \"Test\" may not occur more than once in the same section", ex.getMessage()); + assertContains("The attribute \"Test\" may not occur more than once in the same section", + ex.getMessage()); } } @@ -269,9 +267,9 @@ public class ManifestTest { public void testLongLine() throws IOException, ManifestException { Project p = buildRule.getProject(); p.setUserProperty("test.longline", LONG_LINE); - p.setUserProperty("test.long68name" , LONG_68_NAME); - p.setUserProperty("test.long70name" , LONG_70_NAME); - p.setUserProperty("test.notlongname" , NOT_LONG_NAME); + p.setUserProperty("test.long68name", LONG_68_NAME); + p.setUserProperty("test.long70name", LONG_70_NAME); + p.setUserProperty("test.notlongname", NOT_LONG_NAME); p.setUserProperty("test.value", VALUE); buildRule.executeTarget("testLongLine"); http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/taskdefs/MkdirTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/MkdirTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/MkdirTest.java index 637face..9864a4a 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/MkdirTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/MkdirTest.java @@ -17,6 +17,8 @@ */ package org.apache.tools.ant.taskdefs; +import java.io.File; + import org.apache.tools.ant.BuildException; import org.apache.tools.ant.BuildFileRule; import org.junit.Before; @@ -60,7 +62,7 @@ public class MkdirTest { @Test public void test3() { buildRule.executeTarget("test3"); - java.io.File f = new java.io.File(buildRule.getProject().getProperty("output"), "testdir.tmp"); + File f = new File(buildRule.getProject().getProperty("output"), "testdir.tmp"); if (!f.exists() || !f.isDirectory()) { fail("mkdir failed"); } else { http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/taskdefs/MultiMapTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/MultiMapTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/MultiMapTest.java index 95f9eaf..2d09788 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/MultiMapTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/MultiMapTest.java @@ -68,12 +68,17 @@ public class MultiMapTest { } public static class TestMapper implements FileNameMapper { - public TestMapper() {} - public void setFrom(String from) {} - public void setTo(String to) {} + public TestMapper() { + } + + public void setFrom(String from) { + } + + public void setTo(String to) { + } + public String[] mapFileName(final String source_file_name) { - return new String[] { - source_file_name, source_file_name+".copy2" }; + return new String[] {source_file_name, source_file_name + ".copy2"}; } } } http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/taskdefs/ParallelTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/ParallelTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/ParallelTest.java index 3ca7cf7..97667e4 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/ParallelTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/ParallelTest.java @@ -46,7 +46,7 @@ public class ParallelTest { /** Standard property value for the fail test */ public final static String FAILURE_MESSAGE = "failure"; - /** the build fiel associated with this test */ + /** the build file associated with this test */ public final static String TEST_BUILD_FILE = "src/etc/testcases/taskdefs/parallel.xml"; http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/taskdefs/PropertyTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/PropertyTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/PropertyTest.java index 17e7114..7cead66 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/PropertyTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/PropertyTest.java @@ -66,8 +66,7 @@ public class PropertyTest { try { buildRule.executeTarget("test3"); fail("Did not throw exception on circular exception"); - } - catch (BuildException e) { + } catch (BuildException e) { assertTrue("Circular definition not detected - ", e.getMessage().indexOf("was circularly defined") != -1); } @@ -101,8 +100,7 @@ public class PropertyTest { try { buildRule.executeTarget("prefix.fail"); fail("Did not throw exception on invalid use of prefix"); - } - catch (BuildException e) { + } catch (BuildException e) { assertContains("Prefix allowed on non-resource/file load - ", "Prefix is only valid", e.getMessage()); } http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/taskdefs/ReplaceTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/ReplaceTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/ReplaceTest.java index cd485d0..4e40c28 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/ReplaceTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/ReplaceTest.java @@ -153,7 +153,7 @@ public class ReplaceTest { public void assertEqualContent(File expect, File result) throws AssertionFailedError, IOException { if (!result.exists()) { - fail("Expected file "+result+" doesn\'t exist"); + fail("Expected file " + result + " doesn\'t exist"); } InputStream inExpect = null; http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/taskdefs/RmicAdvancedTest.java ---------------------------------------------------------------------- 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 f2f1861..3bbef0e 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/RmicAdvancedTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/RmicAdvancedTest.java @@ -282,7 +282,7 @@ public class RmicAdvancedTest { public void NotestFailingAdapter() throws Exception { try { buildRule.executeTarget("testFailingAdapter"); - fail("Expected failures to propogate"); + fail("Expected failures to propagate"); } catch (BuildException ex) { AntAssert.assertContains(Rmic.ERROR_RMIC_FAILED, ex.getMessage()); } @@ -291,7 +291,7 @@ public class RmicAdvancedTest { /** * test that version 1.1 stubs are good - * @throws Exception + * @throws Exception if something goes wrong */ @Test public void testVersion11() throws Exception { @@ -300,7 +300,7 @@ public class RmicAdvancedTest { /** * test that version 1.1 stubs are good - * @throws Exception + * @throws Exception if something goes wrong */ @Test public void testVersion11Dest() throws Exception { @@ -310,7 +310,7 @@ public class RmicAdvancedTest { /** * test that version 1.2 stubs are good * - * @throws Exception + * @throws Exception if something goes wrong */ @Test public void testVersion12() throws Exception { @@ -320,7 +320,7 @@ public class RmicAdvancedTest { /** * test that version 1.2 stubs are good * - * @throws Exception + * @throws Exception if something goes wrong */ @Test public void testVersion12Dest() throws Exception { @@ -330,7 +330,7 @@ public class RmicAdvancedTest { /** * test that version compat stubs are good * - * @throws Exception + * @throws Exception if something goes wrong */ @Test public void testVersionCompat() throws Exception { @@ -340,7 +340,7 @@ public class RmicAdvancedTest { /** * test that version compat stubs are good * - * @throws Exception + * @throws Exception if something goes wrong */ @Test public void testVersionCompatDest() throws Exception { @@ -350,7 +350,7 @@ public class RmicAdvancedTest { /** * test that passes -Xnew to sun's rmic running in a different VM. * - * @throws Exception + * @throws Exception if something goes wrong */ @Test public void testXnewForked() throws Exception { @@ -360,7 +360,7 @@ public class RmicAdvancedTest { /** * test that passes -Xnew to sun's rmic running in a different VM. * - * @throws Exception + * @throws Exception if something goes wrong */ @Test public void testXnewForkedDest() throws Exception { @@ -370,7 +370,7 @@ public class RmicAdvancedTest { /** * test that runs the new xnew compiler adapter. * - * @throws Exception + * @throws Exception if something goes wrong */ @Test public void testXnewCompiler() throws Exception { @@ -380,7 +380,7 @@ public class RmicAdvancedTest { /** * test that runs the new xnew compiler adapter. * - * @throws Exception + * @throws Exception if something goes wrong */ @Test public void testXnewCompilerDest() throws Exception { @@ -390,7 +390,7 @@ public class RmicAdvancedTest { /** * test that verifies that IDL compiles. * - * @throws Exception + * @throws Exception if something goes wrong */ @Test public void testIDL() throws Exception { @@ -400,7 +400,7 @@ public class RmicAdvancedTest { /** * test that verifies that IDL compiles. * - * @throws Exception + * @throws Exception if something goes wrong */ @Test public void testIDLDest() throws Exception { @@ -410,7 +410,7 @@ public class RmicAdvancedTest { /** * test that verifies that IIOP compiles. * - * @throws Exception + * @throws Exception if something goes wrong */ @Test public void testIIOP() throws Exception { @@ -420,7 +420,7 @@ public class RmicAdvancedTest { /** * test that verifies that IIOP compiles. * - * @throws Exception + * @throws Exception if something goes wrong */ @Test public void testIIOPDest() throws Exception { http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/taskdefs/RmicTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/RmicTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/RmicTest.java index 8d3200c..a8ef90c 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/RmicTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/RmicTest.java @@ -88,7 +88,7 @@ public class RmicTest { // check defaults String compiler = rmic.getCompiler(); assertNotNull(compiler); - assertEquals("expected sun or kaffe, but found "+compiler,compiler,"default"); + assertEquals("expected sun or kaffe, but found " + compiler, compiler,"default"); project.setNewProperty("build.rmic", "weblogic"); compiler = rmic.getCompiler(); http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/taskdefs/SQLExecTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/SQLExecTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/SQLExecTest.java index fbce8a6..dac6941 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/SQLExecTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/SQLExecTest.java @@ -26,8 +26,8 @@ import java.io.File; import java.net.URL; import java.util.logging.Logger; -import org.apache.tools.ant.Project; import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.Project; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; @@ -70,13 +70,13 @@ public class SQLExecTest { // simple test to ensure that the caching does work... @Test - public void testDriverCaching(){ + public void testDriverCaching() { SQLExec sql = createTask(getProperties(NULL)); assertTrue(!SQLExec.getLoaderMap().containsKey(NULL_DRIVER)); try { sql.execute(); fail("BuildException should have been thrown"); - } catch (BuildException e){ + } catch (BuildException e) { assertContains("No suitable Driver", e.getMessage()); } assertTrue(SQLExec.getLoaderMap().containsKey(NULL_DRIVER)); @@ -104,13 +104,13 @@ public class SQLExecTest { @Ignore @Test - public void testOracle(){ + public void testOracle() { doMultipleCalls(1000, ORACLE, true, false); } @Ignore @Test - public void testMySQL(){ + public void testMySQL() { doMultipleCalls(1000, MYSQL, true, false); } @@ -122,15 +122,15 @@ public class SQLExecTest { * @param caching should caching be enabled ? * @param catchexception true to catch exception for each call, false if not. */ - protected void doMultipleCalls(int calls, int database, boolean caching, boolean catchexception){ + protected void doMultipleCalls(int calls, int database, boolean caching, boolean catchexception) { Properties props = getProperties(database); - for (int i = 0; i < calls; i++){ + for (int i = 0; i < calls; i++) { SQLExec sql = createTask(props); sql.setCaching(caching); try { sql.execute(); - } catch (BuildException e){ - if (!catchexception){ + } catch (BuildException e) { + if (!catchexception) { throw e; } } @@ -141,15 +141,15 @@ public class SQLExecTest { * Create a task from a set of properties * @see #getProperties(int) */ - protected SQLExec createTask(Properties props){ + protected SQLExec createTask(Properties props) { SQLExec sql = new SQLExec(); - sql.setProject( new Project() ); - sql.setDriver( props.getProperty(DRIVER) ); - sql.setUserid( props.getProperty(USER) ); - sql.setPassword( props.getProperty(PASSWORD) ); - sql.setUrl( props.getProperty(URL) ); - sql.createClasspath().setLocation( new File(props.getProperty(PATH)) ); - sql.addText( props.getProperty(SQL) ); + sql.setProject(new Project()); + sql.setDriver(props.getProperty(DRIVER)); + sql.setUserid(props.getProperty(USER)); + sql.setPassword(props.getProperty(PASSWORD)); + sql.setUrl(props.getProperty(URL)); + sql.createClasspath().setLocation(new File(props.getProperty(PATH))); + sql.addText(props.getProperty(SQL)); return sql; } @@ -157,7 +157,7 @@ public class SQLExecTest { * try to find the path from a resource (jar file or directory name) * so that it can be used as a classpath to load the resource. */ - protected String findResourcePath(String resource){ + protected String findResourcePath(String resource) { resource = resource.replace('.', '/') + ".class"; URL url = getClass().getClassLoader().getResource(resource); if (url == null) { @@ -180,9 +180,9 @@ public class SQLExecTest { * tweak this to make it run or add your own database. * The driver lib should be dropped into the system classloader. */ - protected Properties getProperties(int database){ + protected Properties getProperties(int database) { Properties props = null; - switch (database){ + switch (database) { case ORACLE: props = getProperties("oracle.jdbc.driver.OracleDriver", "test", "test", "jdbc:oracle:thin:@127.0.0.1:1521:orcl"); break; @@ -201,7 +201,7 @@ public class SQLExecTest { } /** helper method to build properties */ - protected Properties getProperties(String driver, String user, String pwd, String url){ + protected Properties getProperties(String driver, String user, String pwd, String url) { Properties props = new Properties(); props.put(DRIVER, driver); props.put(USER, user); http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/taskdefs/SleepTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/SleepTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/SleepTest.java index f34c26c..e9db64b 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/SleepTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/SleepTest.java @@ -33,8 +33,7 @@ public class SleepTest { public final BuildFileRule buildRule = new BuildFileRule(); private final static String TASKDEFS_DIR = "src/etc/testcases/taskdefs/"; - private final static int ERROR_RANGE=1000; - + private final static int ERROR_RANGE = 1000; @Before public void setUp() { @@ -43,34 +42,34 @@ public class SleepTest { @Test public void test1() { - Timer timer=new Timer(); + Timer timer = new Timer(); buildRule.executeTarget("test1"); timer.stop(); - assertTrue(timer.time()>=0); + assertTrue(timer.time() >= 0); } @Test public void test2() { - Timer timer=new Timer(); + Timer timer = new Timer(); buildRule.executeTarget("test2"); timer.stop(); - assertTrue(timer.time()>=0); + assertTrue(timer.time() >= 0); } @Test public void test3() { - Timer timer=new Timer(); + Timer timer = new Timer(); buildRule.executeTarget("test3"); timer.stop(); - assertTrue(timer.time()>=(2000-ERROR_RANGE)); + assertTrue(timer.time() >= (2000 - ERROR_RANGE)); } @Test public void test4() { - Timer timer=new Timer(); + Timer timer = new Timer(); buildRule.executeTarget("test3"); timer.stop(); - assertTrue(timer.time()>=(2000-ERROR_RANGE) && timer.time()<60000); + assertTrue(timer.time() >= (2000 - ERROR_RANGE) && timer.time() < 60000); } @Test @@ -85,10 +84,10 @@ public class SleepTest { @Test public void test6() { - Timer timer=new Timer(); + Timer timer = new Timer(); buildRule.executeTarget("test6"); timer.stop(); - assertTrue(timer.time()<2000); + assertTrue(timer.time() < 2000); } @@ -96,23 +95,23 @@ public class SleepTest { * inner timer class */ private static class Timer { - long start=0; - long stop=0; + long start = 0; + long stop = 0; public Timer() { start(); } public void start() { - start=System.currentTimeMillis(); + start = System.currentTimeMillis(); } public void stop() { - stop=System.currentTimeMillis(); + stop = System.currentTimeMillis(); } public long time() { - return stop-start; + return stop - start; } } http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/taskdefs/StyleTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/StyleTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/StyleTest.java index 24c4e9d..a45a098 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/StyleTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/StyleTest.java @@ -64,7 +64,7 @@ public class StyleTest { public void testTransferParameterSet() throws Exception { expectFileContains("testTransferParameterSet", // target buildRule.getOutputDir().getAbsoluteFile() + "/out.xml", // file - "set='myvalue'"); // exptected string + "set='myvalue'"); // expected string } @Test @@ -207,8 +207,7 @@ public class StyleTest { private void expectFileContains( String target, String filename, String contains) - throws IOException - { + throws IOException { buildRule.executeTarget(target); assertFileContains(filename, contains); } http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/taskdefs/SubAntTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/SubAntTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/SubAntTest.java index 58ee4f3..de06753 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/SubAntTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/SubAntTest.java @@ -130,12 +130,23 @@ public class SubAntTest { expectedBasedirs = dirs; } - public void buildStarted(BuildEvent event) {} - public void buildFinished(BuildEvent event) {} - public void targetFinished(BuildEvent event){} - public void taskStarted(BuildEvent event) {} - public void taskFinished(BuildEvent event) {} - public void messageLogged(BuildEvent event) {} + public void buildStarted(BuildEvent event) { + } + + public void buildFinished(BuildEvent event) { + } + + public void targetFinished(BuildEvent event) { + } + + public void taskStarted(BuildEvent event) { + } + + public void taskFinished(BuildEvent event) { + } + + public void messageLogged(BuildEvent event) { + } public void targetStarted(BuildEvent event) { if (event.getTarget().getName().equals("")) { http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/taskdefs/TStampTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/TStampTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/TStampTest.java index 71921cb..033d1b9 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/TStampTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/TStampTest.java @@ -17,13 +17,13 @@ */ package org.apache.tools.ant.taskdefs; +import java.text.SimpleDateFormat; import java.util.Calendar; -import java.util.TimeZone; import java.util.Date; -import java.text.SimpleDateFormat; +import java.util.TimeZone; -import org.apache.tools.ant.Project; import org.apache.tools.ant.Location; +import org.apache.tools.ant.Project; import org.junit.Before; import org.junit.Test; @@ -59,7 +59,7 @@ public class TStampTest { String today = project.getProperty("today"); SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss z"); - sdf.setTimeZone( TimeZone.getTimeZone("GMT") ); + sdf.setTimeZone(TimeZone.getTimeZone("GMT")); String expected = sdf.format(date); assertEquals(expected, today); @@ -68,7 +68,7 @@ public class TStampTest { /** * verifies that custom props have priority over the * originals - * @throws Exception + * @throws Exception if something goes wrong */ @Test public void testWriteOrder() throws Exception { @@ -81,7 +81,7 @@ public class TStampTest { String today = project.getProperty("TODAY"); SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss z"); - sdf.setTimeZone( TimeZone.getTimeZone("GMT") ); + sdf.setTimeZone(TimeZone.getTimeZone("GMT")); String expected = sdf.format(date); assertEquals(expected, today); @@ -91,13 +91,13 @@ public class TStampTest { /** * verifies that custom props have priority over the * originals - * @throws Exception + * @throws Exception if something goes wrong */ @Test public void testPrefix() throws Exception { tstamp.setPrefix("prefix"); tstamp.execute(); - String prop= project.getProperty("prefix.DSTAMP"); + String prop = project.getProperty("prefix.DSTAMP"); assertNotNull(prop); } @@ -110,7 +110,7 @@ public class TStampTest { tstamp.setPrefix("prefix"); tstamp.execute(); - String prop= project.getProperty("prefix.format"); + String prop = project.getProperty("prefix.format"); assertNotNull(prop); } http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/taskdefs/TarTest.java ---------------------------------------------------------------------- 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 3d77ba1..9650dfc 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/TarTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/TarTest.java @@ -165,7 +165,7 @@ public class TarTest { File f1 = new File(buildRule.getProject().getProperty("output"), "untar/test8.xml"); if (! f1.exists()) { - fail("The fullpath attribute or the preserveLeadingSlashes attribute does not work propertly"); + fail("The fullpath attribute or the preserveLeadingSlashes attribute does not work properly"); } } @@ -185,7 +185,7 @@ public class TarTest { File f1 = new File(buildRule.getProject().getProperty("output"), "untar/test10.xml"); if (! f1.exists()) { - fail("The fullpath attribute or the preserveLeadingSlashes attribute does not work propertly"); + fail("The fullpath attribute or the preserveLeadingSlashes attribute does not work properly"); } } @@ -195,7 +195,7 @@ public class TarTest { File f1 = new File(buildRule.getProject().getProperty("output"), "untar/test11.xml"); if (! f1.exists()) { - fail("The fullpath attribute or the preserveLeadingSlashes attribute does not work propertly"); + fail("The fullpath attribute or the preserveLeadingSlashes attribute does not work properly"); } } http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/taskdefs/TestProcess.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/TestProcess.java b/src/tests/junit/org/apache/tools/ant/taskdefs/TestProcess.java index 062003f..a61ca3c 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/TestProcess.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/TestProcess.java @@ -24,23 +24,17 @@ import org.junit.internal.AssumptionViolatedException; * Interactive Testcase for Processdestroyer. * */ -public class TestProcess - implements Runnable -{ +public class TestProcess implements Runnable { private boolean run = true; private boolean done = false; - public void shutdown() - { - if (!done) - { + public void shutdown() { + if (!done) { System.out.println("shutting down TestProcess"); run = false; - synchronized(this) - { - while (!done) - { + synchronized (this) { + while (!done) { try { wait(); } catch (InterruptedException ie) { @@ -53,10 +47,8 @@ public class TestProcess } } - public void run() - { - for (int i = 0; i < 5 && run; i++) - { + public void run() { + for (int i = 0; i < 5 && run; i++) { System.out.println(Thread.currentThread().getName()); try { @@ -66,29 +58,23 @@ public class TestProcess } } - synchronized(this) - { + synchronized (this) { done = true; notifyAll(); } } - public Thread getShutdownHook() - { + public Thread getShutdownHook() { return new TestProcessShutdownHook(); } - private class TestProcessShutdownHook - extends Thread - { - public void run() - { + private class TestProcessShutdownHook extends Thread { + public void run() { shutdown(); } } - public static void main(String[] args) - { + public static void main(String[] args) { TestProcess tp = new TestProcess(); new Thread(tp, "TestProcess thread").start(); Runtime.getRuntime().addShutdownHook(tp.getShutdownHook()); http://git-wip-us.apache.org/repos/asf/ant/blob/866ce9f5/src/tests/junit/org/apache/tools/ant/taskdefs/TouchTest.java ---------------------------------------------------------------------- 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 0a968b2..c19ed33 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/TouchTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/TouchTest.java @@ -56,7 +56,7 @@ public class TouchTest { public long getTargetTime() { File file = new File(System.getProperty("root"), TOUCH_FILE); - if(!file.exists()) { + if (!file.exists()) { throw new BuildException("failed to touch file " + file); } return file.lastModified(); @@ -94,7 +94,7 @@ public class TouchTest { */ @Test public void testNow() { - long now=System.currentTimeMillis(); + long now = System.currentTimeMillis(); buildRule.executeTarget("testNow"); long time = getTargetTime(); assertTimesNearlyMatch(time,now,5000); @@ -179,8 +179,8 @@ public class TouchTest { /** * run a target to touch the test file; verify the timestamp is as expected - * @param targetName - * @param timestamp + * @param targetName String + * @param timestamp long */ private void touchFile(String targetName, long timestamp) { buildRule.executeTarget(targetName); @@ -190,8 +190,8 @@ public class TouchTest { /** * assert that two times are within the current FS granularity; - * @param timestamp - * @param time + * @param timestamp long + * @param time long */ public void assertTimesNearlyMatch(long timestamp,long time) { long granularity= FILE_UTILS.getFileTimestampGranularity(); @@ -200,9 +200,9 @@ public class TouchTest { /** * assert that two times are within a specified range - * @param timestamp - * @param time - * @param range + * @param timestamp long + * @param time long + * @param range long */ private void assertTimesNearlyMatch(long timestamp, long time, long range) { assertTrue("Time " + timestamp + " is not within " + range + " ms of "
