Remove accidental usage of Plexus's CollectionUtils

See gh-16655 and 8f5777cf
pull/19399/head
Andy Wilkinson 5 years ago
parent 1b1c61a2ed
commit ef2eb2f652

@ -18,9 +18,9 @@ package org.springframework.boot.loader;
import java.io.File;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import org.codehaus.plexus.util.CollectionUtils;
import org.junit.jupiter.api.Test;
import org.springframework.boot.loader.archive.Archive;
@ -40,7 +40,8 @@ class JarLauncherTests extends AbstractExecutableArchiveLauncherTests {
void explodedJarHasOnlyBootInfClassesAndContentsOfBootInfLibOnClasspath() throws Exception {
File explodedRoot = explode(createJarArchive("archive.jar", "BOOT-INF"));
JarLauncher launcher = new JarLauncher(new ExplodedArchive(explodedRoot, true));
List<Archive> archives = CollectionUtils.iteratorToList(launcher.getClassPathArchivesIterator());
List<Archive> archives = new ArrayList<>();
launcher.getClassPathArchivesIterator().forEachRemaining(archives::add);
assertThat(archives).hasSize(2);
assertThat(getUrls(archives)).containsOnly(new File(explodedRoot, "BOOT-INF/classes").toURI().toURL(),
new File(explodedRoot, "BOOT-INF/lib/foo.jar").toURI().toURL());
@ -54,7 +55,8 @@ class JarLauncherTests extends AbstractExecutableArchiveLauncherTests {
File jarRoot = createJarArchive("archive.jar", "BOOT-INF");
try (JarFileArchive archive = new JarFileArchive(jarRoot)) {
JarLauncher launcher = new JarLauncher(archive);
List<Archive> classPathArchives = CollectionUtils.iteratorToList(launcher.getClassPathArchivesIterator());
List<Archive> classPathArchives = new ArrayList<>();
launcher.getClassPathArchivesIterator().forEachRemaining(classPathArchives::add);
assertThat(classPathArchives).hasSize(2);
assertThat(getUrls(classPathArchives)).containsOnly(
new URL("jar:" + jarRoot.toURI().toURL() + "!/BOOT-INF/classes!/"),

@ -30,7 +30,6 @@ import java.util.jar.Manifest;
import org.assertj.core.api.Condition;
import org.awaitility.Awaitility;
import org.codehaus.plexus.util.CollectionUtils;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@ -140,7 +139,8 @@ class PropertiesLauncherTests {
System.setProperty("loader.path", "jars/");
PropertiesLauncher launcher = new PropertiesLauncher();
assertThat(ReflectionTestUtils.getField(launcher, "paths").toString()).isEqualTo("[jars/]");
List<Archive> archives = CollectionUtils.iteratorToList(launcher.getClassPathArchivesIterator());
List<Archive> archives = new ArrayList<>();
launcher.getClassPathArchivesIterator().forEachRemaining(archives::add);
assertThat(archives).areExactly(1, endingWith("app.jar"));
}
@ -170,7 +170,8 @@ class PropertiesLauncherTests {
PropertiesLauncher launcher = new PropertiesLauncher();
assertThat(ReflectionTestUtils.getField(launcher, "paths").toString())
.isEqualTo("[jar:file:./src/test/resources/nested-jars/app.jar!/]");
List<Archive> archives = CollectionUtils.iteratorToList(launcher.getClassPathArchivesIterator());
List<Archive> archives = new ArrayList<>();
launcher.getClassPathArchivesIterator().forEachRemaining(archives::add);
assertThat(archives).areExactly(1, endingWith("foo.jar!/"));
assertThat(archives).areExactly(1, endingWith("app.jar"));
}
@ -179,7 +180,8 @@ class PropertiesLauncherTests {
void testUserSpecifiedRootOfJarPathWithDot() throws Exception {
System.setProperty("loader.path", "nested-jars/app.jar!/./");
PropertiesLauncher launcher = new PropertiesLauncher();
List<Archive> archives = CollectionUtils.iteratorToList(launcher.getClassPathArchivesIterator());
List<Archive> archives = new ArrayList<>();
launcher.getClassPathArchivesIterator().forEachRemaining(archives::add);
assertThat(archives).areExactly(1, endingWith("foo.jar!/"));
assertThat(archives).areExactly(1, endingWith("app.jar"));
}
@ -188,7 +190,8 @@ class PropertiesLauncherTests {
void testUserSpecifiedRootOfJarPathWithDotAndJarPrefix() throws Exception {
System.setProperty("loader.path", "jar:file:./src/test/resources/nested-jars/app.jar!/./");
PropertiesLauncher launcher = new PropertiesLauncher();
List<Archive> archives = CollectionUtils.iteratorToList(launcher.getClassPathArchivesIterator());
List<Archive> archives = new ArrayList<>();
launcher.getClassPathArchivesIterator().forEachRemaining(archives::add);
assertThat(archives).areExactly(1, endingWith("foo.jar!/"));
}
@ -197,7 +200,8 @@ class PropertiesLauncherTests {
System.setProperty("loader.path", "nested-jars/app.jar");
System.setProperty("loader.main", "demo.Application");
PropertiesLauncher launcher = new PropertiesLauncher();
List<Archive> archives = CollectionUtils.iteratorToList(launcher.getClassPathArchivesIterator());
List<Archive> archives = new ArrayList<>();
launcher.getClassPathArchivesIterator().forEachRemaining(archives::add);
assertThat(archives).areExactly(1, endingWith("foo.jar!/"));
assertThat(archives).areExactly(1, endingWith("app.jar"));
}
@ -207,7 +211,8 @@ class PropertiesLauncherTests {
System.setProperty("loader.path", "nested-jars/app.jar!/foo.jar");
System.setProperty("loader.main", "demo.Application");
PropertiesLauncher launcher = new PropertiesLauncher();
List<Archive> archives = CollectionUtils.iteratorToList(launcher.getClassPathArchivesIterator());
List<Archive> archives = new ArrayList<>();
launcher.getClassPathArchivesIterator().forEachRemaining(archives::add);
assertThat(archives).hasSize(1).areExactly(1, endingWith("foo.jar!/"));
}
@ -336,7 +341,8 @@ class PropertiesLauncherTests {
loaderPath.mkdir();
System.setProperty("loader.path", loaderPath.toURI().toURL().toString());
PropertiesLauncher launcher = new PropertiesLauncher();
List<Archive> archives = CollectionUtils.iteratorToList(launcher.getClassPathArchivesIterator());
List<Archive> archives = new ArrayList<>();
launcher.getClassPathArchivesIterator().forEachRemaining(archives::add);
assertThat(archives.size()).isEqualTo(1);
File archiveRoot = (File) ReflectionTestUtils.getField(archives.get(0), "root");
assertThat(archiveRoot).isEqualTo(loaderPath);

@ -18,9 +18,9 @@ package org.springframework.boot.loader;
import java.io.File;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import org.codehaus.plexus.util.CollectionUtils;
import org.junit.jupiter.api.Test;
import org.springframework.boot.loader.archive.Archive;
@ -40,7 +40,8 @@ class WarLauncherTests extends AbstractExecutableArchiveLauncherTests {
void explodedWarHasOnlyWebInfClassesAndContentsOfWebInfLibOnClasspath() throws Exception {
File explodedRoot = explode(createJarArchive("archive.war", "WEB-INF"));
WarLauncher launcher = new WarLauncher(new ExplodedArchive(explodedRoot, true));
List<Archive> archives = CollectionUtils.iteratorToList(launcher.getClassPathArchivesIterator());
List<Archive> archives = new ArrayList<>();
launcher.getClassPathArchivesIterator().forEachRemaining(archives::add);
assertThat(archives).hasSize(2);
assertThat(getUrls(archives)).containsOnly(new File(explodedRoot, "WEB-INF/classes").toURI().toURL(),
new File(explodedRoot, "WEB-INF/lib/foo.jar").toURI().toURL());
@ -54,7 +55,8 @@ class WarLauncherTests extends AbstractExecutableArchiveLauncherTests {
File jarRoot = createJarArchive("archive.war", "WEB-INF");
try (JarFileArchive archive = new JarFileArchive(jarRoot)) {
WarLauncher launcher = new WarLauncher(archive);
List<Archive> classPathArchives = CollectionUtils.iteratorToList(launcher.getClassPathArchivesIterator());
List<Archive> classPathArchives = new ArrayList<>();
launcher.getClassPathArchivesIterator().forEachRemaining(classPathArchives::add);
assertThat(classPathArchives).hasSize(2);
assertThat(getUrls(classPathArchives)).containsOnly(
new URL("jar:" + jarRoot.toURI().toURL() + "!/WEB-INF/classes!/"),

Loading…
Cancel
Save