From 01ee6190a287f91f107f6bea4ccbe19ef4d44966 Mon Sep 17 00:00:00 2001 From: dreis2211 Date: Fri, 21 May 2021 15:54:15 +0200 Subject: [PATCH] Remove workaround for SUREFIRE-1679 See gh-26632 --- .../build.gradle | 3 +- ...izerFactoryWithAutoConfigurationTests.java | 22 ++++---- ...ebMvcTestPrintDefaultIntegrationTests.java | 20 +++---- .../spring-boot-test-support/build.gradle | 1 + .../classpath/ModifiedClassPathExtension.java | 31 ++++++----- .../testsupport/junit/platform/Launcher.java | 52 ------------------ .../platform/LauncherDiscoveryRequest.java | 34 ------------ .../LauncherDiscoveryRequestBuilder.java | 54 ------------------- .../junit/platform/ReflectiveWrapper.java | 50 ----------------- .../platform/SummaryGeneratingListener.java | 38 ------------- .../junit/platform/TestExecutionSummary.java | 50 ----------------- .../junit/platform/package-info.java | 21 -------- 12 files changed, 42 insertions(+), 334 deletions(-) delete mode 100644 spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/platform/Launcher.java delete mode 100644 spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/platform/LauncherDiscoveryRequest.java delete mode 100644 spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/platform/LauncherDiscoveryRequestBuilder.java delete mode 100644 spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/platform/ReflectiveWrapper.java delete mode 100644 spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/platform/SummaryGeneratingListener.java delete mode 100644 spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/platform/TestExecutionSummary.java delete mode 100644 spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/platform/package-info.java diff --git a/spring-boot-project/spring-boot-test-autoconfigure/build.gradle b/spring-boot-project/spring-boot-test-autoconfigure/build.gradle index 5ac749a3f5..f6866b6f76 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/build.gradle +++ b/spring-boot-project/spring-boot-test-autoconfigure/build.gradle @@ -70,8 +70,9 @@ dependencies { testImplementation("org.hibernate.validator:hibernate-validator") testImplementation("org.hsqldb:hsqldb") testImplementation("org.jooq:jooq") - testImplementation("org.junit.platform:junit-platform-engine") testImplementation("org.junit.jupiter:junit-jupiter") + testImplementation("org.junit.platform:junit-platform-engine") + testImplementation("org.junit.platform:junit-platform-launcher") testImplementation("org.mockito:mockito-core") testImplementation("org.skyscreamer:jsonassert") testImplementation("org.springframework.hateoas:spring-hateoas") diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/cache/ImportsContextCustomizerFactoryWithAutoConfigurationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/cache/ImportsContextCustomizerFactoryWithAutoConfigurationTests.java index 5a07c65626..7536126a75 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/cache/ImportsContextCustomizerFactoryWithAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/cache/ImportsContextCustomizerFactoryWithAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +21,10 @@ import java.lang.annotation.RetentionPolicy; import org.junit.jupiter.api.Test; import org.junit.platform.engine.discovery.DiscoverySelectors; +import org.junit.platform.launcher.Launcher; +import org.junit.platform.launcher.LauncherDiscoveryRequest; +import org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder; +import org.junit.platform.launcher.core.LauncherFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.AutoConfigurationPackage; @@ -28,9 +32,6 @@ import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; import org.springframework.boot.test.autoconfigure.orm.jpa.ExampleEntity; -import org.springframework.boot.testsupport.junit.platform.Launcher; -import org.springframework.boot.testsupport.junit.platform.LauncherDiscoveryRequest; -import org.springframework.boot.testsupport.junit.platform.LauncherDiscoveryRequestBuilder; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Configuration; import org.springframework.test.context.ContextConfiguration; @@ -49,7 +50,7 @@ class ImportsContextCustomizerFactoryWithAutoConfigurationTests { static ApplicationContext contextFromTest; @Test - void testClassesThatHaveSameAnnotationsShareAContext() throws Throwable { + void testClassesThatHaveSameAnnotationsShareAContext() { executeTests(DataJpaTest1.class); ApplicationContext test1Context = contextFromTest; executeTests(DataJpaTest3.class); @@ -58,7 +59,7 @@ class ImportsContextCustomizerFactoryWithAutoConfigurationTests { } @Test - void testClassesThatOnlyHaveDifferingUnrelatedAnnotationsShareAContext() throws Throwable { + void testClassesThatOnlyHaveDifferingUnrelatedAnnotationsShareAContext() { executeTests(DataJpaTest1.class); ApplicationContext test1Context = contextFromTest; executeTests(DataJpaTest2.class); @@ -67,7 +68,7 @@ class ImportsContextCustomizerFactoryWithAutoConfigurationTests { } @Test - void testClassesThatOnlyHaveDifferingPropertyMappedAnnotationAttributesDoNotShareAContext() throws Throwable { + void testClassesThatOnlyHaveDifferingPropertyMappedAnnotationAttributesDoNotShareAContext() { executeTests(DataJpaTest1.class); ApplicationContext test1Context = contextFromTest; executeTests(DataJpaTest4.class); @@ -75,11 +76,10 @@ class ImportsContextCustomizerFactoryWithAutoConfigurationTests { assertThat(test1Context).isNotSameAs(test2Context); } - private void executeTests(Class testClass) throws Throwable { - ClassLoader classLoader = testClass.getClassLoader(); - LauncherDiscoveryRequest request = new LauncherDiscoveryRequestBuilder(classLoader) + private void executeTests(Class testClass) { + LauncherDiscoveryRequest request = LauncherDiscoveryRequestBuilder.request() .selectors(DiscoverySelectors.selectClass(testClass)).build(); - Launcher launcher = new Launcher(testClass.getClassLoader()); + Launcher launcher = LauncherFactory.create(); launcher.execute(request); } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestPrintDefaultIntegrationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestPrintDefaultIntegrationTests.java index d932291a80..4fa386b7e6 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestPrintDefaultIntegrationTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestPrintDefaultIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,15 +21,16 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestMethodOrder; import org.junit.jupiter.api.extension.ExtendWith; import org.junit.platform.engine.discovery.DiscoverySelectors; +import org.junit.platform.launcher.Launcher; +import org.junit.platform.launcher.LauncherDiscoveryRequest; +import org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder; +import org.junit.platform.launcher.core.LauncherFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.boot.test.system.CapturedOutput; import org.springframework.boot.test.system.OutputCaptureExtension; -import org.springframework.boot.testsupport.junit.platform.Launcher; -import org.springframework.boot.testsupport.junit.platform.LauncherDiscoveryRequest; -import org.springframework.boot.testsupport.junit.platform.LauncherDiscoveryRequestBuilder; import org.springframework.security.test.context.support.WithMockUser; import org.springframework.test.web.servlet.MockMvc; @@ -49,22 +50,21 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. class WebMvcTestPrintDefaultIntegrationTests { @Test - void shouldNotPrint(CapturedOutput output) throws Throwable { + void shouldNotPrint(CapturedOutput output) { executeTests(ShouldNotPrint.class); assertThat(output).doesNotContain("HTTP Method"); } @Test - void shouldPrint(CapturedOutput output) throws Throwable { + void shouldPrint(CapturedOutput output) { executeTests(ShouldPrint.class); assertThat(output).containsOnlyOnce("HTTP Method"); } - private void executeTests(Class testClass) throws Throwable { - ClassLoader classLoader = testClass.getClassLoader(); - LauncherDiscoveryRequest request = new LauncherDiscoveryRequestBuilder(classLoader) + private void executeTests(Class testClass) { + LauncherDiscoveryRequest request = LauncherDiscoveryRequestBuilder.request() .selectors(DiscoverySelectors.selectClass(testClass)).build(); - Launcher launcher = new Launcher(testClass.getClassLoader()); + Launcher launcher = LauncherFactory.create(); launcher.execute(request); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-test-support/build.gradle b/spring-boot-project/spring-boot-tools/spring-boot-test-support/build.gradle index 30c63c0579..48608617ed 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-test-support/build.gradle +++ b/spring-boot-project/spring-boot-tools/spring-boot-test-support/build.gradle @@ -14,6 +14,7 @@ dependencies { compileOnly("org.elasticsearch:elasticsearch") compileOnly("org.junit.jupiter:junit-jupiter") compileOnly("org.junit.platform:junit-platform-engine") + compileOnly("org.junit.platform:junit-platform-launcher") compileOnly("org.mockito:mockito-core") compileOnly("org.neo4j:neo4j-ogm-core") compileOnly("org.springframework:spring-context") diff --git a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/classpath/ModifiedClassPathExtension.java b/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/classpath/ModifiedClassPathExtension.java index 0664e9d058..d57504871c 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/classpath/ModifiedClassPathExtension.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/classpath/ModifiedClassPathExtension.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,12 +24,16 @@ import org.junit.jupiter.api.extension.ExtensionContext; import org.junit.jupiter.api.extension.InvocationInterceptor; import org.junit.jupiter.api.extension.ReflectiveInvocationContext; import org.junit.platform.engine.discovery.DiscoverySelectors; +import org.junit.platform.launcher.Launcher; +import org.junit.platform.launcher.LauncherDiscoveryRequest; +import org.junit.platform.launcher.TestPlan; +import org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder; +import org.junit.platform.launcher.core.LauncherFactory; +import org.junit.platform.launcher.listeners.SummaryGeneratingListener; +import org.junit.platform.launcher.listeners.TestExecutionSummary; -import org.springframework.boot.testsupport.junit.platform.Launcher; -import org.springframework.boot.testsupport.junit.platform.LauncherDiscoveryRequest; -import org.springframework.boot.testsupport.junit.platform.LauncherDiscoveryRequestBuilder; -import org.springframework.boot.testsupport.junit.platform.SummaryGeneratingListener; import org.springframework.util.Assert; +import org.springframework.util.CollectionUtils; import org.springframework.util.ReflectionUtils; /** @@ -94,17 +98,18 @@ class ModifiedClassPathExtension implements InvocationInterceptor { } private void runTest(ClassLoader classLoader, String testClassName, String testMethodName) throws Throwable { - Class testClass = Class.forName(testClassName, false, classLoader); + Class testClass = classLoader.loadClass(testClassName); Method testMethod = findMethod(testClass, testMethodName); - LauncherDiscoveryRequest request = new LauncherDiscoveryRequestBuilder(classLoader) + LauncherDiscoveryRequest request = LauncherDiscoveryRequestBuilder.request() .selectors(DiscoverySelectors.selectMethod(testClass, testMethod)).build(); - Launcher launcher = new Launcher(classLoader); - SummaryGeneratingListener listener = new SummaryGeneratingListener(classLoader); + Launcher launcher = LauncherFactory.create(); + TestPlan testPlan = launcher.discover(request); + SummaryGeneratingListener listener = new SummaryGeneratingListener(); launcher.registerTestExecutionListeners(listener); - launcher.execute(request); - Throwable failure = listener.getSummary().getFailure(); - if (failure != null) { - throw failure; + launcher.execute(testPlan); + TestExecutionSummary summary = listener.getSummary(); + if (!CollectionUtils.isEmpty(summary.getFailures())) { + throw summary.getFailures().get(0).getException(); } } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/platform/Launcher.java b/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/platform/Launcher.java deleted file mode 100644 index 7ae970f0e9..0000000000 --- a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/platform/Launcher.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.testsupport.junit.platform; - -import java.lang.reflect.Array; - -/** - * Reflective mirror of JUnit 5's {@code Launcher}. - * - * @author Phillip Webb - * @since 2.2.0 - */ -public class Launcher extends ReflectiveWrapper { - - private final Class testExecutionListenerType; - - private final Object instance; - - public Launcher(ClassLoader classLoader) throws Throwable { - super(classLoader, "org.junit.platform.launcher.Launcher"); - this.testExecutionListenerType = loadClass("org.junit.platform.launcher.TestExecutionListener"); - Class factoryClass = loadClass("org.junit.platform.launcher.core.LauncherFactory"); - this.instance = factoryClass.getMethod("create").invoke(null); - } - - public void registerTestExecutionListeners(SummaryGeneratingListener listener) throws Throwable { - Object listeners = Array.newInstance(this.testExecutionListenerType, 1); - Array.set(listeners, 0, listener.instance); - this.type.getMethod("registerTestExecutionListeners", listeners.getClass()).invoke(this.instance, listeners); - } - - public void execute(LauncherDiscoveryRequest request) throws Throwable { - Object listeners = Array.newInstance(this.testExecutionListenerType, 0); - this.type.getMethod("execute", request.type, listeners.getClass()).invoke(this.instance, request.instance, - listeners); - } - -} diff --git a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/platform/LauncherDiscoveryRequest.java b/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/platform/LauncherDiscoveryRequest.java deleted file mode 100644 index c71732b7e5..0000000000 --- a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/platform/LauncherDiscoveryRequest.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.testsupport.junit.platform; - -/** - * Reflective mirror of JUnit 5's {@code LauncherDiscoveryRequest}. - * - * @author Phillip Webb - * @since 2.2.0 - */ -public class LauncherDiscoveryRequest extends ReflectiveWrapper { - - final Object instance; - - LauncherDiscoveryRequest(ClassLoader classLoader, Object instance) throws Throwable { - super(classLoader, "org.junit.platform.launcher.LauncherDiscoveryRequest"); - this.instance = instance; - } - -} diff --git a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/platform/LauncherDiscoveryRequestBuilder.java b/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/platform/LauncherDiscoveryRequestBuilder.java deleted file mode 100644 index a029c8ee4e..0000000000 --- a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/platform/LauncherDiscoveryRequestBuilder.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.testsupport.junit.platform; - -import java.lang.reflect.Method; - -import org.junit.platform.engine.DiscoverySelector; - -/** - * Reflective mirror of JUnit 5's {@code LauncherDiscoveryRequestBuilder}. - * - * @author Phillip Webb - * @since 2.2.0 - */ -public class LauncherDiscoveryRequestBuilder extends ReflectiveWrapper { - - final Object instance; - - public LauncherDiscoveryRequestBuilder(ClassLoader classLoader) throws Throwable { - super(classLoader, "org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder"); - this.instance = this.type.getMethod("request").invoke(null); - } - - LauncherDiscoveryRequestBuilder(ClassLoader classLoader, Class type, Object instance) throws Throwable { - super(classLoader, type); - this.instance = instance; - } - - public LauncherDiscoveryRequestBuilder selectors(DiscoverySelector... selectors) throws Throwable { - Class[] parameterTypes = { DiscoverySelector[].class }; - Method method = this.type.getMethod("selectors", parameterTypes); - return new LauncherDiscoveryRequestBuilder(getClassLoader(), this.type, - method.invoke(this.instance, new Object[] { selectors })); - } - - public LauncherDiscoveryRequest build() throws Throwable { - return new LauncherDiscoveryRequest(getClassLoader(), this.type.getMethod("build").invoke(this.instance)); - } - -} diff --git a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/platform/ReflectiveWrapper.java b/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/platform/ReflectiveWrapper.java deleted file mode 100644 index 8bd468a3e6..0000000000 --- a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/platform/ReflectiveWrapper.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.testsupport.junit.platform; - -import org.springframework.util.ClassUtils; - -/** - * Base class for all reflective wrappers. - * - * @author Phillip Webb - */ -class ReflectiveWrapper { - - final ClassLoader classLoader; - - final Class type; - - ReflectiveWrapper(ClassLoader classLoader, String type) throws Throwable { - this.classLoader = classLoader; - this.type = loadClass(type); - } - - protected ReflectiveWrapper(ClassLoader classLoader, Class type) throws Throwable { - this.classLoader = classLoader; - this.type = type; - } - - protected final ClassLoader getClassLoader() { - return this.classLoader; - } - - protected final Class loadClass(String type) throws ClassNotFoundException, LinkageError { - return ClassUtils.forName(type, this.classLoader); - } - -} diff --git a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/platform/SummaryGeneratingListener.java b/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/platform/SummaryGeneratingListener.java deleted file mode 100644 index 918df638af..0000000000 --- a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/platform/SummaryGeneratingListener.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.testsupport.junit.platform; - -/** - * Reflective mirror of JUnit 5's {@code SummaryGeneratingListener}. - * - * @author Phillip Webb - * @since 2.2.0 - */ -public class SummaryGeneratingListener extends ReflectiveWrapper { - - final Object instance; - - public SummaryGeneratingListener(ClassLoader classLoader) throws Throwable { - super(classLoader, "org.junit.platform.launcher.listeners.SummaryGeneratingListener"); - this.instance = this.type.newInstance(); - } - - public TestExecutionSummary getSummary() throws Throwable { - return new TestExecutionSummary(getClassLoader(), this.type.getMethod("getSummary").invoke(this.instance)); - } - -} diff --git a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/platform/TestExecutionSummary.java b/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/platform/TestExecutionSummary.java deleted file mode 100644 index b56d960c60..0000000000 --- a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/platform/TestExecutionSummary.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.testsupport.junit.platform; - -import java.util.List; - -import org.springframework.util.CollectionUtils; - -/** - * Reflective mirror of JUnit 5's {@code TestExecutionSummary}. - * - * @author Phillip Webb - * @since 2.2.0 - */ -public class TestExecutionSummary extends ReflectiveWrapper { - - private final Class failureType; - - private final Object instance; - - TestExecutionSummary(ClassLoader classLoader, Object instance) throws Throwable { - super(classLoader, "org.junit.platform.launcher.listeners.TestExecutionSummary"); - this.failureType = loadClass("org.junit.platform.launcher.listeners.TestExecutionSummary$Failure"); - this.instance = instance; - } - - public Throwable getFailure() throws Throwable { - List failures = (List) this.type.getMethod("getFailures").invoke(this.instance); - if (!CollectionUtils.isEmpty(failures)) { - Object failure = failures.get(0); - return (Throwable) this.failureType.getMethod("getException").invoke(failure); - } - return null; - } - -} diff --git a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/platform/package-info.java b/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/platform/package-info.java deleted file mode 100644 index f516d73744..0000000000 --- a/spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/junit/platform/package-info.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright 2012-2019 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * Reflective mirror of JUnit 5 classes required to workaround surefire bug - * {@code SUREFIRE-1679}. - */ -package org.springframework.boot.testsupport.junit.platform;