提交 979508a7 编写于 作者: S Sam Brannen

Remove JUnit 4 dependency from all modules except spring-test

This commit removes the JUnit 4 dependency from all modules except
spring-test which provides explicit JUnit 4 support.

This commit also includes the following.

- migration from JUnit 4 assertions to JUnit Jupiter assertions in all
  Kotlin tests
- migration from JUnit 4 assumptions in Spring's TestGroup support to
  JUnit Jupiter assumptions, based on org.opentest4j.TestAbortedException
- introduction of a new TestGroups utility class than can be used from
  existing JUnit 4 tests in the spring-test module in order to perform
  assumptions using JUnit 4's Assume class

See gh-23451
上级 3f3e4192
......@@ -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}")
......
......@@ -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
......
......@@ -16,7 +16,7 @@
package org.springframework.beans
import org.junit.Assert.*
import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.Test
/**
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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<Foo>()
fail()
fail("should have thrown an Exception")
} catch (ignored: Exception) {
}
try {
context.getBean<FooFoo>()
fail()
fail("should have thrown an Exception")
} catch (ignored: Exception) {
}
}
......
......@@ -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
......
......@@ -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
/**
......
......@@ -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
/**
......
......@@ -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();
......
......@@ -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.
*
* <p>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"
* </pre>
*
* <p>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.
* <p>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<TestGroup> testGroups = loadTestGroups();
if (!testGroups.contains(group)) {
throw new AssumptionViolatedException("Requires unspecified group " + group + " from " + testGroups);
}
Set<TestGroup> 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}.
* <p>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<TestGroup> 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<TestGroup> 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
......
......@@ -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");
}
}
......
/*
* 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<TestGroup> 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);
}
}
}
......@@ -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 {
......
......@@ -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
......
......@@ -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
......
......@@ -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<Int> = 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<Int>).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<Int> = 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)
......
......@@ -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
/**
......
......@@ -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
/**
......
......@@ -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
......
......@@ -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
......
......@@ -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")
......
......@@ -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
......
......@@ -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();
......
......@@ -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
......
......@@ -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
......
......@@ -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<Class<*>>(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)
}
}
}
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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.*
......
......@@ -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.*
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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.*
......
......@@ -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
......
......@@ -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<List<String>>() {}
every { builder.body(body, typeReference) } returns response
Assert.assertEquals(response, builder.bodyWithType<List<String>>(body))
assertEquals(response, builder.bodyWithType<List<String>>(body))
verify { builder.body(body, typeReference) }
}
}
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册