| @@ -267,13 +267,12 @@ public class IntrospectionHelperTest { | |||
| public void testGetNestedElementMap() { | |||
| Map<String, Class<?>> elemMap = getExpectedNestedElements(); | |||
| Map<String, Class<?>> actualMap = ih.getNestedElementMap(); | |||
| for (Map.Entry<String, Class<?>> entry : actualMap.entrySet()) { | |||
| String elemName = entry.getKey(); | |||
| actualMap.forEach((elemName, value) -> { | |||
| Class<?> elemClass = elemMap.get(elemName); | |||
| assertNotNull("Support for " + elemName + " in IntrospectionHelperTest?", elemClass); | |||
| assertEquals("Type of " + elemName, elemClass, entry.getValue()); | |||
| assertEquals("Type of " + elemName, elemClass, value); | |||
| elemMap.remove(elemName); | |||
| } | |||
| }); | |||
| assertTrue("Found all", elemMap.isEmpty()); | |||
| // Check it's a read-only map. | |||
| @@ -607,13 +606,12 @@ public class IntrospectionHelperTest { | |||
| public void testGetAttributeMap() { | |||
| Map<String, Class<?>> attrMap = getExpectedAttributes(); | |||
| Map<String, Class<?>> actualMap = ih.getAttributeMap(); | |||
| for (Map.Entry<String, Class<?>> entry : actualMap.entrySet()) { | |||
| String attrName = entry.getKey(); | |||
| actualMap.forEach((attrName, value) -> { | |||
| Class<?> attrClass = attrMap.get(attrName); | |||
| assertNotNull("Support for " + attrName + " in IntrospectionHelperTest?", attrClass); | |||
| assertEquals("Type of " + attrName, attrClass, entry.getValue()); | |||
| assertEquals("Type of " + attrName, attrClass, value); | |||
| attrMap.remove(attrName); | |||
| } | |||
| }); | |||
| attrMap.remove("name"); | |||
| assertTrue("Found all", attrMap.isEmpty()); | |||
| @@ -20,6 +20,7 @@ package org.apache.tools.ant.taskdefs; | |||
| import java.io.BufferedReader; | |||
| import java.io.InputStreamReader; | |||
| import java.util.stream.Collectors; | |||
| import org.apache.tools.ant.util.JavaEnvUtils; | |||
| import org.junit.Before; | |||
| @@ -75,12 +76,7 @@ public class ExecuteWatchdogTest { | |||
| private String getErrorOutput(Process p) throws Exception { | |||
| BufferedReader err = new BufferedReader(new InputStreamReader(p.getErrorStream())); | |||
| StringBuilder buf = new StringBuilder(); | |||
| String line; | |||
| while ((line = err.readLine()) != null) { | |||
| buf.append(line); | |||
| } | |||
| return buf.toString(); | |||
| return err.lines().collect(Collectors.joining()); | |||
| } | |||
| private int waitForEnd(Process p) throws Exception { | |||
| @@ -24,6 +24,7 @@ import java.io.FileReader; | |||
| import java.io.InputStream; | |||
| import java.io.InputStreamReader; | |||
| import java.io.IOException; | |||
| import java.util.Collections; | |||
| import java.util.Enumeration; | |||
| import java.util.zip.ZipEntry; | |||
| import java.util.zip.ZipFile; | |||
| @@ -239,15 +240,8 @@ public class JarTest { | |||
| public void testNoDuplicateIndex() throws IOException { | |||
| buildRule.executeTarget("testIndexTests"); | |||
| try (ZipFile archive = new ZipFile(new File(getOutputDir(), tempJar))) { | |||
| Enumeration<? extends ZipEntry> e = archive.entries(); | |||
| int numberOfIndexLists = 0; | |||
| while (e.hasMoreElements()) { | |||
| ZipEntry ze = e.nextElement(); | |||
| if (ze.getName().equals("META-INF/INDEX.LIST")) { | |||
| numberOfIndexLists++; | |||
| } | |||
| } | |||
| assertEquals(1, numberOfIndexLists); | |||
| assertEquals(1, (int) Collections.list(archive.entries()).stream() | |||
| .filter(ze -> ze.getName().equals("META-INF/INDEX.LIST")).count()); | |||
| } | |||
| } | |||
| @@ -24,7 +24,6 @@ import java.io.FileInputStream; | |||
| import java.io.IOException; | |||
| import java.util.ArrayList; | |||
| import java.util.Hashtable; | |||
| import java.util.Map; | |||
| import java.util.List; | |||
| import java.util.Properties; | |||
| @@ -159,7 +158,6 @@ public class XmlPropertyTest { | |||
| workingDir = FILE_UTILS.resolveFile(new File("."), "."); | |||
| } | |||
| File propertyFile = getGoldfile(inputFile, keepRoot, collapse, | |||
| semantic, include, localRoot); | |||
| if (!propertyFile.exists()) { | |||
| @@ -269,13 +267,9 @@ public class XmlPropertyTest { | |||
| */ | |||
| private static void ensureReferences(String msg, File inputFile, | |||
| Hashtable<String, Object> references) { | |||
| for (Map.Entry<String, Object> entry : references.entrySet()) { | |||
| String currentKey = entry.getKey(); | |||
| Object currentValue = entry.getValue(); | |||
| assertTrue(msg + "-" + inputFile.getName() + " Key=" + currentKey | |||
| + " is not a recognized type.", currentValue instanceof Path | |||
| || currentValue instanceof String || currentKey.startsWith("ant.")); | |||
| } | |||
| references.forEach((key, value) -> assertTrue(msg + "-" + inputFile.getName() | |||
| + " Key=" + key + " is not a recognized type.", | |||
| value instanceof Path || value instanceof String || key.startsWith("ant."))); | |||
| } | |||
| /** | |||