Bumping versions
This commit is contained in:
@@ -26,6 +26,7 @@ import org.junit.jupiter.api.extension.ExtendWith;
|
||||
/**
|
||||
* Taken from Spring Boot test utils. https://github.com/spring-projects/spring-boot/blob/
|
||||
* 1.4.x/spring-boot/src/test/java/org/springframework/boot/testutil/ClassPathExclusions.java
|
||||
*
|
||||
* @author Ryan Baxter
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
|
||||
@@ -99,7 +99,8 @@ final class ModifiedClassPathClassLoader extends URLClassLoader {
|
||||
candidates.add(testMethod);
|
||||
candidates.addAll(getAnnotatedElements(arguments.toArray()));
|
||||
List<AnnotatedElement> annotatedElements = candidates.stream()
|
||||
.filter(ModifiedClassPathClassLoader::hasAnnotation).collect(Collectors.toList());
|
||||
.filter(ModifiedClassPathClassLoader::hasAnnotation)
|
||||
.collect(Collectors.toList());
|
||||
if (annotatedElements.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
@@ -128,8 +129,8 @@ final class ModifiedClassPathClassLoader extends URLClassLoader {
|
||||
private static ModifiedClassPathClassLoader compute(ClassLoader classLoader,
|
||||
List<AnnotatedElement> annotatedClasses) {
|
||||
List<MergedAnnotations> annotations = annotatedClasses.stream()
|
||||
.map((source) -> MergedAnnotations.from(source, MergedAnnotations.SearchStrategy.TYPE_HIERARCHY))
|
||||
.toList();
|
||||
.map((source) -> MergedAnnotations.from(source, MergedAnnotations.SearchStrategy.TYPE_HIERARCHY))
|
||||
.toList();
|
||||
return new ModifiedClassPathClassLoader(processUrls(extractUrls(classLoader), annotations),
|
||||
classLoader.getParent(), classLoader);
|
||||
}
|
||||
@@ -152,7 +153,7 @@ final class ModifiedClassPathClassLoader extends URLClassLoader {
|
||||
return Stream.of(urlClassLoader.getURLs());
|
||||
}
|
||||
return Stream.of(ManagementFactory.getRuntimeMXBean().getClassPath().split(File.pathSeparator))
|
||||
.map(ModifiedClassPathClassLoader::toURL);
|
||||
.map(ModifiedClassPathClassLoader::toURL);
|
||||
}
|
||||
|
||||
private static URL toURL(String entry) {
|
||||
@@ -239,7 +240,8 @@ final class ModifiedClassPathClassLoader extends URLClassLoader {
|
||||
DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
|
||||
LocalRepository localRepository = new LocalRepository(System.getProperty("user.home") + "/.m2/repository");
|
||||
RemoteRepository remoteRepository = new RemoteRepository.Builder("central", "default",
|
||||
"https://repo.maven.apache.org/maven2").build();
|
||||
"https://repo.maven.apache.org/maven2")
|
||||
.build();
|
||||
session.setLocalRepositoryManager(repositorySystem.newLocalRepositoryManager(session, localRepository));
|
||||
for (int i = 0; i < MAX_RESOLUTION_ATTEMPTS; i++) {
|
||||
CollectRequest collectRequest = new CollectRequest(null, Arrays.asList(remoteRepository));
|
||||
|
||||
@@ -111,7 +111,8 @@ public class ModifiedClassPathExtension implements InvocationInterceptor {
|
||||
|
||||
private void runTest(String testId) throws Throwable {
|
||||
LauncherDiscoveryRequest request = LauncherDiscoveryRequestBuilder.request()
|
||||
.selectors(DiscoverySelectors.selectUniqueId(testId)).build();
|
||||
.selectors(DiscoverySelectors.selectUniqueId(testId))
|
||||
.build();
|
||||
Launcher launcher = LauncherFactory.create();
|
||||
TestPlan testPlan = launcher.discover(request);
|
||||
SummaryGeneratingListener listener = new SummaryGeneratingListener();
|
||||
|
||||
@@ -121,7 +121,7 @@ public class ModifiedClassPathRunner extends BlockJUnit4ClassRunner {
|
||||
return Stream.of(((URLClassLoader) classLoader).getURLs());
|
||||
}
|
||||
return Stream.of(ManagementFactory.getRuntimeMXBean().getClassPath().split(File.pathSeparator))
|
||||
.map(this::toURL);
|
||||
.map(this::toURL);
|
||||
}
|
||||
|
||||
private URL toURL(String entry) {
|
||||
@@ -286,7 +286,7 @@ public class ModifiedClassPathRunner extends BlockJUnit4ClassRunner {
|
||||
@SuppressWarnings("unchecked")
|
||||
private List<FrameworkMethod> getAnnotatedMethods(String annotationClassName) throws ClassNotFoundException {
|
||||
Class<? extends Annotation> annotationClass = (Class<? extends Annotation>) this.classLoader
|
||||
.loadClass(annotationClassName);
|
||||
.loadClass(annotationClassName);
|
||||
List<FrameworkMethod> methods = super.getAnnotatedMethods(annotationClass);
|
||||
return wrapFrameworkMethods(methods);
|
||||
}
|
||||
|
||||
@@ -192,8 +192,8 @@ public abstract class TestSocketUtils {
|
||||
@Override
|
||||
protected boolean isPortAvailable(int port) {
|
||||
try {
|
||||
ServerSocket serverSocket = ServerSocketFactory.getDefault().createServerSocket(port, 1,
|
||||
InetAddress.getByName("localhost"));
|
||||
ServerSocket serverSocket = ServerSocketFactory.getDefault()
|
||||
.createServerSocket(port, 1, InetAddress.getByName("localhost"));
|
||||
serverSocket.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -34,13 +34,13 @@ public class ModifiedClassPathRunnerOverridesTests {
|
||||
@Test
|
||||
public void classesAreLoadedFromOverride() {
|
||||
assertThat(ApplicationContext.class.getProtectionDomain().getCodeSource().getLocation().toString())
|
||||
.endsWith("spring-context-4.1.0.RELEASE.jar");
|
||||
.endsWith("spring-context-4.1.0.RELEASE.jar");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void classesAreLoadedFromTransitiveDependencyOfOverride() {
|
||||
assertThat(StringUtils.class.getProtectionDomain().getCodeSource().getLocation().toString())
|
||||
.endsWith("spring-core-4.1.0.RELEASE.jar");
|
||||
.endsWith("spring-core-4.1.0.RELEASE.jar");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -65,13 +65,13 @@ class TestSocketUtilsTests {
|
||||
@Test
|
||||
void findAvailableTcpPortWhenPortOnLoopbackInterfaceIsNotAvailable() throws Exception {
|
||||
int port = TestSocketUtils.findAvailableTcpPort();
|
||||
try (ServerSocket socket = ServerSocketFactory.getDefault().createServerSocket(port, 1,
|
||||
InetAddress.getByName("localhost"))) {
|
||||
try (ServerSocket socket = ServerSocketFactory.getDefault()
|
||||
.createServerSocket(port, 1, InetAddress.getByName("localhost"))) {
|
||||
assertThat(socket).isNotNull();
|
||||
// will only look for the exact port
|
||||
assertThatIllegalStateException().isThrownBy(() -> TestSocketUtils.findAvailableTcpPort(port, port))
|
||||
.withMessageStartingWith("Could not find an available TCP port")
|
||||
.withMessageEndingWith("after 1 attempts");
|
||||
.withMessageStartingWith("Could not find an available TCP port")
|
||||
.withMessageEndingWith("after 1 attempts");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,8 +139,8 @@ class TestSocketUtilsTests {
|
||||
assertThat(socket).isNotNull();
|
||||
// will only look for the exact port
|
||||
assertThatIllegalStateException().isThrownBy(() -> TestSocketUtils.findAvailableUdpPort(port, port))
|
||||
.withMessageStartingWith("Could not find an available UDP port")
|
||||
.withMessageEndingWith("after 1 attempts");
|
||||
.withMessageStartingWith("Could not find an available UDP port")
|
||||
.withMessageEndingWith("after 1 attempts");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user