| @@ -34,6 +34,7 @@ import java.util.Iterator; | |||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Set; | import java.util.Set; | ||||
| import java.util.TreeSet; | import java.util.TreeSet; | ||||
| import java.util.stream.Collectors; | |||||
| import org.apache.tools.ant.taskdefs.condition.Os; | import org.apache.tools.ant.taskdefs.condition.Os; | ||||
| import org.apache.tools.ant.types.selectors.TokenizedPath; | import org.apache.tools.ant.types.selectors.TokenizedPath; | ||||
| @@ -486,14 +487,13 @@ public class DirectoryScannerTest { | |||||
| assertEquals("directories present: ", expectedDirectories.length, | assertEquals("directories present: ", expectedDirectories.length, | ||||
| includedDirectories.length); | includedDirectories.length); | ||||
| TreeSet<String> files = new TreeSet<>(); | |||||
| for (String includedFile : includedFiles) { | |||||
| files.add(includedFile.replace(File.separatorChar, '/')); | |||||
| } | |||||
| TreeSet<String> directories = new TreeSet<>(); | |||||
| for (String includedDirectory : includedDirectories) { | |||||
| directories.add(includedDirectory.replace(File.separatorChar, '/')); | |||||
| } | |||||
| TreeSet<String> files = Arrays.stream(includedFiles) | |||||
| .map(includedFile -> includedFile.replace(File.separatorChar, '/')) | |||||
| .collect(Collectors.toCollection(TreeSet::new)); | |||||
| TreeSet<String> directories = Arrays.stream(includedDirectories) | |||||
| .map(includedDirectory -> includedDirectory.replace(File.separatorChar, '/')) | |||||
| .collect(Collectors.toCollection(TreeSet::new)); | |||||
| String currentfile; | String currentfile; | ||||
| Iterator<String> i = files.iterator(); | Iterator<String> i = files.iterator(); | ||||
| @@ -23,6 +23,7 @@ import org.apache.tools.ant.util.FileUtils; | |||||
| import java.io.File; | import java.io.File; | ||||
| import java.io.FileReader; | import java.io.FileReader; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.util.Arrays; | |||||
| import static org.junit.Assume.assumeTrue; | import static org.junit.Assume.assumeTrue; | ||||
| @@ -71,9 +72,7 @@ public class FileUtilities { | |||||
| if (children == null) { | if (children == null) { | ||||
| return; | return; | ||||
| } | } | ||||
| for (File child : children) { | |||||
| rollbackTimestamps(child, seconds); | |||||
| } | |||||
| Arrays.stream(children).forEach(child -> rollbackTimestamps(child, seconds)); | |||||
| } | } | ||||
| } | } | ||||
| @@ -25,6 +25,8 @@ import org.junit.Before; | |||||
| import org.junit.Rule; | import org.junit.Rule; | ||||
| import org.junit.Test; | import org.junit.Test; | ||||
| import java.util.Arrays; | |||||
| import static org.junit.Assert.assertEquals; | import static org.junit.Assert.assertEquals; | ||||
| import static org.junit.Assert.assertTrue; | import static org.junit.Assert.assertTrue; | ||||
| @@ -158,16 +160,8 @@ public class DefaultExcludesTest { | |||||
| // check that both arrays have the same size | // check that both arrays have the same size | ||||
| assertEquals(message + " : string array length match", expected.length, actual.length); | assertEquals(message + " : string array length match", expected.length, actual.length); | ||||
| for (String element : expected) { | for (String element : expected) { | ||||
| boolean found = false; | |||||
| for (String member : actual) { | |||||
| found |= element.equals(member); | |||||
| if (found) { | |||||
| break; | |||||
| } | |||||
| } | |||||
| assertTrue(message + " : didn't find element " | |||||
| + element + " in array match", found); | |||||
| assertTrue(message + " : didn't find element " + element + " in array match", | |||||
| Arrays.stream(actual).anyMatch(member -> member.equals(element))); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -25,6 +25,8 @@ import java.util.Collections; | |||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Set; | import java.util.Set; | ||||
| import java.util.TreeSet; | import java.util.TreeSet; | ||||
| import java.util.stream.Collectors; | |||||
| import org.apache.tools.ant.Project; | import org.apache.tools.ant.Project; | ||||
| import org.apache.tools.ant.taskdefs.Javac; | import org.apache.tools.ant.taskdefs.Javac; | ||||
| import org.apache.tools.ant.types.Commandline; | import org.apache.tools.ant.types.Commandline; | ||||
| @@ -397,11 +399,8 @@ public class DefaultCompilerAdapterTest { | |||||
| Collections.addAll(expectedFiles, | Collections.addAll(expectedFiles, | ||||
| java1.getAbsolutePath(), | java1.getAbsolutePath(), | ||||
| java2.getAbsolutePath()); | java2.getAbsolutePath()); | ||||
| final Set<String> actualFiles = new TreeSet<>(); | |||||
| for (File compileFile : compileList) { | |||||
| actualFiles.add(compileFile.getAbsolutePath()); | |||||
| } | |||||
| assertEquals(expectedFiles, actualFiles); | |||||
| assertEquals(expectedFiles, Arrays.stream(compileList) | |||||
| .map(File::getAbsolutePath).collect(Collectors.toCollection(TreeSet::new))); | |||||
| } finally { | } finally { | ||||
| delete(workDir); | delete(workDir); | ||||
| } | } | ||||
| @@ -525,9 +524,7 @@ public class DefaultCompilerAdapterTest { | |||||
| if (f.isDirectory()) { | if (f.isDirectory()) { | ||||
| final File[] clds = f.listFiles(); | final File[] clds = f.listFiles(); | ||||
| if (clds != null) { | if (clds != null) { | ||||
| for (File cld : clds) { | |||||
| delete(cld); | |||||
| } | |||||
| Arrays.stream(clds).forEach(this::delete); | |||||
| } | } | ||||
| } | } | ||||
| f.delete(); | f.delete(); | ||||
| @@ -593,7 +593,7 @@ public class JUnitTaskTest { | |||||
| } | } | ||||
| @Test | @Test | ||||
| public void testCheckNonDuplicateAntJar() throws Exception { | |||||
| public void testCheckNonDuplicateAntJar() { | |||||
| setupCheckDuplicateTest(); | setupCheckDuplicateTest(); | ||||
| buildRule.getProject().setProperty("includeantruntime", "no"); | buildRule.getProject().setProperty("includeantruntime", "no"); | ||||
| buildRule.executeTarget("testCheckForkedPath"); | buildRule.executeTarget("testCheckForkedPath"); | ||||
| @@ -605,9 +605,7 @@ public class JUnitTaskTest { | |||||
| if (f.isDirectory()) { | if (f.isDirectory()) { | ||||
| final File[] clds = f.listFiles(); | final File[] clds = f.listFiles(); | ||||
| if (clds != null) { | if (clds != null) { | ||||
| for (File cld : clds) { | |||||
| delete(cld); | |||||
| } | |||||
| Arrays.stream(clds).forEach(this::delete); | |||||
| } | } | ||||
| } | } | ||||
| f.delete(); | f.delete(); | ||||
| @@ -63,20 +63,18 @@ public class FTPTest { | |||||
| private String loginFailureMessage; | private String loginFailureMessage; | ||||
| private String tmpDir = null; | |||||
| private String remoteTmpDir = null; | private String remoteTmpDir = null; | ||||
| private String ftpFileSep = null; | |||||
| private myFTP myFTPTask = new myFTP(); | |||||
| private myFTP myFTPTask = new myFTP(); | |||||
| @Before | @Before | ||||
| public void setUp() { | public void setUp() { | ||||
| buildRule.configureProject("src/etc/testcases/taskdefs/optional/net/ftp.xml"); | buildRule.configureProject("src/etc/testcases/taskdefs/optional/net/ftp.xml"); | ||||
| Project project = buildRule.getProject(); | Project project = buildRule.getProject(); | ||||
| project.executeTarget("setup"); | project.executeTarget("setup"); | ||||
| tmpDir = project.getProperty("tmp.dir"); | |||||
| String tmpDir = project.getProperty("tmp.dir"); | |||||
| ftp = new FTPClient(); | ftp = new FTPClient(); | ||||
| ftpFileSep = project.getProperty("ftp.filesep"); | |||||
| String ftpFileSep = project.getProperty("ftp.filesep"); | |||||
| myFTPTask.setSeparator(ftpFileSep); | myFTPTask.setSeparator(ftpFileSep); | ||||
| myFTPTask.setProject(project); | myFTPTask.setProject(project); | ||||
| remoteTmpDir = myFTPTask.resolveFile(tmpDir); | remoteTmpDir = myFTPTask.resolveFile(tmpDir); | ||||
| @@ -643,9 +641,7 @@ public class FTPTest { | |||||
| "custom config: server language code = de" | "custom config: server language code = de" | ||||
| }; | }; | ||||
| LogCounter counter = new LogCounter(); | LogCounter counter = new LogCounter(); | ||||
| for (String message : messages) { | |||||
| counter.addLogMessageToSearch(message); | |||||
| } | |||||
| Arrays.stream(messages).forEach(counter::addLogMessageToSearch); | |||||
| buildRule.getProject().addBuildListener(counter); | buildRule.getProject().addBuildListener(counter); | ||||
| buildRule.getProject().executeTarget(target); | buildRule.getProject().executeTarget(target); | ||||
| @@ -795,9 +791,7 @@ public class FTPTest { | |||||
| "Failed to issue Site Command: umask 222", | "Failed to issue Site Command: umask 222", | ||||
| }; | }; | ||||
| LogCounter counter = new LogCounter(); | LogCounter counter = new LogCounter(); | ||||
| for (String message : messages) { | |||||
| counter.addLogMessageToSearch(message); | |||||
| } | |||||
| Arrays.stream(messages).forEach(counter::addLogMessageToSearch); | |||||
| buildRule.getProject().addBuildListener(counter); | buildRule.getProject().addBuildListener(counter); | ||||
| buildRule.getProject().executeTarget(target); | buildRule.getProject().executeTarget(target); | ||||
| @@ -21,6 +21,8 @@ package org.apache.tools.ant.types; | |||||
| import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
| import org.junit.Test; | import org.junit.Test; | ||||
| import java.util.Arrays; | |||||
| import static org.junit.Assert.assertEquals; | import static org.junit.Assert.assertEquals; | ||||
| import static org.junit.Assert.assertFalse; | import static org.junit.Assert.assertFalse; | ||||
| import static org.junit.Assert.assertTrue; | import static org.junit.Assert.assertTrue; | ||||
| @@ -57,10 +59,7 @@ public class EnumeratedAttributeTest { | |||||
| @Test | @Test | ||||
| public void testExceptionsNormal() { | public void testExceptionsNormal() { | ||||
| EnumeratedAttribute t1 = new TestNormal(); | |||||
| for (String value : expected) { | |||||
| t1.setValue(value); | |||||
| } | |||||
| Arrays.stream(expected).forEach(new TestNormal()::setValue); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -83,7 +83,7 @@ public class MapperResult extends Task { | |||||
| if (result == null) { | if (result == null) { | ||||
| flattened = NULL_MAPPER_RESULT; | flattened = NULL_MAPPER_RESULT; | ||||
| } else { | } else { | ||||
| flattened = Arrays.asList(result).stream().collect(Collectors.joining("|")); | |||||
| flattened = Arrays.stream(result).collect(Collectors.joining("|")); | |||||
| } | } | ||||
| if (!flattened.equals(output)) { | if (!flattened.equals(output)) { | ||||
| throw new BuildException(failMessage + " got " + flattened + " expected " + output); | throw new BuildException(failMessage + " got " + flattened + " expected " + output); | ||||