Repository: ant Updated Branches: refs/heads/master 44cb39844 -> 97ac63abc
Make loops less verbose Project: http://git-wip-us.apache.org/repos/asf/ant/repo Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/97ac63ab Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/97ac63ab Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/97ac63ab Branch: refs/heads/master Commit: 97ac63abcb9cb953b0a4627f97859a43266c872c Parents: 44cb398 Author: Gintas Grigelionis <[email protected]> Authored: Thu Apr 26 16:08:57 2018 +0200 Committer: Gintas Grigelionis <[email protected]> Committed: Thu Apr 26 16:08:57 2018 +0200 ---------------------------------------------------------------------- .../tools/ant/IntrospectionHelperTest.java | 10 +++------ .../tools/ant/taskdefs/XmlPropertyTest.java | 23 +++++++++----------- .../org/apache/tools/zip/UTF8ZipFilesTest.java | 7 ++---- 3 files changed, 15 insertions(+), 25 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ant/blob/97ac63ab/src/tests/junit/org/apache/tools/ant/IntrospectionHelperTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/IntrospectionHelperTest.java b/src/tests/junit/org/apache/tools/ant/IntrospectionHelperTest.java index 262dc67..dc2bfab 100644 --- a/src/tests/junit/org/apache/tools/ant/IntrospectionHelperTest.java +++ b/src/tests/junit/org/apache/tools/ant/IntrospectionHelperTest.java @@ -23,7 +23,7 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.nio.file.Path; import java.nio.file.Paths; -import java.util.Enumeration; +import java.util.Collections; import java.util.HashMap; import java.util.Hashtable; import java.util.List; @@ -253,9 +253,7 @@ public class IntrospectionHelperTest { @Test public void testGetNestedElements() { Map<String, Class<?>> elemMap = getExpectedNestedElements(); - Enumeration<String> e = ih.getNestedElements(); - while (e.hasMoreElements()) { - String name = e.nextElement(); + for (String name : Collections.list(ih.getNestedElements())) { Class<?> expect = elemMap.get(name); assertNotNull("Support for " + name + " in IntrospectioNHelperTest?", expect); @@ -594,9 +592,7 @@ public class IntrospectionHelperTest { @Test public void testGetAttributes() { Map<String, Class<?>> attrMap = getExpectedAttributes(); - Enumeration<String> e = ih.getAttributes(); - while (e.hasMoreElements()) { - String name = e.nextElement(); + for (String name : Collections.list(ih.getAttributes())) { Class<?> expect = attrMap.get(name); assertNotNull("Support for " + name + " in IntrospectionHelperTest?", expect); http://git-wip-us.apache.org/repos/asf/ant/blob/97ac63ab/src/tests/junit/org/apache/tools/ant/taskdefs/XmlPropertyTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/ant/taskdefs/XmlPropertyTest.java b/src/tests/junit/org/apache/tools/ant/taskdefs/XmlPropertyTest.java index c02deb7..391c45c 100644 --- a/src/tests/junit/org/apache/tools/ant/taskdefs/XmlPropertyTest.java +++ b/src/tests/junit/org/apache/tools/ant/taskdefs/XmlPropertyTest.java @@ -22,11 +22,11 @@ import java.io.File; import java.io.FileFilter; import java.io.FileInputStream; import java.io.IOException; -import java.util.Enumeration; +import java.util.ArrayList; import java.util.Hashtable; import java.util.Map; +import java.util.List; import java.util.Properties; -import java.util.Vector; import org.apache.tools.ant.BuildFileRule; import org.apache.tools.ant.Project; @@ -149,10 +149,7 @@ public class XmlPropertyTest { */ private void doTest(String msg, boolean keepRoot, boolean collapse, boolean semantic, boolean include, boolean localRoot) throws IOException { - Enumeration<File> iter = - getFiles(buildRule.getProject().resolveFile("xmlproperty/inputs")); - while (iter.hasMoreElements()) { - File inputFile = iter.nextElement(); + for (File inputFile : getFiles(buildRule.getProject().resolveFile("xmlproperty/inputs"))) { // What's the working directory? If local, then its the // folder of the input file. Otherwise, its the "current" dir.. File workingDir; @@ -325,30 +322,30 @@ public class XmlPropertyTest { * Retrieve a list of xml files in the specified folder * and below. */ - private static Enumeration<File> getFiles(final File startingDir) { - Vector<File> result = new Vector<>(); + private static List<File> getFiles(final File startingDir) { + List<File> result = new ArrayList<>(); getFiles(startingDir, result); - return result.elements(); + return result; } /** * Collect a list of xml files in the specified folder * and below. */ - private static void getFiles(final File startingDir, Vector<File> collect) { + private static void getFiles(final File startingDir, List<File> collect) { FileFilter filter = file -> { if (file.isDirectory()) { return true; } else { - return (file.getPath().indexOf("taskdefs") > 0 && - file.getPath().toLowerCase().endsWith(".xml")); + return file.getPath().contains("taskdefs") + && file.getPath().toLowerCase().endsWith(".xml"); } }; File[] files = startingDir.listFiles(filter); for (File f : files) { if (!f.isDirectory()) { - collect.addElement(f); + collect.add(f); } else { getFiles(f, collect); } http://git-wip-us.apache.org/repos/asf/ant/blob/97ac63ab/src/tests/junit/org/apache/tools/zip/UTF8ZipFilesTest.java ---------------------------------------------------------------------- diff --git a/src/tests/junit/org/apache/tools/zip/UTF8ZipFilesTest.java b/src/tests/junit/org/apache/tools/zip/UTF8ZipFilesTest.java index 39828a5..15efb17 100644 --- a/src/tests/junit/org/apache/tools/zip/UTF8ZipFilesTest.java +++ b/src/tests/junit/org/apache/tools/zip/UTF8ZipFilesTest.java @@ -22,6 +22,7 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; import java.nio.ByteBuffer; +import java.util.Collections; import java.util.Enumeration; import java.util.zip.CRC32; import org.junit.Test; @@ -189,11 +190,7 @@ public class UTF8ZipFilesTest { ZipFile zf = null; try { zf = new ZipFile(file, encoding, false); - - Enumeration<ZipEntry> e = zf.getEntries(); - while (e.hasMoreElements()) { - ZipEntry ze = e.nextElement(); - + for (ZipEntry ze : Collections.list(zf.getEntries())) { if (ze.getName().endsWith("sser.txt")) { assertUnicodeName(ze, OIL_BARREL_TXT, encoding);
