diff --git a/build.gradle b/build.gradle index 0d21caa676..6cfbb3b58a 100644 --- a/build.gradle +++ b/build.gradle @@ -138,9 +138,6 @@ configure(allprojects) { project -> dependencies { testCompile("org.junit.jupiter:junit-jupiter-api") testCompile("org.junit.jupiter:junit-jupiter-params") - testCompile("junit:junit:4.13-beta-3") { - exclude group: "org.hamcrest", module: "hamcrest-core" - } testCompile("org.mockito:mockito-core:3.0.0") { exclude group: "org.hamcrest", module: "hamcrest-core" } @@ -151,7 +148,6 @@ configure(allprojects) { project -> // Pull in the latest JUnit 5 Launcher API to ensure proper support in IDEs. testRuntime("org.junit.platform:junit-platform-launcher") testRuntime("org.junit.jupiter:junit-jupiter-engine") - testRuntime("org.junit.vintage:junit-vintage-engine") testRuntime("org.apache.logging.log4j:log4j-core:${log4jVersion}") testRuntime("org.apache.logging.log4j:log4j-slf4j-impl:${log4jVersion}") testRuntime("org.apache.logging.log4j:log4j-jul:${log4jVersion}") diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/serviceloader/ServiceLoaderTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/serviceloader/ServiceLoaderTests.java index cf17ce62c3..d8bfc15b12 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/serviceloader/ServiceLoaderTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/serviceloader/ServiceLoaderTests.java @@ -26,7 +26,7 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; /** * @author Juergen Hoeller diff --git a/spring-beans/src/test/kotlin/org/springframework/beans/KotlinBeanUtilsTests.kt b/spring-beans/src/test/kotlin/org/springframework/beans/KotlinBeanUtilsTests.kt index 60af2e1dec..fd49701af7 100644 --- a/spring-beans/src/test/kotlin/org/springframework/beans/KotlinBeanUtilsTests.kt +++ b/spring-beans/src/test/kotlin/org/springframework/beans/KotlinBeanUtilsTests.kt @@ -16,7 +16,7 @@ package org.springframework.beans -import org.junit.Assert.* +import org.junit.jupiter.api.Assertions.* import org.junit.jupiter.api.Test /** diff --git a/spring-beans/src/test/kotlin/org/springframework/beans/factory/annotation/KotlinAutowiredTests.kt b/spring-beans/src/test/kotlin/org/springframework/beans/factory/annotation/KotlinAutowiredTests.kt index 0942fd6866..d994970276 100644 --- a/spring-beans/src/test/kotlin/org/springframework/beans/factory/annotation/KotlinAutowiredTests.kt +++ b/spring-beans/src/test/kotlin/org/springframework/beans/factory/annotation/KotlinAutowiredTests.kt @@ -22,7 +22,8 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory import org.springframework.beans.factory.support.RootBeanDefinition import org.springframework.tests.sample.beans.TestBean -import org.junit.Assert.* +import org.junit.jupiter.api.Assertions.* +import org.junit.jupiter.api.fail import org.springframework.beans.factory.BeanCreationException import org.springframework.tests.sample.beans.Colour diff --git a/spring-context/src/test/kotlin/org/springframework/context/annotation/AnnotationConfigApplicationContextExtensionsTests.kt b/spring-context/src/test/kotlin/org/springframework/context/annotation/AnnotationConfigApplicationContextExtensionsTests.kt index 5766e93d93..b248dc6531 100644 --- a/spring-context/src/test/kotlin/org/springframework/context/annotation/AnnotationConfigApplicationContextExtensionsTests.kt +++ b/spring-context/src/test/kotlin/org/springframework/context/annotation/AnnotationConfigApplicationContextExtensionsTests.kt @@ -16,7 +16,7 @@ package org.springframework.context.annotation -import org.junit.Assert.assertNotNull +import org.junit.jupiter.api.Assertions.assertNotNull import org.junit.jupiter.api.Test import org.springframework.beans.factory.getBean import org.springframework.context.support.registerBean diff --git a/spring-context/src/test/kotlin/org/springframework/context/annotation/KotlinConfigurationClassTests.kt b/spring-context/src/test/kotlin/org/springframework/context/annotation/KotlinConfigurationClassTests.kt index 3eed14a961..3f892bfcb3 100644 --- a/spring-context/src/test/kotlin/org/springframework/context/annotation/KotlinConfigurationClassTests.kt +++ b/spring-context/src/test/kotlin/org/springframework/context/annotation/KotlinConfigurationClassTests.kt @@ -16,7 +16,8 @@ package org.springframework.context.annotation -import org.junit.Assert.* +import org.junit.jupiter.api.Assertions.* +import org.junit.jupiter.api.fail import org.junit.jupiter.api.Test import org.springframework.beans.factory.getBean import org.springframework.beans.factory.parsing.BeanDefinitionParsingException diff --git a/spring-context/src/test/kotlin/org/springframework/context/annotation/Spr16022Tests.kt b/spring-context/src/test/kotlin/org/springframework/context/annotation/Spr16022Tests.kt index 6f60ccb339..ff2ecf1489 100644 --- a/spring-context/src/test/kotlin/org/springframework/context/annotation/Spr16022Tests.kt +++ b/spring-context/src/test/kotlin/org/springframework/context/annotation/Spr16022Tests.kt @@ -16,7 +16,7 @@ package org.springframework.context.annotation -import org.junit.Assert.assertEquals +import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Test import org.springframework.beans.factory.BeanFactory import org.springframework.beans.factory.getBean diff --git a/spring-context/src/test/kotlin/org/springframework/context/support/BeanDefinitionDslTests.kt b/spring-context/src/test/kotlin/org/springframework/context/support/BeanDefinitionDslTests.kt index 2a0173b955..c244d4ed41 100644 --- a/spring-context/src/test/kotlin/org/springframework/context/support/BeanDefinitionDslTests.kt +++ b/spring-context/src/test/kotlin/org/springframework/context/support/BeanDefinitionDslTests.kt @@ -16,7 +16,10 @@ package org.springframework.context.support -import org.junit.Assert.* +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Assertions.assertNotNull +import org.junit.jupiter.api.Assertions.assertTrue +import org.junit.jupiter.api.fail import org.junit.jupiter.api.Test import org.springframework.beans.factory.NoSuchBeanDefinitionException import org.springframework.beans.factory.getBean @@ -28,7 +31,7 @@ import java.util.stream.Collectors @Suppress("UNUSED_EXPRESSION") class BeanDefinitionDslTests { - + @Test fun `Declare beans with the functional Kotlin DSL`() { val beans = beans { @@ -193,12 +196,12 @@ class BeanDefinitionDslTests { try { context.getBean() - fail() + fail("should have thrown an Exception") } catch (ignored: Exception) { } try { context.getBean() - fail() + fail("should have thrown an Exception") } catch (ignored: Exception) { } } diff --git a/spring-context/src/test/kotlin/org/springframework/context/support/GenericApplicationContextExtensionsTests.kt b/spring-context/src/test/kotlin/org/springframework/context/support/GenericApplicationContextExtensionsTests.kt index 099b485a99..15120ded96 100644 --- a/spring-context/src/test/kotlin/org/springframework/context/support/GenericApplicationContextExtensionsTests.kt +++ b/spring-context/src/test/kotlin/org/springframework/context/support/GenericApplicationContextExtensionsTests.kt @@ -16,7 +16,7 @@ package org.springframework.context.support -import org.junit.Assert.assertNotNull +import org.junit.jupiter.api.Assertions.assertNotNull import org.junit.jupiter.api.Test import org.springframework.beans.factory.getBean diff --git a/spring-context/src/test/kotlin/org/springframework/ui/ModelExtensionsTests.kt b/spring-context/src/test/kotlin/org/springframework/ui/ModelExtensionsTests.kt index 42f0627a60..21dcc9f03d 100644 --- a/spring-context/src/test/kotlin/org/springframework/ui/ModelExtensionsTests.kt +++ b/spring-context/src/test/kotlin/org/springframework/ui/ModelExtensionsTests.kt @@ -16,8 +16,8 @@ package org.springframework.ui -import org.junit.Assert.assertEquals -import org.junit.Assert.assertTrue +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.Test /** diff --git a/spring-context/src/test/kotlin/org/springframework/ui/ModelMapExtensionsTests.kt b/spring-context/src/test/kotlin/org/springframework/ui/ModelMapExtensionsTests.kt index 723201a58c..5aece4718c 100644 --- a/spring-context/src/test/kotlin/org/springframework/ui/ModelMapExtensionsTests.kt +++ b/spring-context/src/test/kotlin/org/springframework/ui/ModelMapExtensionsTests.kt @@ -16,8 +16,8 @@ package org.springframework.ui -import org.junit.Assert.assertEquals -import org.junit.Assert.assertTrue +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.Test /** diff --git a/spring-core/src/test/java/org/springframework/core/io/ResourceTests.java b/spring-core/src/test/java/org/springframework/core/io/ResourceTests.java index b6ff18c36a..c3518ab9de 100644 --- a/spring-core/src/test/java/org/springframework/core/io/ResourceTests.java +++ b/spring-core/src/test/java/org/springframework/core/io/ResourceTests.java @@ -27,7 +27,7 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.HashSet; -import org.junit.Ignore; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.springframework.util.FileCopyUtils; @@ -218,7 +218,8 @@ public class ResourceTests { assertThat(relative).isEqualTo(new UrlResource("file:dir/subdir")); } - @Ignore @Test // this test is quite slow. TODO: re-enable with JUnit categories + @Disabled + @Test // this test is quite slow. TODO: re-enable with JUnit categories public void testNonFileResourceExists() throws Exception { Resource resource = new UrlResource("https://www.springframework.org"); assertThat(resource.exists()).isTrue(); diff --git a/spring-core/src/test/java/org/springframework/tests/Assume.java b/spring-core/src/test/java/org/springframework/tests/Assume.java index 3fed237d3d..d21af967c8 100644 --- a/spring-core/src/test/java/org/springframework/tests/Assume.java +++ b/spring-core/src/test/java/org/springframework/tests/Assume.java @@ -19,14 +19,14 @@ package org.springframework.tests; import java.util.Set; import org.apache.commons.logging.Log; -import org.junit.AssumptionViolatedException; -import static org.junit.Assume.assumeFalse; +import static org.junit.jupiter.api.Assumptions.assumeFalse; +import static org.junit.jupiter.api.Assumptions.assumeTrue; /** - * Provides utility methods that allow JUnit tests to {@link org.junit.Assume} certain - * conditions hold {@code true}. If the assumption fails, it means the test should be - * skipped. + * Provides utility methods that allow JUnit tests to assume certain conditions + * hold {@code true}. If the assumption fails, it means the test should be + * aborted. * *

Tests can be categorized into {@link TestGroup}s. Active groups are enabled using * the 'testGroups' system property, usually activated from the gradle command line: @@ -35,8 +35,8 @@ import static org.junit.Assume.assumeFalse; * gradle test -PtestGroups="performance" * * - *

Groups can be specified as a comma separated list of values, or using the pseudo group - * 'all'. See {@link TestGroup} for a list of valid groups. + *

Groups can be activated as a comma separated list of values, or using the + * pseudo group 'all'. See {@link TestGroup} for a list of valid groups. * * @author Rob Winch * @author Phillip Webb @@ -44,6 +44,8 @@ import static org.junit.Assume.assumeFalse; * @since 3.2 * @see #group(TestGroup) * @see #group(TestGroup, Executable) + * @see TestGroup + * @see TestGroups */ public abstract class Assume { @@ -51,29 +53,27 @@ public abstract class Assume { /** - * Assume that a particular {@link TestGroup} has been specified. - * @param group the group that must be specified - * @throws AssumptionViolatedException if the assumption fails + * Assume that a particular {@link TestGroup} is active. + * @param group the group that must be active + * @throws org.opentest4j.TestAbortedException if the assumption fails */ public static void group(TestGroup group) { - Set testGroups = loadTestGroups(); - if (!testGroups.contains(group)) { - throw new AssumptionViolatedException("Requires unspecified group " + group + " from " + testGroups); - } + Set testGroups = TestGroups.loadTestGroups(); + assumeTrue(testGroups.contains(group), + () -> "Requires inactive test group " + group + "; active test groups: " + testGroups); } /** - * Assume that a particular {@link TestGroup} has been specified before - * executing the supplied {@link Executable}. + * Assume that a particular {@link TestGroup} is active before executing the + * supplied {@link Executable}. *

If the assumption fails, the executable will not be executed, but - * no {@link AssumptionViolatedException} will be thrown. - * @param group the group that must be specified + * no {@link org.opentest4j.TestAbortedException} will be thrown. + * @param group the group that must be active * @param executable the executable to execute if the test group is active * @since 4.2 */ public static void group(TestGroup group, Executable executable) throws Exception { - Set testGroups = loadTestGroups(); - if (testGroups.contains(group)) { + if (TestGroups.loadTestGroups().contains(group)) { executable.execute(); } } @@ -81,28 +81,13 @@ public abstract class Assume { /** * Assume that the specified log is not set to Trace or Debug. * @param log the log to test - * @throws AssumptionViolatedException if the assumption fails + * @throws org.opentest4j.TestAbortedException if the assumption fails */ public static void notLogging(Log log) { assumeFalse(log.isTraceEnabled()); assumeFalse(log.isDebugEnabled()); } - /** - * Load test groups dynamically instead of during static - * initialization in order to avoid a {@link NoClassDefFoundError} - * being thrown while attempting to load the {@code Assume} class. - */ - private static Set loadTestGroups() { - try { - return TestGroup.parse(System.getProperty(TEST_GROUPS_SYSTEM_PROPERTY)); - } - catch (Exception ex) { - throw new IllegalStateException("Failed to parse '" + TEST_GROUPS_SYSTEM_PROPERTY - + "' system property: " + ex.getMessage(), ex); - } - } - /** * @since 4.2 diff --git a/spring-core/src/test/java/org/springframework/tests/AssumeTests.java b/spring-core/src/test/java/org/springframework/tests/AssumeTests.java index 9bae15a305..86eeb2b88f 100644 --- a/spring-core/src/test/java/org/springframework/tests/AssumeTests.java +++ b/spring-core/src/test/java/org/springframework/tests/AssumeTests.java @@ -18,10 +18,10 @@ package org.springframework.tests; import java.util.Arrays; -import org.junit.AssumptionViolatedException; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.opentest4j.TestAbortedException; import static java.util.stream.Collectors.joining; import static org.assertj.core.api.Assertions.assertThat; @@ -77,7 +77,7 @@ public class AssumeTests { try { Assume.group(LONG_RUNNING); } - catch (AssumptionViolatedException ex) { + catch (TestAbortedException ex) { fail("assumption should NOT have failed"); } } diff --git a/spring-core/src/test/java/org/springframework/tests/TestGroups.java b/spring-core/src/test/java/org/springframework/tests/TestGroups.java new file mode 100644 index 0000000000..7876f18a7e --- /dev/null +++ b/spring-core/src/test/java/org/springframework/tests/TestGroups.java @@ -0,0 +1,58 @@ +/* + * Copyright 2002-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.tests; + +import java.util.Set; + +/** + * Utility methods for working with {@link TestGroup}s. + * + * @author Sam Brannen + * @author Rob Winch + * @author Phillip Webb + * @since 5.2 + */ +public abstract class TestGroups { + + static final String TEST_GROUPS_SYSTEM_PROPERTY = "testGroups"; + + + /** + * Determine if the provided {@link TestGroup} is active. + * @param group the group to check + * @since 5.2 + */ + public static boolean isGroupActive(TestGroup group) { + return loadTestGroups().contains(group); + } + + /** + * Load test groups dynamically instead of during static initialization in + * order to avoid a {@link NoClassDefFoundError} being thrown while attempting + * to load the {@link Assume} class. + */ + static Set loadTestGroups() { + try { + return TestGroup.parse(System.getProperty(TEST_GROUPS_SYSTEM_PROPERTY)); + } + catch (Exception ex) { + throw new IllegalStateException("Failed to parse '" + TEST_GROUPS_SYSTEM_PROPERTY + + "' system property: " + ex.getMessage(), ex); + } + } + +} diff --git a/spring-core/src/test/kotlin/org/springframework/core/KotlinDefaultParameterNameDiscovererTests.kt b/spring-core/src/test/kotlin/org/springframework/core/KotlinDefaultParameterNameDiscovererTests.kt index 6ef4f7b71a..4c7ffceef7 100644 --- a/spring-core/src/test/kotlin/org/springframework/core/KotlinDefaultParameterNameDiscovererTests.kt +++ b/spring-core/src/test/kotlin/org/springframework/core/KotlinDefaultParameterNameDiscovererTests.kt @@ -16,7 +16,7 @@ package org.springframework.core -import org.junit.Assert.assertEquals +import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Test class KotlinDefaultParameterNameDiscovererTests { diff --git a/spring-core/src/test/kotlin/org/springframework/core/KotlinGenericTypeResolverTests.kt b/spring-core/src/test/kotlin/org/springframework/core/KotlinGenericTypeResolverTests.kt index c562e8ab4f..f3f5b903e2 100644 --- a/spring-core/src/test/kotlin/org/springframework/core/KotlinGenericTypeResolverTests.kt +++ b/spring-core/src/test/kotlin/org/springframework/core/KotlinGenericTypeResolverTests.kt @@ -16,7 +16,7 @@ package org.springframework.core -import org.junit.Assert.assertEquals +import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Test import org.springframework.core.GenericTypeResolver.resolveReturnTypeArgument import java.lang.reflect.Method diff --git a/spring-core/src/test/kotlin/org/springframework/core/KotlinMethodParameterTests.kt b/spring-core/src/test/kotlin/org/springframework/core/KotlinMethodParameterTests.kt index 8530afb42e..df7ebd7af1 100644 --- a/spring-core/src/test/kotlin/org/springframework/core/KotlinMethodParameterTests.kt +++ b/spring-core/src/test/kotlin/org/springframework/core/KotlinMethodParameterTests.kt @@ -16,9 +16,9 @@ package org.springframework.core -import org.junit.Assert.assertEquals -import org.junit.Assert.assertFalse -import org.junit.Assert.assertTrue +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Assertions.assertFalse +import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.Test import java.lang.reflect.Method import java.lang.reflect.TypeVariable diff --git a/spring-core/src/test/kotlin/org/springframework/core/KotlinReactiveAdapterRegistryTests.kt b/spring-core/src/test/kotlin/org/springframework/core/KotlinReactiveAdapterRegistryTests.kt index 24352a090c..fb589a025f 100644 --- a/spring-core/src/test/kotlin/org/springframework/core/KotlinReactiveAdapterRegistryTests.kt +++ b/spring-core/src/test/kotlin/org/springframework/core/KotlinReactiveAdapterRegistryTests.kt @@ -24,9 +24,9 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.toList import kotlinx.coroutines.runBlocking -import org.junit.Assert.assertEquals -import org.junit.Assert.assertTrue -import org.junit.Assert.fail +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Assertions.assertTrue +import org.junit.jupiter.api.Assertions.fail import org.junit.jupiter.api.Test import org.reactivestreams.Publisher import reactor.core.publisher.Flux @@ -44,7 +44,7 @@ class KotlinReactiveAdapterRegistryTests { fun deferredToPublisher() { val source = GlobalScope.async { 1 } val target: Publisher = getAdapter(Deferred::class).toPublisher(source) - assertTrue("Expected Mono Publisher: " + target.javaClass.name, target is Mono<*>) + assertTrue(target is Mono<*>, "Expected Mono Publisher: " + target.javaClass.name) assertEquals(1, (target as Mono).block(Duration.ofMillis(1000))) } @@ -54,7 +54,6 @@ class KotlinReactiveAdapterRegistryTests { val target = getAdapter(Deferred::class).fromPublisher(source) assertTrue(target is Deferred<*>) assertEquals(1, runBlocking { (target as Deferred<*>).await() }) - } @Test @@ -65,7 +64,7 @@ class KotlinReactiveAdapterRegistryTests { emit(3) } val target: Publisher = getAdapter(Flow::class).toPublisher(source) - assertTrue("Expected Flux Publisher: " + target.javaClass.name, target is Flux<*>) + assertTrue(target is Flux<*>, "Expected Flux Publisher: " + target.javaClass.name) StepVerifier.create(target) .expectNext(1) .expectNext(2) diff --git a/spring-jdbc/src/test/kotlin/org/springframework/jdbc/core/JdbcOperationsExtensionsTests.kt b/spring-jdbc/src/test/kotlin/org/springframework/jdbc/core/JdbcOperationsExtensionsTests.kt index e19f4627db..9c8df3696d 100644 --- a/spring-jdbc/src/test/kotlin/org/springframework/jdbc/core/JdbcOperationsExtensionsTests.kt +++ b/spring-jdbc/src/test/kotlin/org/springframework/jdbc/core/JdbcOperationsExtensionsTests.kt @@ -21,8 +21,8 @@ import java.sql.* import io.mockk.every import io.mockk.mockk import io.mockk.verify -import org.junit.Assert.assertEquals -import org.junit.Assert.assertNull +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Assertions.assertNull import org.junit.jupiter.api.Test /** diff --git a/spring-jdbc/src/test/kotlin/org/springframework/jdbc/core/namedparam/MapSqlParameterSourceExtensionsTests.kt b/spring-jdbc/src/test/kotlin/org/springframework/jdbc/core/namedparam/MapSqlParameterSourceExtensionsTests.kt index 27d3e07035..c72b73f035 100644 --- a/spring-jdbc/src/test/kotlin/org/springframework/jdbc/core/namedparam/MapSqlParameterSourceExtensionsTests.kt +++ b/spring-jdbc/src/test/kotlin/org/springframework/jdbc/core/namedparam/MapSqlParameterSourceExtensionsTests.kt @@ -18,7 +18,7 @@ package org.springframework.jdbc.core.namedparam import java.sql.JDBCType -import org.junit.Assert.assertEquals +import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Test /** diff --git a/spring-messaging/src/test/kotlin/org/springframework/messaging/rsocket/RSocketRequesterExtensionsTests.kt b/spring-messaging/src/test/kotlin/org/springframework/messaging/rsocket/RSocketRequesterExtensionsTests.kt index aefa3e21bb..383bf8ad04 100644 --- a/spring-messaging/src/test/kotlin/org/springframework/messaging/rsocket/RSocketRequesterExtensionsTests.kt +++ b/spring-messaging/src/test/kotlin/org/springframework/messaging/rsocket/RSocketRequesterExtensionsTests.kt @@ -6,7 +6,7 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.toList import kotlinx.coroutines.runBlocking -import org.junit.Assert.assertEquals +import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Test import org.mockito.ArgumentMatchers.anyInt import org.reactivestreams.Publisher diff --git a/spring-messaging/src/test/kotlin/org/springframework/messaging/simp/annotation/support/SimpAnnotationMethodMessageHandlerKotlinTests.kt b/spring-messaging/src/test/kotlin/org/springframework/messaging/simp/annotation/support/SimpAnnotationMethodMessageHandlerKotlinTests.kt index 99e442df09..28aebe097e 100644 --- a/spring-messaging/src/test/kotlin/org/springframework/messaging/simp/annotation/support/SimpAnnotationMethodMessageHandlerKotlinTests.kt +++ b/spring-messaging/src/test/kotlin/org/springframework/messaging/simp/annotation/support/SimpAnnotationMethodMessageHandlerKotlinTests.kt @@ -36,7 +36,7 @@ import org.springframework.messaging.simp.SimpMessagingTemplate import org.springframework.messaging.support.MessageBuilder import org.springframework.stereotype.Controller -import org.junit.Assert.* +import org.junit.jupiter.api.Assertions.* import org.springframework.messaging.MessageHandlingException import org.springframework.messaging.handler.annotation.MessageExceptionHandler diff --git a/spring-test/spring-test.gradle b/spring-test/spring-test.gradle index 8a948a94a6..5087e67f0d 100644 --- a/spring-test/spring-test.gradle +++ b/spring-test/spring-test.gradle @@ -79,6 +79,7 @@ dependencies { testCompile("io.projectreactor.netty:reactor-netty") testCompile("de.bechte.junit:junit-hierarchicalcontextrunner:4.12.1") testRuntime("org.junit.jupiter:junit-jupiter-engine") + testRuntime("org.junit.vintage:junit-vintage-engine") testRuntime("org.glassfish:javax.el:3.0.1-b08") testRuntime("com.sun.xml.bind:jaxb-core:2.3.0.1") testRuntime("com.sun.xml.bind:jaxb-impl:2.3.0.1") diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/concurrency/SpringJUnit4ConcurrencyTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/concurrency/SpringJUnit4ConcurrencyTests.java index 70be79c38b..941ed2edf7 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/concurrency/SpringJUnit4ConcurrencyTests.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/concurrency/SpringJUnit4ConcurrencyTests.java @@ -40,10 +40,11 @@ import org.springframework.test.context.web.socket.WebSocketServletServerContain import org.springframework.test.web.client.samples.SampleTests; import org.springframework.test.web.servlet.samples.context.JavaConfigTests; import org.springframework.test.web.servlet.samples.context.WebAppResourceTests; -import org.springframework.tests.Assume; import org.springframework.tests.TestGroup; +import org.springframework.tests.TestGroups; import org.springframework.util.ReflectionUtils; +import static org.junit.Assume.assumeTrue; import static org.springframework.core.annotation.AnnotatedElementUtils.hasAnnotation; import static org.springframework.test.context.junit4.JUnitTestingUtils.runTestsAndAssertCounters; @@ -97,7 +98,8 @@ public class SpringJUnit4ConcurrencyTests { @BeforeClass public static void abortIfLongRunningTestGroupIsNotEnabled() { - Assume.group(TestGroup.LONG_RUNNING); + assumeTrue("TestGroup " + TestGroup.LONG_RUNNING + " is not active.", + TestGroups.isGroupActive(TestGroup.LONG_RUNNING)); } @Test diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/DelegatingWebConnectionTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/DelegatingWebConnectionTests.java index d3e9c56c26..e069e422af 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/DelegatingWebConnectionTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/DelegatingWebConnectionTests.java @@ -36,10 +36,11 @@ import org.springframework.stereotype.Controller; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.htmlunit.DelegatingWebConnection.DelegateWebConnection; import org.springframework.test.web.servlet.setup.MockMvcBuilders; -import org.springframework.tests.Assume; import org.springframework.tests.TestGroup; +import org.springframework.tests.TestGroups; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assume.assumeTrue; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; @@ -125,7 +126,8 @@ public class DelegatingWebConnectionTests { @Test public void verifyExampleInClassLevelJavadoc() throws Exception { - Assume.group(TestGroup.PERFORMANCE); + assumeTrue("TestGroup " + TestGroup.PERFORMANCE + " is not active.", + TestGroups.isGroupActive(TestGroup.PERFORMANCE)); WebClient webClient = new WebClient(); diff --git a/spring-test/src/test/kotlin/org/springframework/test/web/reactive/server/WebTestClientExtensionsTests.kt b/spring-test/src/test/kotlin/org/springframework/test/web/reactive/server/WebTestClientExtensionsTests.kt index c984bed5ed..c5bbf08fbb 100644 --- a/spring-test/src/test/kotlin/org/springframework/test/web/reactive/server/WebTestClientExtensionsTests.kt +++ b/spring-test/src/test/kotlin/org/springframework/test/web/reactive/server/WebTestClientExtensionsTests.kt @@ -20,7 +20,7 @@ import io.mockk.mockk import io.mockk.verify import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.Flow -import org.junit.Assert.assertEquals +import org.junit.jupiter.api.Assertions.assertEquals import org.junit.Test import org.reactivestreams.Publisher import org.springframework.core.ParameterizedTypeReference diff --git a/spring-test/src/test/kotlin/org/springframework/test/web/servlet/MockMvcExtensionsTests.kt b/spring-test/src/test/kotlin/org/springframework/test/web/servlet/MockMvcExtensionsTests.kt index 0dc5a6e13d..0dd6003d77 100644 --- a/spring-test/src/test/kotlin/org/springframework/test/web/servlet/MockMvcExtensionsTests.kt +++ b/spring-test/src/test/kotlin/org/springframework/test/web/servlet/MockMvcExtensionsTests.kt @@ -17,8 +17,8 @@ package org.springframework.test.web.servlet import org.hamcrest.CoreMatchers -import org.junit.Assert -import org.junit.Test +import org.junit.jupiter.api.Assertions.* +import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows import org.springframework.http.HttpMethod import org.springframework.http.HttpStatus @@ -81,8 +81,8 @@ class MockMvcExtensionsTests { }.andDo { handle(handler) } - Assert.assertTrue(matcherInvoked) - Assert.assertTrue(handlerInvoked) + assertTrue(matcherInvoked) + assertTrue(handlerInvoked) } @Test diff --git a/spring-web/src/test/kotlin/org/springframework/web/client/RestOperationsExtensionsTests.kt b/spring-web/src/test/kotlin/org/springframework/web/client/RestOperationsExtensionsTests.kt index ff0e948eea..42a5e1f202 100644 --- a/spring-web/src/test/kotlin/org/springframework/web/client/RestOperationsExtensionsTests.kt +++ b/spring-web/src/test/kotlin/org/springframework/web/client/RestOperationsExtensionsTests.kt @@ -19,8 +19,7 @@ package org.springframework.web.client import io.mockk.every import io.mockk.mockk import io.mockk.verify -import org.junit.Assert -import org.junit.Assert.assertEquals +import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Test import org.springframework.core.ParameterizedTypeReference import org.springframework.http.* @@ -277,9 +276,9 @@ class RestOperationsExtensionsTests { if (method.parameterTypes.contains(kClass.java)) { val parameters = mutableListOf>(RestOperations::class.java).apply { addAll(method.parameterTypes.filter { it != kClass.java }) } val f = extensions.getDeclaredMethod(method.name, *parameters.toTypedArray()).kotlinFunction!! - Assert.assertEquals(1, f.typeParameters.size) + assertEquals(1, f.typeParameters.size) System.out.println(method.name + f.typeParameters) - Assert.assertEquals("Failed: " + method.name, listOf(Any::class.createType(nullable = true)), f.typeParameters[0].upperBounds) + assertEquals(listOf(Any::class.createType(nullable = true)), f.typeParameters[0].upperBounds, "Failed: " + method.name) } } } diff --git a/spring-web/src/test/kotlin/org/springframework/web/method/annotation/RequestParamMethodArgumentResolverKotlinTests.kt b/spring-web/src/test/kotlin/org/springframework/web/method/annotation/RequestParamMethodArgumentResolverKotlinTests.kt index 46646e4de6..945ba5aaf8 100644 --- a/spring-web/src/test/kotlin/org/springframework/web/method/annotation/RequestParamMethodArgumentResolverKotlinTests.kt +++ b/spring-web/src/test/kotlin/org/springframework/web/method/annotation/RequestParamMethodArgumentResolverKotlinTests.kt @@ -16,9 +16,9 @@ package org.springframework.web.method.annotation -import org.junit.Assert.assertEquals -import org.junit.Assert.assertNull -import org.junit.Assert.fail +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Assertions.assertNull +import org.junit.jupiter.api.fail import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import org.springframework.core.MethodParameter diff --git a/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/client/ClientResponseExtensionsTests.kt b/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/client/ClientResponseExtensionsTests.kt index 573598bea2..49e642af05 100644 --- a/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/client/ClientResponseExtensionsTests.kt +++ b/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/client/ClientResponseExtensionsTests.kt @@ -21,8 +21,8 @@ import io.mockk.mockk import io.mockk.verify import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.runBlocking -import org.junit.Assert.assertEquals -import org.junit.Assert.assertNull +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Assertions.assertNull import org.junit.jupiter.api.Test import org.springframework.core.ParameterizedTypeReference import org.springframework.http.HttpStatus diff --git a/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/client/WebClientExtensionsTests.kt b/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/client/WebClientExtensionsTests.kt index 1f2232a33b..70dabbfde6 100644 --- a/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/client/WebClientExtensionsTests.kt +++ b/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/client/WebClientExtensionsTests.kt @@ -22,7 +22,7 @@ import io.mockk.verify import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.runBlocking -import org.junit.Assert.assertEquals +import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Test import org.reactivestreams.Publisher import org.springframework.core.ParameterizedTypeReference diff --git a/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/server/CoRouterFunctionDslTests.kt b/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/server/CoRouterFunctionDslTests.kt index 0b081a8847..49d93c3e1f 100644 --- a/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/server/CoRouterFunctionDslTests.kt +++ b/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/server/CoRouterFunctionDslTests.kt @@ -16,7 +16,7 @@ package org.springframework.web.reactive.function.server -import org.junit.Assert.fail +import org.junit.jupiter.api.fail import org.junit.jupiter.api.Test import org.springframework.core.io.ClassPathResource import org.springframework.http.HttpHeaders.* diff --git a/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/server/RouterFunctionDslTests.kt b/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/server/RouterFunctionDslTests.kt index 9376a0f24f..fa61624c06 100644 --- a/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/server/RouterFunctionDslTests.kt +++ b/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/server/RouterFunctionDslTests.kt @@ -16,7 +16,7 @@ package org.springframework.web.reactive.function.server -import org.junit.Assert.fail +import org.junit.jupiter.api.fail import org.junit.jupiter.api.Test import org.springframework.core.io.ClassPathResource import org.springframework.http.HttpHeaders.* diff --git a/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/server/ServerRequestExtensionsTests.kt b/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/server/ServerRequestExtensionsTests.kt index cf898dbd08..ce62c29219 100644 --- a/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/server/ServerRequestExtensionsTests.kt +++ b/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/server/ServerRequestExtensionsTests.kt @@ -21,8 +21,8 @@ import io.mockk.mockk import io.mockk.verify import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.runBlocking -import org.junit.Assert.assertEquals -import org.junit.Assert.assertNull +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Assertions.assertNull import org.junit.jupiter.api.Test import org.springframework.core.ParameterizedTypeReference import org.springframework.http.codec.multipart.Part diff --git a/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/server/ServerResponseExtensionsTests.kt b/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/server/ServerResponseExtensionsTests.kt index 5306a5dd61..5db297834c 100644 --- a/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/server/ServerResponseExtensionsTests.kt +++ b/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/server/ServerResponseExtensionsTests.kt @@ -23,7 +23,7 @@ import io.reactivex.Flowable import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.runBlocking -import org.junit.Assert.assertEquals +import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Test import org.reactivestreams.Publisher import org.springframework.core.ParameterizedTypeReference diff --git a/spring-webflux/src/test/kotlin/org/springframework/web/reactive/result/KotlinInvocableHandlerMethodTests.kt b/spring-webflux/src/test/kotlin/org/springframework/web/reactive/result/KotlinInvocableHandlerMethodTests.kt index 9933a3de2a..02714a72ad 100644 --- a/spring-webflux/src/test/kotlin/org/springframework/web/reactive/result/KotlinInvocableHandlerMethodTests.kt +++ b/spring-webflux/src/test/kotlin/org/springframework/web/reactive/result/KotlinInvocableHandlerMethodTests.kt @@ -21,7 +21,7 @@ import io.mockk.mockk import kotlinx.coroutines.delay import org.hamcrest.CoreMatchers.`is` import org.hamcrest.MatcherAssert.assertThat -import org.junit.Assert.assertEquals +import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Test import org.springframework.http.HttpStatus import org.springframework.http.server.reactive.ServerHttpResponse diff --git a/spring-webflux/src/test/kotlin/org/springframework/web/reactive/result/method/annotation/CoroutinesIntegrationTests.kt b/spring-webflux/src/test/kotlin/org/springframework/web/reactive/result/method/annotation/CoroutinesIntegrationTests.kt index 483616b3cf..eb4af83f14 100644 --- a/spring-webflux/src/test/kotlin/org/springframework/web/reactive/result/method/annotation/CoroutinesIntegrationTests.kt +++ b/spring-webflux/src/test/kotlin/org/springframework/web/reactive/result/method/annotation/CoroutinesIntegrationTests.kt @@ -23,8 +23,8 @@ import kotlinx.coroutines.async import kotlinx.coroutines.delay import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flow -import org.junit.Assert.assertEquals -import org.junit.Assert.fail +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.fail import org.springframework.context.ApplicationContext import org.springframework.context.annotation.AnnotationConfigApplicationContext import org.springframework.context.annotation.ComponentScan diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/ResourceBundleViewResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/ResourceBundleViewResolverTests.java index c05b7cfa37..c653e61a6e 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/ResourceBundleViewResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/ResourceBundleViewResolverTests.java @@ -34,7 +34,7 @@ import org.springframework.web.servlet.View; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; /** * @author Rod Johnson diff --git a/spring-webmvc/src/test/kotlin/org/springframework/web/servlet/function/RouterFunctionDslTests.kt b/spring-webmvc/src/test/kotlin/org/springframework/web/servlet/function/RouterFunctionDslTests.kt index fe2cafefd8..468666a33a 100644 --- a/spring-webmvc/src/test/kotlin/org/springframework/web/servlet/function/RouterFunctionDslTests.kt +++ b/spring-webmvc/src/test/kotlin/org/springframework/web/servlet/function/RouterFunctionDslTests.kt @@ -16,9 +16,9 @@ package org.springframework.web.servlet.function -import org.junit.Assert.assertFalse -import org.junit.Assert.assertTrue -import org.junit.Assert.fail +import org.junit.jupiter.api.Assertions.assertFalse +import org.junit.jupiter.api.Assertions.assertTrue +import org.junit.jupiter.api.fail import org.junit.jupiter.api.Test import org.springframework.core.io.ClassPathResource import org.springframework.http.HttpHeaders.* diff --git a/spring-webmvc/src/test/kotlin/org/springframework/web/servlet/function/ServerRequestExtensionsTests.kt b/spring-webmvc/src/test/kotlin/org/springframework/web/servlet/function/ServerRequestExtensionsTests.kt index fca71de99f..1fbf8eebaf 100644 --- a/spring-webmvc/src/test/kotlin/org/springframework/web/servlet/function/ServerRequestExtensionsTests.kt +++ b/spring-webmvc/src/test/kotlin/org/springframework/web/servlet/function/ServerRequestExtensionsTests.kt @@ -19,8 +19,8 @@ package org.springframework.web.servlet.function import io.mockk.every import io.mockk.mockk import io.mockk.verify -import org.junit.Assert.assertEquals -import org.junit.Assert.assertNull +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Assertions.assertNull import org.junit.jupiter.api.Test import org.springframework.core.ParameterizedTypeReference import org.springframework.http.MediaType diff --git a/spring-webmvc/src/test/kotlin/org/springframework/web/servlet/function/ServerResponseExtensionsTests.kt b/spring-webmvc/src/test/kotlin/org/springframework/web/servlet/function/ServerResponseExtensionsTests.kt index d352d98a0d..e55377e58d 100644 --- a/spring-webmvc/src/test/kotlin/org/springframework/web/servlet/function/ServerResponseExtensionsTests.kt +++ b/spring-webmvc/src/test/kotlin/org/springframework/web/servlet/function/ServerResponseExtensionsTests.kt @@ -19,10 +19,10 @@ package org.springframework.web.servlet.function import io.mockk.every import io.mockk.mockk import io.mockk.verify -import org.junit.Assert import org.junit.jupiter.api.Test import org.springframework.core.ParameterizedTypeReference import java.util.* +import org.junit.jupiter.api.Assertions.assertEquals /** * Tests for WebMvc.fn [ServerResponse] extensions. @@ -38,7 +38,7 @@ class ServerResponseExtensionsTests { val body = Arrays.asList("foo", "bar") val typeReference = object: ParameterizedTypeReference>() {} every { builder.body(body, typeReference) } returns response - Assert.assertEquals(response, builder.bodyWithType>(body)) + assertEquals(response, builder.bodyWithType>(body)) verify { builder.body(body, typeReference) } } } diff --git a/spring-webmvc/src/test/kotlin/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodKotlinTests.kt b/spring-webmvc/src/test/kotlin/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodKotlinTests.kt index fc6b095721..27fd0365ac 100644 --- a/spring-webmvc/src/test/kotlin/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodKotlinTests.kt +++ b/spring-webmvc/src/test/kotlin/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodKotlinTests.kt @@ -16,7 +16,7 @@ package org.springframework.web.servlet.mvc.method.annotation -import org.junit.Assert.* +import org.junit.jupiter.api.Assertions.* import org.junit.jupiter.api.Test import org.springframework.mock.web.test.MockHttpServletRequest import org.springframework.mock.web.test.MockHttpServletResponse