Repository: ant Updated Branches: refs/heads/1.9.x 8190d1031 -> 8c38eb4c6
http://git-wip-us.apache.org/repos/asf/ant/blob/8c38eb4c/src/tests/junit/org/apache/tools/ant/taskdefs/AntTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/AntTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/AntTest.java index 5756519..9371548 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/AntTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/AntTest.java @@ -242,16 +242,16 @@ public class AntTest { buildRule.getProject().resolveFile("ant/test3.log"), buildRule.getProject().resolveFile("ant/test4.log") }; - for (int i=0; i<logFiles.length; i++) { - assertTrue(logFiles[i].getName()+" doesn\'t exist", - !logFiles[i].exists()); + for (File logFile : logFiles) { + assertTrue(logFile.getName() + " doesn\'t exist", + !logFile.exists()); } buildRule.executeTarget("testLogfilePlacement"); - for (int i=0; i<logFiles.length; i++) { - assertTrue(logFiles[i].getName()+" exists", - logFiles[i].exists()); + for (File logFile : logFiles) { + assertTrue(logFile.getName() + " exists", + logFile.exists()); } } http://git-wip-us.apache.org/repos/asf/ant/blob/8c38eb4c/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 5bcc169..34299d5 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/FailTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/FailTest.java @@ -24,6 +24,8 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; +import java.util.Arrays; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; @@ -155,11 +157,9 @@ public class FailTest { String specificMessage = "Nested conditions " + "not permitted in conjunction with if/unless attributes"; - char[] c = {'a', 'b', 'c'}; StringBuilder target = new StringBuilder("testNested4x"); - - for (int i = 0; i < c.length; i++) { - target.setCharAt(target.length() - 1, c[i]); + for (char ch : Arrays.asList('a', 'b', 'c')) { + target.setCharAt(target.length() - 1, ch); try { buildRule.executeTarget(target.toString()); fail("it is required to fail :-)"); @@ -193,11 +193,9 @@ public class FailTest { public void testNested7() { String specificMessage = "A single nested condition is required."; - char[] c = {'a', 'b'}; StringBuilder target = new StringBuilder("testNested7x"); - - for (int i = 0; i < c.length; i++) { - target.setCharAt(target.length() - 1, c[i]); + for (char ch : Arrays.asList('a', 'b')) { + target.setCharAt(target.length() - 1, ch); try { buildRule.executeTarget(target.toString()); fail("it is required to fail :-)"); http://git-wip-us.apache.org/repos/asf/ant/blob/8c38eb4c/src/tests/junit/org/apache/tools/ant/taskdefs/optional/depend/DependTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/depend/DependTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/depend/DependTest.java index 15876b1..1177c8a 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/depend/DependTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/depend/DependTest.java @@ -160,12 +160,11 @@ public class DependTest { * fileset */ private Hashtable getResultFiles() { - FileSet resultFileSet = (FileSet) buildRule.getProject().getReference(RESULT_FILESET); + FileSet resultFileSet = buildRule.getProject().getReference(RESULT_FILESET); DirectoryScanner scanner = resultFileSet.getDirectoryScanner(buildRule.getProject()); - String[] scannedFiles = scanner.getIncludedFiles(); - Hashtable files = new Hashtable(); - for (int i = 0; i < scannedFiles.length; ++i) { - files.put(scannedFiles[i], scannedFiles[i]); + Hashtable<String, String> files = new Hashtable<String, String>(); + for (String scannedFile : scanner.getIncludedFiles()) { + files.put(scannedFile, scannedFile); } return files; } http://git-wip-us.apache.org/repos/asf/ant/blob/8c38eb4c/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ssh/ScpTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ssh/ScpTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ssh/ScpTest.java index f32b4ff..e456d6f 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ssh/ScpTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ssh/ScpTest.java @@ -66,7 +66,7 @@ public class ScpTest { private int port = Integer.parseInt(System.getProperty("scp.port", "22")); private String knownHosts = System.getProperty("scp.known.hosts"); - private List cleanUpList = new ArrayList(); + private List<File> cleanUpList = new ArrayList<File>(); @Before public void setUp() { @@ -79,8 +79,7 @@ public class ScpTest { @After public void tearDown() { - for (Iterator i = cleanUpList.iterator(); i.hasNext();) { - File file = (File) i.next(); + for (File file : cleanUpList) { file.delete(); } } @@ -113,7 +112,7 @@ public class ScpTest { @Test public void testMultiUploadAndDownload() throws IOException { assertNotNull("system property scp.tmp must be set", tempDir); - List uploadList = new ArrayList(); + List<File> uploadList = new ArrayList<File>(); for (int i = 0; i < 5; i++) { uploadList.add(createTemporaryFile()); } @@ -137,8 +136,7 @@ public class ScpTest { scpTask.execute(); FilesMatch match = new FilesMatch(); - for (Iterator i = uploadList.iterator(); i.hasNext();) { - File f = (File) i.next(); + for (File f : uploadList) { match.setFile1(f); File f2 = new File(multi, f.getName()); match.setFile2(f2); http://git-wip-us.apache.org/repos/asf/ant/blob/8c38eb4c/src/tests/junit/org/apache/tools/ant/types/optional/depend/ClassFileSetTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/types/optional/depend/ClassFileSetTest.java b/src/tests/junit/org/apache/tools/ant/types/optional/depend/ClassFileSetTest.java index ce86f06..e225f13 100644 --- a/src/tests/junit/org/apache/tools/ant/types/optional/depend/ClassFileSetTest.java +++ b/src/tests/junit/org/apache/tools/ant/types/optional/depend/ClassFileSetTest.java @@ -59,8 +59,8 @@ public class ClassFileSetTest { DirectoryScanner scanner = resultFileSet.getDirectoryScanner(p); String[] scannedFiles = scanner.getIncludedFiles(); Hashtable files = new Hashtable(); - for (int i = 0; i < scannedFiles.length; ++i) { - files.put(scannedFiles[i], scannedFiles[i]); + for (String scannedFile : scannedFiles) { + files.put(scannedFile, scannedFile); } assertEquals("Classfileset did not pick up expected number of " + "class files", 4, files.size()); @@ -85,8 +85,8 @@ public class ClassFileSetTest { DirectoryScanner scanner = resultFileSet.getDirectoryScanner(p); String[] scannedFiles = scanner.getIncludedFiles(); Hashtable files = new Hashtable(); - for (int i = 0; i < scannedFiles.length; ++i) { - files.put(scannedFiles[i], scannedFiles[i]); + for (String scannedFile : scannedFiles) { + files.put(scannedFile, scannedFile); } assertEquals("Classfileset did not pick up expected number of " + "class files", 2, files.size()); @@ -107,8 +107,8 @@ public class ClassFileSetTest { DirectoryScanner scanner = resultFileSet.getDirectoryScanner(p); String[] scannedFiles = scanner.getIncludedFiles(); Hashtable files = new Hashtable(); - for (int i = 0; i < scannedFiles.length; ++i) { - files.put(scannedFiles[i], scannedFiles[i]); + for (String scannedFile : scannedFiles) { + files.put(scannedFile, scannedFile); } assertEquals("Classfileset did not pick up expected number of " + "class files", 1, files.size()); @@ -135,8 +135,8 @@ public class ClassFileSetTest { DirectoryScanner scanner = resultFileSet.getDirectoryScanner(p); String[] scannedFiles = scanner.getIncludedFiles(); Hashtable files = new Hashtable(); - for (int i = 0; i < scannedFiles.length; ++i) { - files.put(scannedFiles[i], scannedFiles[i]); + for (String scannedFile : scannedFiles) { + files.put(scannedFile, scannedFile); } assertEquals("Classfileset did not pick up expected number of " + "class files", 5, files.size()); @@ -163,8 +163,8 @@ public class ClassFileSetTest { DirectoryScanner scanner = resultFileSet.getDirectoryScanner(p); String[] scannedFiles = scanner.getIncludedFiles(); Hashtable files = new Hashtable(); - for (int i = 0; i < scannedFiles.length; ++i) { - files.put(scannedFiles[i], scannedFiles[i]); + for (String scannedFile : scannedFiles) { + files.put(scannedFile, scannedFile); } assertEquals("Classfileset did not pick up expected number of " + "class files", 4, files.size());