diff --git a/src/tests/junit/org/apache/tools/ant/IntrospectionHelperTest.java b/src/tests/junit/org/apache/tools/ant/IntrospectionHelperTest.java index 262dc67f0..dc2bfab83 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> elemMap = getExpectedNestedElements(); - Enumeration 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> attrMap = getExpectedAttributes(); - Enumeration 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); 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 c02deb7d4..391c45c39 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 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 getFiles(final File startingDir) { - Vector result = new Vector<>(); + private static List getFiles(final File startingDir) { + List 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 collect) { + private static void getFiles(final File startingDir, List 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); } diff --git a/src/tests/junit/org/apache/tools/zip/UTF8ZipFilesTest.java b/src/tests/junit/org/apache/tools/zip/UTF8ZipFilesTest.java index 39828a56a..15efb17d2 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 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);