diff --git a/build.gradle b/build.gradle index 5d930a2240..f5419026e9 100644 --- a/build.gradle +++ b/build.gradle @@ -36,7 +36,7 @@ configure(allprojects) { project -> mavenBom "org.jetbrains.kotlin:kotlin-bom:1.5.30" mavenBom "org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.5.2" mavenBom "org.jetbrains.kotlinx:kotlinx-serialization-bom:1.2.2" - mavenBom "org.junit:junit-bom:5.7.2" + mavenBom "org.junit:junit-bom:5.8.0" } dependencies { dependencySet(group: 'org.apache.logging.log4j', version: '2.14.1') { @@ -346,6 +346,7 @@ configure([rootProject] + javaProjects) { project -> dependencies { testImplementation("org.junit.jupiter:junit-jupiter-api") testImplementation("org.junit.jupiter:junit-jupiter-params") + testImplementation("org.junit.platform:junit-platform-suite-api") testImplementation("org.mockito:mockito-core") testImplementation("org.mockito:mockito-junit-jupiter") testImplementation("io.mockk:mockk") @@ -353,6 +354,7 @@ configure([rootProject] + javaProjects) { project -> // Pull in the latest JUnit 5 Launcher API to ensure proper support in IDEs. testRuntimeOnly("org.junit.platform:junit-platform-launcher") testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine") + testRuntimeOnly("org.junit.platform:junit-platform-suite-engine") testRuntimeOnly("org.apache.logging.log4j:log4j-core") testRuntimeOnly("org.apache.logging.log4j:log4j-slf4j-impl") testRuntimeOnly("org.apache.logging.log4j:log4j-jul") @@ -381,7 +383,7 @@ configure([rootProject] + javaProjects) { project -> "https://hc.apache.org/httpcomponents-client-5.1.x/current/httpclient5/apidocs/", "https://projectreactor.io/docs/test/release/api/", "https://junit.org/junit4/javadoc/4.13.2/", - "https://junit.org/junit5/docs/5.7.2/api/", + "https://junit.org/junit5/docs/5.8.0/api/", "https://www.reactive-streams.org/reactive-streams-1.0.3-javadoc/", "https://javadoc.io/static/io.rsocket/rsocket-core/1.1.1/", "https://r2dbc.io/spec/0.8.5.RELEASE/api/" diff --git a/spring-test/src/test/java/org/springframework/test/context/SpringTestContextFrameworkTestSuite.java b/spring-test/src/test/java/org/springframework/test/context/SpringTestContextFrameworkTestSuite.java index d1532dfcff..4500d55668 100644 --- a/spring-test/src/test/java/org/springframework/test/context/SpringTestContextFrameworkTestSuite.java +++ b/spring-test/src/test/java/org/springframework/test/context/SpringTestContextFrameworkTestSuite.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-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. @@ -16,12 +16,10 @@ package org.springframework.test.context; -import org.junit.platform.runner.JUnitPlatform; import org.junit.platform.suite.api.ExcludeTags; import org.junit.platform.suite.api.IncludeClassNamePatterns; import org.junit.platform.suite.api.SelectPackages; -import org.junit.platform.suite.api.UseTechnicalNames; -import org.junit.runner.RunWith; +import org.junit.platform.suite.api.Suite; /** * JUnit Platform based test suite for tests that involve the Spring TestContext @@ -42,10 +40,9 @@ import org.junit.runner.RunWith; * @author Sam Brannen * @since 5.2 */ -@RunWith(JUnitPlatform.class) +@Suite @SelectPackages("org.springframework.test.context") @IncludeClassNamePatterns(".*Tests?$") @ExcludeTags("failing-test-case") -@UseTechnicalNames -public class SpringTestContextFrameworkTestSuite { +class SpringTestContextFrameworkTestSuite { } diff --git a/spring-test/src/test/java/org/springframework/test/context/env/TestPropertySourceTestSuite.java b/spring-test/src/test/java/org/springframework/test/context/env/TestPropertySourceTestSuite.java index 97c5c62e25..e67528774a 100644 --- a/spring-test/src/test/java/org/springframework/test/context/env/TestPropertySourceTestSuite.java +++ b/spring-test/src/test/java/org/springframework/test/context/env/TestPropertySourceTestSuite.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-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. @@ -16,12 +16,10 @@ package org.springframework.test.context.env; -import org.junit.platform.runner.JUnitPlatform; import org.junit.platform.suite.api.IncludeClassNamePatterns; import org.junit.platform.suite.api.IncludeEngines; import org.junit.platform.suite.api.SelectPackages; -import org.junit.platform.suite.api.UseTechnicalNames; -import org.junit.runner.RunWith; +import org.junit.platform.suite.api.Suite; import org.springframework.test.context.TestPropertySource; @@ -35,10 +33,9 @@ import org.springframework.test.context.TestPropertySource; * @author Sam Brannen * @since 5.2 */ -@RunWith(JUnitPlatform.class) +@Suite @IncludeEngines("junit-jupiter") @SelectPackages("org.springframework.test.context.env") @IncludeClassNamePatterns(".*Tests$") -@UseTechnicalNames -public class TestPropertySourceTestSuite { +class TestPropertySourceTestSuite { } diff --git a/spring-test/src/test/java/org/springframework/test/context/junit/SpringJUnitJupiterTestSuite.java b/spring-test/src/test/java/org/springframework/test/context/junit/SpringJUnitJupiterTestSuite.java index 0a0cf2f84e..28c8071e1c 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit/SpringJUnitJupiterTestSuite.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit/SpringJUnitJupiterTestSuite.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-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. @@ -16,22 +16,17 @@ package org.springframework.test.context.junit; -import org.junit.platform.runner.JUnitPlatform; import org.junit.platform.suite.api.ExcludeTags; import org.junit.platform.suite.api.IncludeClassNamePatterns; import org.junit.platform.suite.api.IncludeEngines; import org.junit.platform.suite.api.SelectPackages; -import org.junit.platform.suite.api.UseTechnicalNames; -import org.junit.runner.RunWith; +import org.junit.platform.suite.api.Suite; /** - * JUnit 4 based test suite for tests that involve the Spring TestContext + * JUnit Platform based test suite for tests that involve the Spring TestContext * Framework and JUnit Jupiter (i.e., JUnit 5's programming model). * - *

This class intentionally does not reside in the "jupiter" package - * so that the entire "jupiter" package can be excluded from the Gradle - * build. This class is therefore responsible for executing all JUnit - * Jupiter based tests in Spring's official test suite. + *

This suite is only intended to be used manually within an IDE. * *

Logging Configuration

* @@ -46,11 +41,10 @@ import org.junit.runner.RunWith; * @author Sam Brannen * @since 5.0 */ -@RunWith(JUnitPlatform.class) +@Suite @IncludeEngines("junit-jupiter") @SelectPackages("org.springframework.test.context.junit.jupiter") @IncludeClassNamePatterns(".*Tests$") @ExcludeTags("failing-test-case") -@UseTechnicalNames public class SpringJUnitJupiterTestSuite { } diff --git a/spring-web/src/test/java/org/springframework/http/client/reactive/ClientHttpConnectorTests.java b/spring-web/src/test/java/org/springframework/http/client/reactive/ClientHttpConnectorTests.java index 3c3debef97..0f30c2391e 100644 --- a/spring-web/src/test/java/org/springframework/http/client/reactive/ClientHttpConnectorTests.java +++ b/spring-web/src/test/java/org/springframework/http/client/reactive/ClientHttpConnectorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-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. @@ -77,7 +77,9 @@ public class ClientHttpConnectorTests { server.shutdown(); } - @ParameterizedTest + // Do not auto-close arguments since HttpComponentsClientHttpConnector implements + // AutoCloseable and is shared between parameterized test invocations. + @ParameterizedTest(autoCloseArguments = false) @MethodSource("org.springframework.http.client.reactive.ClientHttpConnectorTests#methodsWithConnectors") void basic(ClientHttpConnector connector, HttpMethod method) throws Exception { URI uri = this.server.url("/").uri(); @@ -198,10 +200,11 @@ public class ClientHttpConnectorTests { @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) - @ParameterizedTest + // Do not auto-close arguments since HttpComponentsClientHttpConnector implements + // AutoCloseable and is shared between parameterized test invocations. + @ParameterizedTest(autoCloseArguments = false) @MethodSource("org.springframework.http.client.reactive.ClientHttpConnectorTests#connectors") public @interface ParameterizedConnectorTest { - } static List connectors() { diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/PathPatternsParameterizedTest.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/PathPatternsParameterizedTest.java index 7dc77ff73d..ead6e38ab1 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/PathPatternsParameterizedTest.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/PathPatternsParameterizedTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-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. @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.web.servlet.handler; import java.lang.annotation.ElementType; @@ -30,7 +31,9 @@ import java.lang.annotation.Target; */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) -@org.junit.jupiter.params.ParameterizedTest +// Do not auto-close arguments since ConfigurableWebApplicationContext implements +// AutoCloseable and is shared between parameterized test invocations. +@org.junit.jupiter.params.ParameterizedTest(autoCloseArguments = false) @org.junit.jupiter.params.provider.MethodSource("pathPatternsArguments") public @interface PathPatternsParameterizedTest { }