diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/AspectJAdviceParameterNameDiscoverAnnotationTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/AspectJAdviceParameterNameDiscoverAnnotationTests.java index b115447ba93..fb64933db17 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/AspectJAdviceParameterNameDiscoverAnnotationTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/AspectJAdviceParameterNameDiscoverAnnotationTests.java @@ -17,7 +17,7 @@ package org.springframework.aop.aspectj; import org.aspectj.lang.ProceedingJoinPoint; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Additional parameter name discover tests that need Java 5. diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/AspectJAdviceParameterNameDiscovererTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/AspectJAdviceParameterNameDiscovererTests.java index b038595061a..4a4b6242297 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/AspectJAdviceParameterNameDiscovererTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/AspectJAdviceParameterNameDiscovererTests.java @@ -19,7 +19,7 @@ package org.springframework.aop.aspectj; import java.lang.reflect.Method; import org.aspectj.lang.JoinPoint; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.aspectj.AspectJAdviceParameterNameDiscoverer.AmbiguousBindingException; diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/AspectJExpressionPointcutTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/AspectJExpressionPointcutTests.java index d1170b3cd78..2ba65e3502b 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/AspectJExpressionPointcutTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/AspectJExpressionPointcutTests.java @@ -23,8 +23,8 @@ import org.aopalliance.intercept.MethodInvocation; import org.aspectj.weaver.tools.PointcutExpression; import org.aspectj.weaver.tools.PointcutPrimitive; import org.aspectj.weaver.tools.UnsupportedPointcutPrimitiveException; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.aop.ClassFilter; import org.springframework.aop.MethodMatcher; @@ -57,7 +57,7 @@ public class AspectJExpressionPointcutTests { private Method setSomeNumber; - @Before + @BeforeEach public void setUp() throws NoSuchMethodException { getAge = TestBean.class.getMethod("getAge"); setAge = TestBean.class.getMethod("setAge", int.class); diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutMatchingTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutMatchingTests.java index 44ba97915db..37787c68646 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutMatchingTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutMatchingTests.java @@ -16,7 +16,7 @@ package org.springframework.aop.aspectj; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.tests.sample.beans.TestBean; diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPointTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPointTests.java index c60861cf1df..2a59c73dfb5 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPointTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/MethodInvocationProceedingJoinPointTests.java @@ -26,7 +26,7 @@ import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.reflect.MethodSignature; import org.aspectj.lang.reflect.SourceLocation; import org.aspectj.runtime.reflect.Factory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.MethodBeforeAdvice; import org.springframework.aop.framework.AopContext; diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/TigerAspectJAdviceParameterNameDiscovererTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/TigerAspectJAdviceParameterNameDiscovererTests.java index 277731ccf9d..0cc3947260a 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/TigerAspectJAdviceParameterNameDiscovererTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/TigerAspectJAdviceParameterNameDiscovererTests.java @@ -16,7 +16,7 @@ package org.springframework.aop.aspectj; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.aspectj.AspectJAdviceParameterNameDiscoverer.AmbiguousBindingException; diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/TigerAspectJExpressionPointcutTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/TigerAspectJExpressionPointcutTests.java index 5f75a3de435..5e9acc89d42 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/TigerAspectJExpressionPointcutTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/TigerAspectJExpressionPointcutTests.java @@ -21,8 +21,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import test.annotation.EmptySpringAnnotation; import test.annotation.transaction.Tx; @@ -44,7 +44,7 @@ public class TigerAspectJExpressionPointcutTests { private final Map methodsOnHasGeneric = new HashMap<>(); - @Before + @BeforeEach public void setup() throws NoSuchMethodException { getAge = TestBean.class.getMethod("getAge"); // Assumes no overloading diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/TrickyAspectJPointcutExpressionTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/TrickyAspectJPointcutExpressionTests.java index 0652d51f940..a69b4c76b2a 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/TrickyAspectJPointcutExpressionTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/TrickyAspectJPointcutExpressionTests.java @@ -24,7 +24,7 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import java.lang.reflect.Method; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.Advisor; import org.springframework.aop.MethodBeforeAdvice; diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/TypePatternClassFilterTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/TypePatternClassFilterTests.java index 544976127ec..a1a321f6025 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/TypePatternClassFilterTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/TypePatternClassFilterTests.java @@ -16,7 +16,7 @@ package org.springframework.aop.aspectj; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.support.DefaultListableBeanFactory; diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactoryTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactoryTests.java index 8fc79006e1b..a31de710798 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactoryTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactoryTests.java @@ -38,8 +38,8 @@ import org.aspectj.lang.annotation.DeclareParents; import org.aspectj.lang.annotation.DeclarePrecedence; import org.aspectj.lang.annotation.Pointcut; import org.aspectj.lang.reflect.MethodSignature; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import test.aop.DefaultLockable; import test.aop.Lockable; import test.aop.PerTargetAspect; @@ -414,7 +414,7 @@ public abstract class AbstractAspectJAdvisorFactoryTests { // TODO: Why does this test fail? It hasn't been run before, so it maybe never actually passed... @Test - @Ignore + @Disabled public void testIntroductionWithArgumentBinding() { TestBean target = new TestBean(); diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/ArgumentBindingTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/ArgumentBindingTests.java index d7d0c5504a7..e0806be6f06 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/ArgumentBindingTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/ArgumentBindingTests.java @@ -24,7 +24,7 @@ import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Pointcut; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.aspectj.AspectJAdviceParameterNameDiscoverer; import org.springframework.tests.sample.beans.ITestBean; diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectJPointcutAdvisorTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectJPointcutAdvisorTests.java index 40d0e7adf0a..bbc816b3289 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectJPointcutAdvisorTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectJPointcutAdvisorTests.java @@ -16,7 +16,7 @@ package org.springframework.aop.aspectj.annotation; -import org.junit.Test; +import org.junit.jupiter.api.Test; import test.aop.PerTargetAspect; import org.springframework.aop.Pointcut; diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectMetadataTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectMetadataTests.java index b12c0972b24..45c93c628d2 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectMetadataTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectMetadataTests.java @@ -17,7 +17,7 @@ package org.springframework.aop.aspectj.annotation; import org.aspectj.lang.reflect.PerClauseKind; -import org.junit.Test; +import org.junit.jupiter.api.Test; import test.aop.PerTargetAspect; import org.springframework.aop.Pointcut; diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectProxyFactoryTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectProxyFactoryTests.java index e8fc775c837..0c4d6ff1d8d 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectProxyFactoryTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectProxyFactoryTests.java @@ -23,7 +23,7 @@ import org.apache.commons.logging.LogFactory; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; -import org.junit.Test; +import org.junit.jupiter.api.Test; import test.aop.PerThisAspect; import org.springframework.util.SerializationTestUtils; diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJNamespaceHandlerTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJNamespaceHandlerTests.java index 79232a8b651..b2b1323b4fd 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJNamespaceHandlerTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJNamespaceHandlerTests.java @@ -16,8 +16,8 @@ package org.springframework.aop.aspectj.autoproxy; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.aop.config.AopConfigUtils; import org.springframework.aop.config.AopNamespaceUtils; @@ -46,7 +46,7 @@ public class AspectJNamespaceHandlerTests { private BeanDefinitionRegistry registry = new DefaultListableBeanFactory(); - @Before + @BeforeEach public void setUp() throws Exception { SourceExtractor sourceExtractor = new PassThroughSourceExtractor(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(this.registry); diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJPrecedenceComparatorTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJPrecedenceComparatorTests.java index 72859babc6c..b9fc4028049 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJPrecedenceComparatorTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJPrecedenceComparatorTests.java @@ -18,8 +18,8 @@ package org.springframework.aop.aspectj.autoproxy; import java.lang.reflect.Method; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.aop.Advisor; import org.springframework.aop.AfterReturningAdvice; @@ -56,7 +56,7 @@ public class AspectJPrecedenceComparatorTests { private AspectJExpressionPointcut anyOldPointcut; - @Before + @BeforeEach public void setUp() throws Exception { this.comparator = new AspectJPrecedenceComparator(); this.anyOldMethod = getClass().getMethods()[0]; diff --git a/spring-aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerEventTests.java b/spring-aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerEventTests.java index 9e1639f7e2c..c31d5a396d0 100644 --- a/spring-aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerEventTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerEventTests.java @@ -19,8 +19,8 @@ package org.springframework.aop.config; import java.util.HashSet; import java.util.Set; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.BeanReference; @@ -56,7 +56,7 @@ public class AopNamespaceHandlerEventTests { private XmlBeanDefinitionReader reader; - @Before + @BeforeEach public void setup() { this.reader = new XmlBeanDefinitionReader(this.beanFactory); this.reader.setEventListener(this.eventListener); diff --git a/spring-aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests.java b/spring-aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests.java index d447b9bdc84..7b07a2f793e 100644 --- a/spring-aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests.java @@ -16,7 +16,7 @@ package org.springframework.aop.config; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanDefinitionStoreException; import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; diff --git a/spring-aop/src/test/java/org/springframework/aop/config/TopLevelAopTagTests.java b/spring-aop/src/test/java/org/springframework/aop/config/TopLevelAopTagTests.java index bbcdbe93680..95732b92a1d 100644 --- a/spring-aop/src/test/java/org/springframework/aop/config/TopLevelAopTagTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/config/TopLevelAopTagTests.java @@ -16,7 +16,7 @@ package org.springframework.aop.config; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; diff --git a/spring-aop/src/test/java/org/springframework/aop/framework/AopProxyUtilsTests.java b/spring-aop/src/test/java/org/springframework/aop/framework/AopProxyUtilsTests.java index eaa4e44e6c8..f2f9c624424 100644 --- a/spring-aop/src/test/java/org/springframework/aop/framework/AopProxyUtilsTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/framework/AopProxyUtilsTests.java @@ -20,7 +20,7 @@ import java.lang.reflect.Proxy; import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.SpringProxy; import org.springframework.tests.sample.beans.ITestBean; diff --git a/spring-aop/src/test/java/org/springframework/aop/framework/IntroductionBenchmarkTests.java b/spring-aop/src/test/java/org/springframework/aop/framework/IntroductionBenchmarkTests.java index 22afa2cf8f5..50092ca733b 100644 --- a/spring-aop/src/test/java/org/springframework/aop/framework/IntroductionBenchmarkTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/framework/IntroductionBenchmarkTests.java @@ -16,7 +16,7 @@ package org.springframework.aop.framework; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.support.DelegatingIntroductionInterceptor; import org.springframework.tests.sample.beans.ITestBean; diff --git a/spring-aop/src/test/java/org/springframework/aop/framework/MethodInvocationTests.java b/spring-aop/src/test/java/org/springframework/aop/framework/MethodInvocationTests.java index f78d9f9e912..a422e4dcfaf 100644 --- a/spring-aop/src/test/java/org/springframework/aop/framework/MethodInvocationTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/framework/MethodInvocationTests.java @@ -22,7 +22,7 @@ import java.util.List; import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInvocation; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.tests.sample.beans.TestBean; diff --git a/spring-aop/src/test/java/org/springframework/aop/framework/NullPrimitiveTests.java b/spring-aop/src/test/java/org/springframework/aop/framework/NullPrimitiveTests.java index 0256632aa25..c2138f12278 100644 --- a/spring-aop/src/test/java/org/springframework/aop/framework/NullPrimitiveTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/framework/NullPrimitiveTests.java @@ -18,7 +18,7 @@ package org.springframework.aop.framework; import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInvocation; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.AopInvocationException; diff --git a/spring-aop/src/test/java/org/springframework/aop/framework/PrototypeTargetTests.java b/spring-aop/src/test/java/org/springframework/aop/framework/PrototypeTargetTests.java index 83406650890..6174c02a0c1 100644 --- a/spring-aop/src/test/java/org/springframework/aop/framework/PrototypeTargetTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/framework/PrototypeTargetTests.java @@ -18,7 +18,7 @@ package org.springframework.aop.framework; import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInvocation; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; diff --git a/spring-aop/src/test/java/org/springframework/aop/framework/ProxyFactoryTests.java b/spring-aop/src/test/java/org/springframework/aop/framework/ProxyFactoryTests.java index 0310a8bef1e..fcb7f570656 100644 --- a/spring-aop/src/test/java/org/springframework/aop/framework/ProxyFactoryTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/framework/ProxyFactoryTests.java @@ -24,8 +24,8 @@ import javax.swing.RootPaneContainer; import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInvocation; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.springframework.aop.Advisor; import org.springframework.aop.interceptor.DebugInterceptor; @@ -325,7 +325,7 @@ public class ProxyFactoryTests { } @Test - @Ignore("Not implemented yet, see https://jira.springframework.org/browse/SPR-5708") + @Disabled("Not implemented yet, see https://jira.springframework.org/browse/SPR-5708") public void testExclusionOfNonPublicInterfaces() { JFrame frame = new JFrame(); ProxyFactory proxyFactory = new ProxyFactory(frame); diff --git a/spring-aop/src/test/java/org/springframework/aop/framework/adapter/ThrowsAdviceInterceptorTests.java b/spring-aop/src/test/java/org/springframework/aop/framework/adapter/ThrowsAdviceInterceptorTests.java index 62eefa62563..a836bcc0031 100644 --- a/spring-aop/src/test/java/org/springframework/aop/framework/adapter/ThrowsAdviceInterceptorTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/framework/adapter/ThrowsAdviceInterceptorTests.java @@ -23,7 +23,7 @@ import java.rmi.ConnectException; import java.rmi.RemoteException; import org.aopalliance.intercept.MethodInvocation; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.ThrowsAdvice; import org.springframework.tests.aop.advice.MethodCounter; diff --git a/spring-aop/src/test/java/org/springframework/aop/interceptor/ConcurrencyThrottleInterceptorTests.java b/spring-aop/src/test/java/org/springframework/aop/interceptor/ConcurrencyThrottleInterceptorTests.java index c3e8d888c83..9477df4ca01 100644 --- a/spring-aop/src/test/java/org/springframework/aop/interceptor/ConcurrencyThrottleInterceptorTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/interceptor/ConcurrencyThrottleInterceptorTests.java @@ -18,7 +18,7 @@ package org.springframework.aop.interceptor; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.framework.Advised; import org.springframework.aop.framework.ProxyFactory; diff --git a/spring-aop/src/test/java/org/springframework/aop/interceptor/CustomizableTraceInterceptorTests.java b/spring-aop/src/test/java/org/springframework/aop/interceptor/CustomizableTraceInterceptorTests.java index 5d63b554aa3..d5fcae4bd3c 100644 --- a/spring-aop/src/test/java/org/springframework/aop/interceptor/CustomizableTraceInterceptorTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/interceptor/CustomizableTraceInterceptorTests.java @@ -18,7 +18,7 @@ package org.springframework.aop.interceptor; import org.aopalliance.intercept.MethodInvocation; import org.apache.commons.logging.Log; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.mockito.ArgumentMatchers.anyString; diff --git a/spring-aop/src/test/java/org/springframework/aop/interceptor/DebugInterceptorTests.java b/spring-aop/src/test/java/org/springframework/aop/interceptor/DebugInterceptorTests.java index fde013a4905..427b9cbf845 100644 --- a/spring-aop/src/test/java/org/springframework/aop/interceptor/DebugInterceptorTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/interceptor/DebugInterceptorTests.java @@ -18,7 +18,7 @@ package org.springframework.aop.interceptor; import org.aopalliance.intercept.MethodInvocation; import org.apache.commons.logging.Log; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-aop/src/test/java/org/springframework/aop/interceptor/ExposeBeanNameAdvisorsTests.java b/spring-aop/src/test/java/org/springframework/aop/interceptor/ExposeBeanNameAdvisorsTests.java index 721c7b27dd3..ccb4d526313 100644 --- a/spring-aop/src/test/java/org/springframework/aop/interceptor/ExposeBeanNameAdvisorsTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/interceptor/ExposeBeanNameAdvisorsTests.java @@ -16,7 +16,7 @@ package org.springframework.aop.interceptor; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.framework.ProxyFactory; import org.springframework.beans.factory.NamedBean; diff --git a/spring-aop/src/test/java/org/springframework/aop/interceptor/ExposeInvocationInterceptorTests.java b/spring-aop/src/test/java/org/springframework/aop/interceptor/ExposeInvocationInterceptorTests.java index f188ef1a475..76b682bf093 100644 --- a/spring-aop/src/test/java/org/springframework/aop/interceptor/ExposeInvocationInterceptorTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/interceptor/ExposeInvocationInterceptorTests.java @@ -17,7 +17,7 @@ package org.springframework.aop.interceptor; import org.aopalliance.intercept.MethodInvocation; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; diff --git a/spring-aop/src/test/java/org/springframework/aop/interceptor/JamonPerformanceMonitorInterceptorTests.java b/spring-aop/src/test/java/org/springframework/aop/interceptor/JamonPerformanceMonitorInterceptorTests.java index 8d52931442b..18556d6df50 100644 --- a/spring-aop/src/test/java/org/springframework/aop/interceptor/JamonPerformanceMonitorInterceptorTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/interceptor/JamonPerformanceMonitorInterceptorTests.java @@ -19,9 +19,9 @@ package org.springframework.aop.interceptor; import com.jamonapi.MonitorFactory; import org.aopalliance.intercept.MethodInvocation; import org.apache.commons.logging.Log; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; @@ -41,12 +41,12 @@ public class JamonPerformanceMonitorInterceptorTests { private final Log log = mock(Log.class); - @Before + @BeforeEach public void setUp() { MonitorFactory.reset(); } - @After + @AfterEach public void tearDown() { MonitorFactory.reset(); } diff --git a/spring-aop/src/test/java/org/springframework/aop/interceptor/PerformanceMonitorInterceptorTests.java b/spring-aop/src/test/java/org/springframework/aop/interceptor/PerformanceMonitorInterceptorTests.java index 0f1e4b4b347..c4c4f94737d 100644 --- a/spring-aop/src/test/java/org/springframework/aop/interceptor/PerformanceMonitorInterceptorTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/interceptor/PerformanceMonitorInterceptorTests.java @@ -18,7 +18,7 @@ package org.springframework.aop.interceptor; import org.aopalliance.intercept.MethodInvocation; import org.apache.commons.logging.Log; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-aop/src/test/java/org/springframework/aop/interceptor/SimpleTraceInterceptorTests.java b/spring-aop/src/test/java/org/springframework/aop/interceptor/SimpleTraceInterceptorTests.java index b98e25babd1..f076e3136ac 100644 --- a/spring-aop/src/test/java/org/springframework/aop/interceptor/SimpleTraceInterceptorTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/interceptor/SimpleTraceInterceptorTests.java @@ -18,7 +18,7 @@ package org.springframework.aop.interceptor; import org.aopalliance.intercept.MethodInvocation; import org.apache.commons.logging.Log; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.mockito.ArgumentMatchers.anyString; diff --git a/spring-aop/src/test/java/org/springframework/aop/scope/DefaultScopedObjectTests.java b/spring-aop/src/test/java/org/springframework/aop/scope/DefaultScopedObjectTests.java index ef0291ea421..296da8b6594 100644 --- a/spring-aop/src/test/java/org/springframework/aop/scope/DefaultScopedObjectTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/scope/DefaultScopedObjectTests.java @@ -16,7 +16,7 @@ package org.springframework.aop.scope; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.config.ConfigurableBeanFactory; diff --git a/spring-aop/src/test/java/org/springframework/aop/scope/ScopedProxyAutowireTests.java b/spring-aop/src/test/java/org/springframework/aop/scope/ScopedProxyAutowireTests.java index cf0992a22b6..42f32fa1eb0 100644 --- a/spring-aop/src/test/java/org/springframework/aop/scope/ScopedProxyAutowireTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/scope/ScopedProxyAutowireTests.java @@ -18,7 +18,7 @@ package org.springframework.aop.scope; import java.util.Arrays; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; diff --git a/spring-aop/src/test/java/org/springframework/aop/support/AbstractRegexpMethodPointcutTests.java b/spring-aop/src/test/java/org/springframework/aop/support/AbstractRegexpMethodPointcutTests.java index 7b3e8b9455f..f13ebf47fea 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/AbstractRegexpMethodPointcutTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/AbstractRegexpMethodPointcutTests.java @@ -18,8 +18,8 @@ package org.springframework.aop.support; import java.io.IOException; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.tests.sample.beans.TestBean; import org.springframework.util.SerializationTestUtils; @@ -35,7 +35,7 @@ public abstract class AbstractRegexpMethodPointcutTests { private AbstractRegexpMethodPointcut rpc; - @Before + @BeforeEach public void setUp() { rpc = getRegexpMethodPointcut(); } diff --git a/spring-aop/src/test/java/org/springframework/aop/support/AopUtilsTests.java b/spring-aop/src/test/java/org/springframework/aop/support/AopUtilsTests.java index c9c40f57535..63778647deb 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/AopUtilsTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/AopUtilsTests.java @@ -18,7 +18,7 @@ package org.springframework.aop.support; import java.lang.reflect.Method; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.ClassFilter; import org.springframework.aop.MethodMatcher; diff --git a/spring-aop/src/test/java/org/springframework/aop/support/ClassFiltersTests.java b/spring-aop/src/test/java/org/springframework/aop/support/ClassFiltersTests.java index bbc7ce9a8e5..506a20ee016 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/ClassFiltersTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/ClassFiltersTests.java @@ -16,7 +16,7 @@ package org.springframework.aop.support; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.ClassFilter; import org.springframework.core.NestedRuntimeException; diff --git a/spring-aop/src/test/java/org/springframework/aop/support/ClassUtilsTests.java b/spring-aop/src/test/java/org/springframework/aop/support/ClassUtilsTests.java index 3aa9f3abe2f..39139bbbd02 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/ClassUtilsTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/ClassUtilsTests.java @@ -15,7 +15,7 @@ */ package org.springframework.aop.support; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.framework.ProxyFactory; import org.springframework.tests.sample.beans.TestBean; diff --git a/spring-aop/src/test/java/org/springframework/aop/support/ComposablePointcutTests.java b/spring-aop/src/test/java/org/springframework/aop/support/ComposablePointcutTests.java index 36dcde9a825..c4400b3371b 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/ComposablePointcutTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/ComposablePointcutTests.java @@ -18,7 +18,7 @@ package org.springframework.aop.support; import java.lang.reflect.Method; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.ClassFilter; import org.springframework.aop.MethodMatcher; diff --git a/spring-aop/src/test/java/org/springframework/aop/support/ControlFlowPointcutTests.java b/spring-aop/src/test/java/org/springframework/aop/support/ControlFlowPointcutTests.java index 6c7a062657a..7654324d196 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/ControlFlowPointcutTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/ControlFlowPointcutTests.java @@ -16,7 +16,7 @@ package org.springframework.aop.support; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.Pointcut; import org.springframework.aop.framework.ProxyFactory; diff --git a/spring-aop/src/test/java/org/springframework/aop/support/DelegatingIntroductionInterceptorTests.java b/spring-aop/src/test/java/org/springframework/aop/support/DelegatingIntroductionInterceptorTests.java index c4e6022b732..a165be41a40 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/DelegatingIntroductionInterceptorTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/DelegatingIntroductionInterceptorTests.java @@ -19,7 +19,7 @@ package org.springframework.aop.support; import java.io.Serializable; import org.aopalliance.intercept.MethodInterceptor; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.IntroductionAdvisor; import org.springframework.aop.IntroductionInterceptor; diff --git a/spring-aop/src/test/java/org/springframework/aop/support/MethodMatchersTests.java b/spring-aop/src/test/java/org/springframework/aop/support/MethodMatchersTests.java index 3c90cdd8879..f860ef72d4e 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/MethodMatchersTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/MethodMatchersTests.java @@ -18,7 +18,7 @@ package org.springframework.aop.support; import java.lang.reflect.Method; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.MethodMatcher; import org.springframework.lang.Nullable; diff --git a/spring-aop/src/test/java/org/springframework/aop/support/NameMatchMethodPointcutTests.java b/spring-aop/src/test/java/org/springframework/aop/support/NameMatchMethodPointcutTests.java index 83f2d8e99d3..91517e6831c 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/NameMatchMethodPointcutTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/NameMatchMethodPointcutTests.java @@ -16,8 +16,8 @@ package org.springframework.aop.support; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.aop.framework.Advised; import org.springframework.aop.framework.ProxyFactory; @@ -45,7 +45,7 @@ public class NameMatchMethodPointcutTests { /** * Create an empty pointcut, populating instance variables. */ - @Before + @BeforeEach public void setup() { ProxyFactory pf = new ProxyFactory(new SerializablePerson()); nop = new SerializableNopInterceptor(); diff --git a/spring-aop/src/test/java/org/springframework/aop/support/PointcutsTests.java b/spring-aop/src/test/java/org/springframework/aop/support/PointcutsTests.java index 82066758654..5bd684f1be6 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/PointcutsTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/PointcutsTests.java @@ -18,7 +18,7 @@ package org.springframework.aop.support; import java.lang.reflect.Method; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.ClassFilter; import org.springframework.aop.Pointcut; diff --git a/spring-aop/src/test/java/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests.java b/spring-aop/src/test/java/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests.java index d2f7c42e4c8..da9699a305b 100644 --- a/spring-aop/src/test/java/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/support/RegexpMethodPointcutAdvisorIntegrationTests.java @@ -16,7 +16,7 @@ package org.springframework.aop.support; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.framework.Advised; import org.springframework.beans.factory.support.DefaultListableBeanFactory; diff --git a/spring-aop/src/test/java/org/springframework/aop/target/CommonsPool2TargetSourceProxyTests.java b/spring-aop/src/test/java/org/springframework/aop/target/CommonsPool2TargetSourceProxyTests.java index 3c0cf04d2c3..31afac2e099 100644 --- a/spring-aop/src/test/java/org/springframework/aop/target/CommonsPool2TargetSourceProxyTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/target/CommonsPool2TargetSourceProxyTests.java @@ -16,7 +16,7 @@ package org.springframework.aop.target; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.support.AopUtils; import org.springframework.beans.factory.support.DefaultListableBeanFactory; diff --git a/spring-aop/src/test/java/org/springframework/aop/target/HotSwappableTargetSourceTests.java b/spring-aop/src/test/java/org/springframework/aop/target/HotSwappableTargetSourceTests.java index 7e9b615a942..ef7bea56dae 100644 --- a/spring-aop/src/test/java/org/springframework/aop/target/HotSwappableTargetSourceTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/target/HotSwappableTargetSourceTests.java @@ -16,9 +16,9 @@ package org.springframework.aop.target; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.aop.framework.Advised; import org.springframework.aop.framework.ProxyFactory; @@ -47,7 +47,7 @@ public class HotSwappableTargetSourceTests { private DefaultListableBeanFactory beanFactory; - @Before + @BeforeEach public void setup() { this.beanFactory = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(this.beanFactory).loadBeanDefinitions( @@ -57,7 +57,7 @@ public class HotSwappableTargetSourceTests { /** * We must simulate container shutdown, which should clear threads. */ - @After + @AfterEach public void close() { // Will call pool.close() this.beanFactory.destroySingletons(); diff --git a/spring-aop/src/test/java/org/springframework/aop/target/LazyCreationTargetSourceTests.java b/spring-aop/src/test/java/org/springframework/aop/target/LazyCreationTargetSourceTests.java index bf89cf1f55b..4551245335e 100644 --- a/spring-aop/src/test/java/org/springframework/aop/target/LazyCreationTargetSourceTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/target/LazyCreationTargetSourceTests.java @@ -16,7 +16,7 @@ package org.springframework.aop.target; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.TargetSource; import org.springframework.aop.framework.ProxyFactory; diff --git a/spring-aop/src/test/java/org/springframework/aop/target/LazyInitTargetSourceTests.java b/spring-aop/src/test/java/org/springframework/aop/target/LazyInitTargetSourceTests.java index 6e45f0eb7ab..0efaa5165e6 100644 --- a/spring-aop/src/test/java/org/springframework/aop/target/LazyInitTargetSourceTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/target/LazyInitTargetSourceTests.java @@ -18,7 +18,7 @@ package org.springframework.aop.target; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; diff --git a/spring-aop/src/test/java/org/springframework/aop/target/PrototypeBasedTargetSourceTests.java b/spring-aop/src/test/java/org/springframework/aop/target/PrototypeBasedTargetSourceTests.java index 8b771d068a5..f051925ad3c 100644 --- a/spring-aop/src/test/java/org/springframework/aop/target/PrototypeBasedTargetSourceTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/target/PrototypeBasedTargetSourceTests.java @@ -16,7 +16,7 @@ package org.springframework.aop.target; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.TargetSource; import org.springframework.beans.MutablePropertyValues; diff --git a/spring-aop/src/test/java/org/springframework/aop/target/PrototypeTargetSourceTests.java b/spring-aop/src/test/java/org/springframework/aop/target/PrototypeTargetSourceTests.java index c83fff14ac2..edcf3379a7c 100644 --- a/spring-aop/src/test/java/org/springframework/aop/target/PrototypeTargetSourceTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/target/PrototypeTargetSourceTests.java @@ -16,8 +16,8 @@ package org.springframework.aop.target; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; @@ -38,7 +38,7 @@ public class PrototypeTargetSourceTests { private DefaultListableBeanFactory beanFactory; - @Before + @BeforeEach public void setup() { this.beanFactory = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(this.beanFactory).loadBeanDefinitions( diff --git a/spring-aop/src/test/java/org/springframework/aop/target/ThreadLocalTargetSourceTests.java b/spring-aop/src/test/java/org/springframework/aop/target/ThreadLocalTargetSourceTests.java index b15959f2679..bb5e6579d83 100644 --- a/spring-aop/src/test/java/org/springframework/aop/target/ThreadLocalTargetSourceTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/target/ThreadLocalTargetSourceTests.java @@ -16,8 +16,8 @@ package org.springframework.aop.target; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; @@ -39,7 +39,7 @@ public class ThreadLocalTargetSourceTests { private DefaultListableBeanFactory beanFactory; - @Before + @BeforeEach public void setup() { this.beanFactory = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(this.beanFactory).loadBeanDefinitions( diff --git a/spring-aop/src/test/java/org/springframework/aop/target/dynamic/RefreshableTargetSourceTests.java b/spring-aop/src/test/java/org/springframework/aop/target/dynamic/RefreshableTargetSourceTests.java index 3787e4bc113..81505504339 100644 --- a/spring-aop/src/test/java/org/springframework/aop/target/dynamic/RefreshableTargetSourceTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/target/dynamic/RefreshableTargetSourceTests.java @@ -16,7 +16,7 @@ package org.springframework.aop.target.dynamic; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.tests.Assume; import org.springframework.tests.TestGroup; diff --git a/spring-aspects/src/test/java/org/springframework/aop/aspectj/autoproxy/AutoProxyWithCodeStyleAspectsTests.java b/spring-aspects/src/test/java/org/springframework/aop/aspectj/autoproxy/AutoProxyWithCodeStyleAspectsTests.java index d8b71ab33aa..43947fa29c2 100644 --- a/spring-aspects/src/test/java/org/springframework/aop/aspectj/autoproxy/AutoProxyWithCodeStyleAspectsTests.java +++ b/spring-aspects/src/test/java/org/springframework/aop/aspectj/autoproxy/AutoProxyWithCodeStyleAspectsTests.java @@ -16,7 +16,7 @@ package org.springframework.aop.aspectj.autoproxy; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.support.ClassPathXmlApplicationContext; diff --git a/spring-aspects/src/test/java/org/springframework/beans/factory/aspectj/SpringConfiguredWithAutoProxyingTests.java b/spring-aspects/src/test/java/org/springframework/beans/factory/aspectj/SpringConfiguredWithAutoProxyingTests.java index 49a658a7469..a02bcad6793 100644 --- a/spring-aspects/src/test/java/org/springframework/beans/factory/aspectj/SpringConfiguredWithAutoProxyingTests.java +++ b/spring-aspects/src/test/java/org/springframework/beans/factory/aspectj/SpringConfiguredWithAutoProxyingTests.java @@ -16,7 +16,7 @@ package org.springframework.beans.factory.aspectj; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.support.ClassPathXmlApplicationContext; diff --git a/spring-aspects/src/test/java/org/springframework/beans/factory/aspectj/XmlBeanConfigurerTests.java b/spring-aspects/src/test/java/org/springframework/beans/factory/aspectj/XmlBeanConfigurerTests.java index 76dce4fd096..71e98f68295 100644 --- a/spring-aspects/src/test/java/org/springframework/beans/factory/aspectj/XmlBeanConfigurerTests.java +++ b/spring-aspects/src/test/java/org/springframework/beans/factory/aspectj/XmlBeanConfigurerTests.java @@ -16,7 +16,7 @@ package org.springframework.beans.factory.aspectj; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.support.ClassPathXmlApplicationContext; diff --git a/spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJCacheAnnotationTests.java b/spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJCacheAnnotationTests.java index acf2d5255a2..b373056fcc7 100644 --- a/spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJCacheAnnotationTests.java +++ b/spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJCacheAnnotationTests.java @@ -16,7 +16,7 @@ package org.springframework.cache.aspectj; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.cache.Cache; import org.springframework.cache.config.AbstractCacheAnnotationTests; diff --git a/spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJEnableCachingIsolatedTests.java b/spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJEnableCachingIsolatedTests.java index 92207ad0a29..57b9b90f559 100644 --- a/spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJEnableCachingIsolatedTests.java +++ b/spring-aspects/src/test/java/org/springframework/cache/aspectj/AspectJEnableCachingIsolatedTests.java @@ -16,9 +16,9 @@ package org.springframework.cache.aspectj; -import org.junit.After; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanCreationException; import org.springframework.cache.CacheManager; @@ -57,7 +57,7 @@ public class AspectJEnableCachingIsolatedTests { this.ctx = new AnnotationConfigApplicationContext(config); } - @After + @AfterEach public void closeContext() { if (this.ctx != null) { this.ctx.close(); @@ -126,7 +126,7 @@ public class AspectJEnableCachingIsolatedTests { } @Test - @Ignore("AspectJ has some sort of caching that makes this one fail") + @Disabled("AspectJ has some sort of caching that makes this one fail") public void emptyConfigSupport() { load(EmptyConfigSupportConfig.class); AnnotationCacheAspect aspect = this.ctx.getBean(AnnotationCacheAspect.class); diff --git a/spring-aspects/src/test/java/org/springframework/context/annotation/aspectj/AnnotationBeanConfigurerTests.java b/spring-aspects/src/test/java/org/springframework/context/annotation/aspectj/AnnotationBeanConfigurerTests.java index 7eb1ec2cefc..ae781c8fa69 100644 --- a/spring-aspects/src/test/java/org/springframework/context/annotation/aspectj/AnnotationBeanConfigurerTests.java +++ b/spring-aspects/src/test/java/org/springframework/context/annotation/aspectj/AnnotationBeanConfigurerTests.java @@ -16,7 +16,7 @@ package org.springframework.context.annotation.aspectj; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.aspectj.ShouldBeConfiguredBySpring; import org.springframework.context.annotation.AnnotationConfigApplicationContext; diff --git a/spring-aspects/src/test/java/org/springframework/scheduling/aspectj/AnnotationAsyncExecutionAspectTests.java b/spring-aspects/src/test/java/org/springframework/scheduling/aspectj/AnnotationAsyncExecutionAspectTests.java index 02eb4b0c418..bb9decb90bc 100644 --- a/spring-aspects/src/test/java/org/springframework/scheduling/aspectj/AnnotationAsyncExecutionAspectTests.java +++ b/spring-aspects/src/test/java/org/springframework/scheduling/aspectj/AnnotationAsyncExecutionAspectTests.java @@ -22,8 +22,8 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler; import org.springframework.aop.interceptor.SimpleAsyncUncaughtExceptionHandler; @@ -55,7 +55,7 @@ public class AnnotationAsyncExecutionAspectTests { private CountingExecutor executor; - @Before + @BeforeEach public void setUp() { Assume.group(TestGroup.PERFORMANCE); diff --git a/spring-aspects/src/test/java/org/springframework/scheduling/aspectj/AnnotationDrivenBeanDefinitionParserTests.java b/spring-aspects/src/test/java/org/springframework/scheduling/aspectj/AnnotationDrivenBeanDefinitionParserTests.java index 9dc40e74bd9..20c22f4dbb7 100644 --- a/spring-aspects/src/test/java/org/springframework/scheduling/aspectj/AnnotationDrivenBeanDefinitionParserTests.java +++ b/spring-aspects/src/test/java/org/springframework/scheduling/aspectj/AnnotationDrivenBeanDefinitionParserTests.java @@ -18,9 +18,9 @@ package org.springframework.scheduling.aspectj; import java.util.function.Supplier; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.DirectFieldAccessor; import org.springframework.context.ConfigurableApplicationContext; @@ -36,13 +36,13 @@ public class AnnotationDrivenBeanDefinitionParserTests { private ConfigurableApplicationContext context; - @Before + @BeforeEach public void setup() { this.context = new ClassPathXmlApplicationContext( "annotationDrivenContext.xml", AnnotationDrivenBeanDefinitionParserTests.class); } - @After + @AfterEach public void after() { if (this.context != null) { this.context.close(); diff --git a/spring-aspects/src/test/java/org/springframework/transaction/aspectj/JtaTransactionAspectsTests.java b/spring-aspects/src/test/java/org/springframework/transaction/aspectj/JtaTransactionAspectsTests.java index fbe41ae0d94..0a0f811caef 100644 --- a/spring-aspects/src/test/java/org/springframework/transaction/aspectj/JtaTransactionAspectsTests.java +++ b/spring-aspects/src/test/java/org/springframework/transaction/aspectj/JtaTransactionAspectsTests.java @@ -19,15 +19,15 @@ package org.springframework.transaction.aspectj; import java.io.IOException; import javax.transaction.Transactional; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.tests.transaction.CallCountingTransactionManager; import static org.assertj.core.api.Assertions.assertThat; @@ -37,14 +37,14 @@ import static org.assertj.core.api.Assertions.assertThatIOException; /** * @author Stephane Nicoll */ -@RunWith(SpringJUnit4ClassRunner.class) +@ExtendWith(SpringExtension.class) @ContextConfiguration(classes = JtaTransactionAspectsTests.Config.class) public class JtaTransactionAspectsTests { @Autowired private CallCountingTransactionManager txManager; - @Before + @BeforeEach public void setUp() { this.txManager.clear(); } diff --git a/spring-aspects/src/test/java/org/springframework/transaction/aspectj/TransactionAspectTests.java b/spring-aspects/src/test/java/org/springframework/transaction/aspectj/TransactionAspectTests.java index 28ca98d232e..978b2e2da70 100644 --- a/spring-aspects/src/test/java/org/springframework/transaction/aspectj/TransactionAspectTests.java +++ b/spring-aspects/src/test/java/org/springframework/transaction/aspectj/TransactionAspectTests.java @@ -16,8 +16,8 @@ package org.springframework.transaction.aspectj; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.tests.transaction.CallCountingTransactionManager; @@ -47,7 +47,7 @@ public class TransactionAspectTests { new MethodAnnotationOnClassWithNoInterface(); - @Before + @BeforeEach public void initContext() { AnnotationTransactionAspect.aspectOf().setTransactionManager(txManager); } diff --git a/spring-beans/src/test/java/org/springframework/beans/AbstractPropertyAccessorTests.java b/spring-beans/src/test/java/org/springframework/beans/AbstractPropertyAccessorTests.java index dd3d0ef02a2..80db020a664 100644 --- a/spring-beans/src/test/java/org/springframework/beans/AbstractPropertyAccessorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/AbstractPropertyAccessorTests.java @@ -36,7 +36,7 @@ import java.util.TreeMap; import java.util.TreeSet; import org.apache.commons.logging.LogFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowire; import org.springframework.beans.propertyeditors.CustomNumberEditor; @@ -76,14 +76,12 @@ import static org.assertj.core.api.Assertions.within; */ public abstract class AbstractPropertyAccessorTests { - protected abstract AbstractPropertyAccessor createAccessor(Object target); @Test public void createWithNullTarget() { - assertThatIllegalArgumentException().isThrownBy(() -> - createAccessor(null)); + assertThatIllegalArgumentException().isThrownBy(() -> createAccessor(null)); } @Test @@ -114,8 +112,7 @@ public abstract class AbstractPropertyAccessorTests { public void isReadablePropertyNull() { AbstractPropertyAccessor accessor = createAccessor(new NoRead()); - assertThatIllegalArgumentException().isThrownBy(() -> - accessor.isReadableProperty(null)); + assertThatIllegalArgumentException().isThrownBy(() -> accessor.isReadableProperty(null)); } @Test @@ -129,8 +126,7 @@ public abstract class AbstractPropertyAccessorTests { public void isWritablePropertyNull() { AbstractPropertyAccessor accessor = createAccessor(new NoRead()); - assertThatIllegalArgumentException().isThrownBy(() -> - accessor.isWritableProperty(null)); + assertThatIllegalArgumentException().isThrownBy(() -> accessor.isWritableProperty(null)); } @Test @@ -519,7 +515,6 @@ public abstract class AbstractPropertyAccessorTests { assertThat(target.getSpouse() == null).as("spouse is now null").isTrue(); } - @Test public void setIndexedPropertyIgnored() { MutablePropertyValues values = new MutablePropertyValues(); @@ -692,7 +687,6 @@ public abstract class AbstractPropertyAccessorTests { assertThat(target.getMyPrimitiveDouble()).isCloseTo(Double.MAX_VALUE, within(0.001)); assertThat(target.getMyDouble().doubleValue()).isCloseTo(Double.MAX_VALUE, within(0.001)); - } @Test @@ -1105,7 +1099,6 @@ public abstract class AbstractPropertyAccessorTests { assertThat(target.getObject()).isEqualTo(array); } - @Test public void setCollectionProperty() { IndexedTestBean target = new IndexedTestBean(); @@ -1918,7 +1911,6 @@ public abstract class AbstractPropertyAccessorTests { // class to test naming of beans in a error message } - @SuppressWarnings("unused") private static class NumberPropertyBean { diff --git a/spring-beans/src/test/java/org/springframework/beans/BeanUtilsTests.java b/spring-beans/src/test/java/org/springframework/beans/BeanUtilsTests.java index df45480893c..d6f67bbcca3 100644 --- a/spring-beans/src/test/java/org/springframework/beans/BeanUtilsTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/BeanUtilsTests.java @@ -22,7 +22,7 @@ import java.lang.reflect.Constructor; import java.lang.reflect.Method; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.propertyeditors.CustomDateEditor; diff --git a/spring-beans/src/test/java/org/springframework/beans/BeanWrapperAutoGrowingTests.java b/spring-beans/src/test/java/org/springframework/beans/BeanWrapperAutoGrowingTests.java index 16a08701d83..c17e2c7359b 100644 --- a/spring-beans/src/test/java/org/springframework/beans/BeanWrapperAutoGrowingTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/BeanWrapperAutoGrowingTests.java @@ -19,8 +19,8 @@ package org.springframework.beans; import java.util.List; import java.util.Map; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -36,7 +36,7 @@ public class BeanWrapperAutoGrowingTests { private final BeanWrapperImpl wrapper = new BeanWrapperImpl(bean); - @Before + @BeforeEach public void setUp() { wrapper.setAutoGrowNestedPaths(true); } diff --git a/spring-beans/src/test/java/org/springframework/beans/BeanWrapperEnumTests.java b/spring-beans/src/test/java/org/springframework/beans/BeanWrapperEnumTests.java index 0b2457caa67..5327e70a3a4 100644 --- a/spring-beans/src/test/java/org/springframework/beans/BeanWrapperEnumTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/BeanWrapperEnumTests.java @@ -19,7 +19,7 @@ package org.springframework.beans; import java.util.LinkedHashMap; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.convert.support.DefaultConversionService; import org.springframework.tests.sample.beans.CustomEnum; diff --git a/spring-beans/src/test/java/org/springframework/beans/BeanWrapperGenericsTests.java b/spring-beans/src/test/java/org/springframework/beans/BeanWrapperGenericsTests.java index b69082804b0..9205b2c5f99 100644 --- a/spring-beans/src/test/java/org/springframework/beans/BeanWrapperGenericsTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/BeanWrapperGenericsTests.java @@ -29,7 +29,7 @@ import java.util.Map; import java.util.Properties; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.propertyeditors.CustomNumberEditor; import org.springframework.beans.propertyeditors.StringTrimmerEditor; diff --git a/spring-beans/src/test/java/org/springframework/beans/BeanWrapperTests.java b/spring-beans/src/test/java/org/springframework/beans/BeanWrapperTests.java index 60f1828c705..a89e169f03e 100644 --- a/spring-beans/src/test/java/org/springframework/beans/BeanWrapperTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/BeanWrapperTests.java @@ -20,7 +20,7 @@ import java.util.Collections; import java.util.Map; import java.util.Optional; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.tests.sample.beans.TestBean; diff --git a/spring-beans/src/test/java/org/springframework/beans/CachedIntrospectionResultsTests.java b/spring-beans/src/test/java/org/springframework/beans/CachedIntrospectionResultsTests.java index 3a400126941..4c867e3b69e 100644 --- a/spring-beans/src/test/java/org/springframework/beans/CachedIntrospectionResultsTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/CachedIntrospectionResultsTests.java @@ -20,7 +20,7 @@ import java.beans.BeanInfo; import java.beans.PropertyDescriptor; import java.util.ArrayList; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.OverridingClassLoader; import org.springframework.tests.sample.beans.TestBean; diff --git a/spring-beans/src/test/java/org/springframework/beans/ConcurrentBeanWrapperTests.java b/spring-beans/src/test/java/org/springframework/beans/ConcurrentBeanWrapperTests.java index fda482440e0..f1d4912b16e 100644 --- a/spring-beans/src/test/java/org/springframework/beans/ConcurrentBeanWrapperTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/ConcurrentBeanWrapperTests.java @@ -26,7 +26,7 @@ import java.util.Set; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/DirectFieldAccessorTests.java b/spring-beans/src/test/java/org/springframework/beans/DirectFieldAccessorTests.java index 14e8640b283..309e4714efa 100644 --- a/spring-beans/src/test/java/org/springframework/beans/DirectFieldAccessorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/DirectFieldAccessorTests.java @@ -16,7 +16,7 @@ package org.springframework.beans; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.tests.sample.beans.TestBean; diff --git a/spring-beans/src/test/java/org/springframework/beans/ExtendedBeanInfoFactoryTests.java b/spring-beans/src/test/java/org/springframework/beans/ExtendedBeanInfoFactoryTests.java index 6ed39ca5227..c4449bcb5b9 100644 --- a/spring-beans/src/test/java/org/springframework/beans/ExtendedBeanInfoFactoryTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/ExtendedBeanInfoFactoryTests.java @@ -18,7 +18,7 @@ package org.springframework.beans; import java.beans.IntrospectionException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/ExtendedBeanInfoTests.java b/spring-beans/src/test/java/org/springframework/beans/ExtendedBeanInfoTests.java index ab95675e544..640b1b920fb 100644 --- a/spring-beans/src/test/java/org/springframework/beans/ExtendedBeanInfoTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/ExtendedBeanInfoTests.java @@ -23,7 +23,7 @@ import java.beans.Introspector; import java.beans.PropertyDescriptor; import java.math.BigDecimal; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.tests.sample.beans.TestBean; diff --git a/spring-beans/src/test/java/org/springframework/beans/MutablePropertyValuesTests.java b/spring-beans/src/test/java/org/springframework/beans/MutablePropertyValuesTests.java index fe930b748e7..027811ed6a4 100644 --- a/spring-beans/src/test/java/org/springframework/beans/MutablePropertyValuesTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/MutablePropertyValuesTests.java @@ -18,7 +18,7 @@ package org.springframework.beans; import java.util.Iterator; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-beans/src/test/java/org/springframework/beans/PropertyAccessorUtilsTests.java b/spring-beans/src/test/java/org/springframework/beans/PropertyAccessorUtilsTests.java index 60b398f0439..4613f472624 100644 --- a/spring-beans/src/test/java/org/springframework/beans/PropertyAccessorUtilsTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/PropertyAccessorUtilsTests.java @@ -16,7 +16,7 @@ package org.springframework.beans; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/PropertyMatchesTests.java b/spring-beans/src/test/java/org/springframework/beans/PropertyMatchesTests.java index ec2ee7a5fdd..09e72571e00 100644 --- a/spring-beans/src/test/java/org/springframework/beans/PropertyMatchesTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/PropertyMatchesTests.java @@ -16,7 +16,7 @@ package org.springframework.beans; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/SimplePropertyDescriptorTests.java b/spring-beans/src/test/java/org/springframework/beans/SimplePropertyDescriptorTests.java index 41dbec4bd92..4a154ef10a4 100644 --- a/spring-beans/src/test/java/org/springframework/beans/SimplePropertyDescriptorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/SimplePropertyDescriptorTests.java @@ -21,7 +21,7 @@ import java.beans.IntrospectionException; import java.beans.PropertyDescriptor; import java.lang.reflect.Method; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/BeanFactoryUtilsTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/BeanFactoryUtilsTests.java index e36c1a57180..47aa95f8a92 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/BeanFactoryUtilsTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/BeanFactoryUtilsTests.java @@ -20,8 +20,8 @@ import java.util.Arrays; import java.util.List; import java.util.Map; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.StaticListableBeanFactory; @@ -58,7 +58,7 @@ public class BeanFactoryUtilsTests { private DefaultListableBeanFactory dependentBeansFactory; - @Before + @BeforeEach public void setUp() { // Interesting hierarchical factory to test counts. // Slow to read so we cache it. diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/ConcurrentBeanFactoryTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/ConcurrentBeanFactoryTests.java index ad8a597d4c8..c6e2428eabb 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/ConcurrentBeanFactoryTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/ConcurrentBeanFactoryTests.java @@ -27,8 +27,8 @@ import java.util.Set; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; @@ -71,7 +71,7 @@ public class ConcurrentBeanFactoryTests { private Throwable ex; - @Before + @BeforeEach public void setup() throws Exception { Assume.group(TestGroup.PERFORMANCE); diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java index e23dc6b243e..ce126620b02 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/DefaultListableBeanFactoryTests.java @@ -43,8 +43,9 @@ import javax.security.auth.Subject; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Timeout; import org.springframework.beans.BeansException; import org.springframework.beans.MutablePropertyValues; @@ -2329,7 +2330,7 @@ public class DefaultListableBeanFactoryTests { } @Test - @Ignore // TODO re-enable when ConstructorResolver TODO sorted out + @Disabled // TODO re-enable when ConstructorResolver TODO sorted out public void testPrototypeCreationWithConstructorArgumentsIsFastEnough() { Assume.group(TestGroup.PERFORMANCE); Assume.notLogging(factoryLog); @@ -2794,7 +2795,8 @@ public class DefaultListableBeanFactoryTests { * under the 1000 ms timeout, usually ~= 300ms. With caching removed and on the same * hardware the method will take ~13000 ms. See SPR-6870. */ - @Test(timeout = 1000) + @Test + @Timeout(1) public void testByTypeLookupIsFastEnough() { Assume.group(TestGroup.PERFORMANCE); @@ -2810,7 +2812,8 @@ public class DefaultListableBeanFactoryTests { } } - @Test(timeout = 1000) + @Test + @Timeout(1) public void testRegistrationOfManyBeanDefinitionsIsFastEnough() { Assume.group(TestGroup.PERFORMANCE); lbf.registerBeanDefinition("b", new RootBeanDefinition(B.class)); @@ -2821,7 +2824,8 @@ public class DefaultListableBeanFactoryTests { } } - @Test(timeout = 1000) + @Test + @Timeout(1) public void testRegistrationOfManySingletonsIsFastEnough() { Assume.group(TestGroup.PERFORMANCE); lbf.registerBeanDefinition("b", new RootBeanDefinition(B.class)); diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/FactoryBeanLookupTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/FactoryBeanLookupTests.java index e7889ac4145..9075bb9b37c 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/FactoryBeanLookupTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/FactoryBeanLookupTests.java @@ -16,8 +16,8 @@ package org.springframework.beans.factory; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.config.AbstractFactoryBean; import org.springframework.beans.factory.support.BeanDefinitionRegistry; @@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat; public class FactoryBeanLookupTests { private BeanFactory beanFactory; - @Before + @BeforeEach public void setUp() { beanFactory = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader((BeanDefinitionRegistry) beanFactory).loadBeanDefinitions( diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/FactoryBeanTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/FactoryBeanTests.java index 78ae71d453f..3bffa8ca1fa 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/FactoryBeanTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/FactoryBeanTests.java @@ -20,7 +20,7 @@ import java.util.HashMap; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.config.BeanFactoryPostProcessor; import org.springframework.beans.factory.config.BeanPostProcessor; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/Spr5475Tests.java b/spring-beans/src/test/java/org/springframework/beans/factory/Spr5475Tests.java index eabc8c0a6f4..5b82ef031ff 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/Spr5475Tests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/Spr5475Tests.java @@ -16,7 +16,7 @@ package org.springframework.beans.factory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.ConstructorArgumentValues; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/AnnotationBeanWiringInfoResolverTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/AnnotationBeanWiringInfoResolverTests.java index 3b7d0658b76..4851c1387fd 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/AnnotationBeanWiringInfoResolverTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/AnnotationBeanWiringInfoResolverTests.java @@ -16,7 +16,7 @@ package org.springframework.beans.factory.annotation; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.wiring.BeanWiringInfo; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java index f1a4a7da23c..ce0add1cee8 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessorTests.java @@ -40,10 +40,10 @@ import java.util.function.Consumer; import java.util.function.Function; import java.util.stream.Collectors; -import org.junit.After; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.springframework.beans.factory.BeanCreationException; @@ -92,7 +92,7 @@ public class AutowiredAnnotationBeanPostProcessorTests { private AutowiredAnnotationBeanPostProcessor bpp; - @Before + @BeforeEach public void setup() { bf = new DefaultListableBeanFactory(); bf.registerResolvableDependency(BeanFactory.class, bf); @@ -103,7 +103,7 @@ public class AutowiredAnnotationBeanPostProcessorTests { bf.setDependencyComparator(AnnotationAwareOrderComparator.INSTANCE); } - @After + @AfterEach public void close() { bf.destroySingletons(); } @@ -2052,7 +2052,7 @@ public class AutowiredAnnotationBeanPostProcessorTests { } @Test - @Ignore // SPR-11521 + @Disabled // SPR-11521 @SuppressWarnings("rawtypes") public void testGenericsBasedInjectionIntoTypeVariableSelectingBestMatchAgainstFactoryMethodSignature() { RootBeanDefinition bd = new RootBeanDefinition(GenericInterface1Impl.class); diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/CustomAutowireConfigurerTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/CustomAutowireConfigurerTests.java index 69d0db5e1bb..3454c28d9c2 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/CustomAutowireConfigurerTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/CustomAutowireConfigurerTests.java @@ -16,7 +16,7 @@ package org.springframework.beans.factory.annotation; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.config.BeanDefinitionHolder; import org.springframework.beans.factory.config.DependencyDescriptor; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/InjectAnnotationBeanPostProcessorTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/InjectAnnotationBeanPostProcessorTests.java index cd245c92d26..cb6a866e4b2 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/InjectAnnotationBeanPostProcessorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/InjectAnnotationBeanPostProcessorTests.java @@ -26,9 +26,9 @@ import javax.inject.Inject; import javax.inject.Named; import javax.inject.Provider; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.BeanFactory; @@ -62,7 +62,7 @@ public class InjectAnnotationBeanPostProcessorTests { private AutowiredAnnotationBeanPostProcessor bpp; - @Before + @BeforeEach public void setup() { bf = new DefaultListableBeanFactory(); bf.registerResolvableDependency(BeanFactory.class, bf); @@ -72,7 +72,7 @@ public class InjectAnnotationBeanPostProcessorTests { bf.setAutowireCandidateResolver(new QualifierAnnotationAutowireCandidateResolver()); } - @After + @AfterEach public void close() { bf.destroySingletons(); } diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/LookupAnnotationTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/LookupAnnotationTests.java index 29a81a355b0..d276ebb2740 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/LookupAnnotationTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/LookupAnnotationTests.java @@ -16,8 +16,8 @@ package org.springframework.beans.factory.annotation; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; @@ -35,7 +35,7 @@ public class LookupAnnotationTests { private DefaultListableBeanFactory beanFactory; - @Before + @BeforeEach public void setUp() { beanFactory = new DefaultListableBeanFactory(); AutowiredAnnotationBeanPostProcessor aabpp = new AutowiredAnnotationBeanPostProcessor(); diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/ParameterResolutionTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/ParameterResolutionTests.java index b9b3a7f4501..9710d29c38a 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/ParameterResolutionTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/ParameterResolutionTests.java @@ -21,7 +21,7 @@ import java.lang.reflect.Executable; import java.lang.reflect.Method; import java.lang.reflect.Parameter; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.config.AutowireCapableBeanFactory; import org.springframework.beans.factory.config.DependencyDescriptor; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/RequiredAnnotationBeanPostProcessorTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/RequiredAnnotationBeanPostProcessorTests.java index 2cb831e4f39..a88a756029b 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/annotation/RequiredAnnotationBeanPostProcessorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/annotation/RequiredAnnotationBeanPostProcessorTests.java @@ -21,7 +21,7 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.BeanFactory; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/CustomEditorConfigurerTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/CustomEditorConfigurerTests.java index 5397ac4d7b1..921e76100c5 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/CustomEditorConfigurerTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/CustomEditorConfigurerTests.java @@ -25,7 +25,7 @@ import java.util.HashMap; import java.util.Locale; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.MutablePropertyValues; import org.springframework.beans.PropertyEditorRegistrar; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/CustomScopeConfigurerTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/CustomScopeConfigurerTests.java index 7d4c4bbd999..c3026524963 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/CustomScopeConfigurerTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/CustomScopeConfigurerTests.java @@ -19,7 +19,7 @@ package org.springframework.beans.factory.config; import java.util.HashMap; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.DefaultListableBeanFactory; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/DeprecatedBeanWarnerTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/DeprecatedBeanWarnerTests.java index 76319d16c87..2be93f0d400 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/DeprecatedBeanWarnerTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/DeprecatedBeanWarnerTests.java @@ -16,7 +16,7 @@ package org.springframework.beans.factory.config; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBeanTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBeanTests.java index 78e5b11b318..cc20dc84e4d 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBeanTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/FieldRetrievingFactoryBeanTests.java @@ -18,7 +18,7 @@ package org.springframework.beans.factory.config; import java.sql.Connection; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/MethodInvokingFactoryBeanTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/MethodInvokingFactoryBeanTests.java index 9017b5d4bd5..fae712817bd 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/MethodInvokingFactoryBeanTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/MethodInvokingFactoryBeanTests.java @@ -20,7 +20,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.propertyeditors.StringTrimmerEditor; import org.springframework.beans.support.ArgumentConvertingMethodInvoker; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/ObjectFactoryCreatingFactoryBeanTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/ObjectFactoryCreatingFactoryBeanTests.java index 8cb98f403ea..8d439a663bc 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/ObjectFactoryCreatingFactoryBeanTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/ObjectFactoryCreatingFactoryBeanTests.java @@ -19,9 +19,9 @@ package org.springframework.beans.factory.config; import java.util.Date; import javax.inject.Provider; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.ObjectFactory; @@ -46,7 +46,7 @@ public class ObjectFactoryCreatingFactoryBeanTests { private DefaultListableBeanFactory beanFactory; - @Before + @BeforeEach public void setup() { this.beanFactory = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(this.beanFactory).loadBeanDefinitions( @@ -54,7 +54,7 @@ public class ObjectFactoryCreatingFactoryBeanTests { this.beanFactory.setSerializationId("test"); } - @After + @AfterEach public void close() { this.beanFactory.setSerializationId(null); } diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertiesFactoryBeanTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertiesFactoryBeanTests.java index f29b48ff48e..e7b68287893 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertiesFactoryBeanTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertiesFactoryBeanTests.java @@ -18,7 +18,7 @@ package org.springframework.beans.factory.config; import java.util.Properties; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.io.Resource; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyPathFactoryBeanTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyPathFactoryBeanTests.java index 2459ea6ea9b..0c7fcc4a4c1 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyPathFactoryBeanTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyPathFactoryBeanTests.java @@ -16,7 +16,7 @@ package org.springframework.beans.factory.config; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyPlaceholderConfigurerTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyPlaceholderConfigurerTests.java index 01e337a7284..ac0643b3f28 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyPlaceholderConfigurerTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyPlaceholderConfigurerTests.java @@ -18,9 +18,9 @@ package org.springframework.beans.factory.config; import java.util.Properties; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.AbstractBeanDefinition; import org.springframework.beans.factory.support.DefaultListableBeanFactory; @@ -52,7 +52,7 @@ public class PropertyPlaceholderConfigurerTests { private AbstractBeanDefinition p1BeanDef; - @Before + @BeforeEach public void setup() { p1BeanDef = rootBeanDefinition(TestBean.class) .addPropertyValue("name", "${" + P1 + "}") @@ -68,7 +68,7 @@ public class PropertyPlaceholderConfigurerTests { } - @After + @AfterEach public void cleanup() { System.clearProperty(P1); } diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyResourceConfigurerTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyResourceConfigurerTests.java index 1c9e0ec3281..9d5b3909ce6 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyResourceConfigurerTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/PropertyResourceConfigurerTests.java @@ -27,7 +27,7 @@ import java.util.prefs.BackingStoreException; import java.util.prefs.Preferences; import java.util.prefs.PreferencesFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.MutablePropertyValues; import org.springframework.beans.factory.BeanDefinitionStoreException; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/ServiceLocatorFactoryBeanTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/ServiceLocatorFactoryBeanTests.java index a16f8fbc16f..87139e363e3 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/ServiceLocatorFactoryBeanTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/ServiceLocatorFactoryBeanTests.java @@ -16,9 +16,9 @@ package org.springframework.beans.factory.config; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.springframework.beans.FatalBeanException; import org.springframework.beans.factory.BeanFactory; @@ -44,7 +44,7 @@ public class ServiceLocatorFactoryBeanTests { private DefaultListableBeanFactory bf; - @Before + @BeforeEach public void setUp() { bf = new DefaultListableBeanFactory(); } @@ -135,7 +135,7 @@ public class ServiceLocatorFactoryBeanTests { factory.getTestService("bogusTestService")); } - @Ignore @Test // worked when using an ApplicationContext (see commented), fails when using BeanFactory + @Disabled @Test // worked when using an ApplicationContext (see commented), fails when using BeanFactory public void testCombinedLocatorInterface() { bf.registerBeanDefinition("testService", genericBeanDefinition(TestService.class).getBeanDefinition()); bf.registerAlias("testService", "1"); @@ -168,7 +168,7 @@ public class ServiceLocatorFactoryBeanTests { assertThat(factory.toString().contains("TestServiceLocator3")).isTrue(); } - @Ignore @Test // worked when using an ApplicationContext (see commented), fails when using BeanFactory + @Disabled @Test // worked when using an ApplicationContext (see commented), fails when using BeanFactory public void testServiceMappings() { bf.registerBeanDefinition("testService1", genericBeanDefinition(TestService.class).getBeanDefinition()); bf.registerBeanDefinition("testService2", genericBeanDefinition(ExtendedTestService.class).getBeanDefinition()); diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/SimpleScopeTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/SimpleScopeTests.java index 8c116ad7fb6..297c4a655ca 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/SimpleScopeTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/SimpleScopeTests.java @@ -19,8 +19,8 @@ package org.springframework.beans.factory.config; import java.util.LinkedList; import java.util.List; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.ObjectFactory; import org.springframework.beans.factory.support.DefaultListableBeanFactory; @@ -42,7 +42,7 @@ public class SimpleScopeTests { private DefaultListableBeanFactory beanFactory; - @Before + @BeforeEach public void setup() { beanFactory = new DefaultListableBeanFactory(); Scope scope = new NoOpScope() { diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/YamlMapFactoryBeanTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/YamlMapFactoryBeanTests.java index 1a5ffc5438b..b7e05ed6474 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/YamlMapFactoryBeanTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/YamlMapFactoryBeanTests.java @@ -21,7 +21,7 @@ import java.io.InputStream; import java.util.LinkedHashMap; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.yaml.snakeyaml.constructor.DuplicateKeyException; import org.springframework.core.io.AbstractResource; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/YamlProcessorTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/YamlProcessorTests.java index 320d20e7283..0bacf216258 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/YamlProcessorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/YamlProcessorTests.java @@ -20,7 +20,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.yaml.snakeyaml.parser.ParserException; import org.yaml.snakeyaml.scanner.ScannerException; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/config/YamlPropertiesFactoryBeanTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/config/YamlPropertiesFactoryBeanTests.java index 45b44c79543..828ac080818 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/config/YamlPropertiesFactoryBeanTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/config/YamlPropertiesFactoryBeanTests.java @@ -19,7 +19,7 @@ package org.springframework.beans.factory.config; import java.util.Map; import java.util.Properties; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.constructor.DuplicateKeyException; import org.yaml.snakeyaml.scanner.ScannerException; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/parsing/ConstructorArgumentEntryTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/parsing/ConstructorArgumentEntryTests.java index 8f4129cd65e..9e3155dc459 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/parsing/ConstructorArgumentEntryTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/parsing/ConstructorArgumentEntryTests.java @@ -16,7 +16,7 @@ package org.springframework.beans.factory.parsing; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/parsing/CustomProblemReporterTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/parsing/CustomProblemReporterTests.java index 06c75b99090..33caa90d573 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/parsing/CustomProblemReporterTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/parsing/CustomProblemReporterTests.java @@ -19,8 +19,8 @@ package org.springframework.beans.factory.parsing; import java.util.ArrayList; import java.util.List; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; @@ -43,7 +43,7 @@ public class CustomProblemReporterTests { private XmlBeanDefinitionReader reader; - @Before + @BeforeEach public void setup() { this.problemReporter = new CollatingProblemReporter(); this.beanFactory = new DefaultListableBeanFactory(); diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/parsing/FailFastProblemReporterTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/parsing/FailFastProblemReporterTests.java index fe4c134c903..fdd7faed0ea 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/parsing/FailFastProblemReporterTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/parsing/FailFastProblemReporterTests.java @@ -17,7 +17,7 @@ package org.springframework.beans.factory.parsing; import org.apache.commons.logging.Log; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.io.DescriptiveResource; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/parsing/NullSourceExtractorTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/parsing/NullSourceExtractorTests.java index b679643a861..48dd45999e0 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/parsing/NullSourceExtractorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/parsing/NullSourceExtractorTests.java @@ -16,7 +16,7 @@ package org.springframework.beans.factory.parsing; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/parsing/ParseStateTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/parsing/ParseStateTests.java index 2cee2488ec4..ce6a3aaa7df 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/parsing/ParseStateTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/parsing/ParseStateTests.java @@ -16,7 +16,7 @@ package org.springframework.beans.factory.parsing; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/parsing/PassThroughSourceExtractorTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/parsing/PassThroughSourceExtractorTests.java index abc4e0dd5c9..2f6fe191d23 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/parsing/PassThroughSourceExtractorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/parsing/PassThroughSourceExtractorTests.java @@ -16,7 +16,7 @@ package org.springframework.beans.factory.parsing; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/parsing/PropertyEntryTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/parsing/PropertyEntryTests.java index c31aeb5fe5d..084fb1f5a74 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/parsing/PropertyEntryTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/parsing/PropertyEntryTests.java @@ -16,7 +16,7 @@ package org.springframework.beans.factory.parsing; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; 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 213d225e2eb..cf17ce62c33 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 @@ -20,7 +20,7 @@ import java.util.List; import java.util.ServiceLoader; import javax.xml.parsers.DocumentBuilderFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/AutowireUtilsTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/AutowireUtilsTests.java index 9d8a67b71b1..e7e04d7390d 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/AutowireUtilsTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/AutowireUtilsTests.java @@ -20,7 +20,7 @@ import java.lang.reflect.Method; import java.util.HashMap; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.util.ReflectionUtils; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanDefinitionBuilderTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanDefinitionBuilderTests.java index a0f0c3e786f..6d416cdcf79 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanDefinitionBuilderTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanDefinitionBuilderTests.java @@ -18,7 +18,7 @@ package org.springframework.beans.factory.support; import java.util.Arrays; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.tests.sample.beans.TestBean; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanDefinitionTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanDefinitionTests.java index d8bd862af76..ca9eef9d045 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanDefinitionTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanDefinitionTests.java @@ -16,7 +16,7 @@ package org.springframework.beans.factory.support; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.config.BeanDefinitionHolder; import org.springframework.tests.sample.beans.TestBean; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanFactoryGenericsTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanFactoryGenericsTests.java index ab16854a6ca..efb390f35c7 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanFactoryGenericsTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanFactoryGenericsTests.java @@ -32,7 +32,7 @@ import java.util.Map; import java.util.Set; import java.util.stream.Collectors; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.springframework.beans.PropertyEditorRegistrar; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/DefaultSingletonBeanRegistryTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/DefaultSingletonBeanRegistryTests.java index 6d41520e40f..303bc31ec4a 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/DefaultSingletonBeanRegistryTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/DefaultSingletonBeanRegistryTests.java @@ -16,7 +16,7 @@ package org.springframework.beans.factory.support; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.BeansException; import org.springframework.beans.factory.ObjectFactory; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/DefinitionMetadataEqualsHashCodeTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/DefinitionMetadataEqualsHashCodeTests.java index 86ce2297cb6..ca09f9ee846 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/DefinitionMetadataEqualsHashCodeTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/DefinitionMetadataEqualsHashCodeTests.java @@ -16,7 +16,7 @@ package org.springframework.beans.factory.support; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.RuntimeBeanReference; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/LookupMethodTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/LookupMethodTests.java index 63ec1155510..a12a21772b7 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/LookupMethodTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/LookupMethodTests.java @@ -16,8 +16,8 @@ package org.springframework.beans.factory.support; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import org.springframework.core.io.ClassPathResource; @@ -35,7 +35,7 @@ public class LookupMethodTests { private DefaultListableBeanFactory beanFactory; - @Before + @BeforeEach public void setUp() { beanFactory = new DefaultListableBeanFactory(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(beanFactory); diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/ManagedListTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/ManagedListTests.java index 64afa3db0c6..9bf6576d518 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/ManagedListTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/ManagedListTests.java @@ -18,7 +18,7 @@ package org.springframework.beans.factory.support; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/ManagedMapTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/ManagedMapTests.java index 1a3d6422d3d..1f6dc5e416a 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/ManagedMapTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/ManagedMapTests.java @@ -18,7 +18,7 @@ package org.springframework.beans.factory.support; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/ManagedPropertiesTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/ManagedPropertiesTests.java index 9807fc179de..473679f3d10 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/ManagedPropertiesTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/ManagedPropertiesTests.java @@ -18,7 +18,7 @@ package org.springframework.beans.factory.support; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/ManagedSetTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/ManagedSetTests.java index a80bab7b6e3..39c08997814 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/ManagedSetTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/ManagedSetTests.java @@ -18,7 +18,7 @@ package org.springframework.beans.factory.support; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/PropertiesBeanDefinitionReaderTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/PropertiesBeanDefinitionReaderTests.java index a533534560c..dd811aa4123 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/PropertiesBeanDefinitionReaderTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/PropertiesBeanDefinitionReaderTests.java @@ -16,7 +16,7 @@ package org.springframework.beans.factory.support; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.io.ClassPathResource; import org.springframework.tests.sample.beans.TestBean; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/QualifierAnnotationAutowireBeanFactoryTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/QualifierAnnotationAutowireBeanFactoryTests.java index 9d31bc4b8c1..17fd92dd5ff 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/QualifierAnnotationAutowireBeanFactoryTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/QualifierAnnotationAutowireBeanFactoryTests.java @@ -21,8 +21,8 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.config.ConstructorArgumentValues; @@ -73,7 +73,7 @@ public class QualifierAnnotationAutowireBeanFactoryTests { new DependencyDescriptor(Person.class.getDeclaredField("name"), true))).isFalse(); } - @Ignore + @Disabled @Test public void testAutowireCandidateWithFieldDescriptor() throws Exception { DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); @@ -133,7 +133,7 @@ public class QualifierAnnotationAutowireBeanFactoryTests { assertThat(lbf.isAutowireCandidate(JUERGEN, qualifiedDescriptor)).isTrue(); } - @Ignore + @Disabled @Test public void testAutowireCandidateWithConstructorDescriptor() throws Exception { DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); @@ -155,7 +155,7 @@ public class QualifierAnnotationAutowireBeanFactoryTests { assertThat(lbf.isAutowireCandidate(MARK, qualifiedDescriptor)).isFalse(); } - @Ignore + @Disabled @Test public void testAutowireCandidateWithMethodDescriptor() throws Exception { DefaultListableBeanFactory lbf = new DefaultListableBeanFactory(); diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/Spr8954Tests.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/Spr8954Tests.java index 6c4a067828d..aa463b93e2d 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/Spr8954Tests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/Spr8954Tests.java @@ -19,8 +19,8 @@ package org.springframework.beans.factory.support; import java.util.Arrays; import java.util.Map; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor; @@ -44,7 +44,7 @@ public class Spr8954Tests { private DefaultListableBeanFactory bf; - @Before + @BeforeEach public void setUp() { bf = new DefaultListableBeanFactory(); bf.registerBeanDefinition("foo", new RootBeanDefinition(FooFactoryBean.class)); diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/security/CallbacksSecurityTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/security/CallbacksSecurityTests.java index 64bdca4fc69..3817bfb9a02 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/security/CallbacksSecurityTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/security/CallbacksSecurityTests.java @@ -32,8 +32,8 @@ import java.util.function.Consumer; import javax.security.auth.AuthPermission; import javax.security.auth.Subject; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanClassLoaderAware; @@ -297,7 +297,7 @@ public class CallbacksSecurityTests { } } - @Before + @BeforeEach public void setUp() throws Exception { final ProtectionDomain empty = new ProtectionDomain(null, diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/wiring/BeanConfigurerSupportTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/wiring/BeanConfigurerSupportTests.java index a7cb8a91a34..8c5cb1e8b5c 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/wiring/BeanConfigurerSupportTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/wiring/BeanConfigurerSupportTests.java @@ -16,7 +16,7 @@ package org.springframework.beans.factory.wiring; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.support.BeanDefinitionBuilder; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/wiring/BeanWiringInfoTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/wiring/BeanWiringInfoTests.java index 05c5fec3f19..7919ba0a0b4 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/wiring/BeanWiringInfoTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/wiring/BeanWiringInfoTests.java @@ -16,7 +16,7 @@ package org.springframework.beans.factory.wiring; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/wiring/ClassNameBeanWiringInfoResolverTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/wiring/ClassNameBeanWiringInfoResolverTests.java index 62837dc7259..67cef6f1166 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/wiring/ClassNameBeanWiringInfoResolverTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/wiring/ClassNameBeanWiringInfoResolverTests.java @@ -16,7 +16,7 @@ package org.springframework.beans.factory.wiring; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/AbstractBeanFactoryTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/AbstractBeanFactoryTests.java index 29ab847c863..a22c38b1c0b 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/AbstractBeanFactoryTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/AbstractBeanFactoryTests.java @@ -19,7 +19,7 @@ package org.springframework.beans.factory.xml; import java.beans.PropertyEditorSupport; import java.util.StringTokenizer; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.BeansException; import org.springframework.beans.PropertyBatchUpdateException; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/AbstractListableBeanFactoryTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/AbstractListableBeanFactoryTests.java index ad10d4a57f7..dbae0ebed70 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/AbstractListableBeanFactoryTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/AbstractListableBeanFactoryTests.java @@ -16,7 +16,7 @@ package org.springframework.beans.factory.xml; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.FactoryBean; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/AutowireWithExclusionTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/AutowireWithExclusionTests.java index 60ad0d6cd01..2ed794e5747 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/AutowireWithExclusionTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/AutowireWithExclusionTests.java @@ -16,7 +16,7 @@ package org.springframework.beans.factory.xml; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.config.PropertiesFactoryBean; import org.springframework.beans.factory.config.RuntimeBeanReference; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/BeanNameGenerationTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/BeanNameGenerationTests.java index 619e72223c5..55fef5cb34b 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/BeanNameGenerationTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/BeanNameGenerationTests.java @@ -16,8 +16,8 @@ package org.springframework.beans.factory.xml; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.BeanDefinitionReaderUtils; import org.springframework.beans.factory.support.DefaultListableBeanFactory; @@ -34,7 +34,7 @@ public class BeanNameGenerationTests { private DefaultListableBeanFactory beanFactory; - @Before + @BeforeEach public void setUp() { this.beanFactory = new DefaultListableBeanFactory(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(this.beanFactory); diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/CollectionMergingTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/CollectionMergingTests.java index 56efb7db6e1..720bf605f38 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/CollectionMergingTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/CollectionMergingTests.java @@ -22,8 +22,8 @@ import java.util.Map; import java.util.Properties; import java.util.Set; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.BeanDefinitionReader; import org.springframework.beans.factory.support.DefaultListableBeanFactory; @@ -44,7 +44,7 @@ public class CollectionMergingTests { private final DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory(); - @Before + @BeforeEach public void setUp() throws Exception { BeanDefinitionReader reader = new XmlBeanDefinitionReader(this.beanFactory); reader.loadBeanDefinitions(new ClassPathResource("collectionMerging.xml", getClass())); diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/CollectionsWithDefaultTypesTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/CollectionsWithDefaultTypesTests.java index acc18e9f1d1..1cdd84ba9fa 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/CollectionsWithDefaultTypesTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/CollectionsWithDefaultTypesTests.java @@ -19,7 +19,7 @@ package org.springframework.beans.factory.xml; import java.util.List; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.core.io.ClassPathResource; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/DefaultLifecycleMethodsTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/DefaultLifecycleMethodsTests.java index 84bdca12445..0c6f7f80a20 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/DefaultLifecycleMethodsTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/DefaultLifecycleMethodsTests.java @@ -16,8 +16,8 @@ package org.springframework.beans.factory.xml; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.core.io.ClassPathResource; @@ -33,7 +33,7 @@ public class DefaultLifecycleMethodsTests { private final DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory(); - @Before + @BeforeEach public void setup() throws Exception { new XmlBeanDefinitionReader(this.beanFactory).loadBeanDefinitions( new ClassPathResource("defaultLifecycleMethods.xml", getClass())); diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/DelegatingEntityResolverTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/DelegatingEntityResolverTests.java index cb57798520b..6e05b66c7c6 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/DelegatingEntityResolverTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/DelegatingEntityResolverTests.java @@ -16,7 +16,7 @@ package org.springframework.beans.factory.xml; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.xml.sax.EntityResolver; import org.xml.sax.InputSource; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/DuplicateBeanIdTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/DuplicateBeanIdTests.java index 932b1d9b934..983292c56aa 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/DuplicateBeanIdTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/DuplicateBeanIdTests.java @@ -16,7 +16,7 @@ package org.springframework.beans.factory.xml; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.core.io.ClassPathResource; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/EventPublicationTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/EventPublicationTests.java index 8a81d9ed95e..7fef2df708e 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/EventPublicationTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/EventPublicationTests.java @@ -18,8 +18,8 @@ package org.springframework.beans.factory.xml; import java.util.List; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.w3c.dom.Element; import org.springframework.beans.factory.config.BeanDefinition; @@ -48,7 +48,7 @@ public class EventPublicationTests { - @Before + @BeforeEach public void setUp() throws Exception { XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(this.beanFactory); reader.setEventListener(this.eventListener); diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/FactoryMethodTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/FactoryMethodTests.java index 225fd27cff8..3985567eb54 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/FactoryMethodTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/FactoryMethodTests.java @@ -21,7 +21,7 @@ import java.util.Collections; import java.util.List; import java.util.Properties; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.support.DefaultListableBeanFactory; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/MetadataAttachmentTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/MetadataAttachmentTests.java index ec804238332..1c796266d1f 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/MetadataAttachmentTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/MetadataAttachmentTests.java @@ -16,8 +16,8 @@ package org.springframework.beans.factory.xml; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.PropertyValue; import org.springframework.beans.factory.config.BeanDefinition; @@ -34,7 +34,7 @@ public class MetadataAttachmentTests { private DefaultListableBeanFactory beanFactory; - @Before + @BeforeEach public void setUp() throws Exception { this.beanFactory = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(this.beanFactory).loadBeanDefinitions( diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/NestedBeansElementAttributeRecursionTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/NestedBeansElementAttributeRecursionTests.java index 18acabef81a..6934e5166bc 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/NestedBeansElementAttributeRecursionTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/NestedBeansElementAttributeRecursionTests.java @@ -16,7 +16,7 @@ package org.springframework.beans.factory.xml; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.support.DefaultListableBeanFactory; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/NestedBeansElementTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/NestedBeansElementTests.java index ec790b2d1ac..4117c82c432 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/NestedBeansElementTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/NestedBeansElementTests.java @@ -16,7 +16,7 @@ package org.springframework.beans.factory.xml; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.core.env.ConfigurableEnvironment; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/ProfileXmlBeanDefinitionTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/ProfileXmlBeanDefinitionTests.java index e02b6a10ccf..56795fe7573 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/ProfileXmlBeanDefinitionTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/ProfileXmlBeanDefinitionTests.java @@ -17,7 +17,7 @@ package org.springframework.beans.factory.xml; import org.assertj.core.api.Condition; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.BeanDefinitionRegistry; import org.springframework.beans.factory.support.DefaultListableBeanFactory; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/SchemaValidationTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/SchemaValidationTests.java index 9520203f5a0..1d51dc3f0bb 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/SchemaValidationTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/SchemaValidationTests.java @@ -16,7 +16,7 @@ package org.springframework.beans.factory.xml; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.xml.sax.SAXParseException; import org.springframework.beans.BeansException; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/SimpleConstructorNamespaceHandlerTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/SimpleConstructorNamespaceHandlerTests.java index 085050cb283..0d4921e4138 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/SimpleConstructorNamespaceHandlerTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/SimpleConstructorNamespaceHandlerTests.java @@ -16,7 +16,7 @@ package org.springframework.beans.factory.xml; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanDefinitionStoreException; import org.springframework.beans.factory.support.DefaultListableBeanFactory; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/SimplePropertyNamespaceHandlerTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/SimplePropertyNamespaceHandlerTests.java index 0d4626569c1..b8f943fccd2 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/SimplePropertyNamespaceHandlerTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/SimplePropertyNamespaceHandlerTests.java @@ -16,7 +16,7 @@ package org.springframework.beans.factory.xml; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanDefinitionStoreException; import org.springframework.beans.factory.support.DefaultListableBeanFactory; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/UtilNamespaceHandlerTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/UtilNamespaceHandlerTests.java index e95d46d7d67..be6be77551c 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/UtilNamespaceHandlerTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/UtilNamespaceHandlerTests.java @@ -24,8 +24,8 @@ import java.util.Properties; import java.util.Set; import java.util.TreeMap; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.config.FieldRetrievingFactoryBean; import org.springframework.beans.factory.config.PropertiesFactoryBean; @@ -53,7 +53,7 @@ public class UtilNamespaceHandlerTests { private CollectingReaderEventListener listener = new CollectingReaderEventListener(); - @Before + @BeforeEach public void setUp() { this.beanFactory = new DefaultListableBeanFactory(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(this.beanFactory); diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlBeanCollectionTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlBeanCollectionTests.java index 8b764bd8b6b..17eadf0c61d 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlBeanCollectionTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlBeanCollectionTests.java @@ -29,8 +29,8 @@ import java.util.Set; import java.util.TreeMap; import java.util.TreeSet; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.BeanDefinitionStoreException; @@ -58,7 +58,7 @@ public class XmlBeanCollectionTests { private final DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory(); - @Before + @BeforeEach public void loadBeans() { new XmlBeanDefinitionReader(this.beanFactory).loadBeanDefinitions( new ClassPathResource("collections.xml", getClass())); diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlBeanDefinitionReaderTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlBeanDefinitionReaderTests.java index 43fc2ba9cda..9b460c6601a 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlBeanDefinitionReaderTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlBeanDefinitionReaderTests.java @@ -18,7 +18,7 @@ package org.springframework.beans.factory.xml; import java.util.Arrays; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.xml.sax.InputSource; import org.springframework.beans.factory.BeanDefinitionStoreException; diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlListableBeanFactoryTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlListableBeanFactoryTests.java index 82f6c5e9de4..d0b83d98155 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlListableBeanFactoryTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/XmlListableBeanFactoryTests.java @@ -21,8 +21,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.BeansException; import org.springframework.beans.MutablePropertyValues; @@ -50,7 +50,7 @@ public class XmlListableBeanFactoryTests extends AbstractListableBeanFactoryTest private DefaultListableBeanFactory factory; - @Before + @BeforeEach public void setup() { parent = new DefaultListableBeanFactory(); diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/xml/support/DefaultNamespaceHandlerResolverTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/xml/support/DefaultNamespaceHandlerResolverTests.java index 1d46bdcd561..faa41995e6d 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/xml/support/DefaultNamespaceHandlerResolverTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/xml/support/DefaultNamespaceHandlerResolverTests.java @@ -16,7 +16,7 @@ package org.springframework.beans.factory.xml.support; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver; import org.springframework.beans.factory.xml.NamespaceHandler; diff --git a/spring-beans/src/test/java/org/springframework/beans/propertyeditors/BeanInfoTests.java b/spring-beans/src/test/java/org/springframework/beans/propertyeditors/BeanInfoTests.java index 0e759436308..b08587fa6ea 100644 --- a/spring-beans/src/test/java/org/springframework/beans/propertyeditors/BeanInfoTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/propertyeditors/BeanInfoTests.java @@ -20,7 +20,7 @@ import java.beans.IntrospectionException; import java.beans.PropertyDescriptor; import java.beans.SimpleBeanInfo; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.BeanWrapper; import org.springframework.beans.BeanWrapperImpl; diff --git a/spring-beans/src/test/java/org/springframework/beans/propertyeditors/ByteArrayPropertyEditorTests.java b/spring-beans/src/test/java/org/springframework/beans/propertyeditors/ByteArrayPropertyEditorTests.java index dbd9ffed444..0ea1102cdae 100644 --- a/spring-beans/src/test/java/org/springframework/beans/propertyeditors/ByteArrayPropertyEditorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/propertyeditors/ByteArrayPropertyEditorTests.java @@ -18,7 +18,7 @@ package org.springframework.beans.propertyeditors; import java.beans.PropertyEditor; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/propertyeditors/CharArrayPropertyEditorTests.java b/spring-beans/src/test/java/org/springframework/beans/propertyeditors/CharArrayPropertyEditorTests.java index 0df5886fd99..d01f59100e1 100644 --- a/spring-beans/src/test/java/org/springframework/beans/propertyeditors/CharArrayPropertyEditorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/propertyeditors/CharArrayPropertyEditorTests.java @@ -18,7 +18,7 @@ package org.springframework.beans.propertyeditors; import java.beans.PropertyEditor; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/propertyeditors/CustomCollectionEditorTests.java b/spring-beans/src/test/java/org/springframework/beans/propertyeditors/CustomCollectionEditorTests.java index d4e86341934..36fd15b997d 100644 --- a/spring-beans/src/test/java/org/springframework/beans/propertyeditors/CustomCollectionEditorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/propertyeditors/CustomCollectionEditorTests.java @@ -20,7 +20,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-beans/src/test/java/org/springframework/beans/propertyeditors/CustomEditorTests.java b/spring-beans/src/test/java/org/springframework/beans/propertyeditors/CustomEditorTests.java index 60527d248ab..85bf11b9d61 100644 --- a/spring-beans/src/test/java/org/springframework/beans/propertyeditors/CustomEditorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/propertyeditors/CustomEditorTests.java @@ -36,7 +36,7 @@ import java.util.StringTokenizer; import java.util.Vector; import java.util.regex.Pattern; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.BeanWrapper; import org.springframework.beans.BeanWrapperImpl; diff --git a/spring-beans/src/test/java/org/springframework/beans/propertyeditors/FileEditorTests.java b/spring-beans/src/test/java/org/springframework/beans/propertyeditors/FileEditorTests.java index 1dbd7addc27..ec5cc0f469d 100644 --- a/spring-beans/src/test/java/org/springframework/beans/propertyeditors/FileEditorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/propertyeditors/FileEditorTests.java @@ -19,7 +19,7 @@ package org.springframework.beans.propertyeditors; import java.beans.PropertyEditor; import java.io.File; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.util.ClassUtils; diff --git a/spring-beans/src/test/java/org/springframework/beans/propertyeditors/InputStreamEditorTests.java b/spring-beans/src/test/java/org/springframework/beans/propertyeditors/InputStreamEditorTests.java index c22ee1ade11..e0fb3aabce6 100644 --- a/spring-beans/src/test/java/org/springframework/beans/propertyeditors/InputStreamEditorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/propertyeditors/InputStreamEditorTests.java @@ -18,7 +18,7 @@ package org.springframework.beans.propertyeditors; import java.io.InputStream; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.util.ClassUtils; diff --git a/spring-beans/src/test/java/org/springframework/beans/propertyeditors/PathEditorTests.java b/spring-beans/src/test/java/org/springframework/beans/propertyeditors/PathEditorTests.java index d7d30378763..40354fc4464 100644 --- a/spring-beans/src/test/java/org/springframework/beans/propertyeditors/PathEditorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/propertyeditors/PathEditorTests.java @@ -20,7 +20,7 @@ import java.beans.PropertyEditor; import java.io.File; import java.nio.file.Path; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.util.ClassUtils; diff --git a/spring-beans/src/test/java/org/springframework/beans/propertyeditors/PropertiesEditorTests.java b/spring-beans/src/test/java/org/springframework/beans/propertyeditors/PropertiesEditorTests.java index d9166cf4341..32fb123680b 100644 --- a/spring-beans/src/test/java/org/springframework/beans/propertyeditors/PropertiesEditorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/propertyeditors/PropertiesEditorTests.java @@ -20,7 +20,7 @@ import java.util.HashMap; import java.util.Map; import java.util.Properties; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/propertyeditors/ReaderEditorTests.java b/spring-beans/src/test/java/org/springframework/beans/propertyeditors/ReaderEditorTests.java index dac76ab8c4c..55734526206 100644 --- a/spring-beans/src/test/java/org/springframework/beans/propertyeditors/ReaderEditorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/propertyeditors/ReaderEditorTests.java @@ -18,7 +18,7 @@ package org.springframework.beans.propertyeditors; import java.io.Reader; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.util.ClassUtils; diff --git a/spring-beans/src/test/java/org/springframework/beans/propertyeditors/ResourceBundleEditorTests.java b/spring-beans/src/test/java/org/springframework/beans/propertyeditors/ResourceBundleEditorTests.java index 749422021f5..3785304164a 100644 --- a/spring-beans/src/test/java/org/springframework/beans/propertyeditors/ResourceBundleEditorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/propertyeditors/ResourceBundleEditorTests.java @@ -18,7 +18,7 @@ package org.springframework.beans.propertyeditors; import java.util.ResourceBundle; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-beans/src/test/java/org/springframework/beans/propertyeditors/StringArrayPropertyEditorTests.java b/spring-beans/src/test/java/org/springframework/beans/propertyeditors/StringArrayPropertyEditorTests.java index e8b3570b185..09716d04fd0 100644 --- a/spring-beans/src/test/java/org/springframework/beans/propertyeditors/StringArrayPropertyEditorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/propertyeditors/StringArrayPropertyEditorTests.java @@ -16,7 +16,7 @@ package org.springframework.beans.propertyeditors; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/propertyeditors/URIEditorTests.java b/spring-beans/src/test/java/org/springframework/beans/propertyeditors/URIEditorTests.java index d352112cc7f..e9896ed50ab 100644 --- a/spring-beans/src/test/java/org/springframework/beans/propertyeditors/URIEditorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/propertyeditors/URIEditorTests.java @@ -19,7 +19,7 @@ package org.springframework.beans.propertyeditors; import java.beans.PropertyEditor; import java.net.URI; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.util.ClassUtils; diff --git a/spring-beans/src/test/java/org/springframework/beans/propertyeditors/URLEditorTests.java b/spring-beans/src/test/java/org/springframework/beans/propertyeditors/URLEditorTests.java index 40b0afa2d32..2d6c4b0d6a1 100644 --- a/spring-beans/src/test/java/org/springframework/beans/propertyeditors/URLEditorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/propertyeditors/URLEditorTests.java @@ -19,7 +19,7 @@ package org.springframework.beans.propertyeditors; import java.beans.PropertyEditor; import java.net.URL; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.util.ClassUtils; diff --git a/spring-beans/src/test/java/org/springframework/beans/propertyeditors/ZoneIdEditorTests.java b/spring-beans/src/test/java/org/springframework/beans/propertyeditors/ZoneIdEditorTests.java index b2762e74895..7a9162314b2 100644 --- a/spring-beans/src/test/java/org/springframework/beans/propertyeditors/ZoneIdEditorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/propertyeditors/ZoneIdEditorTests.java @@ -18,7 +18,7 @@ package org.springframework.beans.propertyeditors; import java.time.ZoneId; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-beans/src/test/java/org/springframework/beans/support/PagedListHolderTests.java b/spring-beans/src/test/java/org/springframework/beans/support/PagedListHolderTests.java index 25b5d6b62ae..5d3cdf64f92 100644 --- a/spring-beans/src/test/java/org/springframework/beans/support/PagedListHolderTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/support/PagedListHolderTests.java @@ -19,7 +19,7 @@ package org.springframework.beans.support; import java.util.ArrayList; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.tests.Assume; import org.springframework.tests.TestGroup; diff --git a/spring-beans/src/test/java/org/springframework/beans/support/PropertyComparatorTests.java b/spring-beans/src/test/java/org/springframework/beans/support/PropertyComparatorTests.java index cf6ea346222..3ca5a5d8504 100644 --- a/spring-beans/src/test/java/org/springframework/beans/support/PropertyComparatorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/support/PropertyComparatorTests.java @@ -18,7 +18,7 @@ package org.springframework.beans.support; import java.util.Comparator; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; 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 5b348c2b52b..60af2e1dec4 100644 --- a/spring-beans/src/test/kotlin/org/springframework/beans/KotlinBeanUtilsTests.kt +++ b/spring-beans/src/test/kotlin/org/springframework/beans/KotlinBeanUtilsTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * 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. @@ -17,7 +17,7 @@ package org.springframework.beans import org.junit.Assert.* -import org.junit.Test +import org.junit.jupiter.api.Test /** * Kotlin tests for {@link BeanUtils}. diff --git a/spring-beans/src/test/kotlin/org/springframework/beans/factory/BeanFactoryExtensionsTests.kt b/spring-beans/src/test/kotlin/org/springframework/beans/factory/BeanFactoryExtensionsTests.kt index ce8cc085fef..6ba9e5dd50c 100644 --- a/spring-beans/src/test/kotlin/org/springframework/beans/factory/BeanFactoryExtensionsTests.kt +++ b/spring-beans/src/test/kotlin/org/springframework/beans/factory/BeanFactoryExtensionsTests.kt @@ -18,7 +18,7 @@ package org.springframework.beans.factory import io.mockk.mockk import io.mockk.verify -import org.junit.Test +import org.junit.jupiter.api.Test import org.springframework.core.ResolvableType /** diff --git a/spring-beans/src/test/kotlin/org/springframework/beans/factory/ListableBeanFactoryExtensionsTests.kt b/spring-beans/src/test/kotlin/org/springframework/beans/factory/ListableBeanFactoryExtensionsTests.kt index c7fc3a3cdc6..a86a60aec9b 100644 --- a/spring-beans/src/test/kotlin/org/springframework/beans/factory/ListableBeanFactoryExtensionsTests.kt +++ b/spring-beans/src/test/kotlin/org/springframework/beans/factory/ListableBeanFactoryExtensionsTests.kt @@ -18,7 +18,7 @@ package org.springframework.beans.factory import io.mockk.mockk import io.mockk.verify -import org.junit.Test +import org.junit.jupiter.api.Test /** * Mock object based tests for ListableBeanFactory Kotlin extensions 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 88d21f6c9cf..0942fd6866c 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * 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. @@ -16,7 +16,7 @@ package org.springframework.beans.factory.annotation -import org.junit.Test +import org.junit.jupiter.api.Test import org.springframework.beans.factory.support.DefaultListableBeanFactory import org.springframework.beans.factory.support.RootBeanDefinition @@ -183,7 +183,7 @@ class KotlinAutowiredTests { bf.getBean(KotlinBeanWithPrimaryAndSecondaryConstructors::class.java) } - @Test(expected = BeanCreationException::class) // SPR-16022 + @Test // SPR-16022 fun `No autowiring with primary and secondary non annotated constructors`() { val bf = DefaultListableBeanFactory() val bpp = AutowiredAnnotationBeanPostProcessor() @@ -196,8 +196,14 @@ class KotlinAutowiredTests { bf.registerSingleton("testBean", tb) val colour = Colour.BLUE bf.registerSingleton("colour", colour) - - bf.getBean("bean", KotlinBeanWithSecondaryConstructor::class.java) + + try { + bf.getBean("bean", KotlinBeanWithSecondaryConstructor::class.java) + fail("should have thrown a BeanCreationException") + } + catch (e: BeanCreationException) { + // expected + } } diff --git a/spring-context-indexer/src/test/java/org/springframework/context/index/processor/CandidateComponentsIndexerTests.java b/spring-context-indexer/src/test/java/org/springframework/context/index/processor/CandidateComponentsIndexerTests.java index 3cf8e7931c2..9b359989cdc 100644 --- a/spring-context-indexer/src/test/java/org/springframework/context/index/processor/CandidateComponentsIndexerTests.java +++ b/spring-context-indexer/src/test/java/org/springframework/context/index/processor/CandidateComponentsIndexerTests.java @@ -19,6 +19,7 @@ package org.springframework.context.index.processor; import java.io.File; import java.io.FileInputStream; import java.io.IOException; +import java.nio.file.Path; import javax.annotation.ManagedBean; import javax.inject.Named; import javax.persistence.Converter; @@ -27,10 +28,9 @@ import javax.persistence.Entity; import javax.persistence.MappedSuperclass; import javax.transaction.Transactional; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; import org.springframework.context.index.sample.AbstractController; import org.springframework.context.index.sample.MetaControllerIndexed; @@ -62,151 +62,143 @@ import org.springframework.util.ClassUtils; import static org.assertj.core.api.Assertions.assertThat; - - - /** * Tests for {@link CandidateComponentsIndexer}. * * @author Stephane Nicoll * @author Vedran Pavic + * @author Sam Brannen */ -public class CandidateComponentsIndexerTests { +class CandidateComponentsIndexerTests { private TestCompiler compiler; - @Rule - public TemporaryFolder temporaryFolder = new TemporaryFolder(); - - @Before - public void createCompiler() throws IOException { - this.compiler = new TestCompiler(this.temporaryFolder); + @BeforeEach + void createCompiler(@TempDir Path tempDir) throws IOException { + this.compiler = new TestCompiler(tempDir); } @Test - public void noCandidate() { + void noCandidate() { CandidateComponentsMetadata metadata = compile(SampleNone.class); assertThat(metadata.getItems()).hasSize(0); } @Test - public void noAnnotation() { + void noAnnotation() { CandidateComponentsMetadata metadata = compile(CandidateComponentsIndexerTests.class); assertThat(metadata.getItems()).hasSize(0); } @Test - public void stereotypeComponent() { + void stereotypeComponent() { testComponent(SampleComponent.class); } @Test - public void stereotypeService() { + void stereotypeService() { testComponent(SampleService.class); } @Test - public void stereotypeController() { + void stereotypeController() { testComponent(SampleController.class); } @Test - public void stereotypeControllerMetaAnnotation() { + void stereotypeControllerMetaAnnotation() { testComponent(SampleMetaController.class); } @Test - public void stereotypeRepository() { + void stereotypeRepository() { testSingleComponent(SampleRepository.class, Component.class); } @Test - public void stereotypeControllerMetaIndex() { - testSingleComponent(SampleMetaIndexedController.class, - Component.class, MetaControllerIndexed.class); + void stereotypeControllerMetaIndex() { + testSingleComponent(SampleMetaIndexedController.class, Component.class, MetaControllerIndexed.class); } @Test - public void stereotypeOnAbstractClass() { + void stereotypeOnAbstractClass() { testComponent(AbstractController.class); } @Test - public void cdiManagedBean() { + void cdiManagedBean() { testSingleComponent(SampleManagedBean.class, ManagedBean.class); } @Test - public void cdiNamed() { + void cdiNamed() { testSingleComponent(SampleNamed.class, Named.class); } @Test - public void cdiTransactional() { + void cdiTransactional() { testSingleComponent(SampleTransactional.class, Transactional.class); } @Test - public void persistenceEntity() { + void persistenceEntity() { testSingleComponent(SampleEntity.class, Entity.class); } @Test - public void persistenceMappedSuperClass() { + void persistenceMappedSuperClass() { testSingleComponent(SampleMappedSuperClass.class, MappedSuperclass.class); } @Test - public void persistenceEmbeddable() { + void persistenceEmbeddable() { testSingleComponent(SampleEmbeddable.class, Embeddable.class); } @Test - public void persistenceConverter() { + void persistenceConverter() { testSingleComponent(SampleConverter.class, Converter.class); } @Test - public void packageInfo() { - CandidateComponentsMetadata metadata = compile( - "org/springframework/context/index/sample/jpa/package-info"); - assertThat(metadata).has(Metadata.of( - "org.springframework.context.index.sample.jpa", "package-info")); + void packageInfo() { + CandidateComponentsMetadata metadata = compile("org/springframework/context/index/sample/jpa/package-info"); + assertThat(metadata).has(Metadata.of("org.springframework.context.index.sample.jpa", "package-info")); } @Test - public void typeStereotypeFromMetaInterface() { + void typeStereotypeFromMetaInterface() { testSingleComponent(SampleSpecializedRepo.class, Repo.class); } @Test - public void typeStereotypeFromInterfaceFromSuperClass() { + void typeStereotypeFromInterfaceFromSuperClass() { testSingleComponent(SampleRepo.class, Repo.class); } @Test - public void typeStereotypeFromSeveralInterfaces() { + void typeStereotypeFromSeveralInterfaces() { testSingleComponent(SampleSmartRepo.class, Repo.class, SmartRepo.class); } @Test - public void typeStereotypeOnInterface() { + void typeStereotypeOnInterface() { testSingleComponent(SpecializedRepo.class, Repo.class); } @Test - public void typeStereotypeOnInterfaceFromSeveralInterfaces() { + void typeStereotypeOnInterfaceFromSeveralInterfaces() { testSingleComponent(SmartRepo.class, Repo.class, SmartRepo.class); } @Test - public void typeStereotypeOnIndexedInterface() { + void typeStereotypeOnIndexedInterface() { testSingleComponent(Repo.class, Repo.class); } @Test - public void embeddedCandidatesAreDetected() + void embeddedCandidatesAreDetected() throws IOException, ClassNotFoundException { // Validate nested type structure String nestedType = "org.springframework.context.index.sample.SampleEmbedded.Another$AnotherPublicCandidate"; @@ -214,14 +206,13 @@ public class CandidateComponentsIndexerTests { assertThat(type).isSameAs(SampleEmbedded.Another.AnotherPublicCandidate.class); CandidateComponentsMetadata metadata = compile(SampleEmbedded.class); - assertThat(metadata).has(Metadata.of( - SampleEmbedded.PublicCandidate.class, Component.class)); + assertThat(metadata).has(Metadata.of(SampleEmbedded.PublicCandidate.class, Component.class)); assertThat(metadata).has(Metadata.of(nestedType, Component.class.getName())); assertThat(metadata.getItems()).hasSize(2); } @Test - public void embeddedNonStaticCandidateAreIgnored() { + void embeddedNonStaticCandidateAreIgnored() { CandidateComponentsMetadata metadata = compile(SampleNonStaticEmbedded.class); assertThat(metadata.getItems()).hasSize(0); } @@ -254,8 +245,7 @@ public class CandidateComponentsIndexerTests { private CandidateComponentsMetadata readGeneratedMetadata(File outputLocation) { try { - File metadataFile = new File(outputLocation, - MetadataStore.METADATA_PATH); + File metadataFile = new File(outputLocation, MetadataStore.METADATA_PATH); if (metadataFile.isFile()) { return PropertiesMarshaller.read(new FileInputStream(metadataFile)); } diff --git a/spring-context-indexer/src/test/java/org/springframework/context/index/processor/PropertiesMarshallerTests.java b/spring-context-indexer/src/test/java/org/springframework/context/index/processor/PropertiesMarshallerTests.java index 53c51a71ced..e518841ef3a 100644 --- a/spring-context-indexer/src/test/java/org/springframework/context/index/processor/PropertiesMarshallerTests.java +++ b/spring-context-indexer/src/test/java/org/springframework/context/index/processor/PropertiesMarshallerTests.java @@ -23,7 +23,7 @@ import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.HashSet; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context-indexer/src/test/java/org/springframework/context/index/test/TestCompiler.java b/spring-context-indexer/src/test/java/org/springframework/context/index/test/TestCompiler.java index 8949366a267..baa197f564b 100644 --- a/spring-context-indexer/src/test/java/org/springframework/context/index/test/TestCompiler.java +++ b/spring-context-indexer/src/test/java/org/springframework/context/index/test/TestCompiler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * 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. @@ -18,6 +18,7 @@ package org.springframework.context.index.test; import java.io.File; import java.io.IOException; +import java.nio.file.Path; import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -29,12 +30,11 @@ import javax.tools.StandardJavaFileManager; import javax.tools.StandardLocation; import javax.tools.ToolProvider; -import org.junit.rules.TemporaryFolder; - /** * Wrapper to make the {@link JavaCompiler} easier to use in tests. * * @author Stephane Nicoll + * @author Sam Brannen */ public class TestCompiler { @@ -47,14 +47,14 @@ public class TestCompiler { private final File outputLocation; - public TestCompiler(TemporaryFolder temporaryFolder) throws IOException { - this(ToolProvider.getSystemJavaCompiler(), temporaryFolder); + public TestCompiler(Path tempDir) throws IOException { + this(ToolProvider.getSystemJavaCompiler(), tempDir); } - public TestCompiler(JavaCompiler compiler, TemporaryFolder temporaryFolder) throws IOException { + public TestCompiler(JavaCompiler compiler, Path tempDir) throws IOException { this.compiler = compiler; this.fileManager = compiler.getStandardFileManager(null, null, null); - this.outputLocation = temporaryFolder.newFolder(); + this.outputLocation = tempDir.toFile(); Iterable temp = Collections.singletonList(this.outputLocation); this.fileManager.setLocation(StandardLocation.CLASS_OUTPUT, temp); this.fileManager.setLocation(StandardLocation.SOURCE_OUTPUT, temp); diff --git a/spring-context-support/src/test/java/org/springframework/cache/caffeine/CaffeineCacheManagerTests.java b/spring-context-support/src/test/java/org/springframework/cache/caffeine/CaffeineCacheManagerTests.java index 1ea2aca687d..7637e105454 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/caffeine/CaffeineCacheManagerTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/caffeine/CaffeineCacheManagerTests.java @@ -19,7 +19,7 @@ package org.springframework.cache.caffeine; import com.github.benmanes.caffeine.cache.CacheLoader; import com.github.benmanes.caffeine.cache.Caffeine; import com.github.benmanes.caffeine.cache.CaffeineSpec; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.cache.Cache; import org.springframework.cache.CacheManager; diff --git a/spring-context-support/src/test/java/org/springframework/cache/caffeine/CaffeineCacheTests.java b/spring-context-support/src/test/java/org/springframework/cache/caffeine/CaffeineCacheTests.java index 3e4aad7859d..eae5f14bb44 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/caffeine/CaffeineCacheTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/caffeine/CaffeineCacheTests.java @@ -17,8 +17,8 @@ package org.springframework.cache.caffeine; import com.github.benmanes.caffeine.cache.Caffeine; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.cache.AbstractValueAdaptingCacheTests; import org.springframework.cache.Cache; @@ -37,7 +37,7 @@ public class CaffeineCacheTests extends AbstractValueAdaptingCacheTests { private EhCacheCache cache; - @Before + @BeforeEach public void setup() { cacheManager = new CacheManager(new Configuration().name("EhCacheCacheTests") .defaultCache(new CacheConfiguration("default", 100))); @@ -55,7 +55,7 @@ public class EhCacheCacheTests extends AbstractCacheTests { cache = new EhCacheCache(nativeCache); } - @After + @AfterEach public void shutdown() { cacheManager.shutdown(); } diff --git a/spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheSupportTests.java b/spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheSupportTests.java index 4e4cb57a94a..c663b0fba33 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheSupportTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/ehcache/EhCacheSupportTests.java @@ -25,7 +25,7 @@ import net.sf.ehcache.constructs.blocking.BlockingCache; import net.sf.ehcache.constructs.blocking.SelfPopulatingCache; import net.sf.ehcache.constructs.blocking.UpdatingCacheEntryFactory; import net.sf.ehcache.constructs.blocking.UpdatingSelfPopulatingCache; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.io.ClassPathResource; diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/AbstractJCacheTests.java b/spring-context-support/src/test/java/org/springframework/cache/jcache/AbstractJCacheTests.java index b00c9d7e0bc..0d7df53620d 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/AbstractJCacheTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/jcache/AbstractJCacheTests.java @@ -19,8 +19,8 @@ package org.springframework.cache.jcache; import java.util.ArrayList; import java.util.List; -import org.junit.Rule; -import org.junit.rules.TestName; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.TestInfo; import org.springframework.cache.Cache; import org.springframework.cache.CacheManager; @@ -34,11 +34,18 @@ import org.springframework.cache.support.SimpleCacheManager; /** * @author Stephane Nicoll + * @author Sam Brannen */ public abstract class AbstractJCacheTests { - @Rule - public final TestName name = new TestName(); + protected String cacheName; + + + @BeforeEach + void trackCacheName(TestInfo testInfo) { + this.cacheName = testInfo.getTestMethod().get().getName(); + } + protected final CacheManager cacheManager = createSimpleCacheManager("default", "simpleCache"); diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheCacheManagerTests.java b/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheCacheManagerTests.java index 89a3c535b55..cafcd42cb3c 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheCacheManagerTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheCacheManagerTests.java @@ -21,7 +21,7 @@ import java.util.List; import javax.cache.Cache; import javax.cache.CacheManager; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.springframework.cache.transaction.AbstractTransactionSupportingCacheManagerTests; @@ -40,7 +40,7 @@ public class JCacheCacheManagerTests extends AbstractTransactionSupportingCacheM private JCacheCacheManager transactionalCacheManager; - @Before + @BeforeEach public void setupOnce() { cacheManagerMock = new CacheManagerMock(); cacheManagerMock.addCache(CACHE_NAME); diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheEhCacheAnnotationTests.java b/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheEhCacheAnnotationTests.java index 5e6d6db6be9..748c4678fb5 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheEhCacheAnnotationTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheEhCacheAnnotationTests.java @@ -21,9 +21,9 @@ import javax.cache.Caching; import javax.cache.configuration.MutableConfiguration; import javax.cache.spi.CachingProvider; -import org.junit.After; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cache.annotation.CachingConfigurerSupport; @@ -67,7 +67,7 @@ public class JCacheEhCacheAnnotationTests extends AbstractCacheAnnotationTests { return Caching.getCachingProvider("org.ehcache.jcache.JCacheCachingProvider"); } - @After + @AfterEach public void shutdown() { if (jCacheManager != null) { jCacheManager.close(); @@ -77,7 +77,7 @@ public class JCacheEhCacheAnnotationTests extends AbstractCacheAnnotationTests { @Override @Test - @Ignore("Multi cache manager support to be added") + @Disabled("Multi cache manager support to be added") public void testCustomCacheManager() { } diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheEhCacheApiTests.java b/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheEhCacheApiTests.java index 3006d9b0c66..d0797dd9269 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheEhCacheApiTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/jcache/JCacheEhCacheApiTests.java @@ -22,8 +22,8 @@ import javax.cache.Caching; import javax.cache.configuration.MutableConfiguration; import javax.cache.spi.CachingProvider; -import org.junit.After; -import org.junit.Before; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; import org.springframework.cache.AbstractValueAdaptingCacheTests; @@ -41,7 +41,7 @@ public class JCacheEhCacheApiTests extends AbstractValueAdaptingCacheTests()); @@ -57,7 +57,7 @@ public class JCacheEhCacheApiTests extends AbstractValueAdaptingCacheTests - service.cacheWithException(keyItem, true)); + service.cacheWithException(this.keyItem, true)); Cache.ValueWrapper result = cache.get(key); assertThat(result).isNotNull(); @@ -105,26 +101,24 @@ public abstract class AbstractJCacheAnnotationTests { @Test public void cacheExceptionVetoed() { - String keyItem = name.getMethodName(); Cache cache = getCache(EXCEPTION_CACHE); - Object key = createKey(keyItem); + Object key = createKey(this.keyItem); assertThat(cache.get(key)).isNull(); assertThatNullPointerException().isThrownBy(() -> - service.cacheWithException(keyItem, false)); + service.cacheWithException(this.keyItem, false)); assertThat(cache.get(key)).isNull(); } @Test public void cacheCheckedException() { - String keyItem = name.getMethodName(); Cache cache = getCache(EXCEPTION_CACHE); - Object key = createKey(keyItem); + Object key = createKey(this.keyItem); assertThat(cache.get(key)).isNull(); assertThatIOException().isThrownBy(() -> - service.cacheWithCheckedException(keyItem, true)); + service.cacheWithCheckedException(this.keyItem, true)); Cache.ValueWrapper result = cache.get(key); assertThat(result).isNotNull(); @@ -135,16 +129,15 @@ public abstract class AbstractJCacheAnnotationTests { @SuppressWarnings("ThrowableResultOfMethodCallIgnored") @Test public void cacheExceptionRewriteCallStack() { - String keyItem = name.getMethodName(); long ref = service.exceptionInvocations(); assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> - service.cacheWithException(keyItem, true)) + service.cacheWithException(this.keyItem, true)) .satisfies(first -> { // Sanity check, this particular call has called the service // First call should not have been cached assertThat(service.exceptionInvocations()).isEqualTo(ref + 1); - UnsupportedOperationException second = methodInCallStack(keyItem); + UnsupportedOperationException second = methodInCallStack(this.keyItem); // Sanity check, this particular call has *not* called the service // Second call should have been cached assertThat(service.exceptionInvocations()).isEqualTo(ref + 1); @@ -159,30 +152,25 @@ public abstract class AbstractJCacheAnnotationTests { @Test public void cacheAlwaysInvoke() { - String keyItem = name.getMethodName(); - - Object first = service.cacheAlwaysInvoke(keyItem); - Object second = service.cacheAlwaysInvoke(keyItem); + Object first = service.cacheAlwaysInvoke(this.keyItem); + Object second = service.cacheAlwaysInvoke(this.keyItem); assertThat(second).isNotSameAs(first); } @Test public void cacheWithPartialKey() { - String keyItem = name.getMethodName(); - - Object first = service.cacheWithPartialKey(keyItem, true); - Object second = service.cacheWithPartialKey(keyItem, false); + Object first = service.cacheWithPartialKey(this.keyItem, true); + Object second = service.cacheWithPartialKey(this.keyItem, false); // second argument not used, see config assertThat(second).isSameAs(first); } @Test public void cacheWithCustomCacheResolver() { - String keyItem = name.getMethodName(); Cache cache = getCache(DEFAULT_CACHE); - Object key = createKey(keyItem); - service.cacheWithCustomCacheResolver(keyItem); + Object key = createKey(this.keyItem); + service.cacheWithCustomCacheResolver(this.keyItem); // Cache in mock cache assertThat(cache.get(key)).isNull(); @@ -190,25 +178,23 @@ public abstract class AbstractJCacheAnnotationTests { @Test public void cacheWithCustomKeyGenerator() { - String keyItem = name.getMethodName(); Cache cache = getCache(DEFAULT_CACHE); - Object key = createKey(keyItem); - service.cacheWithCustomKeyGenerator(keyItem, "ignored"); + Object key = createKey(this.keyItem); + service.cacheWithCustomKeyGenerator(this.keyItem, "ignored"); assertThat(cache.get(key)).isNull(); } @Test public void put() { - String keyItem = name.getMethodName(); Cache cache = getCache(DEFAULT_CACHE); - Object key = createKey(keyItem); + Object key = createKey(this.keyItem); Object value = new Object(); assertThat(cache.get(key)).isNull(); - service.put(keyItem, value); + service.put(this.keyItem, value); Cache.ValueWrapper result = cache.get(key); assertThat(result).isNotNull(); @@ -217,15 +203,14 @@ public abstract class AbstractJCacheAnnotationTests { @Test public void putWithException() { - String keyItem = name.getMethodName(); Cache cache = getCache(DEFAULT_CACHE); - Object key = createKey(keyItem); + Object key = createKey(this.keyItem); Object value = new Object(); assertThat(cache.get(key)).isNull(); assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> - service.putWithException(keyItem, value, true)); + service.putWithException(this.keyItem, value, true)); Cache.ValueWrapper result = cache.get(key); assertThat(result).isNotNull(); @@ -234,28 +219,26 @@ public abstract class AbstractJCacheAnnotationTests { @Test public void putWithExceptionVetoPut() { - String keyItem = name.getMethodName(); Cache cache = getCache(DEFAULT_CACHE); - Object key = createKey(keyItem); + Object key = createKey(this.keyItem); Object value = new Object(); assertThat(cache.get(key)).isNull(); assertThatNullPointerException().isThrownBy(() -> - service.putWithException(keyItem, value, false)); + service.putWithException(this.keyItem, value, false)); assertThat(cache.get(key)).isNull(); } @Test public void earlyPut() { - String keyItem = name.getMethodName(); Cache cache = getCache(DEFAULT_CACHE); - Object key = createKey(keyItem); + Object key = createKey(this.keyItem); Object value = new Object(); assertThat(cache.get(key)).isNull(); - service.earlyPut(keyItem, value); + service.earlyPut(this.keyItem, value); Cache.ValueWrapper result = cache.get(key); assertThat(result).isNotNull(); @@ -264,15 +247,14 @@ public abstract class AbstractJCacheAnnotationTests { @Test public void earlyPutWithException() { - String keyItem = name.getMethodName(); Cache cache = getCache(DEFAULT_CACHE); - Object key = createKey(keyItem); + Object key = createKey(this.keyItem); Object value = new Object(); assertThat(cache.get(key)).isNull(); assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> - service.earlyPutWithException(keyItem, value, true)); + service.earlyPutWithException(this.keyItem, value, true)); Cache.ValueWrapper result = cache.get(key); assertThat(result).isNotNull(); @@ -281,14 +263,13 @@ public abstract class AbstractJCacheAnnotationTests { @Test public void earlyPutWithExceptionVetoPut() { - String keyItem = name.getMethodName(); Cache cache = getCache(DEFAULT_CACHE); - Object key = createKey(keyItem); + Object key = createKey(this.keyItem); Object value = new Object(); assertThat(cache.get(key)).isNull(); assertThatNullPointerException().isThrownBy(() -> - service.earlyPutWithException(keyItem, value, false)); + service.earlyPutWithException(this.keyItem, value, false)); // This will be cached anyway as the earlyPut has updated the cache before Cache.ValueWrapper result = cache.get(key); assertThat(result).isNotNull(); @@ -297,44 +278,41 @@ public abstract class AbstractJCacheAnnotationTests { @Test public void remove() { - String keyItem = name.getMethodName(); Cache cache = getCache(DEFAULT_CACHE); - Object key = createKey(keyItem); + Object key = createKey(this.keyItem); Object value = new Object(); cache.put(key, value); - service.remove(keyItem); + service.remove(this.keyItem); assertThat(cache.get(key)).isNull(); } @Test public void removeWithException() { - String keyItem = name.getMethodName(); Cache cache = getCache(DEFAULT_CACHE); - Object key = createKey(keyItem); + Object key = createKey(this.keyItem); Object value = new Object(); cache.put(key, value); assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> - service.removeWithException(keyItem, true)); + service.removeWithException(this.keyItem, true)); assertThat(cache.get(key)).isNull(); } @Test public void removeWithExceptionVetoRemove() { - String keyItem = name.getMethodName(); Cache cache = getCache(DEFAULT_CACHE); - Object key = createKey(keyItem); + Object key = createKey(this.keyItem); Object value = new Object(); cache.put(key, value); assertThatNullPointerException().isThrownBy(() -> - service.removeWithException(keyItem, false)); + service.removeWithException(this.keyItem, false)); Cache.ValueWrapper wrapper = cache.get(key); assertThat(wrapper).isNotNull(); assertThat(wrapper.get()).isEqualTo(value); @@ -342,43 +320,40 @@ public abstract class AbstractJCacheAnnotationTests { @Test public void earlyRemove() { - String keyItem = name.getMethodName(); Cache cache = getCache(DEFAULT_CACHE); - Object key = createKey(keyItem); + Object key = createKey(this.keyItem); Object value = new Object(); cache.put(key, value); - service.earlyRemove(keyItem); + service.earlyRemove(this.keyItem); assertThat(cache.get(key)).isNull(); } @Test public void earlyRemoveWithException() { - String keyItem = name.getMethodName(); Cache cache = getCache(DEFAULT_CACHE); - Object key = createKey(keyItem); + Object key = createKey(this.keyItem); Object value = new Object(); cache.put(key, value); assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> - service.earlyRemoveWithException(keyItem, true)); + service.earlyRemoveWithException(this.keyItem, true)); assertThat(cache.get(key)).isNull(); } @Test public void earlyRemoveWithExceptionVetoRemove() { - String keyItem = name.getMethodName(); Cache cache = getCache(DEFAULT_CACHE); - Object key = createKey(keyItem); + Object key = createKey(this.keyItem); Object value = new Object(); cache.put(key, value); assertThatNullPointerException().isThrownBy(() -> - service.earlyRemoveWithException(keyItem, false)); + service.earlyRemoveWithException(this.keyItem, false)); // This will be remove anyway as the earlyRemove has removed the cache before assertThat(cache.get(key)).isNull(); } @@ -387,7 +362,7 @@ public abstract class AbstractJCacheAnnotationTests { public void removeAll() { Cache cache = getCache(DEFAULT_CACHE); - Object key = createKey(name.getMethodName()); + Object key = createKey(this.keyItem); cache.put(key, new Object()); service.removeAll(); @@ -399,7 +374,7 @@ public abstract class AbstractJCacheAnnotationTests { public void removeAllWithException() { Cache cache = getCache(DEFAULT_CACHE); - Object key = createKey(name.getMethodName()); + Object key = createKey(this.keyItem); cache.put(key, new Object()); assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> @@ -412,7 +387,7 @@ public abstract class AbstractJCacheAnnotationTests { public void removeAllWithExceptionVetoRemove() { Cache cache = getCache(DEFAULT_CACHE); - Object key = createKey(name.getMethodName()); + Object key = createKey(this.keyItem); cache.put(key, new Object()); assertThatNullPointerException().isThrownBy(() -> @@ -424,7 +399,7 @@ public abstract class AbstractJCacheAnnotationTests { public void earlyRemoveAll() { Cache cache = getCache(DEFAULT_CACHE); - Object key = createKey(name.getMethodName()); + Object key = createKey(this.keyItem); cache.put(key, new Object()); service.earlyRemoveAll(); @@ -436,7 +411,7 @@ public abstract class AbstractJCacheAnnotationTests { public void earlyRemoveAllWithException() { Cache cache = getCache(DEFAULT_CACHE); - Object key = createKey(name.getMethodName()); + Object key = createKey(this.keyItem); cache.put(key, new Object()); assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> @@ -448,7 +423,7 @@ public abstract class AbstractJCacheAnnotationTests { public void earlyRemoveAllWithExceptionVetoRemove() { Cache cache = getCache(DEFAULT_CACHE); - Object key = createKey(name.getMethodName()); + Object key = createKey(this.keyItem); cache.put(key, new Object()); assertThatNullPointerException().isThrownBy(() -> diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/config/JCacheCustomInterceptorTests.java b/spring-context-support/src/test/java/org/springframework/cache/jcache/config/JCacheCustomInterceptorTests.java index 5bb7f10bcdf..8ac2f4a3e6b 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/config/JCacheCustomInterceptorTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/jcache/config/JCacheCustomInterceptorTests.java @@ -20,9 +20,9 @@ import java.io.IOException; import java.util.Arrays; import java.util.Map; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.cache.Cache; import org.springframework.cache.CacheManager; @@ -53,14 +53,14 @@ public class JCacheCustomInterceptorTests { protected Cache exceptionCache; - @Before + @BeforeEach public void setup() { ctx = new AnnotationConfigApplicationContext(EnableCachingConfig.class); cs = ctx.getBean("service", JCacheableService.class); exceptionCache = ctx.getBean("exceptionCache", Cache.class); } - @After + @AfterEach public void tearDown() { if (ctx != null) { ctx.close(); diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/config/JCacheJavaConfigTests.java b/spring-context-support/src/test/java/org/springframework/cache/jcache/config/JCacheJavaConfigTests.java index f536c96fae8..60555a7a3e7 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/config/JCacheJavaConfigTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/jcache/config/JCacheJavaConfigTests.java @@ -18,7 +18,7 @@ package org.springframework.cache.jcache.config; import java.util.Arrays; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.cache.Cache; import org.springframework.cache.CacheManager; diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/config/JCacheNamespaceDrivenTests.java b/spring-context-support/src/test/java/org/springframework/cache/jcache/config/JCacheNamespaceDrivenTests.java index c3dfa937313..28f7c513c76 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/config/JCacheNamespaceDrivenTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/jcache/config/JCacheNamespaceDrivenTests.java @@ -16,7 +16,7 @@ package org.springframework.cache.jcache.config; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.cache.interceptor.CacheErrorHandler; import org.springframework.cache.jcache.interceptor.DefaultJCacheOperationSource; diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/AbstractCacheOperationTests.java b/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/AbstractCacheOperationTests.java index a46b2b5b00a..a1193b6c658 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/AbstractCacheOperationTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/AbstractCacheOperationTests.java @@ -21,7 +21,7 @@ import java.lang.reflect.Method; import javax.cache.annotation.CacheInvocationParameter; import javax.cache.annotation.CacheMethodDetails; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.cache.jcache.AbstractJCacheTests; import org.springframework.core.annotation.AnnotationUtils; diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/AnnotationCacheOperationSourceTests.java b/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/AnnotationCacheOperationSourceTests.java index b4c652ea17c..c0bb34420a0 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/AnnotationCacheOperationSourceTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/AnnotationCacheOperationSourceTests.java @@ -24,8 +24,8 @@ import javax.cache.annotation.CacheRemove; import javax.cache.annotation.CacheRemoveAll; import javax.cache.annotation.CacheResult; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.cache.interceptor.CacheResolver; @@ -52,7 +52,7 @@ public class AnnotationCacheOperationSourceTests extends AbstractJCacheTests { private final DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory(); - @Before + @BeforeEach public void setup() { source.setCacheResolver(defaultCacheResolver); source.setExceptionCacheResolver(defaultExceptionCacheResolver); @@ -96,13 +96,12 @@ public class AnnotationCacheOperationSourceTests extends AbstractJCacheTests { @Test public void noAnnotation() { - assertThat(getCacheOperation(AnnotatedJCacheableService.class, name.getMethodName())).isNull(); + assertThat(getCacheOperation(AnnotatedJCacheableService.class, this.cacheName)).isNull(); } @Test public void multiAnnotations() { - assertThatIllegalStateException().isThrownBy(() -> - getCacheOperation(InvalidCases.class, name.getMethodName())); + assertThatIllegalStateException().isThrownBy(() -> getCacheOperation(InvalidCases.class, this.cacheName)); } @Test @@ -134,7 +133,7 @@ public class AnnotationCacheOperationSourceTests extends AbstractJCacheTests { @Test public void customCacheResolver() { CacheResultOperation operation = - getCacheOperation(CacheResultOperation.class, CustomService.class, name.getMethodName(), Long.class); + getCacheOperation(CacheResultOperation.class, CustomService.class, this.cacheName, Long.class); assertJCacheResolver(operation.getCacheResolver(), TestableCacheResolver.class); assertJCacheResolver(operation.getExceptionCacheResolver(), null); assertThat(operation.getKeyGenerator().getClass()).isEqualTo(KeyGeneratorAdapter.class); @@ -144,7 +143,7 @@ public class AnnotationCacheOperationSourceTests extends AbstractJCacheTests { @Test public void customKeyGenerator() { CacheResultOperation operation = - getCacheOperation(CacheResultOperation.class, CustomService.class, name.getMethodName(), Long.class); + getCacheOperation(CacheResultOperation.class, CustomService.class, this.cacheName, Long.class); assertThat(operation.getCacheResolver()).isEqualTo(defaultCacheResolver); assertThat(operation.getExceptionCacheResolver()).isNull(); assertCacheKeyGenerator(operation.getKeyGenerator(), TestableCacheKeyGenerator.class); @@ -155,7 +154,7 @@ public class AnnotationCacheOperationSourceTests extends AbstractJCacheTests { TestableCacheKeyGenerator bean = new TestableCacheKeyGenerator(); beanFactory.registerSingleton("fooBar", bean); CacheResultOperation operation = - getCacheOperation(CacheResultOperation.class, CustomService.class, name.getMethodName(), Long.class); + getCacheOperation(CacheResultOperation.class, CustomService.class, this.cacheName, Long.class); assertThat(operation.getCacheResolver()).isEqualTo(defaultCacheResolver); assertThat(operation.getExceptionCacheResolver()).isNull(); KeyGeneratorAdapter adapter = (KeyGeneratorAdapter) operation.getKeyGenerator(); @@ -166,7 +165,7 @@ public class AnnotationCacheOperationSourceTests extends AbstractJCacheTests { @Test public void customKeyGeneratorAndCacheResolver() { CacheResultOperation operation = getCacheOperation(CacheResultOperation.class, - CustomServiceWithDefaults.class, name.getMethodName(), Long.class); + CustomServiceWithDefaults.class, this.cacheName, Long.class); assertJCacheResolver(operation.getCacheResolver(), TestableCacheResolver.class); assertJCacheResolver(operation.getExceptionCacheResolver(), null); assertCacheKeyGenerator(operation.getKeyGenerator(), TestableCacheKeyGenerator.class); @@ -175,7 +174,7 @@ public class AnnotationCacheOperationSourceTests extends AbstractJCacheTests { @Test public void customKeyGeneratorAndCacheResolverWithExceptionName() { CacheResultOperation operation = getCacheOperation(CacheResultOperation.class, - CustomServiceWithDefaults.class, name.getMethodName(), Long.class); + CustomServiceWithDefaults.class, this.cacheName, Long.class); assertJCacheResolver(operation.getCacheResolver(), TestableCacheResolver.class); assertJCacheResolver(operation.getExceptionCacheResolver(), TestableCacheResolver.class); assertCacheKeyGenerator(operation.getKeyGenerator(), TestableCacheKeyGenerator.class); @@ -188,7 +187,7 @@ public class AnnotationCacheOperationSourceTests extends AbstractJCacheTests { } protected > T getDefaultCacheOperation(Class operationType, Class... parameterTypes) { - return getCacheOperation(operationType, AnnotatedJCacheableService.class, name.getMethodName(), parameterTypes); + return getCacheOperation(operationType, AnnotatedJCacheableService.class, this.cacheName, parameterTypes); } protected > T getCacheOperation( @@ -246,8 +245,7 @@ public class AnnotationCacheOperationSourceTests extends AbstractJCacheTests { } - @CacheDefaults(cacheResolverFactory = TestableCacheResolverFactory.class, - cacheKeyGenerator = TestableCacheKeyGenerator.class) + @CacheDefaults(cacheResolverFactory = TestableCacheResolverFactory.class, cacheKeyGenerator = TestableCacheKeyGenerator.class) static class CustomServiceWithDefaults { @CacheResult diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/CachePutOperationTests.java b/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/CachePutOperationTests.java index 0c4f07a5c12..ea4103ec223 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/CachePutOperationTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/CachePutOperationTests.java @@ -21,7 +21,7 @@ import javax.cache.annotation.CacheInvocationParameter; import javax.cache.annotation.CacheMethodDetails; import javax.cache.annotation.CachePut; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/CacheRemoveAllOperationTests.java b/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/CacheRemoveAllOperationTests.java index e1c4aa15954..7327a4059c5 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/CacheRemoveAllOperationTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/CacheRemoveAllOperationTests.java @@ -20,7 +20,7 @@ import javax.cache.annotation.CacheInvocationParameter; import javax.cache.annotation.CacheMethodDetails; import javax.cache.annotation.CacheRemoveAll; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/CacheRemoveOperationTests.java b/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/CacheRemoveOperationTests.java index 0d43c51a8a0..b8ae9595a1b 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/CacheRemoveOperationTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/CacheRemoveOperationTests.java @@ -20,7 +20,7 @@ import javax.cache.annotation.CacheInvocationParameter; import javax.cache.annotation.CacheMethodDetails; import javax.cache.annotation.CacheRemove; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/CacheResolverAdapterTests.java b/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/CacheResolverAdapterTests.java index fcb9fc50c0f..5f73e20679d 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/CacheResolverAdapterTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/CacheResolverAdapterTests.java @@ -24,7 +24,7 @@ import javax.cache.annotation.CacheMethodDetails; import javax.cache.annotation.CacheResolver; import javax.cache.annotation.CacheResult; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.cache.Cache; import org.springframework.cache.jcache.AbstractJCacheTests; diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/CacheResultOperationTests.java b/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/CacheResultOperationTests.java index f70fe0ee604..a0457c24293 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/CacheResultOperationTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/CacheResultOperationTests.java @@ -24,7 +24,7 @@ import javax.cache.annotation.CacheKey; import javax.cache.annotation.CacheMethodDetails; import javax.cache.annotation.CacheResult; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Value; diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/JCacheErrorHandlerTests.java b/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/JCacheErrorHandlerTests.java index 2dc6e3c3734..1c068fefe8d 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/JCacheErrorHandlerTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/JCacheErrorHandlerTests.java @@ -25,8 +25,8 @@ import javax.cache.annotation.CacheRemoveAll; import javax.cache.annotation.CacheResult; import javax.cache.annotation.CacheValue; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.cache.Cache; import org.springframework.cache.CacheManager; @@ -59,7 +59,7 @@ public class JCacheErrorHandlerTests { private SimpleService simpleService; - @Before + @BeforeEach public void setup() { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Config.class); this.cache = context.getBean("mockCache", Cache.class); diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/JCacheInterceptorTests.java b/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/JCacheInterceptorTests.java index 7d1a668472f..0c6671ebbb0 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/JCacheInterceptorTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/JCacheInterceptorTests.java @@ -18,7 +18,7 @@ package org.springframework.cache.jcache.interceptor; import java.lang.reflect.Method; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.StaticListableBeanFactory; import org.springframework.cache.CacheManager; diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/JCacheKeyGeneratorTests.java b/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/JCacheKeyGeneratorTests.java index 0b9345d4fe5..fbba3526bbd 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/JCacheKeyGeneratorTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/JCacheKeyGeneratorTests.java @@ -23,8 +23,8 @@ import javax.cache.annotation.CacheDefaults; import javax.cache.annotation.CacheKey; import javax.cache.annotation.CacheResult; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.cache.Cache; import org.springframework.cache.CacheManager; @@ -51,7 +51,7 @@ public class JCacheKeyGeneratorTests { private Cache cache; - @Before + @BeforeEach public void setup() { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Config.class); this.keyGenerator = context.getBean(TestKeyGenerator.class); diff --git a/spring-context-support/src/test/java/org/springframework/cache/transaction/AbstractTransactionSupportingCacheManagerTests.java b/spring-context-support/src/test/java/org/springframework/cache/transaction/AbstractTransactionSupportingCacheManagerTests.java index 76db2329daa..cf0487eb71c 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/transaction/AbstractTransactionSupportingCacheManagerTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/transaction/AbstractTransactionSupportingCacheManagerTests.java @@ -16,9 +16,9 @@ package org.springframework.cache.transaction; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TestName; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; import org.springframework.cache.Cache; import org.springframework.cache.CacheManager; @@ -30,13 +30,19 @@ import static org.assertj.core.api.Assertions.assertThat; * {@link AbstractTransactionSupportingCacheManager}. * * @author Stephane Nicoll + * @author Sam Brannen */ public abstract class AbstractTransactionSupportingCacheManagerTests { public static final String CACHE_NAME = "testCacheManager"; - @Rule - public final TestName name = new TestName(); + + protected String cacheName; + + @BeforeEach + void trackCacheName(TestInfo testInfo) { + this.cacheName = testInfo.getTestMethod().get().getName(); + } /** @@ -72,24 +78,22 @@ public abstract class AbstractTransactionSupportingCacheManagerTests(); this.cache = new ConcurrentMapCache(CACHE_NAME, this.nativeCache, true); diff --git a/spring-context/src/test/java/org/springframework/cache/config/AbstractCacheAnnotationTests.java b/spring-context/src/test/java/org/springframework/cache/config/AbstractCacheAnnotationTests.java index 9023df7aef7..bf97485ccf9 100644 --- a/spring-context/src/test/java/org/springframework/cache/config/AbstractCacheAnnotationTests.java +++ b/spring-context/src/test/java/org/springframework/cache/config/AbstractCacheAnnotationTests.java @@ -19,9 +19,9 @@ package org.springframework.cache.config; import java.util.Collection; import java.util.UUID; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.aop.framework.AopProxyUtils; import org.springframework.beans.factory.NoSuchBeanDefinitionException; @@ -58,7 +58,7 @@ public abstract class AbstractCacheAnnotationTests { protected abstract ConfigurableApplicationContext getApplicationContext(); - @Before + @BeforeEach public void setup() { this.ctx = getApplicationContext(); this.cs = ctx.getBean("service", CacheableService.class); @@ -71,7 +71,7 @@ public abstract class AbstractCacheAnnotationTests { assertThat(cn.contains("primary")).isTrue(); } - @After + @AfterEach public void close() { if (this.ctx != null) { this.ctx.close(); diff --git a/spring-context/src/test/java/org/springframework/cache/config/AnnotationNamespaceDrivenTests.java b/spring-context/src/test/java/org/springframework/cache/config/AnnotationNamespaceDrivenTests.java index 70dfcc9fa82..13a420feef8 100644 --- a/spring-context/src/test/java/org/springframework/cache/config/AnnotationNamespaceDrivenTests.java +++ b/spring-context/src/test/java/org/springframework/cache/config/AnnotationNamespaceDrivenTests.java @@ -16,7 +16,7 @@ package org.springframework.cache.config; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.cache.interceptor.CacheErrorHandler; import org.springframework.cache.interceptor.CacheInterceptor; diff --git a/spring-context/src/test/java/org/springframework/cache/config/CacheAdviceNamespaceTests.java b/spring-context/src/test/java/org/springframework/cache/config/CacheAdviceNamespaceTests.java index 43ae4ded6d2..097559767d5 100644 --- a/spring-context/src/test/java/org/springframework/cache/config/CacheAdviceNamespaceTests.java +++ b/spring-context/src/test/java/org/springframework/cache/config/CacheAdviceNamespaceTests.java @@ -16,7 +16,7 @@ package org.springframework.cache.config; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.cache.interceptor.CacheInterceptor; import org.springframework.context.ConfigurableApplicationContext; diff --git a/spring-context/src/test/java/org/springframework/cache/config/CacheAdviceParserTests.java b/spring-context/src/test/java/org/springframework/cache/config/CacheAdviceParserTests.java index 0a9383a13ee..66d5b2b28c3 100644 --- a/spring-context/src/test/java/org/springframework/cache/config/CacheAdviceParserTests.java +++ b/spring-context/src/test/java/org/springframework/cache/config/CacheAdviceParserTests.java @@ -16,7 +16,7 @@ package org.springframework.cache.config; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanDefinitionStoreException; import org.springframework.context.support.GenericXmlApplicationContext; diff --git a/spring-context/src/test/java/org/springframework/cache/config/CustomInterceptorTests.java b/spring-context/src/test/java/org/springframework/cache/config/CustomInterceptorTests.java index 8ca33fbce89..cc8aeb18ba8 100644 --- a/spring-context/src/test/java/org/springframework/cache/config/CustomInterceptorTests.java +++ b/spring-context/src/test/java/org/springframework/cache/config/CustomInterceptorTests.java @@ -19,9 +19,9 @@ package org.springframework.cache.config; import java.io.IOException; import java.util.Map; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.cache.CacheManager; import org.springframework.cache.CacheTestUtils; @@ -46,13 +46,13 @@ public class CustomInterceptorTests { protected CacheableService cs; - @Before + @BeforeEach public void setup() { this.ctx = new AnnotationConfigApplicationContext(EnableCachingConfig.class); this.cs = ctx.getBean("service", CacheableService.class); } - @After + @AfterEach public void tearDown() { this.ctx.close(); } diff --git a/spring-context/src/test/java/org/springframework/cache/config/EnableCachingIntegrationTests.java b/spring-context/src/test/java/org/springframework/cache/config/EnableCachingIntegrationTests.java index 11b01147f57..57a186f1dfa 100644 --- a/spring-context/src/test/java/org/springframework/cache/config/EnableCachingIntegrationTests.java +++ b/spring-context/src/test/java/org/springframework/cache/config/EnableCachingIntegrationTests.java @@ -18,8 +18,8 @@ package org.springframework.cache.config; import java.util.concurrent.atomic.AtomicLong; -import org.junit.After; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cache.Cache; @@ -51,7 +51,7 @@ public class EnableCachingIntegrationTests { private ConfigurableApplicationContext context; - @After + @AfterEach public void closeContext() { if (this.context != null) { this.context.close(); diff --git a/spring-context/src/test/java/org/springframework/cache/config/EnableCachingTests.java b/spring-context/src/test/java/org/springframework/cache/config/EnableCachingTests.java index fa1e9b28d2b..94235e694b3 100644 --- a/spring-context/src/test/java/org/springframework/cache/config/EnableCachingTests.java +++ b/spring-context/src/test/java/org/springframework/cache/config/EnableCachingTests.java @@ -16,7 +16,7 @@ package org.springframework.cache.config; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanCreationException; import org.springframework.cache.CacheManager; diff --git a/spring-context/src/test/java/org/springframework/cache/config/ExpressionCachingIntegrationTests.java b/spring-context/src/test/java/org/springframework/cache/config/ExpressionCachingIntegrationTests.java index fcfc543bd19..ae109aec5c5 100644 --- a/spring-context/src/test/java/org/springframework/cache/config/ExpressionCachingIntegrationTests.java +++ b/spring-context/src/test/java/org/springframework/cache/config/ExpressionCachingIntegrationTests.java @@ -16,7 +16,7 @@ package org.springframework.cache.config; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.cache.CacheManager; import org.springframework.cache.annotation.CachePut; diff --git a/spring-context/src/test/java/org/springframework/cache/interceptor/CacheErrorHandlerTests.java b/spring-context/src/test/java/org/springframework/cache/interceptor/CacheErrorHandlerTests.java index cf17ac5cca0..94b808cae33 100644 --- a/spring-context/src/test/java/org/springframework/cache/interceptor/CacheErrorHandlerTests.java +++ b/spring-context/src/test/java/org/springframework/cache/interceptor/CacheErrorHandlerTests.java @@ -19,8 +19,8 @@ package org.springframework.cache.interceptor; import java.util.Collections; import java.util.concurrent.atomic.AtomicLong; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.cache.Cache; import org.springframework.cache.CacheManager; @@ -57,7 +57,7 @@ public class CacheErrorHandlerTests { private SimpleService simpleService; - @Before + @BeforeEach public void setup() { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Config.class); this.cache = context.getBean("mockCache", Cache.class); diff --git a/spring-context/src/test/java/org/springframework/cache/interceptor/CacheProxyFactoryBeanTests.java b/spring-context/src/test/java/org/springframework/cache/interceptor/CacheProxyFactoryBeanTests.java index d62e7e3045c..9a8bc230f87 100644 --- a/spring-context/src/test/java/org/springframework/cache/interceptor/CacheProxyFactoryBeanTests.java +++ b/spring-context/src/test/java/org/springframework/cache/interceptor/CacheProxyFactoryBeanTests.java @@ -19,7 +19,7 @@ package org.springframework.cache.interceptor; import java.util.Arrays; import java.util.concurrent.atomic.AtomicBoolean; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.cache.annotation.EnableCaching; import org.springframework.cache.concurrent.ConcurrentMapCacheManager; diff --git a/spring-context/src/test/java/org/springframework/cache/interceptor/CachePutEvaluationTests.java b/spring-context/src/test/java/org/springframework/cache/interceptor/CachePutEvaluationTests.java index 700e3864588..d17630a8ed2 100644 --- a/spring-context/src/test/java/org/springframework/cache/interceptor/CachePutEvaluationTests.java +++ b/spring-context/src/test/java/org/springframework/cache/interceptor/CachePutEvaluationTests.java @@ -18,9 +18,9 @@ package org.springframework.cache.interceptor; import java.util.concurrent.atomic.AtomicLong; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.cache.Cache; import org.springframework.cache.CacheManager; @@ -51,14 +51,14 @@ public class CachePutEvaluationTests { private SimpleService service; - @Before + @BeforeEach public void setup() { this.context = new AnnotationConfigApplicationContext(Config.class); this.cache = this.context.getBean(CacheManager.class).getCache("test"); this.service = this.context.getBean(SimpleService.class); } - @After + @AfterEach public void close() { if (this.context != null) { this.context.close(); diff --git a/spring-context/src/test/java/org/springframework/cache/interceptor/CacheResolverCustomizationTests.java b/spring-context/src/test/java/org/springframework/cache/interceptor/CacheResolverCustomizationTests.java index a2d1e4cf1a8..c1be67af2bb 100644 --- a/spring-context/src/test/java/org/springframework/cache/interceptor/CacheResolverCustomizationTests.java +++ b/spring-context/src/test/java/org/springframework/cache/interceptor/CacheResolverCustomizationTests.java @@ -21,8 +21,8 @@ import java.util.Collection; import java.util.Collections; import java.util.concurrent.atomic.AtomicLong; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.cache.Cache; @@ -60,7 +60,7 @@ public class CacheResolverCustomizationTests { private SimpleService simpleService; - @Before + @BeforeEach public void setup() { ApplicationContext context = new AnnotationConfigApplicationContext(Config.class); this.cacheManager = context.getBean("cacheManager", CacheManager.class); diff --git a/spring-context/src/test/java/org/springframework/cache/interceptor/CacheSyncFailureTests.java b/spring-context/src/test/java/org/springframework/cache/interceptor/CacheSyncFailureTests.java index a6a461ecc20..3bd47bd1fbe 100644 --- a/spring-context/src/test/java/org/springframework/cache/interceptor/CacheSyncFailureTests.java +++ b/spring-context/src/test/java/org/springframework/cache/interceptor/CacheSyncFailureTests.java @@ -18,9 +18,9 @@ package org.springframework.cache.interceptor; import java.util.concurrent.atomic.AtomicLong; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.cache.CacheManager; import org.springframework.cache.CacheTestUtils; @@ -48,13 +48,13 @@ public class CacheSyncFailureTests { private SimpleService simpleService; - @Before + @BeforeEach public void setUp() { this.context = new AnnotationConfigApplicationContext(Config.class); this.simpleService = this.context.getBean(SimpleService.class); } - @After + @AfterEach public void closeContext() { if (this.context != null) { this.context.close(); diff --git a/spring-context/src/test/java/org/springframework/cache/interceptor/ExpressionEvaluatorTests.java b/spring-context/src/test/java/org/springframework/cache/interceptor/ExpressionEvaluatorTests.java index b321e2ceb7d..495c977b9c6 100644 --- a/spring-context/src/test/java/org/springframework/cache/interceptor/ExpressionEvaluatorTests.java +++ b/spring-context/src/test/java/org/springframework/cache/interceptor/ExpressionEvaluatorTests.java @@ -21,7 +21,7 @@ import java.util.Collection; import java.util.Collections; import java.util.Iterator; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.config.BeanDefinition; diff --git a/spring-context/src/test/java/org/springframework/cache/interceptor/SimpleKeyGeneratorTests.java b/spring-context/src/test/java/org/springframework/cache/interceptor/SimpleKeyGeneratorTests.java index 6b64aae2855..5357949f445 100644 --- a/spring-context/src/test/java/org/springframework/cache/interceptor/SimpleKeyGeneratorTests.java +++ b/spring-context/src/test/java/org/springframework/cache/interceptor/SimpleKeyGeneratorTests.java @@ -16,7 +16,7 @@ package org.springframework.cache.interceptor; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/context/AbstractApplicationContextTests.java b/spring-context/src/test/java/org/springframework/context/AbstractApplicationContextTests.java index 4be8c083d2f..ac18e6d85a5 100644 --- a/spring-context/src/test/java/org/springframework/context/AbstractApplicationContextTests.java +++ b/spring-context/src/test/java/org/springframework/context/AbstractApplicationContextTests.java @@ -22,8 +22,8 @@ import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.util.Locale; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.xml.AbstractListableBeanFactoryTests; @@ -50,7 +50,7 @@ public abstract class AbstractApplicationContextTests extends AbstractListableBe protected TestListener parentListener = new TestListener(); - @Before + @BeforeEach public void setUp() throws Exception { this.applicationContext = createContext(); } diff --git a/spring-context/src/test/java/org/springframework/context/annotation/AbstractCircularImportDetectionTests.java b/spring-context/src/test/java/org/springframework/context/annotation/AbstractCircularImportDetectionTests.java index d637dd693f9..bb33ca5b79d 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/AbstractCircularImportDetectionTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/AbstractCircularImportDetectionTests.java @@ -16,7 +16,7 @@ package org.springframework.context.annotation; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; import org.springframework.tests.sample.beans.TestBean; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/AggressiveFactoryBeanInstantiationTests.java b/spring-context/src/test/java/org/springframework/context/annotation/AggressiveFactoryBeanInstantiationTests.java index 3e91128b32c..9bec2460979 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/AggressiveFactoryBeanInstantiationTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/AggressiveFactoryBeanInstantiationTests.java @@ -16,7 +16,7 @@ package org.springframework.context.annotation; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.beans.factory.FactoryBean; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/AnnotationBeanNameGeneratorTests.java b/spring-context/src/test/java/org/springframework/context/annotation/AnnotationBeanNameGeneratorTests.java index 78305981ea4..4438d2ec330 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/AnnotationBeanNameGeneratorTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/AnnotationBeanNameGeneratorTests.java @@ -22,7 +22,7 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import example.scannable.DefaultNamedComponent; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition; import org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/AnnotationConfigApplicationContextTests.java b/spring-context/src/test/java/org/springframework/context/annotation/AnnotationConfigApplicationContextTests.java index 5dcd74b7a83..9f5fd8e2b78 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/AnnotationConfigApplicationContextTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/AnnotationConfigApplicationContextTests.java @@ -19,7 +19,7 @@ package org.springframework.context.annotation; import java.util.Map; import java.util.regex.Pattern; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.NoSuchBeanDefinitionException; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/AnnotationProcessorPerformanceTests.java b/spring-context/src/test/java/org/springframework/context/annotation/AnnotationProcessorPerformanceTests.java index 6d9e8fa1d97..bca24960781 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/AnnotationProcessorPerformanceTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/AnnotationProcessorPerformanceTests.java @@ -24,8 +24,8 @@ import javax.annotation.Resource; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.awaitility.Awaitility; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.RuntimeBeanReference; @@ -50,7 +50,7 @@ public class AnnotationProcessorPerformanceTests { private static final Log factoryLog = LogFactory.getLog(DefaultListableBeanFactory.class); - @BeforeClass + @BeforeAll public static void commonAssumptions() { Assume.group(TestGroup.PERFORMANCE); Assume.notLogging(factoryLog); diff --git a/spring-context/src/test/java/org/springframework/context/annotation/AnnotationScopeMetadataResolverTests.java b/spring-context/src/test/java/org/springframework/context/annotation/AnnotationScopeMetadataResolverTests.java index 7ae0d5842be..838b9ccec76 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/AnnotationScopeMetadataResolverTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/AnnotationScopeMetadataResolverTests.java @@ -20,7 +20,7 @@ import java.io.IOException; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition; import org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/AutoProxyLazyInitTests.java b/spring-context/src/test/java/org/springframework/context/annotation/AutoProxyLazyInitTests.java index 7421d014cdc..e256d6784fc 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/AutoProxyLazyInitTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/AutoProxyLazyInitTests.java @@ -18,7 +18,7 @@ package org.springframework.context.annotation; import javax.annotation.PreDestroy; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator; import org.springframework.aop.framework.autoproxy.target.LazyInitTargetSourceCreator; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/BeanMethodMetadataTests.java b/spring-context/src/test/java/org/springframework/context/annotation/BeanMethodMetadataTests.java index 711b4ebf11c..b812117e740 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/BeanMethodMetadataTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/BeanMethodMetadataTests.java @@ -20,7 +20,7 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition; import org.springframework.beans.factory.config.BeanDefinition; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/BeanMethodPolymorphismTests.java b/spring-context/src/test/java/org/springframework/context/annotation/BeanMethodPolymorphismTests.java index e1971befa56..61e5868f6de 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/BeanMethodPolymorphismTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/BeanMethodPolymorphismTests.java @@ -18,7 +18,7 @@ package org.springframework.context.annotation; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator; import org.springframework.aop.interceptor.SimpleTraceInterceptor; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ClassPathBeanDefinitionScannerTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ClassPathBeanDefinitionScannerTests.java index 529ce25f8ff..e26c281ae3b 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ClassPathBeanDefinitionScannerTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ClassPathBeanDefinitionScannerTests.java @@ -22,7 +22,7 @@ import example.scannable.FooServiceImpl; import example.scannable.NamedStubDao; import example.scannable.StubFooDao; import org.aspectj.lang.annotation.Aspect; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.BeanInstantiationException; import org.springframework.beans.factory.BeanCreationException; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ClassPathFactoryBeanDefinitionScannerTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ClassPathFactoryBeanDefinitionScannerTests.java index c474b500be9..c4c9101a0cd 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ClassPathFactoryBeanDefinitionScannerTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ClassPathFactoryBeanDefinitionScannerTests.java @@ -16,7 +16,7 @@ package org.springframework.context.annotation; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.scope.ScopedObject; import org.springframework.aop.support.AopUtils; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ClassPathScanningCandidateComponentProviderTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ClassPathScanningCandidateComponentProviderTests.java index a9d7eab18c3..bcef50b1279 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ClassPathScanningCandidateComponentProviderTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ClassPathScanningCandidateComponentProviderTests.java @@ -38,7 +38,7 @@ import example.scannable.ServiceInvocationCounter; import example.scannable.StubFooDao; import example.scannable.sub.BarComponent; import org.aspectj.lang.annotation.Aspect; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition; import org.springframework.beans.factory.config.BeanDefinition; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessorTests.java b/spring-context/src/test/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessorTests.java index 3e44555d288..2e266da1df5 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessorTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/CommonAnnotationBeanPostProcessorTests.java @@ -22,7 +22,7 @@ import javax.annotation.PreDestroy; import javax.annotation.Resource; import javax.ejb.EJB; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanCreationException; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanAndImportAnnotationInteractionTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanAndImportAnnotationInteractionTests.java index bc847f7d222..ae0a9b86b0d 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanAndImportAnnotationInteractionTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanAndImportAnnotationInteractionTests.java @@ -16,7 +16,7 @@ package org.springframework.context.annotation; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.context.annotation.componentscan.importing.ImportingConfig; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanAnnotationIntegrationTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanAnnotationIntegrationTests.java index d359dfae79e..6c20e2dbffb 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanAnnotationIntegrationTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanAnnotationIntegrationTests.java @@ -33,7 +33,7 @@ import example.scannable_implicitbasepackage.ComponentScanAnnotatedConfigWithImp import example.scannable_implicitbasepackage.ConfigurableComponent; import example.scannable_scoped.CustomScopeAnnotationBean; import example.scannable_scoped.MyScope; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.support.AopUtils; import org.springframework.beans.BeansException; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanAnnotationRecursionTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanAnnotationRecursionTests.java index 840c9b4ed81..f7fad0021a7 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanAnnotationRecursionTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanAnnotationRecursionTests.java @@ -16,7 +16,7 @@ package org.springframework.context.annotation; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.annotation.componentscan.cycle.left.LeftConfig; import org.springframework.context.annotation.componentscan.level1.Level1Config; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanAnnotationTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanAnnotationTests.java index 6e8492addab..3853a6fc1f9 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanAnnotationTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanAnnotationTests.java @@ -16,7 +16,7 @@ package org.springframework.context.annotation; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.DefaultBeanNameGenerator; import org.springframework.context.annotation.ComponentScan.Filter; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanParserBeanDefinitionDefaultsTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanParserBeanDefinitionDefaultsTests.java index b30b8021e5d..cbd1b5ca4f5 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanParserBeanDefinitionDefaultsTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanParserBeanDefinitionDefaultsTests.java @@ -16,8 +16,8 @@ package org.springframework.context.annotation; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.UnsatisfiedDependencyException; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; @@ -37,7 +37,7 @@ public class ComponentScanParserBeanDefinitionDefaultsTests { private static final String LOCATION_PREFIX = "org/springframework/context/annotation/"; - @Before + @BeforeEach public void setUp() { DefaultsTestBean.INIT_COUNT = 0; } diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanParserScopedProxyTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanParserScopedProxyTests.java index a19fc249f5c..67480997a35 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanParserScopedProxyTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanParserScopedProxyTests.java @@ -18,7 +18,7 @@ package org.springframework.context.annotation; import example.scannable.FooService; import example.scannable.ScopedProxyTestBean; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.support.AopUtils; import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanParserTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanParserTests.java index 7e4360465cf..9bacf084663 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanParserTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanParserTests.java @@ -23,7 +23,7 @@ import java.lang.annotation.Target; import example.profilescan.ProfileAnnotatedComponent; import example.scannable.AutowiredQualifierFooService; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ConfigurableApplicationContext; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanParserWithUserDefinedStrategiesTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanParserWithUserDefinedStrategiesTests.java index 4d9ac3e8e87..ef8bc04d942 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanParserWithUserDefinedStrategiesTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ComponentScanParserWithUserDefinedStrategiesTests.java @@ -16,7 +16,7 @@ package org.springframework.context.annotation; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.BeansException; import org.springframework.beans.factory.config.BeanDefinition; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassAndBFPPTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassAndBFPPTests.java index d6b66b4f4a0..4b9d0c993e4 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassAndBFPPTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassAndBFPPTests.java @@ -16,7 +16,7 @@ package org.springframework.context.annotation; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.BeansException; import org.springframework.beans.factory.annotation.Autowired; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostConstructAndAutowiringTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostConstructAndAutowiringTests.java index e8c21919bbc..9888d8895b1 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostConstructAndAutowiringTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostConstructAndAutowiringTests.java @@ -18,7 +18,7 @@ package org.springframework.context.annotation; import javax.annotation.PostConstruct; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.tests.sample.beans.TestBean; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostProcessorTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostProcessorTests.java index 076da9bef37..a189d5b440b 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostProcessorTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassPostProcessorTests.java @@ -25,8 +25,8 @@ import java.util.List; import java.util.Map; import javax.annotation.PostConstruct; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator; import org.springframework.aop.interceptor.SimpleTraceInterceptor; @@ -78,7 +78,7 @@ public class ConfigurationClassPostProcessorTests { private final DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory(); - @Before + @BeforeEach public void setup() { QualifierAnnotationAutowireCandidateResolver acr = new QualifierAnnotationAutowireCandidateResolver(); acr.setBeanFactory(this.beanFactory); diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassWithConditionTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassWithConditionTests.java index c9b84903916..5a434faa207 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassWithConditionTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationClassWithConditionTests.java @@ -22,7 +22,7 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.BeanDefinitionRegistry; import org.springframework.beans.factory.support.RootBeanDefinition; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationWithFactoryBeanAndAutowiringTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationWithFactoryBeanAndAutowiringTests.java index 815665dd05a..dc07fdbb01f 100755 --- a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationWithFactoryBeanAndAutowiringTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationWithFactoryBeanAndAutowiringTests.java @@ -16,7 +16,7 @@ package org.springframework.context.annotation; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.InitializingBean; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationWithFactoryBeanAndParametersTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationWithFactoryBeanAndParametersTests.java index ce6034466bc..56fcbc14359 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationWithFactoryBeanAndParametersTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationWithFactoryBeanAndParametersTests.java @@ -16,7 +16,7 @@ package org.springframework.context.annotation; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.annotation.Autowired; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationWithFactoryBeanBeanEarlyDeductionTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationWithFactoryBeanBeanEarlyDeductionTests.java index 588d262ca97..5ddf367dfb0 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationWithFactoryBeanBeanEarlyDeductionTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ConfigurationWithFactoryBeanBeanEarlyDeductionTests.java @@ -18,7 +18,7 @@ package org.springframework.context.annotation; import java.util.Arrays; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.BeansException; import org.springframework.beans.factory.FactoryBean; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/DeferredImportSelectorTests.java b/spring-context/src/test/java/org/springframework/context/annotation/DeferredImportSelectorTests.java index 0b87fe4c26e..374ca4de2cf 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/DeferredImportSelectorTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/DeferredImportSelectorTests.java @@ -16,7 +16,7 @@ package org.springframework.context.annotation; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.annotation.DeferredImportSelector.Group; import org.springframework.core.type.AnnotationMetadata; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/DestroyMethodInferenceTests.java b/spring-context/src/test/java/org/springframework/context/annotation/DestroyMethodInferenceTests.java index 6b070526414..7da4675bed5 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/DestroyMethodInferenceTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/DestroyMethodInferenceTests.java @@ -18,7 +18,7 @@ package org.springframework.context.annotation; import java.io.Closeable; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.DisposableBean; import org.springframework.context.ConfigurableApplicationContext; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/EnableAspectJAutoProxyTests.java b/spring-context/src/test/java/org/springframework/context/annotation/EnableAspectJAutoProxyTests.java index a7a90b5ceb2..7fc48561c15 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/EnableAspectJAutoProxyTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/EnableAspectJAutoProxyTests.java @@ -25,7 +25,7 @@ import example.scannable.FooServiceImpl; import example.scannable.ServiceInvocationCounter; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.framework.AopContext; import org.springframework.aop.support.AopUtils; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/EnableLoadTimeWeavingTests.java b/spring-context/src/test/java/org/springframework/context/annotation/EnableLoadTimeWeavingTests.java index 59e63b6307f..8ebfd0f4bca 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/EnableLoadTimeWeavingTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/EnableLoadTimeWeavingTests.java @@ -18,7 +18,7 @@ package org.springframework.context.annotation; import java.lang.instrument.ClassFileTransformer; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.annotation.EnableLoadTimeWeaving.AspectJWeaving; import org.springframework.context.support.GenericXmlApplicationContext; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ImportAwareTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ImportAwareTests.java index 38dbf1ae5d6..05df9c9d092 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ImportAwareTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ImportAwareTests.java @@ -22,7 +22,7 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import java.util.Arrays; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryAware; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ImportBeanDefinitionRegistrarTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ImportBeanDefinitionRegistrarTests.java index 0d2503ce94d..6626e01af47 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ImportBeanDefinitionRegistrarTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ImportBeanDefinitionRegistrarTests.java @@ -21,7 +21,7 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanClassLoaderAware; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ImportSelectorTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ImportSelectorTests.java index 036600683e5..08af14feedb 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ImportSelectorTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ImportSelectorTests.java @@ -31,8 +31,8 @@ import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.InOrder; import org.springframework.beans.BeansException; @@ -69,7 +69,7 @@ public class ImportSelectorTests { static Map, String> importFrom = new HashMap<>(); - @Before + @BeforeEach public void cleanup() { ImportSelectorTests.importFrom.clear(); SampleImportSelector.cleanup(); diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ImportVersusDirectRegistrationTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ImportVersusDirectRegistrationTests.java index 21c56c38dc2..db22532e1bd 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ImportVersusDirectRegistrationTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ImportVersusDirectRegistrationTests.java @@ -16,7 +16,7 @@ package org.springframework.context.annotation; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.beans.factory.support.RootBeanDefinition; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/InvalidConfigurationClassDefinitionTests.java b/spring-context/src/test/java/org/springframework/context/annotation/InvalidConfigurationClassDefinitionTests.java index 77a7d2c0dbb..d2114d8c345 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/InvalidConfigurationClassDefinitionTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/InvalidConfigurationClassDefinitionTests.java @@ -15,7 +15,7 @@ */ package org.springframework.context.annotation; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/LazyAutowiredAnnotationBeanPostProcessorTests.java b/spring-context/src/test/java/org/springframework/context/annotation/LazyAutowiredAnnotationBeanPostProcessorTests.java index 95aa50b6e20..f35c2e48796 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/LazyAutowiredAnnotationBeanPostProcessorTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/LazyAutowiredAnnotationBeanPostProcessorTests.java @@ -20,7 +20,7 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.beans.factory.annotation.Autowired; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/NestedConfigurationClassTests.java b/spring-context/src/test/java/org/springframework/context/annotation/NestedConfigurationClassTests.java index 54cf8bcd8f0..b601afea1bd 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/NestedConfigurationClassTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/NestedConfigurationClassTests.java @@ -16,7 +16,7 @@ package org.springframework.context.annotation; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.stereotype.Component; import org.springframework.tests.sample.beans.TestBean; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/PrimitiveBeanLookupAndAutowiringTests.java b/spring-context/src/test/java/org/springframework/context/annotation/PrimitiveBeanLookupAndAutowiringTests.java index bb41a9b2c05..31a2d7c631d 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/PrimitiveBeanLookupAndAutowiringTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/PrimitiveBeanLookupAndAutowiringTests.java @@ -18,7 +18,7 @@ package org.springframework.context.annotation; import javax.annotation.Resource; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/PropertySourceAnnotationTests.java b/spring-context/src/test/java/org/springframework/context/annotation/PropertySourceAnnotationTests.java index 650497ae9a9..c9c06fafacf 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/PropertySourceAnnotationTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/PropertySourceAnnotationTests.java @@ -25,7 +25,7 @@ import java.util.Iterator; import java.util.Properties; import javax.inject.Inject; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanDefinitionStoreException; import org.springframework.beans.factory.FactoryBean; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/ReflectionUtilsIntegrationTests.java b/spring-context/src/test/java/org/springframework/context/annotation/ReflectionUtilsIntegrationTests.java index 9f06cc1db6e..ae74584c284 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/ReflectionUtilsIntegrationTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/ReflectionUtilsIntegrationTests.java @@ -18,7 +18,7 @@ package org.springframework.context.annotation; import java.lang.reflect.Method; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.util.ReflectionUtils; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/RoleAndDescriptionAnnotationTests.java b/spring-context/src/test/java/org/springframework/context/annotation/RoleAndDescriptionAnnotationTests.java index 6a9720c01a2..345b28846b9 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/RoleAndDescriptionAnnotationTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/RoleAndDescriptionAnnotationTests.java @@ -16,7 +16,7 @@ package org.springframework.context.annotation; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.context.annotation.role.ComponentWithRole; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/SimpleConfigTests.java b/spring-context/src/test/java/org/springframework/context/annotation/SimpleConfigTests.java index d90d1262f4b..9d7be1a225a 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/SimpleConfigTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/SimpleConfigTests.java @@ -21,7 +21,7 @@ import java.util.concurrent.FutureTask; import example.scannable.FooService; import example.scannable.ServiceInvocationCounter; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.support.ClassPathXmlApplicationContext; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/SimpleScanTests.java b/spring-context/src/test/java/org/springframework/context/annotation/SimpleScanTests.java index df26c5731fa..ee4f47429c9 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/SimpleScanTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/SimpleScanTests.java @@ -18,7 +18,7 @@ package org.springframework.context.annotation; import example.scannable.FooService; import example.scannable.ServiceInvocationCounter; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.support.ClassPathXmlApplicationContext; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/Spr11202Tests.java b/spring-context/src/test/java/org/springframework/context/annotation/Spr11202Tests.java index 45df0cc571b..14fe41df50d 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/Spr11202Tests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/Spr11202Tests.java @@ -22,7 +22,7 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.InitializingBean; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/Spr11310Tests.java b/spring-context/src/test/java/org/springframework/context/annotation/Spr11310Tests.java index 0d2288bc2e0..551d8ab8866 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/Spr11310Tests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/Spr11310Tests.java @@ -18,7 +18,7 @@ package org.springframework.context.annotation; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/Spr12278Tests.java b/spring-context/src/test/java/org/springframework/context/annotation/Spr12278Tests.java index c0b8ac46223..afceea8a090 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/Spr12278Tests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/Spr12278Tests.java @@ -16,8 +16,8 @@ package org.springframework.context.annotation; -import org.junit.After; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanCreationException; @@ -31,7 +31,7 @@ public class Spr12278Tests { private AnnotationConfigApplicationContext context; - @After + @AfterEach public void close() { if (context != null) { context.close(); diff --git a/spring-context/src/test/java/org/springframework/context/annotation/Spr12636Tests.java b/spring-context/src/test/java/org/springframework/context/annotation/Spr12636Tests.java index 13466fb8369..241319a6d1d 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/Spr12636Tests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/Spr12636Tests.java @@ -18,8 +18,8 @@ package org.springframework.context.annotation; import java.util.List; -import org.junit.After; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; import org.springframework.aop.support.AopUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -38,7 +38,7 @@ public class Spr12636Tests { private ConfigurableApplicationContext context; - @After + @AfterEach public void closeContext() { if (this.context != null) { this.context.close(); diff --git a/spring-context/src/test/java/org/springframework/context/annotation/Spr15042Tests.java b/spring-context/src/test/java/org/springframework/context/annotation/Spr15042Tests.java index 10260bdf42d..2048b92c14a 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/Spr15042Tests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/Spr15042Tests.java @@ -16,7 +16,7 @@ package org.springframework.context.annotation; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.framework.ProxyFactoryBean; import org.springframework.aop.target.CommonsPool2TargetSource; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/Spr15275Tests.java b/spring-context/src/test/java/org/springframework/context/annotation/Spr15275Tests.java index 75bc0338f32..ac8222f620a 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/Spr15275Tests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/Spr15275Tests.java @@ -16,7 +16,7 @@ package org.springframework.context.annotation; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.config.AbstractFactoryBean; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/Spr16179Tests.java b/spring-context/src/test/java/org/springframework/context/annotation/Spr16179Tests.java index 5a05c18e6b0..afeae7ece20 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/Spr16179Tests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/Spr16179Tests.java @@ -16,7 +16,7 @@ package org.springframework.context.annotation; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/Spr16217Tests.java b/spring-context/src/test/java/org/springframework/context/annotation/Spr16217Tests.java index 57e11792165..056f8faa8ee 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/Spr16217Tests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/Spr16217Tests.java @@ -16,8 +16,8 @@ package org.springframework.context.annotation; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.springframework.core.type.AnnotatedTypeMetadata; @@ -28,7 +28,7 @@ import org.springframework.core.type.AnnotatedTypeMetadata; public class Spr16217Tests { @Test - @Ignore("TODO") + @Disabled("TODO") public void baseConfigurationIsIncludedWhenFirstSuperclassReferenceIsSkippedInRegisterBeanPhase() { try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(RegisterBeanPhaseImportingConfiguration.class)) { diff --git a/spring-context/src/test/java/org/springframework/context/annotation/Spr3775InitDestroyLifecycleTests.java b/spring-context/src/test/java/org/springframework/context/annotation/Spr3775InitDestroyLifecycleTests.java index 6f6d0a5b0a5..ffd47d2081c 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/Spr3775InitDestroyLifecycleTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/Spr3775InitDestroyLifecycleTests.java @@ -24,7 +24,7 @@ import javax.annotation.PreDestroy; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.InitializingBean; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/Spr6602Tests.java b/spring-context/src/test/java/org/springframework/context/annotation/Spr6602Tests.java index b5f274ea11b..faf5579aac2 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/Spr6602Tests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/Spr6602Tests.java @@ -16,7 +16,7 @@ package org.springframework.context.annotation; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.FactoryBean; import org.springframework.context.ApplicationContext; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/Spr8954Tests.java b/spring-context/src/test/java/org/springframework/context/annotation/Spr8954Tests.java index 045846fb16e..594599121b7 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/Spr8954Tests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/Spr8954Tests.java @@ -18,7 +18,7 @@ package org.springframework.context.annotation; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.PropertyValues; import org.springframework.beans.factory.FactoryBean; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/AutowiredConfigurationTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/AutowiredConfigurationTests.java index 6f7296d8b5c..ea6b670a61e 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/AutowiredConfigurationTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/AutowiredConfigurationTests.java @@ -23,7 +23,7 @@ import java.util.List; import java.util.Optional; import javax.inject.Provider; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.ObjectFactory; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/BeanAnnotationAttributePropagationTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/BeanAnnotationAttributePropagationTests.java index e4522ad5404..0ba5a872653 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/BeanAnnotationAttributePropagationTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/BeanAnnotationAttributePropagationTests.java @@ -16,7 +16,7 @@ package org.springframework.context.annotation.configuration; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowire; import org.springframework.beans.factory.config.BeanDefinition; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/BeanMethodQualificationTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/BeanMethodQualificationTests.java index e991ec2d2e1..6190c13fcaa 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/BeanMethodQualificationTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/BeanMethodQualificationTests.java @@ -19,7 +19,7 @@ package org.springframework.context.annotation.configuration; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.BeanFactoryAnnotationUtils; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationBeanNameTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationBeanNameTests.java index 2660f1c894f..cbe2d51a5c0 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationBeanNameTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationBeanNameTests.java @@ -16,7 +16,7 @@ package org.springframework.context.annotation.configuration; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.support.BeanDefinitionRegistry; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassAspectIntegrationTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassAspectIntegrationTests.java index 7c2d0133abf..4cf2d628164 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassAspectIntegrationTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassAspectIntegrationTests.java @@ -20,7 +20,7 @@ import org.aspectj.lang.JoinPoint; import org.aspectj.lang.annotation.After; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassProcessingTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassProcessingTests.java index 3e3d03b0673..a7826ffb40f 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassProcessingTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassProcessingTests.java @@ -24,7 +24,7 @@ import java.util.function.Supplier; import javax.annotation.Resource; import javax.inject.Provider; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanClassLoaderAware; import org.springframework.beans.factory.BeanFactory; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassWithPlaceholderConfigurerBeanTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassWithPlaceholderConfigurerBeanTests.java index c23d3bc8163..fb83e0789ad 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassWithPlaceholderConfigurerBeanTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationClassWithPlaceholderConfigurerBeanTests.java @@ -16,7 +16,7 @@ package org.springframework.context.annotation.configuration; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.AnnotationConfigApplicationContext; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationMetaAnnotationTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationMetaAnnotationTests.java index 0b22c7f714b..39e4dd9e46c 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationMetaAnnotationTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ConfigurationMetaAnnotationTests.java @@ -19,7 +19,7 @@ package org.springframework.context.annotation.configuration; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/DuplicateConfigurationClassPostProcessorTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/DuplicateConfigurationClassPostProcessorTests.java index 237b8e14514..c3e43458bf7 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/DuplicateConfigurationClassPostProcessorTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/DuplicateConfigurationClassPostProcessorTests.java @@ -16,7 +16,7 @@ package org.springframework.context.annotation.configuration; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.context.annotation.Bean; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/DuplicatePostProcessingTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/DuplicatePostProcessingTests.java index b7b36474f37..3271beb190c 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/DuplicatePostProcessingTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/DuplicatePostProcessingTests.java @@ -16,7 +16,7 @@ package org.springframework.context.annotation.configuration; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryAware; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportAnnotationDetectionTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportAnnotationDetectionTests.java index bbbff6c724e..1028b349dc5 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportAnnotationDetectionTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportAnnotationDetectionTests.java @@ -21,7 +21,7 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportResourceTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportResourceTests.java index 0f7e0ba8855..283ac0e63cf 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportResourceTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportResourceTests.java @@ -20,7 +20,7 @@ import java.util.Collections; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.support.AopUtils; import org.springframework.beans.factory.annotation.Autowired; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportTests.java index a34810c8436..6e49c97b031 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportTests.java @@ -16,7 +16,7 @@ package org.springframework.context.annotation.configuration; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportWithConditionTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportWithConditionTests.java index 4a9f904a32d..1a7b5f998b2 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportWithConditionTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportWithConditionTests.java @@ -16,7 +16,7 @@ package org.springframework.context.annotation.configuration; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.AnnotationConfigApplicationContext; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportedConfigurationClassEnhancementTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportedConfigurationClassEnhancementTests.java index fd47f448c64..98f5f12af0a 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportedConfigurationClassEnhancementTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ImportedConfigurationClassEnhancementTests.java @@ -16,7 +16,7 @@ package org.springframework.context.annotation.configuration; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/PackagePrivateBeanMethodInheritanceTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/PackagePrivateBeanMethodInheritanceTests.java index 31ec2bce43d..39b6995cd10 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/PackagePrivateBeanMethodInheritanceTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/PackagePrivateBeanMethodInheritanceTests.java @@ -16,7 +16,7 @@ package org.springframework.context.annotation.configuration; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ScopingTests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ScopingTests.java index f8377cb9c4c..a3391b69cad 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/ScopingTests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/ScopingTests.java @@ -23,9 +23,9 @@ import java.lang.annotation.Target; import java.util.HashMap; import java.util.Map; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.aop.scope.ScopedObject; import org.springframework.beans.factory.ObjectFactory; @@ -60,13 +60,13 @@ public class ScopingTests { private GenericApplicationContext ctx; - @Before + @BeforeEach public void setUp() throws Exception { customScope = new CustomScope(); ctx = createContext(ScopedConfigurationClass.class); } - @After + @AfterEach public void tearDown() throws Exception { if (ctx != null) { ctx.close(); diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/Spr10668Tests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/Spr10668Tests.java index 2b7e27a2072..a8237a1e132 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/Spr10668Tests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/Spr10668Tests.java @@ -16,7 +16,7 @@ package org.springframework.context.annotation.configuration; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.AnnotationConfigApplicationContext; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/Spr10744Tests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/Spr10744Tests.java index 0521f28cb09..279d520fa59 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/Spr10744Tests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/Spr10744Tests.java @@ -16,7 +16,7 @@ package org.springframework.context.annotation.configuration; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.ObjectFactory; import org.springframework.context.annotation.AnnotationConfigApplicationContext; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/Spr12526Tests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/Spr12526Tests.java index b0805b40c8f..17260535e40 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/Spr12526Tests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/Spr12526Tests.java @@ -18,7 +18,7 @@ package org.springframework.context.annotation.configuration; import javax.annotation.Resource; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/Spr7167Tests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/Spr7167Tests.java index d27c6a39b2f..ef73432110c 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/Spr7167Tests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/Spr7167Tests.java @@ -16,7 +16,7 @@ package org.springframework.context.annotation.configuration; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.BeansException; import org.springframework.beans.factory.config.BeanFactoryPostProcessor; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/spr8955/Spr8955Tests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/spr8955/Spr8955Tests.java index d816aac5f45..396dc12a4f0 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/spr8955/Spr8955Tests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/spr8955/Spr8955Tests.java @@ -16,7 +16,7 @@ package org.springframework.context.annotation.configuration.spr8955; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.annotation.AnnotationConfigApplicationContext; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/configuration/spr9031/Spr9031Tests.java b/spring-context/src/test/java/org/springframework/context/annotation/configuration/spr9031/Spr9031Tests.java index e23bb7f5864..74adf340c9e 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/configuration/spr9031/Spr9031Tests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/configuration/spr9031/Spr9031Tests.java @@ -19,7 +19,7 @@ package org.springframework.context.annotation.configuration.spr9031; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.AnnotationConfigApplicationContext; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/spr10546/Spr10546Tests.java b/spring-context/src/test/java/org/springframework/context/annotation/spr10546/Spr10546Tests.java index f325a367cf4..c7a32b22b6e 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/spr10546/Spr10546Tests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/spr10546/Spr10546Tests.java @@ -16,8 +16,8 @@ package org.springframework.context.annotation.spr10546; -import org.junit.After; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; @@ -34,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat; public class Spr10546Tests { private ConfigurableApplicationContext context; - @After + @AfterEach public void closeContext() { if (context != null) { context.close(); diff --git a/spring-context/src/test/java/org/springframework/context/annotation/spr12233/Spr12233Tests.java b/spring-context/src/test/java/org/springframework/context/annotation/spr12233/Spr12233Tests.java index f67d9ab178d..d9b8044b3fd 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/spr12233/Spr12233Tests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/spr12233/Spr12233Tests.java @@ -16,7 +16,7 @@ package org.springframework.context.annotation.spr12233; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.AnnotationConfigApplicationContext; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/spr12334/Spr12334Tests.java b/spring-context/src/test/java/org/springframework/context/annotation/spr12334/Spr12334Tests.java index a03d328cc9e..079b2a809ca 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/spr12334/Spr12334Tests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/spr12334/Spr12334Tests.java @@ -16,7 +16,7 @@ package org.springframework.context.annotation.spr12334; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.BeanDefinitionRegistry; import org.springframework.context.annotation.AnnotationConfigApplicationContext; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/spr16756/Spr16756Tests.java b/spring-context/src/test/java/org/springframework/context/annotation/spr16756/Spr16756Tests.java index a4664602d97..54e3d4e2a4f 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/spr16756/Spr16756Tests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/spr16756/Spr16756Tests.java @@ -16,7 +16,7 @@ package org.springframework.context.annotation.spr16756; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.annotation.AnnotationConfigApplicationContext; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/spr8761/Spr8761Tests.java b/spring-context/src/test/java/org/springframework/context/annotation/spr8761/Spr8761Tests.java index 529fd710635..946b35ec1fb 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/spr8761/Spr8761Tests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/spr8761/Spr8761Tests.java @@ -19,7 +19,7 @@ package org.springframework.context.annotation.spr8761; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.stereotype.Component; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/spr8808/Spr8808Tests.java b/spring-context/src/test/java/org/springframework/context/annotation/spr8808/Spr8808Tests.java index 6ea33c47c01..ad7160499e4 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/spr8808/Spr8808Tests.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/spr8808/Spr8808Tests.java @@ -16,7 +16,7 @@ package org.springframework.context.annotation.spr8808; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.ComponentScan; diff --git a/spring-context/src/test/java/org/springframework/context/config/ContextNamespaceHandlerTests.java b/spring-context/src/test/java/org/springframework/context/config/ContextNamespaceHandlerTests.java index 4608cda6e33..b6949845a99 100644 --- a/spring-context/src/test/java/org/springframework/context/config/ContextNamespaceHandlerTests.java +++ b/spring-context/src/test/java/org/springframework/context/config/ContextNamespaceHandlerTests.java @@ -19,8 +19,8 @@ package org.springframework.context.config; import java.util.Calendar; import java.util.Date; -import org.junit.After; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.FatalBeanException; import org.springframework.context.ApplicationContext; @@ -41,7 +41,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; */ public class ContextNamespaceHandlerTests { - @After + @AfterEach public void tearDown() { System.getProperties().remove("foo"); } diff --git a/spring-context/src/test/java/org/springframework/context/conversionservice/ConversionServiceContextConfigTests.java b/spring-context/src/test/java/org/springframework/context/conversionservice/ConversionServiceContextConfigTests.java index 5498d6ce0b4..e4e08839747 100644 --- a/spring-context/src/test/java/org/springframework/context/conversionservice/ConversionServiceContextConfigTests.java +++ b/spring-context/src/test/java/org/springframework/context/conversionservice/ConversionServiceContextConfigTests.java @@ -16,7 +16,7 @@ package org.springframework.context.conversionservice; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.support.ClassPathXmlApplicationContext; diff --git a/spring-context/src/test/java/org/springframework/context/event/AnnotationDrivenEventListenerTests.java b/spring-context/src/test/java/org/springframework/context/event/AnnotationDrivenEventListenerTests.java index c54370ff271..8618107c153 100644 --- a/spring-context/src/test/java/org/springframework/context/event/AnnotationDrivenEventListenerTests.java +++ b/spring-context/src/test/java/org/springframework/context/event/AnnotationDrivenEventListenerTests.java @@ -30,9 +30,9 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import javax.annotation.PostConstruct; -import org.junit.After; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -85,7 +85,7 @@ public class AnnotationDrivenEventListenerTests { private CountDownLatch countDownLatch; // 1 call by default - @After + @AfterEach public void closeContext() { if (this.context != null) { this.context.close(); @@ -613,7 +613,7 @@ public class AnnotationDrivenEventListenerTests { assertThat(listener.order).contains("first", "second", "third"); } - @Test @Ignore // SPR-15122 + @Test @Disabled // SPR-15122 public void listenersReceiveEarlyEvents() { load(EventOnPostConstruct.class, OrderedTestListener.class); OrderedTestListener listener = this.context.getBean(OrderedTestListener.class); diff --git a/spring-context/src/test/java/org/springframework/context/event/ApplicationContextEventTests.java b/spring-context/src/test/java/org/springframework/context/event/ApplicationContextEventTests.java index bedafcd5387..3896d96382a 100644 --- a/spring-context/src/test/java/org/springframework/context/event/ApplicationContextEventTests.java +++ b/spring-context/src/test/java/org/springframework/context/event/ApplicationContextEventTests.java @@ -23,7 +23,7 @@ import java.util.Set; import java.util.concurrent.Executor; import org.aopalliance.intercept.MethodInvocation; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.framework.ProxyFactory; import org.springframework.beans.BeansException; diff --git a/spring-context/src/test/java/org/springframework/context/event/ApplicationListenerMethodAdapterTests.java b/spring-context/src/test/java/org/springframework/context/event/ApplicationListenerMethodAdapterTests.java index 4fd1a32adc9..9d989d33cef 100644 --- a/spring-context/src/test/java/org/springframework/context/event/ApplicationListenerMethodAdapterTests.java +++ b/spring-context/src/test/java/org/springframework/context/event/ApplicationListenerMethodAdapterTests.java @@ -20,7 +20,7 @@ import java.io.IOException; import java.lang.reflect.Method; import java.lang.reflect.UndeclaredThrowableException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.framework.ProxyFactory; import org.springframework.context.ApplicationContext; diff --git a/spring-context/src/test/java/org/springframework/context/event/EventPublicationInterceptorTests.java b/spring-context/src/test/java/org/springframework/context/event/EventPublicationInterceptorTests.java index 3239a472134..1ec94b8e047 100644 --- a/spring-context/src/test/java/org/springframework/context/event/EventPublicationInterceptorTests.java +++ b/spring-context/src/test/java/org/springframework/context/event/EventPublicationInterceptorTests.java @@ -16,7 +16,7 @@ package org.springframework.context.event; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.framework.ProxyFactory; import org.springframework.beans.BeansException; diff --git a/spring-context/src/test/java/org/springframework/context/event/GenericApplicationListenerAdapterTests.java b/spring-context/src/test/java/org/springframework/context/event/GenericApplicationListenerAdapterTests.java index c6586aaaf68..18bbae40521 100644 --- a/spring-context/src/test/java/org/springframework/context/event/GenericApplicationListenerAdapterTests.java +++ b/spring-context/src/test/java/org/springframework/context/event/GenericApplicationListenerAdapterTests.java @@ -16,7 +16,7 @@ package org.springframework.context.event; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.ApplicationEvent; import org.springframework.context.ApplicationListener; diff --git a/spring-context/src/test/java/org/springframework/context/event/LifecycleEventTests.java b/spring-context/src/test/java/org/springframework/context/event/LifecycleEventTests.java index 519151d7b42..5c4917c7fda 100644 --- a/spring-context/src/test/java/org/springframework/context/event/LifecycleEventTests.java +++ b/spring-context/src/test/java/org/springframework/context/event/LifecycleEventTests.java @@ -16,7 +16,7 @@ package org.springframework.context.event; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationEvent; diff --git a/spring-context/src/test/java/org/springframework/context/event/PayloadApplicationEventTests.java b/spring-context/src/test/java/org/springframework/context/event/PayloadApplicationEventTests.java index 6d414179854..ed0cbffaeba 100644 --- a/spring-context/src/test/java/org/springframework/context/event/PayloadApplicationEventTests.java +++ b/spring-context/src/test/java/org/springframework/context/event/PayloadApplicationEventTests.java @@ -19,7 +19,7 @@ package org.springframework.context.event; import java.util.ArrayList; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.PayloadApplicationEvent; diff --git a/spring-context/src/test/java/org/springframework/context/expression/AnnotatedElementKeyTests.java b/spring-context/src/test/java/org/springframework/context/expression/AnnotatedElementKeyTests.java index a1bcc6a3a62..6726f65a6b1 100644 --- a/spring-context/src/test/java/org/springframework/context/expression/AnnotatedElementKeyTests.java +++ b/spring-context/src/test/java/org/springframework/context/expression/AnnotatedElementKeyTests.java @@ -18,9 +18,9 @@ package org.springframework.context.expression; import java.lang.reflect.Method; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TestName; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; import org.springframework.util.ReflectionUtils; @@ -28,47 +28,49 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Stephane Nicoll + * @author Sam Brannen */ -public class AnnotatedElementKeyTests { +class AnnotatedElementKeyTests { - @Rule - public final TestName name = new TestName(); + private Method method; + + @BeforeEach + void setUpMethod(TestInfo testInfo) { + this.method = ReflectionUtils.findMethod(getClass(), testInfo.getTestMethod().get().getName()); + } @Test - public void sameInstanceEquals() { - Method m = ReflectionUtils.findMethod(getClass(), name.getMethodName()); - AnnotatedElementKey instance = new AnnotatedElementKey(m, getClass()); + void sameInstanceEquals() { + AnnotatedElementKey instance = new AnnotatedElementKey(this.method, getClass()); + assertKeyEquals(instance, instance); } @Test - public void equals() { - Method m = ReflectionUtils.findMethod(getClass(), name.getMethodName()); - AnnotatedElementKey first = new AnnotatedElementKey(m, getClass()); - AnnotatedElementKey second = new AnnotatedElementKey(m, getClass()); + void equals() { + AnnotatedElementKey first = new AnnotatedElementKey(this.method, getClass()); + AnnotatedElementKey second = new AnnotatedElementKey(this.method, getClass()); assertKeyEquals(first, second); } @Test - public void equalsNoTarget() { - Method m = ReflectionUtils.findMethod(getClass(), name.getMethodName()); - AnnotatedElementKey first = new AnnotatedElementKey(m, null); - AnnotatedElementKey second = new AnnotatedElementKey(m, null); + void equalsNoTarget() { + AnnotatedElementKey first = new AnnotatedElementKey(this.method, null); + AnnotatedElementKey second = new AnnotatedElementKey(this.method, null); assertKeyEquals(first, second); } @Test - public void noTargetClassNotEquals() { - Method m = ReflectionUtils.findMethod(getClass(), name.getMethodName()); - AnnotatedElementKey first = new AnnotatedElementKey(m, getClass()); - AnnotatedElementKey second = new AnnotatedElementKey(m, null); + void noTargetClassNotEquals() { + AnnotatedElementKey first = new AnnotatedElementKey(this.method, getClass()); + AnnotatedElementKey second = new AnnotatedElementKey(this.method, null); assertThat(first.equals(second)).isFalse(); } - protected void assertKeyEquals(AnnotatedElementKey first, AnnotatedElementKey second) { + private void assertKeyEquals(AnnotatedElementKey first, AnnotatedElementKey second) { assertThat(second).isEqualTo(first); assertThat(second.hashCode()).isEqualTo(first.hashCode()); } diff --git a/spring-context/src/test/java/org/springframework/context/expression/ApplicationContextExpressionTests.java b/spring-context/src/test/java/org/springframework/context/expression/ApplicationContextExpressionTests.java index 78b5bb6c12c..81804c8cd22 100644 --- a/spring-context/src/test/java/org/springframework/context/expression/ApplicationContextExpressionTests.java +++ b/spring-context/src/test/java/org/springframework/context/expression/ApplicationContextExpressionTests.java @@ -30,7 +30,7 @@ import java.util.Properties; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.ObjectFactory; import org.springframework.beans.factory.annotation.Autowired; diff --git a/spring-context/src/test/java/org/springframework/context/expression/CachedExpressionEvaluatorTests.java b/spring-context/src/test/java/org/springframework/context/expression/CachedExpressionEvaluatorTests.java index 9b1d4f42a61..f81a7945d73 100644 --- a/spring-context/src/test/java/org/springframework/context/expression/CachedExpressionEvaluatorTests.java +++ b/spring-context/src/test/java/org/springframework/context/expression/CachedExpressionEvaluatorTests.java @@ -20,7 +20,7 @@ import java.lang.reflect.Method; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.expression.Expression; import org.springframework.expression.spel.standard.SpelExpressionParser; diff --git a/spring-context/src/test/java/org/springframework/context/expression/EnvironmentAccessorIntegrationTests.java b/spring-context/src/test/java/org/springframework/context/expression/EnvironmentAccessorIntegrationTests.java index efd66b7a771..5f4600e82a4 100644 --- a/spring-context/src/test/java/org/springframework/context/expression/EnvironmentAccessorIntegrationTests.java +++ b/spring-context/src/test/java/org/springframework/context/expression/EnvironmentAccessorIntegrationTests.java @@ -16,7 +16,7 @@ package org.springframework.context.expression; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.context.support.AbstractApplicationContext; diff --git a/spring-context/src/test/java/org/springframework/context/expression/FactoryBeanAccessTests.java b/spring-context/src/test/java/org/springframework/context/expression/FactoryBeanAccessTests.java index 178016dbca8..fb20b5e48f9 100644 --- a/spring-context/src/test/java/org/springframework/context/expression/FactoryBeanAccessTests.java +++ b/spring-context/src/test/java/org/springframework/context/expression/FactoryBeanAccessTests.java @@ -16,7 +16,7 @@ package org.springframework.context.expression; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanIsNotAFactoryException; import org.springframework.beans.factory.FactoryBean; diff --git a/spring-context/src/test/java/org/springframework/context/expression/MapAccessorTests.java b/spring-context/src/test/java/org/springframework/context/expression/MapAccessorTests.java index 10027134418..df73adaa36d 100644 --- a/spring-context/src/test/java/org/springframework/context/expression/MapAccessorTests.java +++ b/spring-context/src/test/java/org/springframework/context/expression/MapAccessorTests.java @@ -19,7 +19,7 @@ package org.springframework.context.expression; import java.util.HashMap; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.expression.Expression; import org.springframework.expression.spel.standard.SpelCompiler; diff --git a/spring-context/src/test/java/org/springframework/context/expression/MethodBasedEvaluationContextTests.java b/spring-context/src/test/java/org/springframework/context/expression/MethodBasedEvaluationContextTests.java index 7acf07c0905..de40c7dca4c 100644 --- a/spring-context/src/test/java/org/springframework/context/expression/MethodBasedEvaluationContextTests.java +++ b/spring-context/src/test/java/org/springframework/context/expression/MethodBasedEvaluationContextTests.java @@ -18,7 +18,7 @@ package org.springframework.context.expression; import java.lang.reflect.Method; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.DefaultParameterNameDiscoverer; import org.springframework.core.ParameterNameDiscoverer; diff --git a/spring-context/src/test/java/org/springframework/context/groovy/GroovyApplicationContextTests.java b/spring-context/src/test/java/org/springframework/context/groovy/GroovyApplicationContextTests.java index a8c53429c66..c4caed25376 100644 --- a/spring-context/src/test/java/org/springframework/context/groovy/GroovyApplicationContextTests.java +++ b/spring-context/src/test/java/org/springframework/context/groovy/GroovyApplicationContextTests.java @@ -16,7 +16,7 @@ package org.springframework.context.groovy; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; import org.springframework.context.support.GenericGroovyApplicationContext; diff --git a/spring-context/src/test/java/org/springframework/context/i18n/LocaleContextHolderTests.java b/spring-context/src/test/java/org/springframework/context/i18n/LocaleContextHolderTests.java index d9dafbf26fb..2355c8c2786 100644 --- a/spring-context/src/test/java/org/springframework/context/i18n/LocaleContextHolderTests.java +++ b/spring-context/src/test/java/org/springframework/context/i18n/LocaleContextHolderTests.java @@ -19,7 +19,7 @@ package org.springframework.context.i18n; import java.util.Locale; import java.util.TimeZone; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/context/index/CandidateComponentsIndexLoaderTests.java b/spring-context/src/test/java/org/springframework/context/index/CandidateComponentsIndexLoaderTests.java index d828876add1..dc5798a3b50 100644 --- a/spring-context/src/test/java/org/springframework/context/index/CandidateComponentsIndexLoaderTests.java +++ b/spring-context/src/test/java/org/springframework/context/index/CandidateComponentsIndexLoaderTests.java @@ -19,7 +19,7 @@ package org.springframework.context.index; import java.io.IOException; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.io.ClassPathResource; diff --git a/spring-context/src/test/java/org/springframework/context/index/CandidateComponentsIndexTests.java b/spring-context/src/test/java/org/springframework/context/index/CandidateComponentsIndexTests.java index 274f26d2b1f..70a99034629 100644 --- a/spring-context/src/test/java/org/springframework/context/index/CandidateComponentsIndexTests.java +++ b/spring-context/src/test/java/org/springframework/context/index/CandidateComponentsIndexTests.java @@ -21,7 +21,7 @@ import java.util.Collections; import java.util.Properties; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/context/support/ApplicationContextLifecycleTests.java b/spring-context/src/test/java/org/springframework/context/support/ApplicationContextLifecycleTests.java index fafe355c955..6208d79a7b9 100644 --- a/spring-context/src/test/java/org/springframework/context/support/ApplicationContextLifecycleTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/ApplicationContextLifecycleTests.java @@ -16,7 +16,7 @@ package org.springframework.context.support; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/context/support/BeanFactoryPostProcessorTests.java b/spring-context/src/test/java/org/springframework/context/support/BeanFactoryPostProcessorTests.java index 1ddd43ef3f2..2976825d6d9 100644 --- a/spring-context/src/test/java/org/springframework/context/support/BeanFactoryPostProcessorTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/BeanFactoryPostProcessorTests.java @@ -16,7 +16,7 @@ package org.springframework.context.support; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.BeansException; import org.springframework.beans.MutablePropertyValues; diff --git a/spring-context/src/test/java/org/springframework/context/support/ClassPathXmlApplicationContextTests.java b/spring-context/src/test/java/org/springframework/context/support/ClassPathXmlApplicationContextTests.java index 61b54fbafb5..b3c46cd5b1d 100644 --- a/spring-context/src/test/java/org/springframework/context/support/ClassPathXmlApplicationContextTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/ClassPathXmlApplicationContextTests.java @@ -26,7 +26,7 @@ import java.util.Arrays; import java.util.List; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.support.AopUtils; import org.springframework.beans.TypeMismatchException; diff --git a/spring-context/src/test/java/org/springframework/context/support/ConversionServiceFactoryBeanTests.java b/spring-context/src/test/java/org/springframework/context/support/ConversionServiceFactoryBeanTests.java index 545edec4f6f..ec96b605143 100644 --- a/spring-context/src/test/java/org/springframework/context/support/ConversionServiceFactoryBeanTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/ConversionServiceFactoryBeanTests.java @@ -21,7 +21,7 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.ApplicationContext; import org.springframework.core.convert.ConversionService; diff --git a/spring-context/src/test/java/org/springframework/context/support/DefaultLifecycleProcessorTests.java b/spring-context/src/test/java/org/springframework/context/support/DefaultLifecycleProcessorTests.java index 7f91807048d..579aea587cb 100644 --- a/spring-context/src/test/java/org/springframework/context/support/DefaultLifecycleProcessorTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/DefaultLifecycleProcessorTests.java @@ -18,7 +18,7 @@ package org.springframework.context.support; import java.util.concurrent.CopyOnWriteArrayList; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.DirectFieldAccessor; import org.springframework.beans.factory.FactoryBean; diff --git a/spring-context/src/test/java/org/springframework/context/support/EnvironmentIntegrationTests.java b/spring-context/src/test/java/org/springframework/context/support/EnvironmentIntegrationTests.java index 2f0454b2e4e..b0c344f6f40 100644 --- a/spring-context/src/test/java/org/springframework/context/support/EnvironmentIntegrationTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/EnvironmentIntegrationTests.java @@ -16,7 +16,7 @@ package org.springframework.context.support; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.ConfigurableApplicationContext; diff --git a/spring-context/src/test/java/org/springframework/context/support/EnvironmentSecurityManagerIntegrationTests.java b/spring-context/src/test/java/org/springframework/context/support/EnvironmentSecurityManagerIntegrationTests.java index bc6f5f2fd05..584f242e7d9 100644 --- a/spring-context/src/test/java/org/springframework/context/support/EnvironmentSecurityManagerIntegrationTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/EnvironmentSecurityManagerIntegrationTests.java @@ -20,9 +20,9 @@ import java.security.AccessControlException; import java.security.Permission; import java.util.Map; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.context.annotation.AnnotatedBeanDefinitionReader; @@ -47,14 +47,14 @@ public class EnvironmentSecurityManagerIntegrationTests { private Map env; - @Before + @BeforeEach public void setUp() { originalSecurityManager = System.getSecurityManager(); env = StandardEnvironmentTests.getModifiableSystemEnvironment(); env.put(AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME, "p1"); } - @After + @AfterEach public void tearDown() { env.remove(AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME); System.setSecurityManager(originalSecurityManager); diff --git a/spring-context/src/test/java/org/springframework/context/support/GenericApplicationContextTests.java b/spring-context/src/test/java/org/springframework/context/support/GenericApplicationContextTests.java index bbf3568b8cf..8cd441aa88d 100644 --- a/spring-context/src/test/java/org/springframework/context/support/GenericApplicationContextTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/GenericApplicationContextTests.java @@ -16,7 +16,7 @@ package org.springframework.context.support; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.NoUniqueBeanDefinitionException; import org.springframework.beans.factory.support.RootBeanDefinition; diff --git a/spring-context/src/test/java/org/springframework/context/support/GenericXmlApplicationContextTests.java b/spring-context/src/test/java/org/springframework/context/support/GenericXmlApplicationContextTests.java index 961d2718ffb..cfb96aca28d 100644 --- a/spring-context/src/test/java/org/springframework/context/support/GenericXmlApplicationContextTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/GenericXmlApplicationContextTests.java @@ -16,7 +16,7 @@ package org.springframework.context.support; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.ApplicationContext; import org.springframework.util.ClassUtils; diff --git a/spring-context/src/test/java/org/springframework/context/support/LiveBeansViewTests.java b/spring-context/src/test/java/org/springframework/context/support/LiveBeansViewTests.java index 09ea419e692..50095387d67 100644 --- a/spring-context/src/test/java/org/springframework/context/support/LiveBeansViewTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/LiveBeansViewTests.java @@ -21,9 +21,8 @@ import java.util.Set; import javax.management.MalformedObjectNameException; import javax.management.ObjectName; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TestName; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.mock.env.MockEnvironment; @@ -36,64 +35,66 @@ import static org.mockito.Mockito.mock; * Tests for {@link LiveBeansView} * * @author Stephane Nicoll + * @author Sam Brannen */ -public class LiveBeansViewTests { - - @Rule - public TestName name = new TestName(); +class LiveBeansViewTests { private final MockEnvironment environment = new MockEnvironment(); + @Test - public void registerIgnoredIfPropertyIsNotSet() throws MalformedObjectNameException { + void registerIgnoredIfPropertyIsNotSet(TestInfo testInfo) throws MalformedObjectNameException { ConfigurableApplicationContext context = createApplicationContext("app"); - assertThat(searchLiveBeansViewMeans().size()).isEqualTo(0); + assertThat(searchLiveBeansViewMeans(testInfo).size()).isEqualTo(0); LiveBeansView.registerApplicationContext(context); - assertThat(searchLiveBeansViewMeans().size()).isEqualTo(0); + assertThat(searchLiveBeansViewMeans(testInfo).size()).isEqualTo(0); LiveBeansView.unregisterApplicationContext(context); } @Test - public void registerUnregisterSingleContext() throws MalformedObjectNameException { - this.environment.setProperty(LiveBeansView.MBEAN_DOMAIN_PROPERTY_NAME, this.name.getMethodName()); + void registerUnregisterSingleContext(TestInfo testInfo) throws MalformedObjectNameException { + this.environment.setProperty(LiveBeansView.MBEAN_DOMAIN_PROPERTY_NAME, + testInfo.getTestMethod().get().getName()); ConfigurableApplicationContext context = createApplicationContext("app"); - assertThat(searchLiveBeansViewMeans().size()).isEqualTo(0); + assertThat(searchLiveBeansViewMeans(testInfo).size()).isEqualTo(0); LiveBeansView.registerApplicationContext(context); - assertSingleLiveBeansViewMbean("app"); + assertSingleLiveBeansViewMbean(testInfo, "app"); LiveBeansView.unregisterApplicationContext(context); - assertThat(searchLiveBeansViewMeans().size()).isEqualTo(0); + assertThat(searchLiveBeansViewMeans(testInfo).size()).isEqualTo(0); } @Test - public void registerUnregisterSeveralContexts() throws MalformedObjectNameException { - this.environment.setProperty(LiveBeansView.MBEAN_DOMAIN_PROPERTY_NAME, this.name.getMethodName()); + void registerUnregisterSeveralContexts(TestInfo testInfo) throws MalformedObjectNameException { + this.environment.setProperty(LiveBeansView.MBEAN_DOMAIN_PROPERTY_NAME, + testInfo.getTestMethod().get().getName()); ConfigurableApplicationContext context = createApplicationContext("app"); ConfigurableApplicationContext childContext = createApplicationContext("child"); - assertThat(searchLiveBeansViewMeans().size()).isEqualTo(0); + assertThat(searchLiveBeansViewMeans(testInfo).size()).isEqualTo(0); LiveBeansView.registerApplicationContext(context); - assertSingleLiveBeansViewMbean("app"); + assertSingleLiveBeansViewMbean(testInfo, "app"); LiveBeansView.registerApplicationContext(childContext); // Only one MBean - assertThat(searchLiveBeansViewMeans().size()).isEqualTo(1); + assertThat(searchLiveBeansViewMeans(testInfo).size()).isEqualTo(1); LiveBeansView.unregisterApplicationContext(childContext); - assertSingleLiveBeansViewMbean("app"); // Root context removes it + assertSingleLiveBeansViewMbean(testInfo, "app"); // Root context removes it LiveBeansView.unregisterApplicationContext(context); - assertThat(searchLiveBeansViewMeans().size()).isEqualTo(0); + assertThat(searchLiveBeansViewMeans(testInfo).size()).isEqualTo(0); } @Test - public void registerUnregisterSeveralContextsDifferentOrder() throws MalformedObjectNameException { - this.environment.setProperty(LiveBeansView.MBEAN_DOMAIN_PROPERTY_NAME, this.name.getMethodName()); + void registerUnregisterSeveralContextsDifferentOrder(TestInfo testInfo) throws MalformedObjectNameException { + this.environment.setProperty(LiveBeansView.MBEAN_DOMAIN_PROPERTY_NAME, + testInfo.getTestMethod().get().getName()); ConfigurableApplicationContext context = createApplicationContext("app"); ConfigurableApplicationContext childContext = createApplicationContext("child"); - assertThat(searchLiveBeansViewMeans().size()).isEqualTo(0); + assertThat(searchLiveBeansViewMeans(testInfo).size()).isEqualTo(0); LiveBeansView.registerApplicationContext(context); - assertSingleLiveBeansViewMbean("app"); + assertSingleLiveBeansViewMbean(testInfo, "app"); LiveBeansView.registerApplicationContext(childContext); - assertSingleLiveBeansViewMbean("app"); // Only one MBean + assertSingleLiveBeansViewMbean(testInfo, "app"); // Only one MBean LiveBeansView.unregisterApplicationContext(context); LiveBeansView.unregisterApplicationContext(childContext); - assertThat(searchLiveBeansViewMeans().size()).isEqualTo(0); + assertThat(searchLiveBeansViewMeans(testInfo).size()).isEqualTo(0); } private ConfigurableApplicationContext createApplicationContext(String applicationName) { @@ -103,17 +104,16 @@ public class LiveBeansViewTests { return context; } - public void assertSingleLiveBeansViewMbean(String applicationName) throws MalformedObjectNameException { - Set objectNames = searchLiveBeansViewMeans(); + private void assertSingleLiveBeansViewMbean(TestInfo testInfo, String applicationName) throws MalformedObjectNameException { + Set objectNames = searchLiveBeansViewMeans(testInfo); assertThat(objectNames.size()).isEqualTo(1); - assertThat(objectNames.iterator().next().getCanonicalName()).as("Wrong MBean name").isEqualTo(String.format("%s:application=%s", this.name.getMethodName(), applicationName)); - + assertThat(objectNames.iterator().next().getCanonicalName()).as("Wrong MBean name").isEqualTo( + String.format("%s:application=%s", testInfo.getTestMethod().get().getName(), applicationName)); } - private Set searchLiveBeansViewMeans() - throws MalformedObjectNameException { - String objectName = String.format("%s:*,%s=*", this.name.getMethodName(), - LiveBeansView.MBEAN_APPLICATION_KEY); + private Set searchLiveBeansViewMeans(TestInfo testInfo) throws MalformedObjectNameException { + String objectName = String.format("%s:*,%s=*", testInfo.getTestMethod().get().getName(), + LiveBeansView.MBEAN_APPLICATION_KEY); return ManagementFactory.getPlatformMBeanServer().queryNames(new ObjectName(objectName), null); } diff --git a/spring-context/src/test/java/org/springframework/context/support/PropertyResourceConfigurerIntegrationTests.java b/spring-context/src/test/java/org/springframework/context/support/PropertyResourceConfigurerIntegrationTests.java index 2b37720cf14..f876a6a7f6f 100644 --- a/spring-context/src/test/java/org/springframework/context/support/PropertyResourceConfigurerIntegrationTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/PropertyResourceConfigurerIntegrationTests.java @@ -18,8 +18,8 @@ package org.springframework.context.support; import java.io.FileNotFoundException; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.springframework.beans.MutablePropertyValues; import org.springframework.beans.factory.BeanDefinitionStoreException; @@ -139,7 +139,7 @@ public class PropertyResourceConfigurerIntegrationTests { ac::refresh); } - @Ignore // this test was breaking after the 3.0 repackaging + @Disabled // this test was breaking after the 3.0 repackaging @Test public void testPropertyPlaceholderConfigurerWithAutowireByType() { // StaticApplicationContext ac = new StaticApplicationContext(); diff --git a/spring-context/src/test/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurerTests.java b/spring-context/src/test/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurerTests.java index b15ecb02821..c08b49210eb 100644 --- a/spring-context/src/test/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurerTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurerTests.java @@ -19,7 +19,7 @@ package org.springframework.context.support; import java.util.Optional; import java.util.Properties; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanDefinitionStoreException; import org.springframework.beans.factory.support.DefaultListableBeanFactory; diff --git a/spring-context/src/test/java/org/springframework/context/support/ResourceBundleMessageSourceTests.java b/spring-context/src/test/java/org/springframework/context/support/ResourceBundleMessageSourceTests.java index fc139e1fe9f..2653289c7db 100644 --- a/spring-context/src/test/java/org/springframework/context/support/ResourceBundleMessageSourceTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/ResourceBundleMessageSourceTests.java @@ -21,8 +21,8 @@ import java.util.Locale; import java.util.Properties; import java.util.ResourceBundle; -import org.junit.After; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.MutablePropertyValues; import org.springframework.context.MessageSourceResolvable; @@ -426,7 +426,7 @@ public class ResourceBundleMessageSourceTests { } - @After + @AfterEach public void tearDown() { ResourceBundle.clearCache(); } diff --git a/spring-context/src/test/java/org/springframework/context/support/SerializableBeanFactoryMemoryLeakTests.java b/spring-context/src/test/java/org/springframework/context/support/SerializableBeanFactoryMemoryLeakTests.java index 58b2351409f..45aaac584dd 100644 --- a/spring-context/src/test/java/org/springframework/context/support/SerializableBeanFactoryMemoryLeakTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/SerializableBeanFactoryMemoryLeakTests.java @@ -19,9 +19,9 @@ package org.springframework.context.support; import java.lang.reflect.Field; import java.util.Map; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.support.BeanDefinitionRegistry; @@ -42,8 +42,8 @@ public class SerializableBeanFactoryMemoryLeakTests { * Defensively zero-out static factory count - other tests * may have misbehaved before us. */ - @BeforeClass - @AfterClass + @BeforeAll + @AfterAll public static void zeroOutFactoryCount() throws Exception { getSerializableFactoryMap().clear(); } diff --git a/spring-context/src/test/java/org/springframework/context/support/SimpleThreadScopeTests.java b/spring-context/src/test/java/org/springframework/context/support/SimpleThreadScopeTests.java index bae8630c3e7..f1e0c9cc312 100644 --- a/spring-context/src/test/java/org/springframework/context/support/SimpleThreadScopeTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/SimpleThreadScopeTests.java @@ -19,7 +19,7 @@ package org.springframework.context.support; import java.util.concurrent.TimeUnit; import org.awaitility.Awaitility; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.ApplicationContext; import org.springframework.tests.sample.beans.TestBean; diff --git a/spring-context/src/test/java/org/springframework/context/support/Spr7283Tests.java b/spring-context/src/test/java/org/springframework/context/support/Spr7283Tests.java index dee3e0167da..374613fe1ae 100644 --- a/spring-context/src/test/java/org/springframework/context/support/Spr7283Tests.java +++ b/spring-context/src/test/java/org/springframework/context/support/Spr7283Tests.java @@ -18,7 +18,7 @@ package org.springframework.context.support; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/context/support/Spr7816Tests.java b/spring-context/src/test/java/org/springframework/context/support/Spr7816Tests.java index 643a4c379d9..087d72345d4 100644 --- a/spring-context/src/test/java/org/springframework/context/support/Spr7816Tests.java +++ b/spring-context/src/test/java/org/springframework/context/support/Spr7816Tests.java @@ -18,7 +18,7 @@ package org.springframework.context.support; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.ApplicationContext; diff --git a/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextMulticasterTests.java b/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextMulticasterTests.java index bce7e26f109..aa4b7d25fce 100644 --- a/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextMulticasterTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextMulticasterTests.java @@ -20,7 +20,7 @@ import java.util.HashMap; import java.util.Locale; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.MutablePropertyValues; import org.springframework.beans.factory.support.PropertiesBeanDefinitionReader; diff --git a/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextTests.java b/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextTests.java index 9ad3e66a15c..5a525c90fc7 100644 --- a/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/StaticApplicationContextTests.java @@ -20,7 +20,7 @@ import java.util.HashMap; import java.util.Locale; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.MutablePropertyValues; import org.springframework.beans.factory.support.PropertiesBeanDefinitionReader; diff --git a/spring-context/src/test/java/org/springframework/context/support/StaticMessageSourceTests.java b/spring-context/src/test/java/org/springframework/context/support/StaticMessageSourceTests.java index 44c68e9facb..d28aa814b9f 100644 --- a/spring-context/src/test/java/org/springframework/context/support/StaticMessageSourceTests.java +++ b/spring-context/src/test/java/org/springframework/context/support/StaticMessageSourceTests.java @@ -21,7 +21,7 @@ import java.util.HashMap; import java.util.Locale; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.MutablePropertyValues; import org.springframework.beans.factory.support.PropertiesBeanDefinitionReader; diff --git a/spring-context/src/test/java/org/springframework/ejb/access/LocalSlsbInvokerInterceptorTests.java b/spring-context/src/test/java/org/springframework/ejb/access/LocalSlsbInvokerInterceptorTests.java index 8f5876be1fd..127dd832779 100644 --- a/spring-context/src/test/java/org/springframework/ejb/access/LocalSlsbInvokerInterceptorTests.java +++ b/spring-context/src/test/java/org/springframework/ejb/access/LocalSlsbInvokerInterceptorTests.java @@ -22,7 +22,7 @@ import javax.ejb.EJBLocalObject; import javax.naming.Context; import javax.naming.NamingException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.framework.ProxyFactory; import org.springframework.jndi.JndiTemplate; diff --git a/spring-context/src/test/java/org/springframework/ejb/access/LocalStatelessSessionProxyFactoryBeanTests.java b/spring-context/src/test/java/org/springframework/ejb/access/LocalStatelessSessionProxyFactoryBeanTests.java index b07b347f766..f1fc6306b9f 100644 --- a/spring-context/src/test/java/org/springframework/ejb/access/LocalStatelessSessionProxyFactoryBeanTests.java +++ b/spring-context/src/test/java/org/springframework/ejb/access/LocalStatelessSessionProxyFactoryBeanTests.java @@ -22,7 +22,7 @@ import javax.ejb.EJBLocalHome; import javax.ejb.EJBLocalObject; import javax.naming.NamingException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.jndi.JndiTemplate; diff --git a/spring-context/src/test/java/org/springframework/ejb/access/SimpleRemoteSlsbInvokerInterceptorTests.java b/spring-context/src/test/java/org/springframework/ejb/access/SimpleRemoteSlsbInvokerInterceptorTests.java index 7369acce549..79b232531a3 100644 --- a/spring-context/src/test/java/org/springframework/ejb/access/SimpleRemoteSlsbInvokerInterceptorTests.java +++ b/spring-context/src/test/java/org/springframework/ejb/access/SimpleRemoteSlsbInvokerInterceptorTests.java @@ -24,7 +24,7 @@ import javax.ejb.EJBObject; import javax.naming.Context; import javax.naming.NamingException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.framework.ProxyFactory; import org.springframework.jndi.JndiTemplate; diff --git a/spring-context/src/test/java/org/springframework/ejb/access/SimpleRemoteStatelessSessionProxyFactoryBeanTests.java b/spring-context/src/test/java/org/springframework/ejb/access/SimpleRemoteStatelessSessionProxyFactoryBeanTests.java index 422e8aa98f0..9ca7f8f793c 100644 --- a/spring-context/src/test/java/org/springframework/ejb/access/SimpleRemoteStatelessSessionProxyFactoryBeanTests.java +++ b/spring-context/src/test/java/org/springframework/ejb/access/SimpleRemoteStatelessSessionProxyFactoryBeanTests.java @@ -23,7 +23,7 @@ import javax.ejb.EJBHome; import javax.ejb.EJBObject; import javax.naming.NamingException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.jndi.JndiTemplate; import org.springframework.remoting.RemoteAccessException; diff --git a/spring-context/src/test/java/org/springframework/ejb/config/JeeNamespaceHandlerEventTests.java b/spring-context/src/test/java/org/springframework/ejb/config/JeeNamespaceHandlerEventTests.java index 16369a478fa..750ba274968 100644 --- a/spring-context/src/test/java/org/springframework/ejb/config/JeeNamespaceHandlerEventTests.java +++ b/spring-context/src/test/java/org/springframework/ejb/config/JeeNamespaceHandlerEventTests.java @@ -16,8 +16,8 @@ package org.springframework.ejb.config; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.parsing.BeanComponentDefinition; import org.springframework.beans.factory.parsing.ComponentDefinition; @@ -42,7 +42,7 @@ public class JeeNamespaceHandlerEventTests { private DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory(); - @Before + @BeforeEach public void setUp() throws Exception { this.reader = new XmlBeanDefinitionReader(this.beanFactory); this.reader.setEventListener(this.eventListener); diff --git a/spring-context/src/test/java/org/springframework/ejb/config/JeeNamespaceHandlerTests.java b/spring-context/src/test/java/org/springframework/ejb/config/JeeNamespaceHandlerTests.java index 093051cd1d6..0922393a8ce 100644 --- a/spring-context/src/test/java/org/springframework/ejb/config/JeeNamespaceHandlerTests.java +++ b/spring-context/src/test/java/org/springframework/ejb/config/JeeNamespaceHandlerTests.java @@ -16,8 +16,8 @@ package org.springframework.ejb.config; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; @@ -42,7 +42,7 @@ public class JeeNamespaceHandlerTests { private ConfigurableListableBeanFactory beanFactory; - @Before + @BeforeEach public void setUp() throws Exception { GenericApplicationContext ctx = new GenericApplicationContext(); new XmlBeanDefinitionReader(ctx).loadBeanDefinitions( diff --git a/spring-context/src/test/java/org/springframework/format/datetime/DateFormatterTests.java b/spring-context/src/test/java/org/springframework/format/datetime/DateFormatterTests.java index e5699d81013..7737902082a 100644 --- a/spring-context/src/test/java/org/springframework/format/datetime/DateFormatterTests.java +++ b/spring-context/src/test/java/org/springframework/format/datetime/DateFormatterTests.java @@ -26,7 +26,7 @@ import java.util.TimeZone; import org.joda.time.DateTimeZone; import org.joda.time.format.DateTimeFormat; import org.joda.time.format.DateTimeFormatter; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.format.annotation.DateTimeFormat.ISO; diff --git a/spring-context/src/test/java/org/springframework/format/datetime/DateFormattingTests.java b/spring-context/src/test/java/org/springframework/format/datetime/DateFormattingTests.java index 6535b9efdbc..129f01b3d93 100644 --- a/spring-context/src/test/java/org/springframework/format/datetime/DateFormattingTests.java +++ b/spring-context/src/test/java/org/springframework/format/datetime/DateFormattingTests.java @@ -22,10 +22,10 @@ import java.util.Date; import java.util.List; import java.util.Locale; -import org.junit.After; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.springframework.beans.MutablePropertyValues; import org.springframework.context.i18n.LocaleContextHolder; @@ -50,7 +50,7 @@ public class DateFormattingTests { private DataBinder binder; - @Before + @BeforeEach public void setup() { DateFormatterRegistrar registrar = new DateFormatterRegistrar(); setup(registrar); @@ -68,7 +68,7 @@ public class DateFormattingTests { LocaleContextHolder.setLocale(Locale.US); } - @After + @AfterEach public void tearDown() { LocaleContextHolder.setLocale(null); } @@ -128,7 +128,7 @@ public class DateFormattingTests { } @Test - @Ignore + @Disabled public void testBindDateAnnotatedWithFallbackError() { // TODO This currently passes because of the Date(String) constructor fallback is used MutablePropertyValues propertyValues = new MutablePropertyValues(); diff --git a/spring-context/src/test/java/org/springframework/format/datetime/joda/DateTimeFormatterFactoryBeanTests.java b/spring-context/src/test/java/org/springframework/format/datetime/joda/DateTimeFormatterFactoryBeanTests.java index b26cc5f7993..4472cb321e1 100644 --- a/spring-context/src/test/java/org/springframework/format/datetime/joda/DateTimeFormatterFactoryBeanTests.java +++ b/spring-context/src/test/java/org/springframework/format/datetime/joda/DateTimeFormatterFactoryBeanTests.java @@ -18,7 +18,7 @@ package org.springframework.format.datetime.joda; import org.joda.time.format.DateTimeFormat; import org.joda.time.format.DateTimeFormatter; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/format/datetime/joda/DateTimeFormatterFactoryTests.java b/spring-context/src/test/java/org/springframework/format/datetime/joda/DateTimeFormatterFactoryTests.java index 457711e7f6a..d76302fe109 100644 --- a/spring-context/src/test/java/org/springframework/format/datetime/joda/DateTimeFormatterFactoryTests.java +++ b/spring-context/src/test/java/org/springframework/format/datetime/joda/DateTimeFormatterFactoryTests.java @@ -23,7 +23,7 @@ import org.joda.time.DateTime; import org.joda.time.DateTimeZone; import org.joda.time.format.DateTimeFormat; import org.joda.time.format.DateTimeFormatter; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.format.annotation.DateTimeFormat.ISO; diff --git a/spring-context/src/test/java/org/springframework/format/datetime/joda/JodaTimeFormattingTests.java b/spring-context/src/test/java/org/springframework/format/datetime/joda/JodaTimeFormattingTests.java index 254d6d0f231..63a241f504d 100644 --- a/spring-context/src/test/java/org/springframework/format/datetime/joda/JodaTimeFormattingTests.java +++ b/spring-context/src/test/java/org/springframework/format/datetime/joda/JodaTimeFormattingTests.java @@ -33,9 +33,9 @@ import org.joda.time.MonthDay; import org.joda.time.Period; import org.joda.time.YearMonth; import org.joda.time.chrono.ISOChronology; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.MutablePropertyValues; import org.springframework.context.i18n.LocaleContextHolder; @@ -60,7 +60,7 @@ public class JodaTimeFormattingTests { private DataBinder binder; - @Before + @BeforeEach public void setup() { JodaTimeFormatterRegistrar registrar = new JodaTimeFormatterRegistrar(); setup(registrar); @@ -82,7 +82,7 @@ public class JodaTimeFormattingTests { JodaTimeContextHolder.setJodaTimeContext(context); } - @After + @AfterEach public void cleanup() { LocaleContextHolder.setLocale(null); JodaTimeContextHolder.setJodaTimeContext(null); diff --git a/spring-context/src/test/java/org/springframework/format/datetime/standard/DateTimeFormatterFactoryBeanTests.java b/spring-context/src/test/java/org/springframework/format/datetime/standard/DateTimeFormatterFactoryBeanTests.java index 5d22c354de0..eb3b3ea126d 100644 --- a/spring-context/src/test/java/org/springframework/format/datetime/standard/DateTimeFormatterFactoryBeanTests.java +++ b/spring-context/src/test/java/org/springframework/format/datetime/standard/DateTimeFormatterFactoryBeanTests.java @@ -19,7 +19,7 @@ package org.springframework.format.datetime.standard; import java.time.format.DateTimeFormatter; import java.time.format.FormatStyle; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/format/datetime/standard/DateTimeFormatterFactoryTests.java b/spring-context/src/test/java/org/springframework/format/datetime/standard/DateTimeFormatterFactoryTests.java index 24038f085f6..3ae83030ae1 100644 --- a/spring-context/src/test/java/org/springframework/format/datetime/standard/DateTimeFormatterFactoryTests.java +++ b/spring-context/src/test/java/org/springframework/format/datetime/standard/DateTimeFormatterFactoryTests.java @@ -24,7 +24,7 @@ import java.time.format.FormatStyle; import java.util.Locale; import java.util.TimeZone; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.format.annotation.DateTimeFormat.ISO; diff --git a/spring-context/src/test/java/org/springframework/format/datetime/standard/DateTimeFormattingTests.java b/spring-context/src/test/java/org/springframework/format/datetime/standard/DateTimeFormattingTests.java index 29e7a5b75bd..23f640cb941 100644 --- a/spring-context/src/test/java/org/springframework/format/datetime/standard/DateTimeFormattingTests.java +++ b/spring-context/src/test/java/org/springframework/format/datetime/standard/DateTimeFormattingTests.java @@ -36,9 +36,9 @@ import java.util.List; import java.util.Locale; import java.util.TimeZone; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.MutablePropertyValues; import org.springframework.context.i18n.LocaleContextHolder; @@ -62,7 +62,7 @@ public class DateTimeFormattingTests { private DataBinder binder; - @Before + @BeforeEach public void setup() { DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar(); setup(registrar); @@ -84,7 +84,7 @@ public class DateTimeFormattingTests { DateTimeContextHolder.setDateTimeContext(context); } - @After + @AfterEach public void cleanup() { LocaleContextHolder.setLocale(null); DateTimeContextHolder.setDateTimeContext(null); diff --git a/spring-context/src/test/java/org/springframework/format/number/CurrencyStyleFormatterTests.java b/spring-context/src/test/java/org/springframework/format/number/CurrencyStyleFormatterTests.java index 464812afc39..2a8feb879ea 100644 --- a/spring-context/src/test/java/org/springframework/format/number/CurrencyStyleFormatterTests.java +++ b/spring-context/src/test/java/org/springframework/format/number/CurrencyStyleFormatterTests.java @@ -21,7 +21,7 @@ import java.math.RoundingMode; import java.text.ParseException; import java.util.Locale; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-context/src/test/java/org/springframework/format/number/NumberFormattingTests.java b/spring-context/src/test/java/org/springframework/format/number/NumberFormattingTests.java index 9c8a2ec7184..406d6549f9e 100644 --- a/spring-context/src/test/java/org/springframework/format/number/NumberFormattingTests.java +++ b/spring-context/src/test/java/org/springframework/format/number/NumberFormattingTests.java @@ -20,9 +20,9 @@ import java.math.BigDecimal; import java.util.List; import java.util.Locale; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.MutablePropertyValues; import org.springframework.context.i18n.LocaleContextHolder; @@ -46,7 +46,7 @@ public class NumberFormattingTests { private DataBinder binder; - @Before + @BeforeEach public void setUp() { DefaultConversionService.addDefaultConverters(conversionService); conversionService.setEmbeddedValueResolver(new StringValueResolver() { @@ -67,7 +67,7 @@ public class NumberFormattingTests { binder.setConversionService(conversionService); } - @After + @AfterEach public void tearDown() { LocaleContextHolder.setLocale(null); } diff --git a/spring-context/src/test/java/org/springframework/format/number/NumberStyleFormatterTests.java b/spring-context/src/test/java/org/springframework/format/number/NumberStyleFormatterTests.java index 49ac2b76ac2..babd8a3267d 100644 --- a/spring-context/src/test/java/org/springframework/format/number/NumberStyleFormatterTests.java +++ b/spring-context/src/test/java/org/springframework/format/number/NumberStyleFormatterTests.java @@ -20,7 +20,7 @@ import java.math.BigDecimal; import java.text.ParseException; import java.util.Locale; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-context/src/test/java/org/springframework/format/number/PercentStyleFormatterTests.java b/spring-context/src/test/java/org/springframework/format/number/PercentStyleFormatterTests.java index c91679adbd4..de9cbf227e3 100644 --- a/spring-context/src/test/java/org/springframework/format/number/PercentStyleFormatterTests.java +++ b/spring-context/src/test/java/org/springframework/format/number/PercentStyleFormatterTests.java @@ -20,7 +20,7 @@ import java.math.BigDecimal; import java.text.ParseException; import java.util.Locale; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-context/src/test/java/org/springframework/format/number/money/MoneyFormattingTests.java b/spring-context/src/test/java/org/springframework/format/number/money/MoneyFormattingTests.java index 0890abc7ba9..b30612f10ed 100644 --- a/spring-context/src/test/java/org/springframework/format/number/money/MoneyFormattingTests.java +++ b/spring-context/src/test/java/org/springframework/format/number/money/MoneyFormattingTests.java @@ -20,9 +20,9 @@ import java.util.Locale; import javax.money.CurrencyUnit; import javax.money.MonetaryAmount; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.MutablePropertyValues; import org.springframework.context.i18n.LocaleContextHolder; @@ -42,12 +42,12 @@ public class MoneyFormattingTests { private final FormattingConversionService conversionService = new DefaultFormattingConversionService(); - @Before + @BeforeEach public void setUp() { LocaleContextHolder.setLocale(Locale.US); } - @After + @AfterEach public void tearDown() { LocaleContextHolder.setLocale(null); } diff --git a/spring-context/src/test/java/org/springframework/format/support/FormattingConversionServiceFactoryBeanTests.java b/spring-context/src/test/java/org/springframework/format/support/FormattingConversionServiceFactoryBeanTests.java index 5fe063b0b3a..8b8aacf6dd5 100644 --- a/spring-context/src/test/java/org/springframework/format/support/FormattingConversionServiceFactoryBeanTests.java +++ b/spring-context/src/test/java/org/springframework/format/support/FormattingConversionServiceFactoryBeanTests.java @@ -25,7 +25,7 @@ import java.util.HashSet; import java.util.Locale; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.core.annotation.AliasFor; diff --git a/spring-context/src/test/java/org/springframework/format/support/FormattingConversionServiceTests.java b/spring-context/src/test/java/org/springframework/format/support/FormattingConversionServiceTests.java index 2eeb64b4258..3e068c9041f 100644 --- a/spring-context/src/test/java/org/springframework/format/support/FormattingConversionServiceTests.java +++ b/spring-context/src/test/java/org/springframework/format/support/FormattingConversionServiceTests.java @@ -27,9 +27,9 @@ import java.util.Properties; import org.joda.time.DateTime; import org.joda.time.LocalDate; import org.joda.time.format.DateTimeFormat; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.aop.framework.ProxyFactory; import org.springframework.beans.ConfigurablePropertyAccessor; @@ -68,14 +68,14 @@ public class FormattingConversionServiceTests { private FormattingConversionService formattingService; - @Before + @BeforeEach public void setUp() { formattingService = new FormattingConversionService(); DefaultConversionService.addDefaultConverters(formattingService); LocaleContextHolder.setLocale(Locale.US); } - @After + @AfterEach public void tearDown() { LocaleContextHolder.setLocale(null); } diff --git a/spring-context/src/test/java/org/springframework/instrument/classloading/InstrumentableClassLoaderTests.java b/spring-context/src/test/java/org/springframework/instrument/classloading/InstrumentableClassLoaderTests.java index 26d9ce0b43d..b70628ea4e0 100644 --- a/spring-context/src/test/java/org/springframework/instrument/classloading/InstrumentableClassLoaderTests.java +++ b/spring-context/src/test/java/org/springframework/instrument/classloading/InstrumentableClassLoaderTests.java @@ -16,7 +16,7 @@ package org.springframework.instrument.classloading; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.util.ClassUtils; diff --git a/spring-context/src/test/java/org/springframework/instrument/classloading/ReflectiveLoadTimeWeaverTests.java b/spring-context/src/test/java/org/springframework/instrument/classloading/ReflectiveLoadTimeWeaverTests.java index 4ed15afb7be..448f71572ac 100644 --- a/spring-context/src/test/java/org/springframework/instrument/classloading/ReflectiveLoadTimeWeaverTests.java +++ b/spring-context/src/test/java/org/springframework/instrument/classloading/ReflectiveLoadTimeWeaverTests.java @@ -19,7 +19,7 @@ package org.springframework.instrument.classloading; import java.lang.instrument.ClassFileTransformer; import java.security.ProtectionDomain; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-context/src/test/java/org/springframework/instrument/classloading/ResourceOverridingShadowingClassLoaderTests.java b/spring-context/src/test/java/org/springframework/instrument/classloading/ResourceOverridingShadowingClassLoaderTests.java index 3e31bb4bb6f..86d5a692450 100644 --- a/spring-context/src/test/java/org/springframework/instrument/classloading/ResourceOverridingShadowingClassLoaderTests.java +++ b/spring-context/src/test/java/org/springframework/instrument/classloading/ResourceOverridingShadowingClassLoaderTests.java @@ -19,7 +19,7 @@ package org.springframework.instrument.classloading; import java.io.IOException; import java.util.Enumeration; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/jmx/AbstractMBeanServerTests.java b/spring-context/src/test/java/org/springframework/jmx/AbstractMBeanServerTests.java index ea4b0af3e93..6b7f11b98c8 100644 --- a/spring-context/src/test/java/org/springframework/jmx/AbstractMBeanServerTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/AbstractMBeanServerTests.java @@ -20,8 +20,8 @@ import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import javax.management.ObjectName; -import org.junit.After; -import org.junit.Before; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import org.springframework.context.ConfigurableApplicationContext; @@ -55,7 +55,7 @@ public abstract class AbstractMBeanServerTests { protected MBeanServer server; - @Before + @BeforeEach public final void setUp() throws Exception { this.server = MBeanServerFactory.createMBeanServer(); try { @@ -75,7 +75,7 @@ public abstract class AbstractMBeanServerTests { return ctx; } - @After + @AfterEach public void tearDown() throws Exception { releaseServer(); onTearDown(); diff --git a/spring-context/src/test/java/org/springframework/jmx/access/MBeanClientInterceptorTests.java b/spring-context/src/test/java/org/springframework/jmx/access/MBeanClientInterceptorTests.java index ab5c628fb10..b4a352daeb3 100644 --- a/spring-context/src/test/java/org/springframework/jmx/access/MBeanClientInterceptorTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/access/MBeanClientInterceptorTests.java @@ -27,7 +27,7 @@ import javax.management.remote.JMXConnectorServer; import javax.management.remote.JMXConnectorServerFactory; import javax.management.remote.JMXServiceURL; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.jmx.AbstractMBeanServerTests; import org.springframework.jmx.IJmxTestBean; diff --git a/spring-context/src/test/java/org/springframework/jmx/access/RemoteMBeanClientInterceptorTests.java b/spring-context/src/test/java/org/springframework/jmx/access/RemoteMBeanClientInterceptorTests.java index 628aac0b096..312ed0984c8 100644 --- a/spring-context/src/test/java/org/springframework/jmx/access/RemoteMBeanClientInterceptorTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/access/RemoteMBeanClientInterceptorTests.java @@ -25,7 +25,7 @@ import javax.management.remote.JMXConnectorServer; import javax.management.remote.JMXConnectorServerFactory; import javax.management.remote.JMXServiceURL; -import org.junit.After; +import org.junit.jupiter.api.AfterEach; import org.springframework.util.SocketUtils; @@ -75,7 +75,7 @@ public class RemoteMBeanClientInterceptorTests extends MBeanClientInterceptorTes return this.connector.getMBeanServerConnection(); } - @After + @AfterEach @Override public void tearDown() throws Exception { if (this.connector != null) { diff --git a/spring-context/src/test/java/org/springframework/jmx/export/CustomEditorConfigurerTests.java b/spring-context/src/test/java/org/springframework/jmx/export/CustomEditorConfigurerTests.java index 5f4a71b7afa..7a11f7b72f2 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/CustomEditorConfigurerTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/CustomEditorConfigurerTests.java @@ -21,7 +21,7 @@ import java.text.SimpleDateFormat; import java.util.Date; import javax.management.ObjectName; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.jmx.AbstractJmxTests; diff --git a/spring-context/src/test/java/org/springframework/jmx/export/LazyInitMBeanTests.java b/spring-context/src/test/java/org/springframework/jmx/export/LazyInitMBeanTests.java index 0b45b86871b..83335785232 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/LazyInitMBeanTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/LazyInitMBeanTests.java @@ -19,7 +19,7 @@ package org.springframework.jmx.export; import javax.management.MBeanServer; import javax.management.ObjectName; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.jmx.support.ObjectNameManager; diff --git a/spring-context/src/test/java/org/springframework/jmx/export/MBeanExporterOperationsTests.java b/spring-context/src/test/java/org/springframework/jmx/export/MBeanExporterOperationsTests.java index a970dadfef1..2fc032ef7ec 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/MBeanExporterOperationsTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/MBeanExporterOperationsTests.java @@ -23,7 +23,7 @@ import javax.management.modelmbean.ModelMBeanInfo; import javax.management.modelmbean.ModelMBeanInfoSupport; import javax.management.modelmbean.RequiredModelMBean; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.jmx.AbstractMBeanServerTests; import org.springframework.jmx.JmxTestBean; diff --git a/spring-context/src/test/java/org/springframework/jmx/export/MBeanExporterTests.java b/spring-context/src/test/java/org/springframework/jmx/export/MBeanExporterTests.java index 09e2954bab9..477e67788c9 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/MBeanExporterTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/MBeanExporterTests.java @@ -34,7 +34,7 @@ import javax.management.ObjectInstance; import javax.management.ObjectName; import javax.management.modelmbean.ModelMBeanInfo; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.framework.ProxyFactory; import org.springframework.beans.factory.FactoryBean; diff --git a/spring-context/src/test/java/org/springframework/jmx/export/NotificationListenerTests.java b/spring-context/src/test/java/org/springframework/jmx/export/NotificationListenerTests.java index edd2c178d4d..cbc2bd74eb4 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/NotificationListenerTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/NotificationListenerTests.java @@ -26,7 +26,7 @@ import javax.management.NotificationFilter; import javax.management.NotificationListener; import javax.management.ObjectName; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.jmx.AbstractMBeanServerTests; diff --git a/spring-context/src/test/java/org/springframework/jmx/export/NotificationPublisherTests.java b/spring-context/src/test/java/org/springframework/jmx/export/NotificationPublisherTests.java index 49334a42467..786c608c2a5 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/NotificationPublisherTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/NotificationPublisherTests.java @@ -32,7 +32,7 @@ import javax.management.NotificationBroadcasterSupport; import javax.management.NotificationListener; import javax.management.ReflectionException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.jmx.AbstractMBeanServerTests; diff --git a/spring-context/src/test/java/org/springframework/jmx/export/PropertyPlaceholderConfigurerTests.java b/spring-context/src/test/java/org/springframework/jmx/export/PropertyPlaceholderConfigurerTests.java index 3e5aa271a2d..5068ed7f5b6 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/PropertyPlaceholderConfigurerTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/PropertyPlaceholderConfigurerTests.java @@ -18,7 +18,7 @@ package org.springframework.jmx.export; import javax.management.ObjectName; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.jmx.AbstractJmxTests; import org.springframework.jmx.IJmxTestBean; diff --git a/spring-context/src/test/java/org/springframework/jmx/export/annotation/AnnotationLazyInitMBeanTests.java b/spring-context/src/test/java/org/springframework/jmx/export/annotation/AnnotationLazyInitMBeanTests.java index 0f1a355359d..04e5134b21b 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/annotation/AnnotationLazyInitMBeanTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/annotation/AnnotationLazyInitMBeanTests.java @@ -19,7 +19,7 @@ package org.springframework.jmx.export.annotation; import javax.management.MBeanServer; import javax.management.ObjectName; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; diff --git a/spring-context/src/test/java/org/springframework/jmx/export/annotation/AnnotationMetadataAssemblerTests.java b/spring-context/src/test/java/org/springframework/jmx/export/annotation/AnnotationMetadataAssemblerTests.java index 34556d09f62..e58d826c4fa 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/annotation/AnnotationMetadataAssemblerTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/annotation/AnnotationMetadataAssemblerTests.java @@ -20,7 +20,7 @@ import javax.management.modelmbean.ModelMBeanAttributeInfo; import javax.management.modelmbean.ModelMBeanInfo; import javax.management.modelmbean.ModelMBeanOperationInfo; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.jmx.IJmxTestBean; import org.springframework.jmx.export.assembler.AbstractMetadataAssemblerTests; diff --git a/spring-context/src/test/java/org/springframework/jmx/export/annotation/EnableMBeanExportConfigurationTests.java b/spring-context/src/test/java/org/springframework/jmx/export/annotation/EnableMBeanExportConfigurationTests.java index e68e411b394..5d7f8998a80 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/annotation/EnableMBeanExportConfigurationTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/annotation/EnableMBeanExportConfigurationTests.java @@ -19,8 +19,8 @@ package org.springframework.jmx.export.annotation; import javax.management.MBeanServer; import javax.management.ObjectName; -import org.junit.After; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; @@ -54,7 +54,7 @@ public class EnableMBeanExportConfigurationTests { private AnnotationConfigApplicationContext ctx; - @After + @AfterEach public void closeContext() { if (this.ctx != null) { this.ctx.close(); diff --git a/spring-context/src/test/java/org/springframework/jmx/export/annotation/JmxUtilsAnnotationTests.java b/spring-context/src/test/java/org/springframework/jmx/export/annotation/JmxUtilsAnnotationTests.java index b7f6135ac54..b96118a8820 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/annotation/JmxUtilsAnnotationTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/annotation/JmxUtilsAnnotationTests.java @@ -18,7 +18,7 @@ package org.springframework.jmx.export.annotation; import javax.management.MXBean; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.jmx.support.JmxUtils; diff --git a/spring-context/src/test/java/org/springframework/jmx/export/assembler/AbstractAutodetectTests.java b/spring-context/src/test/java/org/springframework/jmx/export/assembler/AbstractAutodetectTests.java index b57362bcd75..5b4933b3e97 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/assembler/AbstractAutodetectTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/assembler/AbstractAutodetectTests.java @@ -16,7 +16,7 @@ package org.springframework.jmx.export.assembler; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.jmx.JmxTestBean; diff --git a/spring-context/src/test/java/org/springframework/jmx/export/assembler/AbstractJmxAssemblerTests.java b/spring-context/src/test/java/org/springframework/jmx/export/assembler/AbstractJmxAssemblerTests.java index 5d7caaf1487..26a8b0defff 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/assembler/AbstractJmxAssemblerTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/assembler/AbstractJmxAssemblerTests.java @@ -28,7 +28,7 @@ import javax.management.modelmbean.ModelMBeanAttributeInfo; import javax.management.modelmbean.ModelMBeanInfo; import javax.management.modelmbean.ModelMBeanOperationInfo; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.jmx.AbstractJmxTests; import org.springframework.jmx.IJmxTestBean; diff --git a/spring-context/src/test/java/org/springframework/jmx/export/assembler/AbstractMetadataAssemblerTests.java b/spring-context/src/test/java/org/springframework/jmx/export/assembler/AbstractMetadataAssemblerTests.java index 66863ee8339..ceae3cbd884 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/assembler/AbstractMetadataAssemblerTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/assembler/AbstractMetadataAssemblerTests.java @@ -25,7 +25,7 @@ import javax.management.modelmbean.ModelMBeanAttributeInfo; import javax.management.modelmbean.ModelMBeanInfo; import javax.management.modelmbean.ModelMBeanOperationInfo; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.framework.ProxyFactory; import org.springframework.jmx.IJmxTestBean; diff --git a/spring-context/src/test/java/org/springframework/jmx/export/assembler/InterfaceBasedMBeanInfoAssemblerCustomTests.java b/spring-context/src/test/java/org/springframework/jmx/export/assembler/InterfaceBasedMBeanInfoAssemblerCustomTests.java index 241a4bbdeba..a3a2a808252 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/assembler/InterfaceBasedMBeanInfoAssemblerCustomTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/assembler/InterfaceBasedMBeanInfoAssemblerCustomTests.java @@ -19,7 +19,7 @@ package org.springframework.jmx.export.assembler; import javax.management.modelmbean.ModelMBeanAttributeInfo; import javax.management.modelmbean.ModelMBeanInfo; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/jmx/export/assembler/InterfaceBasedMBeanInfoAssemblerMappedTests.java b/spring-context/src/test/java/org/springframework/jmx/export/assembler/InterfaceBasedMBeanInfoAssemblerMappedTests.java index 584085edeec..474d264b455 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/assembler/InterfaceBasedMBeanInfoAssemblerMappedTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/assembler/InterfaceBasedMBeanInfoAssemblerMappedTests.java @@ -21,7 +21,7 @@ import javax.management.MBeanAttributeInfo; import javax.management.modelmbean.ModelMBeanAttributeInfo; import javax.management.modelmbean.ModelMBeanInfo; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssemblerComboTests.java b/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssemblerComboTests.java index 0f1bc4c949b..3347a8f4ebf 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssemblerComboTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssemblerComboTests.java @@ -21,7 +21,7 @@ import javax.management.MBeanAttributeInfo; import javax.management.modelmbean.ModelMBeanAttributeInfo; import javax.management.modelmbean.ModelMBeanInfo; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssemblerMappedTests.java b/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssemblerMappedTests.java index 927d337ab47..f5290b6d8b7 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssemblerMappedTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssemblerMappedTests.java @@ -21,7 +21,7 @@ import javax.management.MBeanAttributeInfo; import javax.management.modelmbean.ModelMBeanAttributeInfo; import javax.management.modelmbean.ModelMBeanInfo; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssemblerNotMappedTests.java b/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssemblerNotMappedTests.java index f20181d9dee..83c02d28054 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssemblerNotMappedTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssemblerNotMappedTests.java @@ -21,7 +21,7 @@ import javax.management.MBeanAttributeInfo; import javax.management.modelmbean.ModelMBeanAttributeInfo; import javax.management.modelmbean.ModelMBeanInfo; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssemblerTests.java b/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssemblerTests.java index 7fb37d4bf37..60621fa2053 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssemblerTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodExclusionMBeanInfoAssemblerTests.java @@ -21,7 +21,7 @@ import java.util.Properties; import javax.management.modelmbean.ModelMBeanAttributeInfo; import javax.management.modelmbean.ModelMBeanInfo; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.jmx.JmxTestBean; diff --git a/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodNameBasedMBeanInfoAssemblerMappedTests.java b/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodNameBasedMBeanInfoAssemblerMappedTests.java index 786bbdd2195..2f95af580b5 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodNameBasedMBeanInfoAssemblerMappedTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodNameBasedMBeanInfoAssemblerMappedTests.java @@ -21,7 +21,7 @@ import javax.management.MBeanAttributeInfo; import javax.management.modelmbean.ModelMBeanAttributeInfo; import javax.management.modelmbean.ModelMBeanInfo; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodNameBasedMBeanInfoAssemblerTests.java b/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodNameBasedMBeanInfoAssemblerTests.java index c7c00034043..f287abb69ef 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodNameBasedMBeanInfoAssemblerTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/assembler/MethodNameBasedMBeanInfoAssemblerTests.java @@ -20,7 +20,7 @@ import javax.management.MBeanOperationInfo; import javax.management.modelmbean.ModelMBeanAttributeInfo; import javax.management.modelmbean.ModelMBeanInfo; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/jmx/export/naming/AbstractNamingStrategyTests.java b/spring-context/src/test/java/org/springframework/jmx/export/naming/AbstractNamingStrategyTests.java index c85496c0f89..404c7df367b 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/naming/AbstractNamingStrategyTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/naming/AbstractNamingStrategyTests.java @@ -18,7 +18,7 @@ package org.springframework.jmx.export.naming; import javax.management.ObjectName; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/jmx/export/naming/IdentityNamingStrategyTests.java b/spring-context/src/test/java/org/springframework/jmx/export/naming/IdentityNamingStrategyTests.java index 4571ccb8e89..3aa4baa2053 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/naming/IdentityNamingStrategyTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/naming/IdentityNamingStrategyTests.java @@ -19,7 +19,7 @@ package org.springframework.jmx.export.naming; import javax.management.MalformedObjectNameException; import javax.management.ObjectName; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.jmx.JmxTestBean; import org.springframework.util.ClassUtils; diff --git a/spring-context/src/test/java/org/springframework/jmx/export/notification/ModelMBeanNotificationPublisherTests.java b/spring-context/src/test/java/org/springframework/jmx/export/notification/ModelMBeanNotificationPublisherTests.java index 92b5275bd5e..b8d28a9b23d 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/notification/ModelMBeanNotificationPublisherTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/notification/ModelMBeanNotificationPublisherTests.java @@ -23,7 +23,7 @@ import javax.management.Notification; import javax.management.ObjectName; import javax.management.RuntimeOperationsException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.jmx.export.SpringModelMBean; diff --git a/spring-context/src/test/java/org/springframework/jmx/support/ConnectorServerFactoryBeanTests.java b/spring-context/src/test/java/org/springframework/jmx/support/ConnectorServerFactoryBeanTests.java index 03bc5d5d45c..6a77b6c9681 100644 --- a/spring-context/src/test/java/org/springframework/jmx/support/ConnectorServerFactoryBeanTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/support/ConnectorServerFactoryBeanTests.java @@ -27,7 +27,7 @@ import javax.management.remote.JMXConnector; import javax.management.remote.JMXConnectorFactory; import javax.management.remote.JMXServiceURL; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.jmx.AbstractMBeanServerTests; diff --git a/spring-context/src/test/java/org/springframework/jmx/support/JmxUtilsTests.java b/spring-context/src/test/java/org/springframework/jmx/support/JmxUtilsTests.java index 70867a89137..b0ffc28e612 100644 --- a/spring-context/src/test/java/org/springframework/jmx/support/JmxUtilsTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/support/JmxUtilsTests.java @@ -25,7 +25,7 @@ import javax.management.NotCompliantMBeanException; import javax.management.ObjectName; import javax.management.StandardMBean; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.BeanWrapperImpl; import org.springframework.jmx.IJmxTestBean; diff --git a/spring-context/src/test/java/org/springframework/jmx/support/MBeanServerConnectionFactoryBeanTests.java b/spring-context/src/test/java/org/springframework/jmx/support/MBeanServerConnectionFactoryBeanTests.java index 1fb9add38d9..3b59c4f9daa 100644 --- a/spring-context/src/test/java/org/springframework/jmx/support/MBeanServerConnectionFactoryBeanTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/support/MBeanServerConnectionFactoryBeanTests.java @@ -22,7 +22,7 @@ import javax.management.remote.JMXConnectorServer; import javax.management.remote.JMXConnectorServerFactory; import javax.management.remote.JMXServiceURL; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.support.AopUtils; import org.springframework.jmx.AbstractMBeanServerTests; diff --git a/spring-context/src/test/java/org/springframework/jmx/support/MBeanServerFactoryBeanTests.java b/spring-context/src/test/java/org/springframework/jmx/support/MBeanServerFactoryBeanTests.java index 1fa9022a0af..a0c0ab385ac 100644 --- a/spring-context/src/test/java/org/springframework/jmx/support/MBeanServerFactoryBeanTests.java +++ b/spring-context/src/test/java/org/springframework/jmx/support/MBeanServerFactoryBeanTests.java @@ -21,9 +21,9 @@ import java.util.List; import javax.management.MBeanServer; import javax.management.MBeanServerFactory; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.util.MBeanTestUtils; @@ -37,13 +37,13 @@ import static org.assertj.core.api.Assertions.assertThat; public class MBeanServerFactoryBeanTests { - @Before + @BeforeEach public void setUp() throws Exception { MBeanTestUtils.resetMBeanServers(); } - @After + @AfterEach public void tearDown() throws Exception { MBeanTestUtils.resetMBeanServers(); } diff --git a/spring-context/src/test/java/org/springframework/jndi/JndiLocatorDelegateTests.java b/spring-context/src/test/java/org/springframework/jndi/JndiLocatorDelegateTests.java index 8b7c869d88f..de9afad329e 100644 --- a/spring-context/src/test/java/org/springframework/jndi/JndiLocatorDelegateTests.java +++ b/spring-context/src/test/java/org/springframework/jndi/JndiLocatorDelegateTests.java @@ -19,7 +19,7 @@ package org.springframework.jndi; import java.lang.reflect.Field; import javax.naming.spi.NamingManager; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/jndi/JndiObjectFactoryBeanTests.java b/spring-context/src/test/java/org/springframework/jndi/JndiObjectFactoryBeanTests.java index a769de951fd..0483dd68243 100644 --- a/spring-context/src/test/java/org/springframework/jndi/JndiObjectFactoryBeanTests.java +++ b/spring-context/src/test/java/org/springframework/jndi/JndiObjectFactoryBeanTests.java @@ -19,7 +19,7 @@ package org.springframework.jndi; import javax.naming.Context; import javax.naming.NamingException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.tests.mock.jndi.ExpectedLookupTemplate; diff --git a/spring-context/src/test/java/org/springframework/jndi/JndiPropertySourceTests.java b/spring-context/src/test/java/org/springframework/jndi/JndiPropertySourceTests.java index 2c0ff609839..9ea45ecefce 100644 --- a/spring-context/src/test/java/org/springframework/jndi/JndiPropertySourceTests.java +++ b/spring-context/src/test/java/org/springframework/jndi/JndiPropertySourceTests.java @@ -19,7 +19,7 @@ package org.springframework.jndi; import javax.naming.Context; import javax.naming.NamingException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.tests.mock.jndi.SimpleNamingContext; diff --git a/spring-context/src/test/java/org/springframework/jndi/JndiTemplateEditorTests.java b/spring-context/src/test/java/org/springframework/jndi/JndiTemplateEditorTests.java index 695d2e3cda9..ab6980725d4 100644 --- a/spring-context/src/test/java/org/springframework/jndi/JndiTemplateEditorTests.java +++ b/spring-context/src/test/java/org/springframework/jndi/JndiTemplateEditorTests.java @@ -16,7 +16,7 @@ package org.springframework.jndi; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-context/src/test/java/org/springframework/jndi/JndiTemplateTests.java b/spring-context/src/test/java/org/springframework/jndi/JndiTemplateTests.java index ddf504d4fb8..5cb91731efe 100644 --- a/spring-context/src/test/java/org/springframework/jndi/JndiTemplateTests.java +++ b/spring-context/src/test/java/org/springframework/jndi/JndiTemplateTests.java @@ -19,7 +19,7 @@ package org.springframework.jndi; import javax.naming.Context; import javax.naming.NameNotFoundException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-context/src/test/java/org/springframework/jndi/SimpleNamingContextTests.java b/spring-context/src/test/java/org/springframework/jndi/SimpleNamingContextTests.java index c4265263876..3f34deaae68 100644 --- a/spring-context/src/test/java/org/springframework/jndi/SimpleNamingContextTests.java +++ b/spring-context/src/test/java/org/springframework/jndi/SimpleNamingContextTests.java @@ -33,7 +33,7 @@ import javax.naming.NamingException; import javax.naming.spi.InitialContextFactory; import javax.sql.DataSource; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.tests.mock.jndi.SimpleNamingContext; import org.springframework.tests.mock.jndi.SimpleNamingContextBuilder; diff --git a/spring-context/src/test/java/org/springframework/remoting/rmi/RmiSupportTests.java b/spring-context/src/test/java/org/springframework/remoting/rmi/RmiSupportTests.java index 87faf4e2c61..1e3dffcf0e6 100644 --- a/spring-context/src/test/java/org/springframework/remoting/rmi/RmiSupportTests.java +++ b/spring-context/src/test/java/org/springframework/remoting/rmi/RmiSupportTests.java @@ -30,7 +30,7 @@ import java.rmi.UnknownHostException; import java.rmi.UnmarshalException; import org.aopalliance.intercept.MethodInvocation; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.remoting.RemoteAccessException; import org.springframework.remoting.RemoteConnectFailureException; diff --git a/spring-context/src/test/java/org/springframework/remoting/support/RemoteInvocationUtilsTests.java b/spring-context/src/test/java/org/springframework/remoting/support/RemoteInvocationUtilsTests.java index b00a76e9b7d..dbaa7a42944 100644 --- a/spring-context/src/test/java/org/springframework/remoting/support/RemoteInvocationUtilsTests.java +++ b/spring-context/src/test/java/org/springframework/remoting/support/RemoteInvocationUtilsTests.java @@ -16,7 +16,7 @@ package org.springframework.remoting.support; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/scheduling/annotation/AnnotationAsyncExecutionInterceptorTests.java b/spring-context/src/test/java/org/springframework/scheduling/annotation/AnnotationAsyncExecutionInterceptorTests.java index 40edfc38843..51566b02293 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/annotation/AnnotationAsyncExecutionInterceptorTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/annotation/AnnotationAsyncExecutionInterceptorTests.java @@ -19,7 +19,7 @@ package org.springframework.scheduling.annotation; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-context/src/test/java/org/springframework/scheduling/annotation/AsyncAnnotationBeanPostProcessorTests.java b/spring-context/src/test/java/org/springframework/scheduling/annotation/AsyncAnnotationBeanPostProcessorTests.java index 1106ba51b8e..477a97dec3d 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/annotation/AsyncAnnotationBeanPostProcessorTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/annotation/AsyncAnnotationBeanPostProcessorTests.java @@ -24,7 +24,7 @@ import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import org.aopalliance.intercept.MethodInterceptor; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.framework.ProxyFactory; import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler; diff --git a/spring-context/src/test/java/org/springframework/scheduling/annotation/AsyncExecutionTests.java b/spring-context/src/test/java/org/springframework/scheduling/annotation/AsyncExecutionTests.java index d4f41029c9d..691ce11ac92 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/annotation/AsyncExecutionTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/annotation/AsyncExecutionTests.java @@ -29,7 +29,7 @@ import java.util.concurrent.TimeUnit; import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInvocation; import org.awaitility.Awaitility; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.framework.ProxyFactory; import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator; diff --git a/spring-context/src/test/java/org/springframework/scheduling/annotation/AsyncResultTests.java b/spring-context/src/test/java/org/springframework/scheduling/annotation/AsyncResultTests.java index fc9cecc0866..6b4f67a0b30 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/annotation/AsyncResultTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/annotation/AsyncResultTests.java @@ -21,7 +21,7 @@ import java.util.HashSet; import java.util.Set; import java.util.concurrent.ExecutionException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.util.concurrent.ListenableFuture; import org.springframework.util.concurrent.ListenableFutureCallback; diff --git a/spring-context/src/test/java/org/springframework/scheduling/annotation/EnableAsyncTests.java b/spring-context/src/test/java/org/springframework/scheduling/annotation/EnableAsyncTests.java index b1352508ed8..e60333950f4 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/annotation/EnableAsyncTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/annotation/EnableAsyncTests.java @@ -28,7 +28,7 @@ import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import org.awaitility.Awaitility; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.springframework.aop.Advisor; diff --git a/spring-context/src/test/java/org/springframework/scheduling/annotation/EnableSchedulingTests.java b/spring-context/src/test/java/org/springframework/scheduling/annotation/EnableSchedulingTests.java index 564303d4373..a82f58ddafe 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/annotation/EnableSchedulingTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/annotation/EnableSchedulingTests.java @@ -20,8 +20,8 @@ import java.util.Arrays; import java.util.Date; import java.util.concurrent.atomic.AtomicInteger; -import org.junit.After; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; @@ -49,7 +49,7 @@ public class EnableSchedulingTests { private AnnotationConfigApplicationContext ctx; - @After + @AfterEach public void tearDown() { if (ctx != null) { ctx.close(); diff --git a/spring-context/src/test/java/org/springframework/scheduling/annotation/ScheduledAnnotationBeanPostProcessorTests.java b/spring-context/src/test/java/org/springframework/scheduling/annotation/ScheduledAnnotationBeanPostProcessorTests.java index 5aacb9c4914..84291007022 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/annotation/ScheduledAnnotationBeanPostProcessorTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/annotation/ScheduledAnnotationBeanPostProcessorTests.java @@ -30,8 +30,8 @@ import java.util.Map; import java.util.Properties; import java.util.TimeZone; -import org.junit.After; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; import org.springframework.aop.framework.ProxyFactory; import org.springframework.aop.scope.ScopedProxyUtils; @@ -73,7 +73,7 @@ public class ScheduledAnnotationBeanPostProcessorTests { private final StaticApplicationContext context = new StaticApplicationContext(); - @After + @AfterEach public void closeContextAfterTest() { context.close(); } diff --git a/spring-context/src/test/java/org/springframework/scheduling/concurrent/AbstractSchedulingTaskExecutorTests.java b/spring-context/src/test/java/org/springframework/scheduling/concurrent/AbstractSchedulingTaskExecutorTests.java index ed8d839f3b4..d4aa11504be 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/concurrent/AbstractSchedulingTaskExecutorTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/concurrent/AbstractSchedulingTaskExecutorTests.java @@ -25,9 +25,9 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import org.awaitility.Awaitility; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.DisposableBean; import org.springframework.core.task.AsyncListenableTaskExecutor; @@ -50,14 +50,14 @@ public abstract class AbstractSchedulingTaskExecutorTests { private volatile Object outcome; - @Before + @BeforeEach public void initExecutor() { executor = buildExecutor(); } protected abstract AsyncListenableTaskExecutor buildExecutor(); - @After + @AfterEach public void shutdownExecutor() throws Exception { if (executor instanceof DisposableBean) { ((DisposableBean) executor).destroy(); diff --git a/spring-context/src/test/java/org/springframework/scheduling/concurrent/ConcurrentTaskExecutorTests.java b/spring-context/src/test/java/org/springframework/scheduling/concurrent/ConcurrentTaskExecutorTests.java index 6c867d87c07..48e02e1ebeb 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/concurrent/ConcurrentTaskExecutorTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/concurrent/ConcurrentTaskExecutorTests.java @@ -22,7 +22,7 @@ import java.util.concurrent.RunnableFuture; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.task.AsyncListenableTaskExecutor; import org.springframework.core.task.NoOpRunnable; diff --git a/spring-context/src/test/java/org/springframework/scheduling/concurrent/ScheduledExecutorFactoryBeanTests.java b/spring-context/src/test/java/org/springframework/scheduling/concurrent/ScheduledExecutorFactoryBeanTests.java index 424ef91aae7..f930921a1e2 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/concurrent/ScheduledExecutorFactoryBeanTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/concurrent/ScheduledExecutorFactoryBeanTests.java @@ -20,8 +20,8 @@ import java.util.concurrent.RejectedExecutionHandler; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ThreadFactory; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.springframework.core.task.NoOpRunnable; import org.springframework.tests.Assume; @@ -146,7 +146,7 @@ public class ScheduledExecutorFactoryBeanTests { verify(runnable, atLeast(2)).run(); } - @Ignore + @Disabled @Test public void testWithInitialDelayRepeatedExecutionIsSetUpAndFiresCorrectly() throws Exception { Runnable runnable = mock(Runnable.class); @@ -166,7 +166,7 @@ public class ScheduledExecutorFactoryBeanTests { verify(runnable, never()).run(); } - @Ignore + @Disabled @Test public void testWithInitialDelayRepeatedExecutionIsSetUpAndFiresCorrectlyAfterException() throws Exception { Runnable runnable = mock(Runnable.class); diff --git a/spring-context/src/test/java/org/springframework/scheduling/concurrent/ThreadPoolExecutorFactoryBeanTests.java b/spring-context/src/test/java/org/springframework/scheduling/concurrent/ThreadPoolExecutorFactoryBeanTests.java index 322578efd9c..35e632bae4b 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/concurrent/ThreadPoolExecutorFactoryBeanTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/concurrent/ThreadPoolExecutorFactoryBeanTests.java @@ -19,7 +19,7 @@ package org.springframework.scheduling.concurrent; import java.util.concurrent.ExecutorService; import java.util.concurrent.FutureTask; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; diff --git a/spring-context/src/test/java/org/springframework/scheduling/concurrent/ThreadPoolTaskSchedulerTests.java b/spring-context/src/test/java/org/springframework/scheduling/concurrent/ThreadPoolTaskSchedulerTests.java index fefb94aa1c4..87fe3d4132c 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/concurrent/ThreadPoolTaskSchedulerTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/concurrent/ThreadPoolTaskSchedulerTests.java @@ -24,7 +24,7 @@ import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.task.AsyncListenableTaskExecutor; import org.springframework.scheduling.Trigger; diff --git a/spring-context/src/test/java/org/springframework/scheduling/config/AnnotationDrivenBeanDefinitionParserTests.java b/spring-context/src/test/java/org/springframework/scheduling/config/AnnotationDrivenBeanDefinitionParserTests.java index 759f24b433c..cd7e0d8037d 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/config/AnnotationDrivenBeanDefinitionParserTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/config/AnnotationDrivenBeanDefinitionParserTests.java @@ -18,8 +18,8 @@ package org.springframework.scheduling.config; import java.util.function.Supplier; -import org.junit.After; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.DirectFieldAccessor; import org.springframework.context.ConfigurableApplicationContext; @@ -37,7 +37,7 @@ public class AnnotationDrivenBeanDefinitionParserTests { "annotationDrivenContext.xml", AnnotationDrivenBeanDefinitionParserTests.class); - @After + @AfterEach public void closeApplicationContext() { context.close(); } diff --git a/spring-context/src/test/java/org/springframework/scheduling/config/ExecutorBeanDefinitionParserTests.java b/spring-context/src/test/java/org/springframework/scheduling/config/ExecutorBeanDefinitionParserTests.java index 2919a286217..a52f768abdc 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/config/ExecutorBeanDefinitionParserTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/config/ExecutorBeanDefinitionParserTests.java @@ -20,8 +20,8 @@ import java.util.concurrent.Callable; import java.util.concurrent.Executor; import java.util.concurrent.FutureTask; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.DirectFieldAccessor; import org.springframework.beans.factory.BeanCreationException; @@ -43,7 +43,7 @@ public class ExecutorBeanDefinitionParserTests { private ApplicationContext context; - @Before + @BeforeEach public void setup() { this.context = new ClassPathXmlApplicationContext( "executorContext.xml", ExecutorBeanDefinitionParserTests.class); diff --git a/spring-context/src/test/java/org/springframework/scheduling/config/LazyScheduledTasksBeanDefinitionParserTests.java b/spring-context/src/test/java/org/springframework/scheduling/config/LazyScheduledTasksBeanDefinitionParserTests.java index 6f7be728acd..4a7f9d70996 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/config/LazyScheduledTasksBeanDefinitionParserTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/config/LazyScheduledTasksBeanDefinitionParserTests.java @@ -16,8 +16,10 @@ package org.springframework.scheduling.config; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Timeout; +import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.support.GenericXmlApplicationContext; /** @@ -27,23 +29,26 @@ import org.springframework.context.support.GenericXmlApplicationContext; * * @author Mike Youngstrom * @author Chris Beams + * @author Sam Brannen */ -public class LazyScheduledTasksBeanDefinitionParserTests { - - @Test(timeout = 5000) - @SuppressWarnings("resource") - public void checkTarget() { - Task task = - new GenericXmlApplicationContext( - LazyScheduledTasksBeanDefinitionParserTests.class, - "lazyScheduledTasksContext.xml") - .getBean(Task.class); - - while (!task.executed) { - try { - Thread.sleep(10); +class LazyScheduledTasksBeanDefinitionParserTests { + + @Test + @Timeout(5) + void checkTarget() { + try (ConfigurableApplicationContext applicationContext = + new GenericXmlApplicationContext(getClass(), "lazyScheduledTasksContext.xml")) { + + Task task = applicationContext.getBean(Task.class); + + while (!task.executed) { + try { + Thread.sleep(10); + } + catch (Exception ex) { + /* Do Nothing */ + } } - catch (Exception ex) { /* Do Nothing */ } } } diff --git a/spring-context/src/test/java/org/springframework/scheduling/config/ScheduledTaskRegistrarTests.java b/spring-context/src/test/java/org/springframework/scheduling/config/ScheduledTaskRegistrarTests.java index 832a9bd45e3..2b787b08b7d 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/config/ScheduledTaskRegistrarTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/config/ScheduledTaskRegistrarTests.java @@ -19,7 +19,7 @@ package org.springframework.scheduling.config; import java.util.Collections; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; diff --git a/spring-context/src/test/java/org/springframework/scheduling/config/ScheduledTasksBeanDefinitionParserTests.java b/spring-context/src/test/java/org/springframework/scheduling/config/ScheduledTasksBeanDefinitionParserTests.java index ce2e34440e6..16879f1e796 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/config/ScheduledTasksBeanDefinitionParserTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/config/ScheduledTasksBeanDefinitionParserTests.java @@ -20,8 +20,8 @@ import java.lang.reflect.Method; import java.util.Date; import java.util.List; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.DirectFieldAccessor; import org.springframework.context.ApplicationContext; @@ -46,7 +46,7 @@ public class ScheduledTasksBeanDefinitionParserTests { private Object testBean; - @Before + @BeforeEach public void setup() { this.context = new ClassPathXmlApplicationContext( "scheduledTasksContext.xml", ScheduledTasksBeanDefinitionParserTests.class); diff --git a/spring-context/src/test/java/org/springframework/scheduling/config/SchedulerBeanDefinitionParserTests.java b/spring-context/src/test/java/org/springframework/scheduling/config/SchedulerBeanDefinitionParserTests.java index 2649618f2ca..8069ddb5ed0 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/config/SchedulerBeanDefinitionParserTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/config/SchedulerBeanDefinitionParserTests.java @@ -16,8 +16,8 @@ package org.springframework.scheduling.config; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.DirectFieldAccessor; import org.springframework.context.ApplicationContext; @@ -34,7 +34,7 @@ public class SchedulerBeanDefinitionParserTests { private ApplicationContext context; - @Before + @BeforeEach public void setup() { this.context = new ClassPathXmlApplicationContext( "schedulerContext.xml", SchedulerBeanDefinitionParserTests.class); diff --git a/spring-context/src/test/java/org/springframework/scheduling/support/CronSequenceGeneratorTests.java b/spring-context/src/test/java/org/springframework/scheduling/support/CronSequenceGeneratorTests.java index 994b24ec917..fff8b6eeb13 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/support/CronSequenceGeneratorTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/support/CronSequenceGeneratorTests.java @@ -18,7 +18,7 @@ package org.springframework.scheduling.support; import java.util.Date; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-context/src/test/java/org/springframework/scheduling/support/CronTriggerTests.java b/spring-context/src/test/java/org/springframework/scheduling/support/CronTriggerTests.java index afe35ef4178..91843399961 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/support/CronTriggerTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/support/CronTriggerTests.java @@ -16,751 +16,835 @@ package org.springframework.scheduling.support; -import java.util.ArrayList; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; -import java.util.List; import java.util.TimeZone; +import java.util.stream.Stream; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import org.joda.time.LocalDateTime; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.springframework.scheduling.TriggerContext; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; +import static org.junit.jupiter.params.provider.Arguments.arguments; /** + * Unit tests for {@link CronTrigger}. + * * @author Dave Syer * @author Mark Fisher * @author Juergen Hoeller + * @author Sam Brannen */ -@RunWith(Parameterized.class) -public class CronTriggerTests { +class CronTriggerTests { private final Calendar calendar = new GregorianCalendar(); - private final Date date; - - private final TimeZone timeZone; - - - public CronTriggerTests(Date date, TimeZone timeZone) { - this.date = date; - this.timeZone = timeZone; - } - - @Parameters(name = "date [{0}], time zone [{1}]") - public static List getParameters() { - List list = new ArrayList<>(); - list.add(new Object[] { new Date(), TimeZone.getTimeZone("PST") }); - list.add(new Object[] { new Date(), TimeZone.getTimeZone("CET") }); - return list; + private void setUp(LocalDateTime localDateTime, TimeZone timeZone) { + this.calendar.setTimeZone(timeZone); + this.calendar.setTime(localDateTime.toDate()); + roundup(this.calendar); } - private void roundup(Calendar calendar) { - calendar.add(Calendar.SECOND, 1); - calendar.set(Calendar.MILLISECOND, 0); - } + @ParameterizedCronTriggerTest + void testMatchAll(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); - @Before - public void setUp() { - calendar.setTimeZone(timeZone); - calendar.setTime(date); - roundup(calendar); - } - - @Test - public void testMatchAll() throws Exception { CronTrigger trigger = new CronTrigger("* * * * * *", timeZone); - TriggerContext context = getTriggerContext(date); - assertThat(trigger.nextExecutionTime(context)).isEqualTo(calendar.getTime()); + TriggerContext context = getTriggerContext(localDateTime.toDate()); + assertThat(trigger.nextExecutionTime(context)).isEqualTo(this.calendar.getTime()); } - @Test - public void testMatchLastSecond() throws Exception { + @ParameterizedCronTriggerTest + void testMatchLastSecond(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); + CronTrigger trigger = new CronTrigger("* * * * * *", timeZone); GregorianCalendar calendar = new GregorianCalendar(); calendar.set(Calendar.SECOND, 58); assertMatchesNextSecond(trigger, calendar); } - @Test - public void testMatchSpecificSecond() throws Exception { + @ParameterizedCronTriggerTest + void testMatchSpecificSecond(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); + CronTrigger trigger = new CronTrigger("10 * * * * *", timeZone); GregorianCalendar calendar = new GregorianCalendar(); calendar.set(Calendar.SECOND, 9); assertMatchesNextSecond(trigger, calendar); } - @Test - public void testIncrementSecondByOne() throws Exception { + @ParameterizedCronTriggerTest + void testIncrementSecondByOne(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); + CronTrigger trigger = new CronTrigger("11 * * * * *", timeZone); - calendar.set(Calendar.SECOND, 10); - Date date = calendar.getTime(); - calendar.add(Calendar.SECOND, 1); - TriggerContext context = getTriggerContext(date); - assertThat(trigger.nextExecutionTime(context)).isEqualTo(calendar.getTime()); + this.calendar.set(Calendar.SECOND, 10); + Date localDate = this.calendar.getTime(); + this.calendar.add(Calendar.SECOND, 1); + TriggerContext context = getTriggerContext(localDate); + assertThat(trigger.nextExecutionTime(context)).isEqualTo(this.calendar.getTime()); } - @Test - public void testIncrementSecondWithPreviousExecutionTooEarly() throws Exception { + @ParameterizedCronTriggerTest + void testIncrementSecondWithPreviousExecutionTooEarly(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); + CronTrigger trigger = new CronTrigger("11 * * * * *", timeZone); - calendar.set(Calendar.SECOND, 11); + this.calendar.set(Calendar.SECOND, 11); SimpleTriggerContext context = new SimpleTriggerContext(); - context.update(calendar.getTime(), new Date(calendar.getTimeInMillis() - 100), - new Date(calendar.getTimeInMillis() - 90)); - calendar.add(Calendar.MINUTE, 1); - assertThat(trigger.nextExecutionTime(context)).isEqualTo(calendar.getTime()); + context.update(this.calendar.getTime(), new Date(this.calendar.getTimeInMillis() - 100), + new Date(this.calendar.getTimeInMillis() - 90)); + this.calendar.add(Calendar.MINUTE, 1); + assertThat(trigger.nextExecutionTime(context)).isEqualTo(this.calendar.getTime()); } - @Test - public void testIncrementSecondAndRollover() throws Exception { + @ParameterizedCronTriggerTest + void testIncrementSecondAndRollover(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); + CronTrigger trigger = new CronTrigger("10 * * * * *", timeZone); - calendar.set(Calendar.SECOND, 11); - Date date = calendar.getTime(); - calendar.add(Calendar.SECOND, 59); - TriggerContext context = getTriggerContext(date); - assertThat(trigger.nextExecutionTime(context)).isEqualTo(calendar.getTime()); + this.calendar.set(Calendar.SECOND, 11); + Date localDate = this.calendar.getTime(); + this.calendar.add(Calendar.SECOND, 59); + TriggerContext context = getTriggerContext(localDate); + assertThat(trigger.nextExecutionTime(context)).isEqualTo(this.calendar.getTime()); } - @Test - public void testSecondRange() throws Exception { + @ParameterizedCronTriggerTest + void testSecondRange(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); + CronTrigger trigger = new CronTrigger("10-15 * * * * *", timeZone); - calendar.set(Calendar.SECOND, 9); - assertMatchesNextSecond(trigger, calendar); - calendar.set(Calendar.SECOND, 14); - assertMatchesNextSecond(trigger, calendar); + this.calendar.set(Calendar.SECOND, 9); + assertMatchesNextSecond(trigger, this.calendar); + this.calendar.set(Calendar.SECOND, 14); + assertMatchesNextSecond(trigger, this.calendar); } - @Test - public void testIncrementMinute() throws Exception { + @ParameterizedCronTriggerTest + void testIncrementMinute(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); + CronTrigger trigger = new CronTrigger("0 * * * * *", timeZone); - calendar.set(Calendar.MINUTE, 10); - Date date = calendar.getTime(); - calendar.add(Calendar.MINUTE, 1); - calendar.set(Calendar.SECOND, 0); - TriggerContext context1 = getTriggerContext(date); - date = trigger.nextExecutionTime(context1); - assertThat(date).isEqualTo(calendar.getTime()); - calendar.add(Calendar.MINUTE, 1); - TriggerContext context2 = getTriggerContext(date); - date = trigger.nextExecutionTime(context2); - assertThat(date).isEqualTo(calendar.getTime()); - } - - @Test - public void testIncrementMinuteByOne() throws Exception { + this.calendar.set(Calendar.MINUTE, 10); + Date localDate = this.calendar.getTime(); + this.calendar.add(Calendar.MINUTE, 1); + this.calendar.set(Calendar.SECOND, 0); + TriggerContext context1 = getTriggerContext(localDate); + localDate = trigger.nextExecutionTime(context1); + assertThat(localDate).isEqualTo(this.calendar.getTime()); + this.calendar.add(Calendar.MINUTE, 1); + TriggerContext context2 = getTriggerContext(localDate); + localDate = trigger.nextExecutionTime(context2); + assertThat(localDate).isEqualTo(this.calendar.getTime()); + } + + @ParameterizedCronTriggerTest + void testIncrementMinuteByOne(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); + CronTrigger trigger = new CronTrigger("0 11 * * * *", timeZone); - calendar.set(Calendar.MINUTE, 10); - TriggerContext context = getTriggerContext(calendar.getTime()); - calendar.add(Calendar.MINUTE, 1); - calendar.set(Calendar.SECOND, 0); - assertThat(trigger.nextExecutionTime(context)).isEqualTo(calendar.getTime()); + this.calendar.set(Calendar.MINUTE, 10); + TriggerContext context = getTriggerContext(this.calendar.getTime()); + this.calendar.add(Calendar.MINUTE, 1); + this.calendar.set(Calendar.SECOND, 0); + assertThat(trigger.nextExecutionTime(context)).isEqualTo(this.calendar.getTime()); } - @Test - public void testIncrementMinuteAndRollover() throws Exception { + @ParameterizedCronTriggerTest + void testIncrementMinuteAndRollover(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); + CronTrigger trigger = new CronTrigger("0 10 * * * *", timeZone); - calendar.set(Calendar.MINUTE, 11); - calendar.set(Calendar.SECOND, 0); - Date date = calendar.getTime(); - calendar.add(Calendar.MINUTE, 59); - TriggerContext context = getTriggerContext(date); - assertThat(trigger.nextExecutionTime(context)).isEqualTo(calendar.getTime()); + this.calendar.set(Calendar.MINUTE, 11); + this.calendar.set(Calendar.SECOND, 0); + Date localDate = this.calendar.getTime(); + this.calendar.add(Calendar.MINUTE, 59); + TriggerContext context = getTriggerContext(localDate); + assertThat(trigger.nextExecutionTime(context)).isEqualTo(this.calendar.getTime()); } - @Test - public void testIncrementHour() throws Exception { + @ParameterizedCronTriggerTest + void testIncrementHour(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); + CronTrigger trigger = new CronTrigger("0 0 * * * *", timeZone); - calendar.set(Calendar.MONTH, 9); - calendar.set(Calendar.DAY_OF_MONTH, 30); - calendar.set(Calendar.HOUR_OF_DAY, 11); - calendar.set(Calendar.MINUTE, 1); - calendar.set(Calendar.SECOND, 0); - Date date = calendar.getTime(); - calendar.set(Calendar.MINUTE, 0); - calendar.set(Calendar.HOUR_OF_DAY, 12); - TriggerContext context1 = getTriggerContext(date); - Object actual = date = trigger.nextExecutionTime(context1); - assertThat(actual).isEqualTo(calendar.getTime()); - calendar.set(Calendar.HOUR_OF_DAY, 13); - TriggerContext context2 = getTriggerContext(date); - assertThat(trigger.nextExecutionTime(context2)).isEqualTo(calendar.getTime()); - } - - @Test - public void testIncrementHourAndRollover() throws Exception { + this.calendar.set(Calendar.MONTH, 9); + this.calendar.set(Calendar.DAY_OF_MONTH, 30); + this.calendar.set(Calendar.HOUR_OF_DAY, 11); + this.calendar.set(Calendar.MINUTE, 1); + this.calendar.set(Calendar.SECOND, 0); + Date localDate = this.calendar.getTime(); + this.calendar.set(Calendar.MINUTE, 0); + this.calendar.set(Calendar.HOUR_OF_DAY, 12); + TriggerContext context1 = getTriggerContext(localDate); + Object actual = localDate = trigger.nextExecutionTime(context1); + assertThat(actual).isEqualTo(this.calendar.getTime()); + this.calendar.set(Calendar.HOUR_OF_DAY, 13); + TriggerContext context2 = getTriggerContext(localDate); + assertThat(trigger.nextExecutionTime(context2)).isEqualTo(this.calendar.getTime()); + } + + @ParameterizedCronTriggerTest + void testIncrementHourAndRollover(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); + CronTrigger trigger = new CronTrigger("0 0 * * * *", timeZone); - calendar.set(Calendar.MONTH, 9); - calendar.set(Calendar.DAY_OF_MONTH, 10); - calendar.set(Calendar.HOUR_OF_DAY, 23); - calendar.set(Calendar.MINUTE, 1); - calendar.set(Calendar.SECOND, 0); - Date date = calendar.getTime(); - calendar.set(Calendar.MINUTE, 0); - calendar.set(Calendar.HOUR_OF_DAY, 0); - calendar.set(Calendar.DAY_OF_MONTH, 11); - TriggerContext context1 = getTriggerContext(date); - Object actual = date = trigger.nextExecutionTime(context1); - assertThat(actual).isEqualTo(calendar.getTime()); - calendar.set(Calendar.HOUR_OF_DAY, 1); - TriggerContext context2 = getTriggerContext(date); - assertThat(trigger.nextExecutionTime(context2)).isEqualTo(calendar.getTime()); - } - - @Test - public void testIncrementDayOfMonth() throws Exception { + this.calendar.set(Calendar.MONTH, 9); + this.calendar.set(Calendar.DAY_OF_MONTH, 10); + this.calendar.set(Calendar.HOUR_OF_DAY, 23); + this.calendar.set(Calendar.MINUTE, 1); + this.calendar.set(Calendar.SECOND, 0); + Date localDate = this.calendar.getTime(); + this.calendar.set(Calendar.MINUTE, 0); + this.calendar.set(Calendar.HOUR_OF_DAY, 0); + this.calendar.set(Calendar.DAY_OF_MONTH, 11); + TriggerContext context1 = getTriggerContext(localDate); + Object actual = localDate = trigger.nextExecutionTime(context1); + assertThat(actual).isEqualTo(this.calendar.getTime()); + this.calendar.set(Calendar.HOUR_OF_DAY, 1); + TriggerContext context2 = getTriggerContext(localDate); + assertThat(trigger.nextExecutionTime(context2)).isEqualTo(this.calendar.getTime()); + } + + @ParameterizedCronTriggerTest + void testIncrementDayOfMonth(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); + CronTrigger trigger = new CronTrigger("0 0 0 * * *", timeZone); - calendar.set(Calendar.DAY_OF_MONTH, 1); - Date date = calendar.getTime(); - calendar.add(Calendar.DAY_OF_MONTH, 1); - calendar.set(Calendar.HOUR_OF_DAY, 0); - calendar.set(Calendar.MINUTE, 0); - calendar.set(Calendar.SECOND, 0); - TriggerContext context1 = getTriggerContext(date); - Object actual1 = date = trigger.nextExecutionTime(context1); - assertThat(actual1).isEqualTo(calendar.getTime()); - assertThat(calendar.get(Calendar.DAY_OF_MONTH)).isEqualTo(2); - calendar.add(Calendar.DAY_OF_MONTH, 1); - TriggerContext context2 = getTriggerContext(date); - Object actual = date = trigger.nextExecutionTime(context2); - assertThat(actual).isEqualTo(calendar.getTime()); - assertThat(calendar.get(Calendar.DAY_OF_MONTH)).isEqualTo(3); - } - - @Test - public void testIncrementDayOfMonthByOne() throws Exception { + this.calendar.set(Calendar.DAY_OF_MONTH, 1); + Date localDate = this.calendar.getTime(); + this.calendar.add(Calendar.DAY_OF_MONTH, 1); + this.calendar.set(Calendar.HOUR_OF_DAY, 0); + this.calendar.set(Calendar.MINUTE, 0); + this.calendar.set(Calendar.SECOND, 0); + TriggerContext context1 = getTriggerContext(localDate); + Object actual1 = localDate = trigger.nextExecutionTime(context1); + assertThat(actual1).isEqualTo(this.calendar.getTime()); + assertThat(this.calendar.get(Calendar.DAY_OF_MONTH)).isEqualTo(2); + this.calendar.add(Calendar.DAY_OF_MONTH, 1); + TriggerContext context2 = getTriggerContext(localDate); + Object actual = localDate = trigger.nextExecutionTime(context2); + assertThat(actual).isEqualTo(this.calendar.getTime()); + assertThat(this.calendar.get(Calendar.DAY_OF_MONTH)).isEqualTo(3); + } + + @ParameterizedCronTriggerTest + void testIncrementDayOfMonthByOne(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); + CronTrigger trigger = new CronTrigger("* * * 10 * *", timeZone); - calendar.set(Calendar.DAY_OF_MONTH, 9); - Date date = calendar.getTime(); - calendar.add(Calendar.DAY_OF_MONTH, 1); - calendar.set(Calendar.HOUR_OF_DAY, 0); - calendar.set(Calendar.MINUTE, 0); - calendar.set(Calendar.SECOND, 0); - TriggerContext context = getTriggerContext(date); - assertThat(trigger.nextExecutionTime(context)).isEqualTo(calendar.getTime()); + this.calendar.set(Calendar.DAY_OF_MONTH, 9); + Date localDate = this.calendar.getTime(); + this.calendar.add(Calendar.DAY_OF_MONTH, 1); + this.calendar.set(Calendar.HOUR_OF_DAY, 0); + this.calendar.set(Calendar.MINUTE, 0); + this.calendar.set(Calendar.SECOND, 0); + TriggerContext context = getTriggerContext(localDate); + assertThat(trigger.nextExecutionTime(context)).isEqualTo(this.calendar.getTime()); } - @Test - public void testIncrementDayOfMonthAndRollover() throws Exception { + @ParameterizedCronTriggerTest + void testIncrementDayOfMonthAndRollover(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); + CronTrigger trigger = new CronTrigger("* * * 10 * *", timeZone); - calendar.set(Calendar.DAY_OF_MONTH, 11); - Date date = calendar.getTime(); - calendar.add(Calendar.MONTH, 1); - calendar.set(Calendar.DAY_OF_MONTH, 10); - calendar.set(Calendar.HOUR_OF_DAY, 0); - calendar.set(Calendar.MINUTE, 0); - calendar.set(Calendar.SECOND, 0); - TriggerContext context = getTriggerContext(date); - assertThat(trigger.nextExecutionTime(context)).isEqualTo(calendar.getTime()); + this.calendar.set(Calendar.DAY_OF_MONTH, 11); + Date localDate = this.calendar.getTime(); + this.calendar.add(Calendar.MONTH, 1); + this.calendar.set(Calendar.DAY_OF_MONTH, 10); + this.calendar.set(Calendar.HOUR_OF_DAY, 0); + this.calendar.set(Calendar.MINUTE, 0); + this.calendar.set(Calendar.SECOND, 0); + TriggerContext context = getTriggerContext(localDate); + assertThat(trigger.nextExecutionTime(context)).isEqualTo(this.calendar.getTime()); } - @Test - public void testDailyTriggerInShortMonth() throws Exception { + @ParameterizedCronTriggerTest + void testDailyTriggerInShortMonth(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); + CronTrigger trigger = new CronTrigger("0 0 0 * * *", timeZone); - calendar.set(Calendar.MONTH, 8); // September: 30 days - calendar.set(Calendar.DAY_OF_MONTH, 30); - Date date = calendar.getTime(); - calendar.set(Calendar.MONTH, 9); // October - calendar.set(Calendar.HOUR_OF_DAY, 0); - calendar.set(Calendar.MINUTE, 0); - calendar.set(Calendar.SECOND, 0); - calendar.set(Calendar.DAY_OF_MONTH, 1); - TriggerContext context1 = getTriggerContext(date); - Object actual = date = trigger.nextExecutionTime(context1); - assertThat(actual).isEqualTo(calendar.getTime()); - calendar.set(Calendar.DAY_OF_MONTH, 2); - TriggerContext context2 = getTriggerContext(date); - assertThat(trigger.nextExecutionTime(context2)).isEqualTo(calendar.getTime()); - } - - @Test - public void testDailyTriggerInLongMonth() throws Exception { + this.calendar.set(Calendar.MONTH, 8); // September: 30 days + this.calendar.set(Calendar.DAY_OF_MONTH, 30); + Date localDate = this.calendar.getTime(); + this.calendar.set(Calendar.MONTH, 9); // October + this.calendar.set(Calendar.HOUR_OF_DAY, 0); + this.calendar.set(Calendar.MINUTE, 0); + this.calendar.set(Calendar.SECOND, 0); + this.calendar.set(Calendar.DAY_OF_MONTH, 1); + TriggerContext context1 = getTriggerContext(localDate); + Object actual = localDate = trigger.nextExecutionTime(context1); + assertThat(actual).isEqualTo(this.calendar.getTime()); + this.calendar.set(Calendar.DAY_OF_MONTH, 2); + TriggerContext context2 = getTriggerContext(localDate); + assertThat(trigger.nextExecutionTime(context2)).isEqualTo(this.calendar.getTime()); + } + + @ParameterizedCronTriggerTest + void testDailyTriggerInLongMonth(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); + CronTrigger trigger = new CronTrigger("0 0 0 * * *", timeZone); - calendar.set(Calendar.MONTH, 7); // August: 31 days and not a daylight saving boundary - calendar.set(Calendar.DAY_OF_MONTH, 30); - Date date = calendar.getTime(); - calendar.set(Calendar.HOUR_OF_DAY, 0); - calendar.set(Calendar.MINUTE, 0); - calendar.set(Calendar.SECOND, 0); - calendar.set(Calendar.DAY_OF_MONTH, 31); - TriggerContext context1 = getTriggerContext(date); - Object actual = date = trigger.nextExecutionTime(context1); - assertThat(actual).isEqualTo(calendar.getTime()); - calendar.set(Calendar.MONTH, 8); // September - calendar.set(Calendar.DAY_OF_MONTH, 1); - TriggerContext context2 = getTriggerContext(date); - assertThat(trigger.nextExecutionTime(context2)).isEqualTo(calendar.getTime()); - } - - @Test - public void testDailyTriggerOnDaylightSavingBoundary() throws Exception { + this.calendar.set(Calendar.MONTH, 7); // August: 31 days and not a daylight saving boundary + this.calendar.set(Calendar.DAY_OF_MONTH, 30); + Date localDate = this.calendar.getTime(); + this.calendar.set(Calendar.HOUR_OF_DAY, 0); + this.calendar.set(Calendar.MINUTE, 0); + this.calendar.set(Calendar.SECOND, 0); + this.calendar.set(Calendar.DAY_OF_MONTH, 31); + TriggerContext context1 = getTriggerContext(localDate); + Object actual = localDate = trigger.nextExecutionTime(context1); + assertThat(actual).isEqualTo(this.calendar.getTime()); + this.calendar.set(Calendar.MONTH, 8); // September + this.calendar.set(Calendar.DAY_OF_MONTH, 1); + TriggerContext context2 = getTriggerContext(localDate); + assertThat(trigger.nextExecutionTime(context2)).isEqualTo(this.calendar.getTime()); + } + + @ParameterizedCronTriggerTest + void testDailyTriggerOnDaylightSavingBoundary(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); + CronTrigger trigger = new CronTrigger("0 0 0 * * *", timeZone); - calendar.set(Calendar.MONTH, 9); // October: 31 days and a daylight saving boundary in CET - calendar.set(Calendar.DAY_OF_MONTH, 30); - Date date = calendar.getTime(); - calendar.set(Calendar.HOUR_OF_DAY, 0); - calendar.set(Calendar.MINUTE, 0); - calendar.set(Calendar.SECOND, 0); - calendar.set(Calendar.DAY_OF_MONTH, 31); - TriggerContext context1 = getTriggerContext(date); - Object actual = date = trigger.nextExecutionTime(context1); - assertThat(actual).isEqualTo(calendar.getTime()); - calendar.set(Calendar.MONTH, 10); // November - calendar.set(Calendar.DAY_OF_MONTH, 1); - TriggerContext context2 = getTriggerContext(date); - assertThat(trigger.nextExecutionTime(context2)).isEqualTo(calendar.getTime()); - } - - @Test - public void testIncrementMonth() throws Exception { + this.calendar.set(Calendar.MONTH, 9); // October: 31 days and a daylight saving boundary in CET + this.calendar.set(Calendar.DAY_OF_MONTH, 30); + Date localDate = this.calendar.getTime(); + this.calendar.set(Calendar.HOUR_OF_DAY, 0); + this.calendar.set(Calendar.MINUTE, 0); + this.calendar.set(Calendar.SECOND, 0); + this.calendar.set(Calendar.DAY_OF_MONTH, 31); + TriggerContext context1 = getTriggerContext(localDate); + Object actual = localDate = trigger.nextExecutionTime(context1); + assertThat(actual).isEqualTo(this.calendar.getTime()); + this.calendar.set(Calendar.MONTH, 10); // November + this.calendar.set(Calendar.DAY_OF_MONTH, 1); + TriggerContext context2 = getTriggerContext(localDate); + assertThat(trigger.nextExecutionTime(context2)).isEqualTo(this.calendar.getTime()); + } + + @ParameterizedCronTriggerTest + void testIncrementMonth(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); + CronTrigger trigger = new CronTrigger("0 0 0 1 * *", timeZone); - calendar.set(Calendar.MONTH, 9); - calendar.set(Calendar.DAY_OF_MONTH, 30); - Date date = calendar.getTime(); - calendar.set(Calendar.DAY_OF_MONTH, 1); - calendar.set(Calendar.HOUR_OF_DAY, 0); - calendar.set(Calendar.MINUTE, 0); - calendar.set(Calendar.SECOND, 0); - calendar.set(Calendar.MONTH, 10); - TriggerContext context1 = getTriggerContext(date); - Object actual = date = trigger.nextExecutionTime(context1); - assertThat(actual).isEqualTo(calendar.getTime()); - calendar.set(Calendar.MONTH, 11); - TriggerContext context2 = getTriggerContext(date); - assertThat(trigger.nextExecutionTime(context2)).isEqualTo(calendar.getTime()); - } - - @Test - public void testIncrementMonthAndRollover() throws Exception { + this.calendar.set(Calendar.MONTH, 9); + this.calendar.set(Calendar.DAY_OF_MONTH, 30); + Date localDate = this.calendar.getTime(); + this.calendar.set(Calendar.DAY_OF_MONTH, 1); + this.calendar.set(Calendar.HOUR_OF_DAY, 0); + this.calendar.set(Calendar.MINUTE, 0); + this.calendar.set(Calendar.SECOND, 0); + this.calendar.set(Calendar.MONTH, 10); + TriggerContext context1 = getTriggerContext(localDate); + Object actual = localDate = trigger.nextExecutionTime(context1); + assertThat(actual).isEqualTo(this.calendar.getTime()); + this.calendar.set(Calendar.MONTH, 11); + TriggerContext context2 = getTriggerContext(localDate); + assertThat(trigger.nextExecutionTime(context2)).isEqualTo(this.calendar.getTime()); + } + + @ParameterizedCronTriggerTest + void testIncrementMonthAndRollover(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); + CronTrigger trigger = new CronTrigger("0 0 0 1 * *", timeZone); - calendar.set(Calendar.MONTH, 11); - calendar.set(Calendar.DAY_OF_MONTH, 31); - calendar.set(Calendar.YEAR, 2010); - Date date = calendar.getTime(); - calendar.set(Calendar.DAY_OF_MONTH, 1); - calendar.set(Calendar.HOUR_OF_DAY, 0); - calendar.set(Calendar.MINUTE, 0); - calendar.set(Calendar.SECOND, 0); - calendar.set(Calendar.MONTH, 0); - calendar.set(Calendar.YEAR, 2011); - TriggerContext context1 = getTriggerContext(date); - Object actual = date = trigger.nextExecutionTime(context1); - assertThat(actual).isEqualTo(calendar.getTime()); - calendar.set(Calendar.MONTH, 1); - TriggerContext context2 = getTriggerContext(date); - assertThat(trigger.nextExecutionTime(context2)).isEqualTo(calendar.getTime()); - } - - @Test - public void testMonthlyTriggerInLongMonth() throws Exception { + this.calendar.set(Calendar.MONTH, 11); + this.calendar.set(Calendar.DAY_OF_MONTH, 31); + this.calendar.set(Calendar.YEAR, 2010); + Date localDate = this.calendar.getTime(); + this.calendar.set(Calendar.DAY_OF_MONTH, 1); + this.calendar.set(Calendar.HOUR_OF_DAY, 0); + this.calendar.set(Calendar.MINUTE, 0); + this.calendar.set(Calendar.SECOND, 0); + this.calendar.set(Calendar.MONTH, 0); + this.calendar.set(Calendar.YEAR, 2011); + TriggerContext context1 = getTriggerContext(localDate); + Object actual = localDate = trigger.nextExecutionTime(context1); + assertThat(actual).isEqualTo(this.calendar.getTime()); + this.calendar.set(Calendar.MONTH, 1); + TriggerContext context2 = getTriggerContext(localDate); + assertThat(trigger.nextExecutionTime(context2)).isEqualTo(this.calendar.getTime()); + } + + @ParameterizedCronTriggerTest + void testMonthlyTriggerInLongMonth(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); + CronTrigger trigger = new CronTrigger("0 0 0 31 * *", timeZone); - calendar.set(Calendar.MONTH, 9); - calendar.set(Calendar.DAY_OF_MONTH, 30); - Date date = calendar.getTime(); - calendar.set(Calendar.DAY_OF_MONTH, 31); - calendar.set(Calendar.HOUR_OF_DAY, 0); - calendar.set(Calendar.MINUTE, 0); - calendar.set(Calendar.SECOND, 0); - TriggerContext context = getTriggerContext(date); - assertThat(trigger.nextExecutionTime(context)).isEqualTo(calendar.getTime()); + this.calendar.set(Calendar.MONTH, 9); + this.calendar.set(Calendar.DAY_OF_MONTH, 30); + Date localDate = this.calendar.getTime(); + this.calendar.set(Calendar.DAY_OF_MONTH, 31); + this.calendar.set(Calendar.HOUR_OF_DAY, 0); + this.calendar.set(Calendar.MINUTE, 0); + this.calendar.set(Calendar.SECOND, 0); + TriggerContext context = getTriggerContext(localDate); + assertThat(trigger.nextExecutionTime(context)).isEqualTo(this.calendar.getTime()); } - @Test - public void testMonthlyTriggerInShortMonth() throws Exception { + @ParameterizedCronTriggerTest + void testMonthlyTriggerInShortMonth(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); + CronTrigger trigger = new CronTrigger("0 0 0 1 * *", timeZone); - calendar.set(Calendar.MONTH, 9); - calendar.set(Calendar.DAY_OF_MONTH, 30); - Date date = calendar.getTime(); - calendar.set(Calendar.MONTH, 10); - calendar.set(Calendar.DAY_OF_MONTH, 1); - calendar.set(Calendar.HOUR_OF_DAY, 0); - calendar.set(Calendar.MINUTE, 0); - calendar.set(Calendar.SECOND, 0); - TriggerContext context = getTriggerContext(date); - assertThat(trigger.nextExecutionTime(context)).isEqualTo(calendar.getTime()); - } + this.calendar.set(Calendar.MONTH, 9); + this.calendar.set(Calendar.DAY_OF_MONTH, 30); + Date localDate = this.calendar.getTime(); + this.calendar.set(Calendar.MONTH, 10); + this.calendar.set(Calendar.DAY_OF_MONTH, 1); + this.calendar.set(Calendar.HOUR_OF_DAY, 0); + this.calendar.set(Calendar.MINUTE, 0); + this.calendar.set(Calendar.SECOND, 0); + TriggerContext context = getTriggerContext(localDate); + assertThat(trigger.nextExecutionTime(context)).isEqualTo(this.calendar.getTime()); + } + + @ParameterizedCronTriggerTest + void testIncrementDayOfWeekByOne(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); - @Test - public void testIncrementDayOfWeekByOne() throws Exception { CronTrigger trigger = new CronTrigger("* * * * * 2", timeZone); - calendar.set(Calendar.DAY_OF_WEEK, 2); - Date date = calendar.getTime(); - calendar.add(Calendar.DAY_OF_WEEK, 1); - calendar.set(Calendar.HOUR_OF_DAY, 0); - calendar.set(Calendar.MINUTE, 0); - calendar.set(Calendar.SECOND, 0); - TriggerContext context = getTriggerContext(date); - assertThat(trigger.nextExecutionTime(context)).isEqualTo(calendar.getTime()); - assertThat(calendar.get(Calendar.DAY_OF_WEEK)).isEqualTo(Calendar.TUESDAY); + this.calendar.set(Calendar.DAY_OF_WEEK, 2); + Date localDate = this.calendar.getTime(); + this.calendar.add(Calendar.DAY_OF_WEEK, 1); + this.calendar.set(Calendar.HOUR_OF_DAY, 0); + this.calendar.set(Calendar.MINUTE, 0); + this.calendar.set(Calendar.SECOND, 0); + TriggerContext context = getTriggerContext(localDate); + assertThat(trigger.nextExecutionTime(context)).isEqualTo(this.calendar.getTime()); + assertThat(this.calendar.get(Calendar.DAY_OF_WEEK)).isEqualTo(Calendar.TUESDAY); } - @Test - public void testIncrementDayOfWeekAndRollover() throws Exception { + @ParameterizedCronTriggerTest + void testIncrementDayOfWeekAndRollover(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); + CronTrigger trigger = new CronTrigger("* * * * * 2", timeZone); - calendar.set(Calendar.DAY_OF_WEEK, 4); - Date date = calendar.getTime(); - calendar.add(Calendar.DAY_OF_MONTH, 6); - calendar.set(Calendar.HOUR_OF_DAY, 0); - calendar.set(Calendar.MINUTE, 0); - calendar.set(Calendar.SECOND, 0); - TriggerContext context = getTriggerContext(date); - assertThat(trigger.nextExecutionTime(context)).isEqualTo(calendar.getTime()); - assertThat(calendar.get(Calendar.DAY_OF_WEEK)).isEqualTo(Calendar.TUESDAY); + this.calendar.set(Calendar.DAY_OF_WEEK, 4); + Date localDate = this.calendar.getTime(); + this.calendar.add(Calendar.DAY_OF_MONTH, 6); + this.calendar.set(Calendar.HOUR_OF_DAY, 0); + this.calendar.set(Calendar.MINUTE, 0); + this.calendar.set(Calendar.SECOND, 0); + TriggerContext context = getTriggerContext(localDate); + assertThat(trigger.nextExecutionTime(context)).isEqualTo(this.calendar.getTime()); + assertThat(this.calendar.get(Calendar.DAY_OF_WEEK)).isEqualTo(Calendar.TUESDAY); } - @Test - public void testSpecificMinuteSecond() throws Exception { + @ParameterizedCronTriggerTest + void testSpecificMinuteSecond(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); + CronTrigger trigger = new CronTrigger("55 5 * * * *", timeZone); - calendar.set(Calendar.MINUTE, 4); - calendar.set(Calendar.SECOND, 54); - Date date = calendar.getTime(); - TriggerContext context1 = getTriggerContext(date); - calendar.add(Calendar.MINUTE, 1); - calendar.set(Calendar.SECOND, 55); - Object actual1 = date = trigger.nextExecutionTime(context1); - assertThat(actual1).isEqualTo(calendar.getTime()); - calendar.add(Calendar.HOUR, 1); - TriggerContext context2 = getTriggerContext(date); - Object actual = date = trigger.nextExecutionTime(context2); - assertThat(actual).isEqualTo(calendar.getTime()); - } - - @Test - public void testSpecificHourSecond() throws Exception { + this.calendar.set(Calendar.MINUTE, 4); + this.calendar.set(Calendar.SECOND, 54); + Date localDate = this.calendar.getTime(); + TriggerContext context1 = getTriggerContext(localDate); + this.calendar.add(Calendar.MINUTE, 1); + this.calendar.set(Calendar.SECOND, 55); + Object actual1 = localDate = trigger.nextExecutionTime(context1); + assertThat(actual1).isEqualTo(this.calendar.getTime()); + this.calendar.add(Calendar.HOUR, 1); + TriggerContext context2 = getTriggerContext(localDate); + Object actual = localDate = trigger.nextExecutionTime(context2); + assertThat(actual).isEqualTo(this.calendar.getTime()); + } + + @ParameterizedCronTriggerTest + void testSpecificHourSecond(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); + CronTrigger trigger = new CronTrigger("55 * 10 * * *", timeZone); - calendar.set(Calendar.HOUR_OF_DAY, 9); - calendar.set(Calendar.SECOND, 54); - Date date = calendar.getTime(); - TriggerContext context1 = getTriggerContext(date); - calendar.add(Calendar.HOUR_OF_DAY, 1); - calendar.set(Calendar.MINUTE, 0); - calendar.set(Calendar.SECOND, 55); - Object actual1 = date = trigger.nextExecutionTime(context1); - assertThat(actual1).isEqualTo(calendar.getTime()); - calendar.add(Calendar.MINUTE, 1); - TriggerContext context2 = getTriggerContext(date); - Object actual = date = trigger.nextExecutionTime(context2); - assertThat(actual).isEqualTo(calendar.getTime()); - } - - @Test - public void testSpecificMinuteHour() throws Exception { + this.calendar.set(Calendar.HOUR_OF_DAY, 9); + this.calendar.set(Calendar.SECOND, 54); + Date localDate = this.calendar.getTime(); + TriggerContext context1 = getTriggerContext(localDate); + this.calendar.add(Calendar.HOUR_OF_DAY, 1); + this.calendar.set(Calendar.MINUTE, 0); + this.calendar.set(Calendar.SECOND, 55); + Object actual1 = localDate = trigger.nextExecutionTime(context1); + assertThat(actual1).isEqualTo(this.calendar.getTime()); + this.calendar.add(Calendar.MINUTE, 1); + TriggerContext context2 = getTriggerContext(localDate); + Object actual = localDate = trigger.nextExecutionTime(context2); + assertThat(actual).isEqualTo(this.calendar.getTime()); + } + + @ParameterizedCronTriggerTest + void testSpecificMinuteHour(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); + CronTrigger trigger = new CronTrigger("* 5 10 * * *", timeZone); - calendar.set(Calendar.MINUTE, 4); - calendar.set(Calendar.HOUR_OF_DAY, 9); - Date date = calendar.getTime(); - calendar.add(Calendar.MINUTE, 1); - calendar.add(Calendar.HOUR_OF_DAY, 1); - calendar.set(Calendar.SECOND, 0); - TriggerContext context1 = getTriggerContext(date); - Object actual1 = date = trigger.nextExecutionTime(context1); - assertThat(actual1).isEqualTo(calendar.getTime()); + this.calendar.set(Calendar.MINUTE, 4); + this.calendar.set(Calendar.HOUR_OF_DAY, 9); + Date localDate = this.calendar.getTime(); + this.calendar.add(Calendar.MINUTE, 1); + this.calendar.add(Calendar.HOUR_OF_DAY, 1); + this.calendar.set(Calendar.SECOND, 0); + TriggerContext context1 = getTriggerContext(localDate); + Object actual1 = localDate = trigger.nextExecutionTime(context1); + assertThat(actual1).isEqualTo(this.calendar.getTime()); // next trigger is in one second because second is wildcard - calendar.add(Calendar.SECOND, 1); - TriggerContext context2 = getTriggerContext(date); - Object actual = date = trigger.nextExecutionTime(context2); - assertThat(actual).isEqualTo(calendar.getTime()); + this.calendar.add(Calendar.SECOND, 1); + TriggerContext context2 = getTriggerContext(localDate); + Object actual = localDate = trigger.nextExecutionTime(context2); + assertThat(actual).isEqualTo(this.calendar.getTime()); } - @Test - public void testSpecificDayOfMonthSecond() throws Exception { + @ParameterizedCronTriggerTest + void testSpecificDayOfMonthSecond(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); + CronTrigger trigger = new CronTrigger("55 * * 3 * *", timeZone); - calendar.set(Calendar.DAY_OF_MONTH, 2); - calendar.set(Calendar.SECOND, 54); - Date date = calendar.getTime(); - TriggerContext context1 = getTriggerContext(date); - calendar.add(Calendar.DAY_OF_MONTH, 1); - calendar.set(Calendar.HOUR_OF_DAY, 0); - calendar.set(Calendar.MINUTE, 0); - calendar.set(Calendar.SECOND, 55); - Object actual1 = date = trigger.nextExecutionTime(context1); - assertThat(actual1).isEqualTo(calendar.getTime()); - calendar.add(Calendar.MINUTE, 1); - TriggerContext context2 = getTriggerContext(date); - Object actual = date = trigger.nextExecutionTime(context2); - assertThat(actual).isEqualTo(calendar.getTime()); - } - - @Test - public void testSpecificDate() throws Exception { + this.calendar.set(Calendar.DAY_OF_MONTH, 2); + this.calendar.set(Calendar.SECOND, 54); + Date localDate = this.calendar.getTime(); + TriggerContext context1 = getTriggerContext(localDate); + this.calendar.add(Calendar.DAY_OF_MONTH, 1); + this.calendar.set(Calendar.HOUR_OF_DAY, 0); + this.calendar.set(Calendar.MINUTE, 0); + this.calendar.set(Calendar.SECOND, 55); + Object actual1 = localDate = trigger.nextExecutionTime(context1); + assertThat(actual1).isEqualTo(this.calendar.getTime()); + this.calendar.add(Calendar.MINUTE, 1); + TriggerContext context2 = getTriggerContext(localDate); + Object actual = localDate = trigger.nextExecutionTime(context2); + assertThat(actual).isEqualTo(this.calendar.getTime()); + } + + @ParameterizedCronTriggerTest + void testSpecificDate(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); + CronTrigger trigger = new CronTrigger("* * * 3 11 *", timeZone); - calendar.set(Calendar.DAY_OF_MONTH, 2); - calendar.set(Calendar.MONTH, 9); - Date date = calendar.getTime(); - TriggerContext context1 = getTriggerContext(date); - calendar.add(Calendar.DAY_OF_MONTH, 1); - calendar.set(Calendar.HOUR_OF_DAY, 0); - calendar.set(Calendar.MONTH, 10); // 10=November - calendar.set(Calendar.MINUTE, 0); - calendar.set(Calendar.SECOND, 0); - Object actual1 = date = trigger.nextExecutionTime(context1); - assertThat(actual1).isEqualTo(calendar.getTime()); - calendar.add(Calendar.SECOND, 1); - TriggerContext context2 = getTriggerContext(date); - Object actual = date = trigger.nextExecutionTime(context2); - assertThat(actual).isEqualTo(calendar.getTime()); - } + this.calendar.set(Calendar.DAY_OF_MONTH, 2); + this.calendar.set(Calendar.MONTH, 9); + Date localDate = this.calendar.getTime(); + TriggerContext context1 = getTriggerContext(localDate); + this.calendar.add(Calendar.DAY_OF_MONTH, 1); + this.calendar.set(Calendar.HOUR_OF_DAY, 0); + this.calendar.set(Calendar.MONTH, 10); // 10=November + this.calendar.set(Calendar.MINUTE, 0); + this.calendar.set(Calendar.SECOND, 0); + Object actual1 = localDate = trigger.nextExecutionTime(context1); + assertThat(actual1).isEqualTo(this.calendar.getTime()); + this.calendar.add(Calendar.SECOND, 1); + TriggerContext context2 = getTriggerContext(localDate); + Object actual = localDate = trigger.nextExecutionTime(context2); + assertThat(actual).isEqualTo(this.calendar.getTime()); + } + + @ParameterizedCronTriggerTest + void testNonExistentSpecificDate(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); - @Test - public void testNonExistentSpecificDate() throws Exception { // TODO: maybe try and detect this as a special case in parser? CronTrigger trigger = new CronTrigger("0 0 0 31 6 *", timeZone); - calendar.set(Calendar.DAY_OF_MONTH, 10); - calendar.set(Calendar.MONTH, 2); - Date date = calendar.getTime(); - TriggerContext context1 = getTriggerContext(date); - assertThatIllegalArgumentException().isThrownBy(() -> - trigger.nextExecutionTime(context1)); - // new CronTrigger("0 0 0 30 1 ?", timeZone); + this.calendar.set(Calendar.DAY_OF_MONTH, 10); + this.calendar.set(Calendar.MONTH, 2); + Date localDate = this.calendar.getTime(); + TriggerContext context1 = getTriggerContext(localDate); + assertThatIllegalArgumentException().isThrownBy(() -> trigger.nextExecutionTime(context1)); } - @Test - public void testLeapYearSpecificDate() throws Exception { + @ParameterizedCronTriggerTest + void testLeapYearSpecificDate(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); + CronTrigger trigger = new CronTrigger("0 0 0 29 2 *", timeZone); - calendar.set(Calendar.YEAR, 2007); - calendar.set(Calendar.DAY_OF_MONTH, 10); - calendar.set(Calendar.MONTH, 1); // 2=February - Date date = calendar.getTime(); - TriggerContext context1 = getTriggerContext(date); - calendar.set(Calendar.YEAR, 2008); - calendar.set(Calendar.DAY_OF_MONTH, 29); - calendar.set(Calendar.HOUR_OF_DAY, 0); - calendar.set(Calendar.MINUTE, 0); - calendar.set(Calendar.SECOND, 0); - Object actual1 = date = trigger.nextExecutionTime(context1); - assertThat(actual1).isEqualTo(calendar.getTime()); - calendar.add(Calendar.YEAR, 4); - TriggerContext context2 = getTriggerContext(date); - Object actual = date = trigger.nextExecutionTime(context2); - assertThat(actual).isEqualTo(calendar.getTime()); - } - - @Test - public void testWeekDaySequence() throws Exception { + this.calendar.set(Calendar.YEAR, 2007); + this.calendar.set(Calendar.DAY_OF_MONTH, 10); + this.calendar.set(Calendar.MONTH, 1); // 2=February + Date localDate = this.calendar.getTime(); + TriggerContext context1 = getTriggerContext(localDate); + this.calendar.set(Calendar.YEAR, 2008); + this.calendar.set(Calendar.DAY_OF_MONTH, 29); + this.calendar.set(Calendar.HOUR_OF_DAY, 0); + this.calendar.set(Calendar.MINUTE, 0); + this.calendar.set(Calendar.SECOND, 0); + Object actual1 = localDate = trigger.nextExecutionTime(context1); + assertThat(actual1).isEqualTo(this.calendar.getTime()); + this.calendar.add(Calendar.YEAR, 4); + TriggerContext context2 = getTriggerContext(localDate); + Object actual = localDate = trigger.nextExecutionTime(context2); + assertThat(actual).isEqualTo(this.calendar.getTime()); + } + + @ParameterizedCronTriggerTest + void testWeekDaySequence(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); + CronTrigger trigger = new CronTrigger("0 0 7 ? * MON-FRI", timeZone); // This is a Saturday - calendar.set(2009, 8, 26); - Date date = calendar.getTime(); + this.calendar.set(2009, 8, 26); + Date localDate = this.calendar.getTime(); // 7 am is the trigger time - calendar.set(Calendar.HOUR_OF_DAY, 7); - calendar.set(Calendar.MINUTE, 0); - calendar.set(Calendar.SECOND, 0); + this.calendar.set(Calendar.HOUR_OF_DAY, 7); + this.calendar.set(Calendar.MINUTE, 0); + this.calendar.set(Calendar.SECOND, 0); // Add two days because we start on Saturday - calendar.add(Calendar.DAY_OF_MONTH, 2); - TriggerContext context1 = getTriggerContext(date); - Object actual2 = date = trigger.nextExecutionTime(context1); - assertThat(actual2).isEqualTo(calendar.getTime()); + this.calendar.add(Calendar.DAY_OF_MONTH, 2); + TriggerContext context1 = getTriggerContext(localDate); + Object actual2 = localDate = trigger.nextExecutionTime(context1); + assertThat(actual2).isEqualTo(this.calendar.getTime()); // Next day is a week day so add one - calendar.add(Calendar.DAY_OF_MONTH, 1); - TriggerContext context2 = getTriggerContext(date); - Object actual1 = date = trigger.nextExecutionTime(context2); - assertThat(actual1).isEqualTo(calendar.getTime()); - calendar.add(Calendar.DAY_OF_MONTH, 1); - TriggerContext context3 = getTriggerContext(date); - Object actual = date = trigger.nextExecutionTime(context3); - assertThat(actual).isEqualTo(calendar.getTime()); - } - - @Test - public void testDayOfWeekIndifferent() throws Exception { + this.calendar.add(Calendar.DAY_OF_MONTH, 1); + TriggerContext context2 = getTriggerContext(localDate); + Object actual1 = localDate = trigger.nextExecutionTime(context2); + assertThat(actual1).isEqualTo(this.calendar.getTime()); + this.calendar.add(Calendar.DAY_OF_MONTH, 1); + TriggerContext context3 = getTriggerContext(localDate); + Object actual = localDate = trigger.nextExecutionTime(context3); + assertThat(actual).isEqualTo(this.calendar.getTime()); + } + + @ParameterizedCronTriggerTest + void testDayOfWeekIndifferent(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); + CronTrigger trigger1 = new CronTrigger("* * * 2 * *", timeZone); CronTrigger trigger2 = new CronTrigger("* * * 2 * ?", timeZone); assertThat(trigger2).isEqualTo(trigger1); } - @Test - public void testSecondIncrementer() throws Exception { + @ParameterizedCronTriggerTest + void testSecondIncrementer(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); + CronTrigger trigger1 = new CronTrigger("57,59 * * * * *", timeZone); CronTrigger trigger2 = new CronTrigger("57/2 * * * * *", timeZone); assertThat(trigger2).isEqualTo(trigger1); } - @Test - public void testSecondIncrementerWithRange() throws Exception { + @ParameterizedCronTriggerTest + void testSecondIncrementerWithRange(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); + CronTrigger trigger1 = new CronTrigger("1,3,5 * * * * *", timeZone); CronTrigger trigger2 = new CronTrigger("1-6/2 * * * * *", timeZone); assertThat(trigger2).isEqualTo(trigger1); } - @Test - public void testHourIncrementer() throws Exception { + @ParameterizedCronTriggerTest + void testHourIncrementer(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); + CronTrigger trigger1 = new CronTrigger("* * 4,8,12,16,20 * * *", timeZone); CronTrigger trigger2 = new CronTrigger("* * 4/4 * * *", timeZone); assertThat(trigger2).isEqualTo(trigger1); } - @Test - public void testDayNames() throws Exception { + @ParameterizedCronTriggerTest + void testDayNames(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); + CronTrigger trigger1 = new CronTrigger("* * * * * 0-6", timeZone); CronTrigger trigger2 = new CronTrigger("* * * * * TUE,WED,THU,FRI,SAT,SUN,MON", timeZone); assertThat(trigger2).isEqualTo(trigger1); } - @Test - public void testSundayIsZero() throws Exception { + @ParameterizedCronTriggerTest + void testSundayIsZero(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); + CronTrigger trigger1 = new CronTrigger("* * * * * 0", timeZone); CronTrigger trigger2 = new CronTrigger("* * * * * SUN", timeZone); assertThat(trigger2).isEqualTo(trigger1); } - @Test - public void testSundaySynonym() throws Exception { + @ParameterizedCronTriggerTest + void testSundaySynonym(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); + CronTrigger trigger1 = new CronTrigger("* * * * * 0", timeZone); CronTrigger trigger2 = new CronTrigger("* * * * * 7", timeZone); assertThat(trigger2).isEqualTo(trigger1); } - @Test - public void testMonthNames() throws Exception { + @ParameterizedCronTriggerTest + void testMonthNames(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); + CronTrigger trigger1 = new CronTrigger("* * * * 1-12 *", timeZone); CronTrigger trigger2 = new CronTrigger("* * * * FEB,JAN,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC *", timeZone); assertThat(trigger2).isEqualTo(trigger1); } - @Test - public void testMonthNamesMixedCase() throws Exception { + @ParameterizedCronTriggerTest + void testMonthNamesMixedCase(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); + CronTrigger trigger1 = new CronTrigger("* * * * 2 *", timeZone); CronTrigger trigger2 = new CronTrigger("* * * * Feb *", timeZone); assertThat(trigger2).isEqualTo(trigger1); } - @Test - public void testSecondInvalid() throws Exception { - assertThatIllegalArgumentException().isThrownBy(() -> - new CronTrigger("77 * * * * *", timeZone)); + @ParameterizedCronTriggerTest + void testSecondInvalid(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); + + assertThatIllegalArgumentException().isThrownBy(() -> new CronTrigger("77 * * * * *", timeZone)); } - @Test - public void testSecondRangeInvalid() throws Exception { - assertThatIllegalArgumentException().isThrownBy(() -> - new CronTrigger("44-77 * * * * *", timeZone)); + @ParameterizedCronTriggerTest + void testSecondRangeInvalid(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); + + assertThatIllegalArgumentException().isThrownBy(() -> new CronTrigger("44-77 * * * * *", timeZone)); } - @Test - public void testMinuteInvalid() throws Exception { - assertThatIllegalArgumentException().isThrownBy(() -> - new CronTrigger("* 77 * * * *", timeZone)); + @ParameterizedCronTriggerTest + void testMinuteInvalid(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); + + assertThatIllegalArgumentException().isThrownBy(() -> new CronTrigger("* 77 * * * *", timeZone)); } - @Test - public void testMinuteRangeInvalid() throws Exception { - assertThatIllegalArgumentException().isThrownBy(() -> - new CronTrigger("* 44-77 * * * *", timeZone)); + @ParameterizedCronTriggerTest + void testMinuteRangeInvalid(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); + + assertThatIllegalArgumentException().isThrownBy(() -> new CronTrigger("* 44-77 * * * *", timeZone)); } - @Test - public void testHourInvalid() throws Exception { - assertThatIllegalArgumentException().isThrownBy(() -> - new CronTrigger("* * 27 * * *", timeZone)); + @ParameterizedCronTriggerTest + void testHourInvalid(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); + + assertThatIllegalArgumentException().isThrownBy(() -> new CronTrigger("* * 27 * * *", timeZone)); } - @Test - public void testHourRangeInvalid() throws Exception { - assertThatIllegalArgumentException().isThrownBy(() -> - new CronTrigger("* * 23-28 * * *", timeZone)); + @ParameterizedCronTriggerTest + void testHourRangeInvalid(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); + + assertThatIllegalArgumentException().isThrownBy(() -> new CronTrigger("* * 23-28 * * *", timeZone)); } - @Test - public void testDayInvalid() throws Exception { - assertThatIllegalArgumentException().isThrownBy(() -> - new CronTrigger("* * * 45 * *", timeZone)); + @ParameterizedCronTriggerTest + void testDayInvalid(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); + + assertThatIllegalArgumentException().isThrownBy(() -> new CronTrigger("* * * 45 * *", timeZone)); } - @Test - public void testDayRangeInvalid() throws Exception { - assertThatIllegalArgumentException().isThrownBy(() -> - new CronTrigger("* * * 28-45 * *", timeZone)); + @ParameterizedCronTriggerTest + void testDayRangeInvalid(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); + + assertThatIllegalArgumentException().isThrownBy(() -> new CronTrigger("* * * 28-45 * *", timeZone)); } - @Test - public void testMonthInvalid() throws Exception { - assertThatIllegalArgumentException().isThrownBy(() -> - new CronTrigger("0 0 0 25 13 ?", timeZone)); + @ParameterizedCronTriggerTest + void testMonthInvalid(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); + + assertThatIllegalArgumentException().isThrownBy(() -> new CronTrigger("0 0 0 25 13 ?", timeZone)); } - @Test - public void testMonthInvalidTooSmall() throws Exception { - assertThatIllegalArgumentException().isThrownBy(() -> - new CronTrigger("0 0 0 25 0 ?", timeZone)); + @ParameterizedCronTriggerTest + void testMonthInvalidTooSmall(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); + + assertThatIllegalArgumentException().isThrownBy(() -> new CronTrigger("0 0 0 25 0 ?", timeZone)); } - @Test - public void testDayOfMonthInvalid() throws Exception { - assertThatIllegalArgumentException().isThrownBy(() -> - new CronTrigger("0 0 0 32 12 ?", timeZone)); + @ParameterizedCronTriggerTest + void testDayOfMonthInvalid(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); + + assertThatIllegalArgumentException().isThrownBy(() -> new CronTrigger("0 0 0 32 12 ?", timeZone)); } - @Test - public void testMonthRangeInvalid() throws Exception { - assertThatIllegalArgumentException().isThrownBy(() -> - new CronTrigger("* * * * 11-13 *", timeZone)); + @ParameterizedCronTriggerTest + void testMonthRangeInvalid(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); + + assertThatIllegalArgumentException().isThrownBy(() -> new CronTrigger("* * * * 11-13 *", timeZone)); } - @Test - public void testWhitespace() throws Exception { + @ParameterizedCronTriggerTest + void testWhitespace(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); + CronTrigger trigger1 = new CronTrigger("* * * * 1 *", timeZone); CronTrigger trigger2 = new CronTrigger("* * * * 1 *", timeZone); assertThat(trigger2).isEqualTo(trigger1); } - @Test - public void testMonthSequence() throws Exception { + @ParameterizedCronTriggerTest + void testMonthSequence(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); + CronTrigger trigger = new CronTrigger("0 30 23 30 1/3 ?", timeZone); - calendar.set(2010, 11, 30); - Date date = calendar.getTime(); + this.calendar.set(2010, 11, 30); + Date localDate = this.calendar.getTime(); // set expected next trigger time - calendar.set(Calendar.HOUR_OF_DAY, 23); - calendar.set(Calendar.MINUTE, 30); - calendar.set(Calendar.SECOND, 0); - calendar.add(Calendar.MONTH, 1); - TriggerContext context1 = getTriggerContext(date); - Object actual2 = date = trigger.nextExecutionTime(context1); - assertThat(actual2).isEqualTo(calendar.getTime()); + this.calendar.set(Calendar.HOUR_OF_DAY, 23); + this.calendar.set(Calendar.MINUTE, 30); + this.calendar.set(Calendar.SECOND, 0); + this.calendar.add(Calendar.MONTH, 1); + TriggerContext context1 = getTriggerContext(localDate); + Object actual2 = localDate = trigger.nextExecutionTime(context1); + assertThat(actual2).isEqualTo(this.calendar.getTime()); // Next trigger is 3 months latter - calendar.add(Calendar.MONTH, 3); - TriggerContext context2 = getTriggerContext(date); - Object actual1 = date = trigger.nextExecutionTime(context2); - assertThat(actual1).isEqualTo(calendar.getTime()); + this.calendar.add(Calendar.MONTH, 3); + TriggerContext context2 = getTriggerContext(localDate); + Object actual1 = localDate = trigger.nextExecutionTime(context2); + assertThat(actual1).isEqualTo(this.calendar.getTime()); // Next trigger is 3 months latter - calendar.add(Calendar.MONTH, 3); - TriggerContext context3 = getTriggerContext(date); - Object actual = date = trigger.nextExecutionTime(context3); - assertThat(actual).isEqualTo(calendar.getTime()); + this.calendar.add(Calendar.MONTH, 3); + TriggerContext context3 = getTriggerContext(localDate); + Object actual = localDate = trigger.nextExecutionTime(context3); + assertThat(actual).isEqualTo(this.calendar.getTime()); } - @Test - public void testDaylightSavingMissingHour() throws Exception { + @ParameterizedCronTriggerTest + void testDaylightSavingMissingHour(LocalDateTime localDateTime, TimeZone timeZone) { + setUp(localDateTime, timeZone); + // This trigger has to be somewhere in between 2am and 3am CronTrigger trigger = new CronTrigger("0 10 2 * * *", timeZone); - calendar.set(Calendar.DAY_OF_MONTH, 31); - calendar.set(Calendar.MONTH, Calendar.MARCH); - calendar.set(Calendar.YEAR, 2013); - calendar.set(Calendar.HOUR_OF_DAY, 1); - calendar.set(Calendar.SECOND, 54); - Date date = calendar.getTime(); - TriggerContext context1 = getTriggerContext(date); + this.calendar.set(Calendar.DAY_OF_MONTH, 31); + this.calendar.set(Calendar.MONTH, Calendar.MARCH); + this.calendar.set(Calendar.YEAR, 2013); + this.calendar.set(Calendar.HOUR_OF_DAY, 1); + this.calendar.set(Calendar.SECOND, 54); + Date localDate = this.calendar.getTime(); + TriggerContext context1 = getTriggerContext(localDate); if (timeZone.equals(TimeZone.getTimeZone("CET"))) { - // Clocks go forward an hour so 2am doesn't exist in CET for this date - calendar.add(Calendar.DAY_OF_MONTH, 1); + // Clocks go forward an hour so 2am doesn't exist in CET for this localDateTime + this.calendar.add(Calendar.DAY_OF_MONTH, 1); } - calendar.add(Calendar.HOUR_OF_DAY, 1); - calendar.set(Calendar.MINUTE, 10); - calendar.set(Calendar.SECOND, 0); - Object actual = date = trigger.nextExecutionTime(context1); - assertThat(actual).isEqualTo(calendar.getTime()); + this.calendar.add(Calendar.HOUR_OF_DAY, 1); + this.calendar.set(Calendar.MINUTE, 10); + this.calendar.set(Calendar.SECOND, 0); + Object actual = localDate = trigger.nextExecutionTime(context1); + assertThat(actual).isEqualTo(this.calendar.getTime()); + } + + private static void roundup(Calendar calendar) { + calendar.add(Calendar.SECOND, 1); + calendar.set(Calendar.MILLISECOND, 0); } - private void assertMatchesNextSecond(CronTrigger trigger, Calendar calendar) { - Date date = calendar.getTime(); + private static void assertMatchesNextSecond(CronTrigger trigger, Calendar calendar) { + Date localDateTime = calendar.getTime(); roundup(calendar); - TriggerContext context = getTriggerContext(date); + TriggerContext context = getTriggerContext(localDateTime); assertThat(trigger.nextExecutionTime(context)).isEqualTo(calendar.getTime()); } @@ -770,4 +854,19 @@ public class CronTriggerTests { return context; } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.METHOD) + @ParameterizedTest(name = "localDateTime [{0}], time zone [{1}]") + @MethodSource("parameters") + @interface ParameterizedCronTriggerTest { + } + + static Stream parameters() { + return Stream.of( + arguments(LocalDateTime.now(), TimeZone.getTimeZone("PST")), + arguments(LocalDateTime.now(), TimeZone.getTimeZone("CET")) + ); + } + } diff --git a/spring-context/src/test/java/org/springframework/scheduling/support/PeriodicTriggerTests.java b/spring-context/src/test/java/org/springframework/scheduling/support/PeriodicTriggerTests.java index 99beab8ee91..60e09f07962 100644 --- a/spring-context/src/test/java/org/springframework/scheduling/support/PeriodicTriggerTests.java +++ b/spring-context/src/test/java/org/springframework/scheduling/support/PeriodicTriggerTests.java @@ -19,7 +19,7 @@ package org.springframework.scheduling.support; import java.util.Date; import java.util.concurrent.TimeUnit; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.scheduling.TriggerContext; import org.springframework.util.NumberUtils; diff --git a/spring-context/src/test/java/org/springframework/scripting/bsh/BshScriptEvaluatorTests.java b/spring-context/src/test/java/org/springframework/scripting/bsh/BshScriptEvaluatorTests.java index 710a732cf42..dff1f6424b8 100644 --- a/spring-context/src/test/java/org/springframework/scripting/bsh/BshScriptEvaluatorTests.java +++ b/spring-context/src/test/java/org/springframework/scripting/bsh/BshScriptEvaluatorTests.java @@ -19,7 +19,7 @@ package org.springframework.scripting.bsh; import java.util.HashMap; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.io.ClassPathResource; import org.springframework.scripting.ScriptEvaluator; diff --git a/spring-context/src/test/java/org/springframework/scripting/bsh/BshScriptFactoryTests.java b/spring-context/src/test/java/org/springframework/scripting/bsh/BshScriptFactoryTests.java index 335ead34e1a..108db8c817e 100644 --- a/spring-context/src/test/java/org/springframework/scripting/bsh/BshScriptFactoryTests.java +++ b/spring-context/src/test/java/org/springframework/scripting/bsh/BshScriptFactoryTests.java @@ -20,7 +20,7 @@ import java.io.IOException; import java.util.Arrays; import java.util.Collection; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.support.AopUtils; import org.springframework.aop.target.dynamic.Refreshable; diff --git a/spring-context/src/test/java/org/springframework/scripting/config/ScriptingDefaultsTests.java b/spring-context/src/test/java/org/springframework/scripting/config/ScriptingDefaultsTests.java index c29af4e2800..07f9892b5ff 100644 --- a/spring-context/src/test/java/org/springframework/scripting/config/ScriptingDefaultsTests.java +++ b/spring-context/src/test/java/org/springframework/scripting/config/ScriptingDefaultsTests.java @@ -18,7 +18,7 @@ package org.springframework.scripting.config; import java.lang.reflect.Field; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.framework.Advised; import org.springframework.aop.support.AopUtils; diff --git a/spring-context/src/test/java/org/springframework/scripting/groovy/GroovyAspectIntegrationTests.java b/spring-context/src/test/java/org/springframework/scripting/groovy/GroovyAspectIntegrationTests.java index a5a6c2ab22c..2e0a6f41256 100644 --- a/spring-context/src/test/java/org/springframework/scripting/groovy/GroovyAspectIntegrationTests.java +++ b/spring-context/src/test/java/org/springframework/scripting/groovy/GroovyAspectIntegrationTests.java @@ -16,8 +16,8 @@ package org.springframework.scripting.groovy; -import org.junit.After; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; import org.springframework.context.support.GenericXmlApplicationContext; @@ -87,7 +87,7 @@ public class GroovyAspectIntegrationTests { assertThat(logAdvice.getCountThrows()).isEqualTo(1); } - @After + @AfterEach public void close() { if (context != null) { context.close(); diff --git a/spring-context/src/test/java/org/springframework/scripting/groovy/GroovyAspectTests.java b/spring-context/src/test/java/org/springframework/scripting/groovy/GroovyAspectTests.java index 0d1290e2c3c..6f1550f7c8e 100644 --- a/spring-context/src/test/java/org/springframework/scripting/groovy/GroovyAspectTests.java +++ b/spring-context/src/test/java/org/springframework/scripting/groovy/GroovyAspectTests.java @@ -16,7 +16,7 @@ package org.springframework.scripting.groovy; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.Advisor; import org.springframework.aop.aspectj.AspectJExpressionPointcut; diff --git a/spring-context/src/test/java/org/springframework/scripting/groovy/GroovyClassLoadingTests.java b/spring-context/src/test/java/org/springframework/scripting/groovy/GroovyClassLoadingTests.java index 623db3253c9..5bf307fbc73 100644 --- a/spring-context/src/test/java/org/springframework/scripting/groovy/GroovyClassLoadingTests.java +++ b/spring-context/src/test/java/org/springframework/scripting/groovy/GroovyClassLoadingTests.java @@ -19,7 +19,7 @@ package org.springframework.scripting.groovy; import java.lang.reflect.Method; import groovy.lang.GroovyClassLoader; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.context.support.StaticApplicationContext; diff --git a/spring-context/src/test/java/org/springframework/scripting/groovy/GroovyScriptEvaluatorTests.java b/spring-context/src/test/java/org/springframework/scripting/groovy/GroovyScriptEvaluatorTests.java index 8719bf149f5..4b584f0b240 100644 --- a/spring-context/src/test/java/org/springframework/scripting/groovy/GroovyScriptEvaluatorTests.java +++ b/spring-context/src/test/java/org/springframework/scripting/groovy/GroovyScriptEvaluatorTests.java @@ -20,7 +20,7 @@ import java.util.HashMap; import java.util.Map; import org.codehaus.groovy.control.customizers.ImportCustomizer; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.io.ClassPathResource; import org.springframework.scripting.ScriptEvaluator; diff --git a/spring-context/src/test/java/org/springframework/scripting/groovy/GroovyScriptFactoryTests.java b/spring-context/src/test/java/org/springframework/scripting/groovy/GroovyScriptFactoryTests.java index 551dc941d39..6f2df78bdd5 100644 --- a/spring-context/src/test/java/org/springframework/scripting/groovy/GroovyScriptFactoryTests.java +++ b/spring-context/src/test/java/org/springframework/scripting/groovy/GroovyScriptFactoryTests.java @@ -22,7 +22,7 @@ import java.util.Map; import groovy.lang.DelegatingMetaClass; import groovy.lang.GroovyObject; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.support.AopUtils; import org.springframework.aop.target.dynamic.Refreshable; diff --git a/spring-context/src/test/java/org/springframework/scripting/support/RefreshableScriptTargetSourceTests.java b/spring-context/src/test/java/org/springframework/scripting/support/RefreshableScriptTargetSourceTests.java index 1f7202ae65b..2d81f5da26a 100644 --- a/spring-context/src/test/java/org/springframework/scripting/support/RefreshableScriptTargetSourceTests.java +++ b/spring-context/src/test/java/org/springframework/scripting/support/RefreshableScriptTargetSourceTests.java @@ -16,7 +16,7 @@ package org.springframework.scripting.support; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanFactory; diff --git a/spring-context/src/test/java/org/springframework/scripting/support/ResourceScriptSourceTests.java b/spring-context/src/test/java/org/springframework/scripting/support/ResourceScriptSourceTests.java index 2bc78a118c3..a5ab6c5a55d 100644 --- a/spring-context/src/test/java/org/springframework/scripting/support/ResourceScriptSourceTests.java +++ b/spring-context/src/test/java/org/springframework/scripting/support/ResourceScriptSourceTests.java @@ -18,7 +18,7 @@ package org.springframework.scripting.support; import java.io.IOException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.io.ByteArrayResource; import org.springframework.core.io.Resource; diff --git a/spring-context/src/test/java/org/springframework/scripting/support/ScriptFactoryPostProcessorTests.java b/spring-context/src/test/java/org/springframework/scripting/support/ScriptFactoryPostProcessorTests.java index 1bdaf6a9153..ac8df1db7f4 100644 --- a/spring-context/src/test/java/org/springframework/scripting/support/ScriptFactoryPostProcessorTests.java +++ b/spring-context/src/test/java/org/springframework/scripting/support/ScriptFactoryPostProcessorTests.java @@ -16,8 +16,8 @@ package org.springframework.scripting.support; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.FatalBeanException; import org.springframework.beans.factory.BeanFactory; @@ -77,7 +77,7 @@ public class ScriptFactoryPostProcessorTests { " }\n" + "}"; - @Before + @BeforeEach public void setUp() { Assume.group(TestGroup.PERFORMANCE); } diff --git a/spring-context/src/test/java/org/springframework/scripting/support/StandardScriptFactoryTests.java b/spring-context/src/test/java/org/springframework/scripting/support/StandardScriptFactoryTests.java index 2d1d9d962f0..9acbb7d0b5d 100644 --- a/spring-context/src/test/java/org/springframework/scripting/support/StandardScriptFactoryTests.java +++ b/spring-context/src/test/java/org/springframework/scripting/support/StandardScriptFactoryTests.java @@ -18,7 +18,7 @@ package org.springframework.scripting.support; import java.util.Arrays; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.support.AopUtils; import org.springframework.aop.target.dynamic.Refreshable; diff --git a/spring-context/src/test/java/org/springframework/scripting/support/StaticScriptSourceTests.java b/spring-context/src/test/java/org/springframework/scripting/support/StaticScriptSourceTests.java index 9ebce57c509..a9bddab9003 100644 --- a/spring-context/src/test/java/org/springframework/scripting/support/StaticScriptSourceTests.java +++ b/spring-context/src/test/java/org/springframework/scripting/support/StaticScriptSourceTests.java @@ -16,7 +16,7 @@ package org.springframework.scripting.support; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-context/src/test/java/org/springframework/ui/ModelMapTests.java b/spring-context/src/test/java/org/springframework/ui/ModelMapTests.java index 9a85a76396f..afa9fee847c 100644 --- a/spring-context/src/test/java/org/springframework/ui/ModelMapTests.java +++ b/spring-context/src/test/java/org/springframework/ui/ModelMapTests.java @@ -27,7 +27,7 @@ import java.util.HashSet; import java.util.List; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.framework.ProxyFactory; import org.springframework.tests.sample.beans.TestBean; diff --git a/spring-context/src/test/java/org/springframework/validation/DataBinderFieldAccessTests.java b/spring-context/src/test/java/org/springframework/validation/DataBinderFieldAccessTests.java index bcd425f9ff3..4603386af36 100644 --- a/spring-context/src/test/java/org/springframework/validation/DataBinderFieldAccessTests.java +++ b/spring-context/src/test/java/org/springframework/validation/DataBinderFieldAccessTests.java @@ -19,7 +19,7 @@ package org.springframework.validation; import java.beans.PropertyEditorSupport; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.MutablePropertyValues; import org.springframework.beans.NotWritablePropertyException; diff --git a/spring-context/src/test/java/org/springframework/validation/DataBinderTests.java b/spring-context/src/test/java/org/springframework/validation/DataBinderTests.java index a05f1072c06..bccedfdb40a 100644 --- a/spring-context/src/test/java/org/springframework/validation/DataBinderTests.java +++ b/spring-context/src/test/java/org/springframework/validation/DataBinderTests.java @@ -36,7 +36,7 @@ import java.util.Optional; import java.util.Set; import java.util.TreeSet; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.BeanWrapper; import org.springframework.beans.InvalidPropertyException; diff --git a/spring-context/src/test/java/org/springframework/validation/DefaultMessageCodesResolverTests.java b/spring-context/src/test/java/org/springframework/validation/DefaultMessageCodesResolverTests.java index 276cb78b482..a2861ea039b 100644 --- a/spring-context/src/test/java/org/springframework/validation/DefaultMessageCodesResolverTests.java +++ b/spring-context/src/test/java/org/springframework/validation/DefaultMessageCodesResolverTests.java @@ -16,7 +16,7 @@ package org.springframework.validation; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.tests.sample.beans.TestBean; import org.springframework.validation.DefaultMessageCodesResolver.Format; diff --git a/spring-context/src/test/java/org/springframework/validation/ValidationUtilsTests.java b/spring-context/src/test/java/org/springframework/validation/ValidationUtilsTests.java index c82077ab9f8..50cb35484fe 100644 --- a/spring-context/src/test/java/org/springframework/validation/ValidationUtilsTests.java +++ b/spring-context/src/test/java/org/springframework/validation/ValidationUtilsTests.java @@ -16,7 +16,7 @@ package org.springframework.validation; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.lang.Nullable; import org.springframework.tests.sample.beans.TestBean; diff --git a/spring-context/src/test/java/org/springframework/validation/beanvalidation/BeanValidationPostProcessorTests.java b/spring-context/src/test/java/org/springframework/validation/beanvalidation/BeanValidationPostProcessorTests.java index c2ced70336f..b2828f40b10 100644 --- a/spring-context/src/test/java/org/springframework/validation/beanvalidation/BeanValidationPostProcessorTests.java +++ b/spring-context/src/test/java/org/springframework/validation/beanvalidation/BeanValidationPostProcessorTests.java @@ -20,7 +20,7 @@ import javax.annotation.PostConstruct; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator; import org.springframework.beans.factory.BeanCreationException; diff --git a/spring-context/src/test/java/org/springframework/validation/beanvalidation/MethodValidationTests.java b/spring-context/src/test/java/org/springframework/validation/beanvalidation/MethodValidationTests.java index 3ff7d3a92a8..78af65653b5 100644 --- a/spring-context/src/test/java/org/springframework/validation/beanvalidation/MethodValidationTests.java +++ b/spring-context/src/test/java/org/springframework/validation/beanvalidation/MethodValidationTests.java @@ -24,7 +24,7 @@ import javax.validation.constraints.Max; import javax.validation.constraints.NotNull; import javax.validation.groups.Default; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.framework.ProxyFactory; import org.springframework.beans.MutablePropertyValues; diff --git a/spring-context/src/test/java/org/springframework/validation/beanvalidation/SpringValidatorAdapterTests.java b/spring-context/src/test/java/org/springframework/validation/beanvalidation/SpringValidatorAdapterTests.java index d9e6ae307d4..4d78f3b7ab2 100644 --- a/spring-context/src/test/java/org/springframework/validation/beanvalidation/SpringValidatorAdapterTests.java +++ b/spring-context/src/test/java/org/springframework/validation/beanvalidation/SpringValidatorAdapterTests.java @@ -43,8 +43,8 @@ import javax.validation.constraints.NotNull; import javax.validation.constraints.Pattern; import javax.validation.constraints.Size; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.BeanWrapper; import org.springframework.beans.BeanWrapperImpl; @@ -69,7 +69,7 @@ public class SpringValidatorAdapterTests { private final StaticMessageSource messageSource = new StaticMessageSource(); - @Before + @BeforeEach public void setupSpringValidatorAdapter() { messageSource.addMessage("Size", Locale.ENGLISH, "Size of {0} must be between {2} and {1}"); messageSource.addMessage("Same", Locale.ENGLISH, "{2} must be same value as {1}"); diff --git a/spring-context/src/test/java/org/springframework/validation/beanvalidation/ValidatorFactoryTests.java b/spring-context/src/test/java/org/springframework/validation/beanvalidation/ValidatorFactoryTests.java index 0d2e23cc47c..d9a77a33e26 100644 --- a/spring-context/src/test/java/org/springframework/validation/beanvalidation/ValidatorFactoryTests.java +++ b/spring-context/src/test/java/org/springframework/validation/beanvalidation/ValidatorFactoryTests.java @@ -39,7 +39,7 @@ import javax.validation.constraints.NotNull; import org.hibernate.validator.HibernateValidator; import org.hibernate.validator.HibernateValidatorFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ConfigurableApplicationContext; 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 77a8f38f0f5..5766e93d93a 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 @@ -17,7 +17,7 @@ package org.springframework.context.annotation import org.junit.Assert.assertNotNull -import org.junit.Test +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 7787f44778c..3eed14a9612 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,16 +16,22 @@ package org.springframework.context.annotation -import org.junit.Assert.assertEquals -import org.junit.Test +import org.junit.Assert.* +import org.junit.jupiter.api.Test import org.springframework.beans.factory.getBean import org.springframework.beans.factory.parsing.BeanDefinitionParsingException class KotlinConfigurationClassTests { - @Test(expected = BeanDefinitionParsingException::class) + @Test fun `Final configuration with default proxyBeanMethods value`() { - AnnotationConfigApplicationContext(FinalConfigurationWithProxy::class.java) + try { + AnnotationConfigApplicationContext(FinalConfigurationWithProxy::class.java) + fail("should have thrown a BeanDefinitionParsingException") + } + catch (e: BeanDefinitionParsingException) { + // expected + } } @Test 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 7c225275dec..6f60ccb3392 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * 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. @@ -13,10 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.context.annotation import org.junit.Assert.assertEquals -import org.junit.Test +import org.junit.jupiter.api.Test import org.springframework.beans.factory.BeanFactory import org.springframework.beans.factory.getBean import org.springframework.context.support.ClassPathXmlApplicationContext 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 218ae00b294..2a0173b955f 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * 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. @@ -17,7 +17,7 @@ package org.springframework.context.support import org.junit.Assert.* -import org.junit.Test +import org.junit.jupiter.api.Test import org.springframework.beans.factory.NoSuchBeanDefinitionException import org.springframework.beans.factory.getBean import org.springframework.context.support.BeanDefinitionDsl.* 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 62931984f77..099b485a995 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * 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. @@ -17,7 +17,7 @@ package org.springframework.context.support import org.junit.Assert.assertNotNull -import org.junit.Test +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 dc27cf78151..42f0627a60f 100644 --- a/spring-context/src/test/kotlin/org/springframework/ui/ModelExtensionsTests.kt +++ b/spring-context/src/test/kotlin/org/springframework/ui/ModelExtensionsTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors + * 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. @@ -18,7 +18,7 @@ package org.springframework.ui import org.junit.Assert.assertEquals import org.junit.Assert.assertTrue -import org.junit.Test +import org.junit.jupiter.api.Test /** * Tests for [Model] Kotlin extensions. 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 1ab6deaef2c..723201a58ce 100644 --- a/spring-context/src/test/kotlin/org/springframework/ui/ModelMapExtensionsTests.kt +++ b/spring-context/src/test/kotlin/org/springframework/ui/ModelMapExtensionsTests.kt @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors + * 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. @@ -18,7 +18,7 @@ package org.springframework.ui import org.junit.Assert.assertEquals import org.junit.Assert.assertTrue -import org.junit.Test +import org.junit.jupiter.api.Test /** * Tests for [ModelMap] Kotlin extensions. diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/ArrayConstructorTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/ArrayConstructorTests.java index f58ff537c4c..267b45d26c9 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/ArrayConstructorTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/ArrayConstructorTests.java @@ -16,7 +16,7 @@ package org.springframework.expression.spel; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.expression.Expression; import org.springframework.expression.spel.standard.SpelExpressionParser; diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/BooleanExpressionTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/BooleanExpressionTests.java index f0614abaacb..9761734adec 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/BooleanExpressionTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/BooleanExpressionTests.java @@ -16,7 +16,7 @@ package org.springframework.expression.spel; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.convert.TypeDescriptor; import org.springframework.core.convert.support.GenericConversionService; diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/CachedMethodExecutorTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/CachedMethodExecutorTests.java index 62459ffdb2f..147faf8d349 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/CachedMethodExecutorTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/CachedMethodExecutorTests.java @@ -16,7 +16,7 @@ package org.springframework.expression.spel; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.expression.Expression; import org.springframework.expression.ExpressionParser; diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/ConstructorInvocationTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/ConstructorInvocationTests.java index 36e1ef40186..a1618232b55 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/ConstructorInvocationTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/ConstructorInvocationTests.java @@ -19,8 +19,8 @@ package org.springframework.expression.spel; import java.util.ArrayList; import java.util.List; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.springframework.core.convert.TypeDescriptor; import org.springframework.expression.AccessException; @@ -229,7 +229,7 @@ public class ConstructorInvocationTests extends AbstractExpressionTests { } @Test - @Ignore + @Disabled public void testArgumentConversion01() { // Closest ctor will be new String(String) and converter supports Double>String // TODO currently failing as with new ObjectToArray converter closest constructor diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/DefaultComparatorUnitTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/DefaultComparatorUnitTests.java index 0afdb577ce4..edc88bdebeb 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/DefaultComparatorUnitTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/DefaultComparatorUnitTests.java @@ -17,7 +17,7 @@ package org.springframework.expression.spel; import java.math.BigDecimal; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.expression.EvaluationException; import org.springframework.expression.TypeComparator; diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/EvaluationTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/EvaluationTests.java index c310ccbda59..98b9704ea33 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/EvaluationTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/EvaluationTests.java @@ -23,7 +23,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.convert.TypeDescriptor; import org.springframework.expression.AccessException; diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/ExpressionLanguageScenarioTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/ExpressionLanguageScenarioTests.java index 2396b17f0d9..08e370d16cc 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/ExpressionLanguageScenarioTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/ExpressionLanguageScenarioTests.java @@ -23,7 +23,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.expression.AccessException; import org.springframework.expression.EvaluationContext; diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/ExpressionStateTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/ExpressionStateTests.java index 63e835ee07f..a789b20560e 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/ExpressionStateTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/ExpressionStateTests.java @@ -19,7 +19,7 @@ package org.springframework.expression.spel; import java.util.HashMap; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.convert.TypeDescriptor; import org.springframework.expression.EvaluationContext; diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/ExpressionWithConversionTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/ExpressionWithConversionTests.java index d67ec475293..6ad4fe68e76 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/ExpressionWithConversionTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/ExpressionWithConversionTests.java @@ -21,8 +21,8 @@ import java.util.Collection; import java.util.Collections; import java.util.List; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.MethodParameter; import org.springframework.core.convert.ConversionService; @@ -58,7 +58,7 @@ public class ExpressionWithConversionTests extends AbstractExpressionTests { listOfInteger.add(6); } - @Before + @BeforeEach public void setUp() throws Exception { ExpressionWithConversionTests.typeDescriptorForListOfString = new TypeDescriptor(ExpressionWithConversionTests.class.getDeclaredField("listOfString")); ExpressionWithConversionTests.typeDescriptorForListOfInteger = new TypeDescriptor(ExpressionWithConversionTests.class.getDeclaredField("listOfInteger")); diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/InProgressTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/InProgressTests.java index 4238440be8a..a1c7d7724ee 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/InProgressTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/InProgressTests.java @@ -19,7 +19,7 @@ package org.springframework.expression.spel; import java.util.ArrayList; import java.util.HashMap; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.expression.spel.standard.SpelExpression; diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/IndexingTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/IndexingTests.java index b85ff308cd1..0af23293e7b 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/IndexingTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/IndexingTests.java @@ -26,7 +26,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.expression.AccessException; import org.springframework.expression.EvaluationContext; diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/ListTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/ListTests.java index 08c1e88c0aa..9250c1b9d90 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/ListTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/ListTests.java @@ -19,7 +19,7 @@ package org.springframework.expression.spel; import java.util.ArrayList; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.expression.spel.ast.InlineList; import org.springframework.expression.spel.standard.SpelExpression; diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/LiteralExpressionTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/LiteralExpressionTests.java index 6acbce3dcc5..4c599023788 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/LiteralExpressionTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/LiteralExpressionTests.java @@ -16,7 +16,7 @@ package org.springframework.expression.spel; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.expression.EvaluationContext; import org.springframework.expression.EvaluationException; diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/LiteralTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/LiteralTests.java index 16c38a63979..fec61a45c55 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/LiteralTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/LiteralTests.java @@ -16,7 +16,7 @@ package org.springframework.expression.spel; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.expression.spel.standard.SpelExpression; import org.springframework.expression.spel.support.StandardEvaluationContext; diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/MapAccessTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/MapAccessTests.java index 6cb5e83bc85..fc4896b93b3 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/MapAccessTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/MapAccessTests.java @@ -19,7 +19,7 @@ package org.springframework.expression.spel; import java.util.HashMap; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.expression.AccessException; import org.springframework.expression.EvaluationContext; diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/MapTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/MapTests.java index 40270a74372..759a15f4e1f 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/MapTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/MapTests.java @@ -22,7 +22,7 @@ import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.expression.spel.ast.InlineMap; import org.springframework.expression.spel.standard.SpelExpression; diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/MethodInvocationTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/MethodInvocationTests.java index 69d08965681..67f077f1676 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/MethodInvocationTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/MethodInvocationTests.java @@ -23,7 +23,7 @@ import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.convert.TypeDescriptor; import org.springframework.expression.AccessException; diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/OperatorOverloaderTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/OperatorOverloaderTests.java index f6bc255c16f..d949e0733b8 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/OperatorOverloaderTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/OperatorOverloaderTests.java @@ -16,7 +16,7 @@ package org.springframework.expression.spel; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.expression.EvaluationException; import org.springframework.expression.Operation; diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/OperatorTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/OperatorTests.java index 511e40d9178..92fef3bec69 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/OperatorTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/OperatorTests.java @@ -19,7 +19,7 @@ package org.springframework.expression.spel; import java.math.BigDecimal; import java.math.BigInteger; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.expression.spel.ast.Operator; import org.springframework.expression.spel.standard.SpelExpression; diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/ParserErrorMessagesTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/ParserErrorMessagesTests.java index aa2af2c93e4..359cfc17326 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/ParserErrorMessagesTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/ParserErrorMessagesTests.java @@ -16,7 +16,7 @@ package org.springframework.expression.spel; -import org.junit.Test; +import org.junit.jupiter.api.Test; /** * Tests the messages and exceptions that come out for badly formed expressions diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/ParsingTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/ParsingTests.java index 181f5d88428..f065fd8cff6 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/ParsingTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/ParsingTests.java @@ -16,7 +16,7 @@ package org.springframework.expression.spel; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.expression.spel.standard.SpelExpression; import org.springframework.expression.spel.standard.SpelExpressionParser; diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/PerformanceTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/PerformanceTests.java index 815d8ec18ab..ea86b740029 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/PerformanceTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/PerformanceTests.java @@ -16,7 +16,7 @@ package org.springframework.expression.spel; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.expression.EvaluationContext; import org.springframework.expression.Expression; diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/PropertyAccessTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/PropertyAccessTests.java index 6434f280e94..a4452225a9d 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/PropertyAccessTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/PropertyAccessTests.java @@ -21,7 +21,7 @@ import java.util.Collections; import java.util.List; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.convert.TypeDescriptor; import org.springframework.expression.AccessException; diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/ScenariosForSpringSecurity.java b/spring-expression/src/test/java/org/springframework/expression/spel/ScenariosForSpringSecurity.java index ce8d90c65d7..42a44f936b0 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/ScenariosForSpringSecurity.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/ScenariosForSpringSecurity.java @@ -19,7 +19,7 @@ package org.springframework.expression.spel; import java.lang.reflect.Method; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.MethodParameter; import org.springframework.core.convert.TypeDescriptor; diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/SelectionAndProjectionTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/SelectionAndProjectionTests.java index eac74c4153e..2b62a154f9d 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/SelectionAndProjectionTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/SelectionAndProjectionTests.java @@ -24,7 +24,7 @@ import java.util.Map; import java.util.Set; import java.util.TreeMap; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.expression.EvaluationContext; import org.springframework.expression.Expression; diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/SetValueTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/SetValueTests.java index ffcce6b8bed..6073d735b51 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/SetValueTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/SetValueTests.java @@ -19,7 +19,7 @@ package org.springframework.expression.spel; import java.util.Collection; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.expression.EvaluationException; import org.springframework.expression.Expression; diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/SpelCompilationCoverageTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/SpelCompilationCoverageTests.java index 6ccc9dd0459..45e5bc5cd3a 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/SpelCompilationCoverageTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/SpelCompilationCoverageTests.java @@ -28,7 +28,7 @@ import java.util.Map; import java.util.Set; import java.util.StringTokenizer; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.asm.MethodVisitor; import org.springframework.expression.AccessException; diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/SpelCompilationPerformanceTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/SpelCompilationPerformanceTests.java index 33de567b23d..a4609f4d200 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/SpelCompilationPerformanceTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/SpelCompilationPerformanceTests.java @@ -16,8 +16,8 @@ package org.springframework.expression.spel; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.springframework.expression.Expression; import org.springframework.expression.spel.standard.SpelCompiler; @@ -28,13 +28,13 @@ import static org.assertj.core.api.Assertions.fail; /** * Checks the speed of compiled SpEL expressions. * - *

By default these tests are marked @Ignore since they can fail on a busy machine + *

By default these tests are marked @Disabled since they can fail on a busy machine * because they compare relative performance of interpreted vs compiled. * * @author Andy Clement * @since 4.1 */ -@Ignore +@Disabled public class SpelCompilationPerformanceTests extends AbstractExpressionTests { int count = 50000; // number of evaluations that are timed in one run diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/SpelDocumentationTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/SpelDocumentationTests.java index 9b6e0daf3e2..884401a934e 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/SpelDocumentationTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/SpelDocumentationTests.java @@ -24,7 +24,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.expression.EvaluationContext; import org.springframework.expression.Expression; diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/SpelExceptionTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/SpelExceptionTests.java index 2d52e1edb47..f72ac2f261f 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/SpelExceptionTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/SpelExceptionTests.java @@ -19,7 +19,7 @@ package org.springframework.expression.spel; import java.util.ArrayList; import java.util.HashMap; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.expression.Expression; import org.springframework.expression.ExpressionParser; diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/SpelReproTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/SpelReproTests.java index 5f6665cbbc0..f35780b6378 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/SpelReproTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/SpelReproTests.java @@ -35,7 +35,7 @@ import java.util.Map; import java.util.Properties; import java.util.concurrent.atomic.AtomicInteger; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.MethodParameter; import org.springframework.core.convert.TypeDescriptor; diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/StandardTypeLocatorTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/StandardTypeLocatorTests.java index e51555ef3c3..a41ac5691ac 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/StandardTypeLocatorTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/StandardTypeLocatorTests.java @@ -17,7 +17,7 @@ package org.springframework.expression.spel; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.expression.EvaluationException; import org.springframework.expression.spel.support.StandardTypeLocator; diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/TemplateExpressionParsingTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/TemplateExpressionParsingTests.java index 12a35edcc6f..49face8bf7d 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/TemplateExpressionParsingTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/TemplateExpressionParsingTests.java @@ -16,7 +16,7 @@ package org.springframework.expression.spel; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.expression.EvaluationContext; import org.springframework.expression.EvaluationException; diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/VariableAndFunctionTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/VariableAndFunctionTests.java index 7d3ed06930c..0333e20ff96 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/VariableAndFunctionTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/VariableAndFunctionTests.java @@ -16,7 +16,7 @@ package org.springframework.expression.spel; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.expression.spel.standard.SpelExpressionParser; import org.springframework.expression.spel.support.StandardEvaluationContext; diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/ast/FormatHelperTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/ast/FormatHelperTests.java index 99a001d7277..2ecdc9eccb4 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/ast/FormatHelperTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/ast/FormatHelperTests.java @@ -18,7 +18,7 @@ package org.springframework.expression.spel.ast; import java.util.Arrays; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.convert.TypeDescriptor; diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/ast/OpPlusTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/ast/OpPlusTests.java index 3e715a4a5e4..ef6cb02b7ff 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/ast/OpPlusTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/ast/OpPlusTests.java @@ -21,7 +21,7 @@ import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.convert.support.GenericConversionService; import org.springframework.expression.TypedValue; diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/standard/PropertiesConversionSpelTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/standard/PropertiesConversionSpelTests.java index e5b55ef2cc9..887bf227f4c 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/standard/PropertiesConversionSpelTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/standard/PropertiesConversionSpelTests.java @@ -21,7 +21,7 @@ import java.util.Map; import java.util.Properties; import java.util.UUID; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.expression.Expression; import org.springframework.expression.spel.support.StandardEvaluationContext; diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/standard/SpelParserTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/standard/SpelParserTests.java index c0c60bd6f04..f2a37e55ede 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/standard/SpelParserTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/standard/SpelParserTests.java @@ -18,7 +18,7 @@ package org.springframework.expression.spel.standard; import java.util.function.Consumer; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.expression.EvaluationContext; import org.springframework.expression.ExpressionException; diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/support/ReflectionHelperTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/support/ReflectionHelperTests.java index 2c7a29740d4..82f6974c7f0 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/support/ReflectionHelperTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/support/ReflectionHelperTests.java @@ -22,7 +22,7 @@ import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.convert.TypeDescriptor; import org.springframework.expression.EvaluationContext; diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/support/StandardComponentsTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/support/StandardComponentsTests.java index e561ce1e114..62bd171e0b7 100644 --- a/spring-expression/src/test/java/org/springframework/expression/spel/support/StandardComponentsTests.java +++ b/spring-expression/src/test/java/org/springframework/expression/spel/support/StandardComponentsTests.java @@ -18,7 +18,7 @@ package org.springframework.expression.spel.support; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.convert.TypeDescriptor; import org.springframework.expression.EvaluationException; diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/config/InitializeDatabaseIntegrationTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/config/InitializeDatabaseIntegrationTests.java index 5fce291bdee..35248c3f8ae 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/config/InitializeDatabaseIntegrationTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/config/InitializeDatabaseIntegrationTests.java @@ -20,9 +20,9 @@ import java.util.List; import java.util.Map; import javax.sql.DataSource; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.InitializingBean; import org.springframework.context.support.ClassPathXmlApplicationContext; @@ -42,12 +42,12 @@ public class InitializeDatabaseIntegrationTests { private ClassPathXmlApplicationContext context; - @Before + @BeforeEach public void init() { enabled = System.setProperty("ENABLED", "true"); } - @After + @AfterEach public void after() { if (enabled != null) { System.setProperty("ENABLED", enabled); diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/config/JdbcNamespaceIntegrationTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/config/JdbcNamespaceIntegrationTests.java index 887cb07c2e7..711e07c76b6 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/config/JdbcNamespaceIntegrationTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/config/JdbcNamespaceIntegrationTests.java @@ -19,7 +19,7 @@ package org.springframework.jdbc.config; import java.util.function.Predicate; import javax.sql.DataSource; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.PropertyValue; import org.springframework.beans.factory.config.BeanDefinition; diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/core/BeanPropertyRowMapperTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/core/BeanPropertyRowMapperTests.java index b5dd056f02c..5672c88ca51 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/core/BeanPropertyRowMapperTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/core/BeanPropertyRowMapperTests.java @@ -18,7 +18,7 @@ package org.springframework.jdbc.core; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.TypeMismatchException; import org.springframework.dao.InvalidDataAccessApiUsageException; diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/core/JdbcTemplateQueryTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/core/JdbcTemplateQueryTests.java index f5b6e4e805b..06dd8256635 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/core/JdbcTemplateQueryTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/core/JdbcTemplateQueryTests.java @@ -28,8 +28,8 @@ import java.util.List; import java.util.Map; import javax.sql.DataSource; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.dao.IncorrectResultSizeDataAccessException; @@ -63,7 +63,7 @@ public class JdbcTemplateQueryTests { private JdbcTemplate template; - @Before + @BeforeEach public void setUp() throws Exception { this.connection = mock(Connection.class); this.dataSource = mock(DataSource.class); diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/core/JdbcTemplateTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/core/JdbcTemplateTests.java index 981cf2a34aa..4b70d22193e 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/core/JdbcTemplateTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/core/JdbcTemplateTests.java @@ -35,8 +35,8 @@ import java.util.List; import java.util.Map; import javax.sql.DataSource; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.dao.DataAccessException; import org.springframework.dao.InvalidDataAccessApiUsageException; @@ -89,7 +89,7 @@ public class JdbcTemplateTests { private CallableStatement callableStatement; - @Before + @BeforeEach public void setup() throws Exception { this.connection = mock(Connection.class); this.dataSource = mock(DataSource.class); diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/core/RowMapperTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/core/RowMapperTests.java index c29e9c9fb7f..1d96de162ac 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/core/RowMapperTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/core/RowMapperTests.java @@ -24,9 +24,9 @@ import java.sql.Statement; import java.sql.Types; import java.util.List; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.jdbc.datasource.SingleConnectionDataSource; import org.springframework.jdbc.support.SQLStateSQLExceptionTranslator; @@ -60,7 +60,7 @@ public class RowMapperTests { private List result; - @Before + @BeforeEach public void setUp() throws SQLException { given(connection.createStatement()).willReturn(statement); given(connection.prepareStatement(anyString())).willReturn(preparedStatement); @@ -75,13 +75,13 @@ public class RowMapperTests { template.afterPropertiesSet(); } - @After + @AfterEach public void verifyClosed() throws Exception { verify(resultSet).close(); // verify(connection).close(); } - @After + @AfterEach public void verifyResults() { assertThat(result).isNotNull(); assertThat(result.size()).isEqualTo(2); diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/core/SingleColumnRowMapperTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/core/SingleColumnRowMapperTests.java index 3a32cb31d3b..24f8413abd2 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/core/SingleColumnRowMapperTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/core/SingleColumnRowMapperTests.java @@ -23,7 +23,7 @@ import java.sql.SQLFeatureNotSupportedException; import java.sql.Timestamp; import java.time.LocalDateTime; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.convert.support.DefaultConversionService; import org.springframework.dao.TypeMismatchDataAccessException; diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/core/StatementCreatorUtilsTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/core/StatementCreatorUtilsTests.java index afcabd94860..7588a754d7e 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/core/StatementCreatorUtilsTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/core/StatementCreatorUtilsTests.java @@ -24,8 +24,8 @@ import java.sql.SQLException; import java.sql.Types; import java.util.GregorianCalendar; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; @@ -41,7 +41,7 @@ public class StatementCreatorUtilsTests { private PreparedStatement preparedStatement; - @Before + @BeforeEach public void setUp() { preparedStatement = mock(PreparedStatement.class); } diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/BeanPropertySqlParameterSourceTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/BeanPropertySqlParameterSourceTests.java index 16ab1809b21..cb1891d8c3f 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/BeanPropertySqlParameterSourceTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/BeanPropertySqlParameterSourceTests.java @@ -19,7 +19,7 @@ package org.springframework.jdbc.core.namedparam; import java.sql.Types; import java.util.Arrays; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.tests.sample.beans.TestBean; diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/MapSqlParameterSourceTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/MapSqlParameterSourceTests.java index d437ff9105a..2159ab1f50a 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/MapSqlParameterSourceTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/MapSqlParameterSourceTests.java @@ -18,7 +18,7 @@ package org.springframework.jdbc.core.namedparam; import java.sql.Types; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.jdbc.core.SqlParameterValue; import org.springframework.jdbc.support.JdbcUtils; diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcTemplateTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcTemplateTests.java index 4d9c56ce681..f58c9ad3957 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcTemplateTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcTemplateTests.java @@ -30,9 +30,9 @@ import java.util.List; import java.util.Map; import javax.sql.DataSource; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.mockito.InOrder; import org.springframework.jdbc.Customer; @@ -95,7 +95,7 @@ public class NamedParameterJdbcTemplateTests { private NamedParameterJdbcTemplate namedParameterTemplate; - @Before + @BeforeEach public void setup() throws Exception { connection = mock(Connection.class); dataSource = mock(DataSource.class); @@ -150,7 +150,7 @@ public class NamedParameterJdbcTemplateTests { verify(connection).close(); } - @Ignore("SPR-16340") + @Disabled("SPR-16340") @Test public void testExecuteArray() throws SQLException { given(preparedStatement.executeUpdate()).willReturn(1); diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/NamedParameterQueryTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/NamedParameterQueryTests.java index 5491a73996f..ede726fc89d 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/NamedParameterQueryTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/NamedParameterQueryTests.java @@ -30,9 +30,9 @@ import java.util.List; import java.util.Map; import javax.sql.DataSource; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.jdbc.core.RowMapper; @@ -61,7 +61,7 @@ public class NamedParameterQueryTests { private NamedParameterJdbcTemplate template; - @Before + @BeforeEach public void setup() throws Exception { connection = mock(Connection.class); dataSource = mock(DataSource.class); @@ -76,7 +76,7 @@ public class NamedParameterQueryTests { given(preparedStatement.executeQuery()).willReturn(resultSet); } - @After + @AfterEach public void verifyClose() throws Exception { verify(preparedStatement).close(); verify(resultSet).close(); diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/NamedParameterUtilsTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/NamedParameterUtilsTests.java index ee230e4f973..685d2f3aaeb 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/NamedParameterUtilsTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/core/namedparam/NamedParameterUtilsTests.java @@ -20,7 +20,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.dao.InvalidDataAccessApiUsageException; diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/core/simple/CallMetaDataContextTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/core/simple/CallMetaDataContextTests.java index 2f8f6b9840b..14a15fd4c74 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/core/simple/CallMetaDataContextTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/core/simple/CallMetaDataContextTests.java @@ -24,9 +24,9 @@ import java.util.List; import java.util.Map; import javax.sql.DataSource; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.jdbc.core.SqlInOutParameter; import org.springframework.jdbc.core.SqlOutParameter; @@ -55,7 +55,7 @@ public class CallMetaDataContextTests { private CallMetaDataContext context = new CallMetaDataContext(); - @Before + @BeforeEach public void setUp() throws Exception { connection = mock(Connection.class); databaseMetaData = mock(DatabaseMetaData.class); @@ -64,7 +64,7 @@ public class CallMetaDataContextTests { given(dataSource.getConnection()).willReturn(connection); } - @After + @AfterEach public void verifyClosed() throws Exception { verify(connection).close(); } diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/core/simple/SimpleJdbcCallTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/core/simple/SimpleJdbcCallTests.java index 7ae26bfac9d..139c7f1aad8 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/core/simple/SimpleJdbcCallTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/core/simple/SimpleJdbcCallTests.java @@ -24,8 +24,8 @@ import java.sql.SQLException; import java.sql.Types; import javax.sql.DataSource; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.dao.InvalidDataAccessApiUsageException; import org.springframework.jdbc.BadSqlGrammarException; @@ -57,7 +57,7 @@ public class SimpleJdbcCallTests { private CallableStatement callableStatement; - @Before + @BeforeEach public void setUp() throws Exception { connection = mock(Connection.class); databaseMetaData = mock(DatabaseMetaData.class); diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/core/simple/SimpleJdbcInsertTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/core/simple/SimpleJdbcInsertTests.java index b215706626b..06662bc46b7 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/core/simple/SimpleJdbcInsertTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/core/simple/SimpleJdbcInsertTests.java @@ -22,9 +22,9 @@ import java.sql.ResultSet; import java.util.HashMap; import javax.sql.DataSource; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.dao.InvalidDataAccessApiUsageException; @@ -47,7 +47,7 @@ public class SimpleJdbcInsertTests { private DataSource dataSource; - @Before + @BeforeEach public void setUp() throws Exception { connection = mock(Connection.class); databaseMetaData = mock(DatabaseMetaData.class); @@ -56,7 +56,7 @@ public class SimpleJdbcInsertTests { given(dataSource.getConnection()).willReturn(connection); } - @After + @AfterEach public void verifyClosed() throws Exception { verify(connection).close(); } diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/core/simple/TableMetaDataContextTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/core/simple/TableMetaDataContextTests.java index bd93e253409..cae12d2db8c 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/core/simple/TableMetaDataContextTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/core/simple/TableMetaDataContextTests.java @@ -25,8 +25,8 @@ import java.util.Date; import java.util.List; import javax.sql.DataSource; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.jdbc.core.SqlParameterValue; import org.springframework.jdbc.core.metadata.TableMetaDataContext; @@ -54,7 +54,7 @@ public class TableMetaDataContextTests { private TableMetaDataContext context = new TableMetaDataContext(); - @Before + @BeforeEach public void setUp() throws Exception { connection = mock(Connection.class); dataSource = mock(DataSource.class); diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/core/support/JdbcBeanDefinitionReaderTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/core/support/JdbcBeanDefinitionReaderTests.java index bef52ee3e69..94fabb4e864 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/core/support/JdbcBeanDefinitionReaderTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/core/support/JdbcBeanDefinitionReaderTests.java @@ -21,7 +21,7 @@ import java.sql.ResultSet; import java.sql.Statement; import javax.sql.DataSource; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.tests.sample.beans.TestBean; diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/core/support/JdbcDaoSupportTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/core/support/JdbcDaoSupportTests.java index 8d419f99459..05aede4bcfe 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/core/support/JdbcDaoSupportTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/core/support/JdbcDaoSupportTests.java @@ -20,7 +20,7 @@ import java.util.ArrayList; import java.util.List; import javax.sql.DataSource; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.jdbc.core.JdbcTemplate; diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/core/support/LobSupportTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/core/support/LobSupportTests.java index bab20e2da59..d0ba6edf8f9 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/core/support/LobSupportTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/core/support/LobSupportTests.java @@ -21,7 +21,7 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.dao.DataAccessException; import org.springframework.dao.IncorrectResultSizeDataAccessException; diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/core/support/SqlLobValueTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/core/support/SqlLobValueTests.java index 4a37c43a3dc..87d45d03d2c 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/core/support/SqlLobValueTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/core/support/SqlLobValueTests.java @@ -23,13 +23,15 @@ import java.sql.PreparedStatement; import java.sql.SQLException; import java.sql.Types; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; import org.springframework.jdbc.support.lob.LobCreator; import org.springframework.jdbc.support.lob.LobHandler; @@ -56,8 +58,9 @@ import static org.mockito.Mockito.verify; * * @author Alef Arendsen */ -@RunWith(MockitoJUnitRunner.class) -public class SqlLobValueTests { +@ExtendWith(MockitoExtension.class) +@MockitoSettings(strictness = Strictness.LENIENT) +class SqlLobValueTests { @Mock private PreparedStatement preparedStatement; @@ -71,13 +74,13 @@ public class SqlLobValueTests { @Captor private ArgumentCaptor inputStreamCaptor; - @Before - public void setUp() { + @BeforeEach + void setUp() { given(handler.getLobCreator()).willReturn(creator); } @Test - public void test1() throws SQLException { + void test1() throws SQLException { byte[] testBytes = "Bla".getBytes(); SqlLobValue lob = new SqlLobValue(testBytes, handler); lob.setTypeValue(preparedStatement, 1, Types.BLOB, "test"); @@ -85,7 +88,7 @@ public class SqlLobValueTests { } @Test - public void test2() throws SQLException { + void test2() throws SQLException { String testString = "Bla"; SqlLobValue lob = new SqlLobValue(testString, handler); lob.setTypeValue(preparedStatement, 1, Types.BLOB, "test"); @@ -93,14 +96,14 @@ public class SqlLobValueTests { } @Test - public void test3() throws SQLException { + void test3() throws SQLException { SqlLobValue lob = new SqlLobValue(new InputStreamReader(new ByteArrayInputStream("Bla".getBytes())), 12); assertThatIllegalArgumentException().isThrownBy(() -> lob.setTypeValue(preparedStatement, 1, Types.BLOB, "test")); } @Test - public void test4() throws SQLException { + void test4() throws SQLException { String testContent = "Bla"; SqlLobValue lob = new SqlLobValue(testContent, handler); lob.setTypeValue(preparedStatement, 1, Types.CLOB, "test"); @@ -108,7 +111,7 @@ public class SqlLobValueTests { } @Test - public void test5() throws Exception { + void test5() throws Exception { byte[] testContent = "Bla".getBytes(); SqlLobValue lob = new SqlLobValue(new ByteArrayInputStream(testContent), 3, handler); lob.setTypeValue(preparedStatement, 1, Types.CLOB, "test"); @@ -119,7 +122,7 @@ public class SqlLobValueTests { } @Test - public void test6() throws SQLException { + void test6() throws SQLException { byte[] testContent = "Bla".getBytes(); ByteArrayInputStream bais = new ByteArrayInputStream(testContent); InputStreamReader reader = new InputStreamReader(bais); @@ -129,14 +132,14 @@ public class SqlLobValueTests { } @Test - public void test7() throws SQLException { + void test7() throws SQLException { SqlLobValue lob = new SqlLobValue("bla".getBytes()); assertThatIllegalArgumentException().isThrownBy(() -> lob.setTypeValue(preparedStatement, 1, Types.CLOB, "test")); } @Test - public void testOtherConstructors() throws SQLException { + void testOtherConstructors() throws SQLException { // a bit BS, but we need to test them, as long as they don't throw exceptions SqlLobValue lob = new SqlLobValue("bla"); @@ -170,7 +173,7 @@ public class SqlLobValueTests { } @Test - public void testCorrectCleanup() throws SQLException { + void testCorrectCleanup() throws SQLException { SqlLobValue lob = new SqlLobValue("Bla", handler); lob.setTypeValue(preparedStatement, 1, Types.CLOB, "test"); lob.cleanup(); @@ -179,7 +182,7 @@ public class SqlLobValueTests { } @Test - public void testOtherSqlType() throws SQLException { + void testOtherSqlType() throws SQLException { SqlLobValue lob = new SqlLobValue("Bla", handler); assertThatIllegalArgumentException().isThrownBy(() -> lob.setTypeValue(preparedStatement, 1, Types.SMALLINT, "test")); diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/DataSourceJtaTransactionTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/DataSourceJtaTransactionTests.java index 0a81c6f3c36..abad52cad57 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/DataSourceJtaTransactionTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/DataSourceJtaTransactionTests.java @@ -29,9 +29,9 @@ import javax.transaction.Transaction; import javax.transaction.TransactionManager; import javax.transaction.UserTransaction; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.StaticListableBeanFactory; import org.springframework.jdbc.datasource.lookup.BeanFactoryDataSourceLookup; @@ -68,7 +68,7 @@ public class DataSourceJtaTransactionTests { private TransactionManager transactionManager; private Transaction transaction; - @Before + @BeforeEach public void setup() throws Exception { connection =mock(Connection.class); dataSource = mock(DataSource.class); @@ -78,7 +78,7 @@ public class DataSourceJtaTransactionTests { given(dataSource.getConnection()).willReturn(connection); } - @After + @AfterEach public void verifyTransactionSynchronizationManagerState() { assertThat(TransactionSynchronizationManager.getResourceMap().isEmpty()).isTrue(); assertThat(TransactionSynchronizationManager.isSynchronizationActive()).isFalse(); diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/DataSourceTransactionManagerTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/DataSourceTransactionManagerTests.java index 266cd3a12a5..7747ef29142 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/DataSourceTransactionManagerTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/DataSourceTransactionManagerTests.java @@ -24,9 +24,9 @@ import java.sql.Savepoint; import java.sql.Statement; import javax.sql.DataSource; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.InOrder; import org.springframework.dao.DataAccessResourceFailureException; @@ -72,7 +72,7 @@ public class DataSourceTransactionManagerTests { private DataSourceTransactionManager tm; - @Before + @BeforeEach public void setup() throws Exception { ds = mock(DataSource.class); con = mock(Connection.class); @@ -80,7 +80,7 @@ public class DataSourceTransactionManagerTests { tm = new DataSourceTransactionManager(ds); } - @After + @AfterEach public void verifyTransactionSynchronizationManagerState() { assertThat(TransactionSynchronizationManager.getResourceMap().isEmpty()).isTrue(); assertThat(TransactionSynchronizationManager.isSynchronizationActive()).isFalse(); diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/DelegatingDataSourceTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/DelegatingDataSourceTests.java index e238eb07d65..9c24806ff4b 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/DelegatingDataSourceTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/DelegatingDataSourceTests.java @@ -21,7 +21,7 @@ import java.io.PrintWriter; import java.sql.Connection; import javax.sql.DataSource; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/DriverManagerDataSourceTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/DriverManagerDataSourceTests.java index e4f27e05156..3b5ecbe8930 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/DriverManagerDataSourceTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/DriverManagerDataSourceTests.java @@ -19,7 +19,7 @@ package org.springframework.jdbc.datasource; import java.sql.Connection; import java.util.Properties; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/UserCredentialsDataSourceAdapterTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/UserCredentialsDataSourceAdapterTests.java index e5418b2f0cb..55a03f00119 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/UserCredentialsDataSourceAdapterTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/UserCredentialsDataSourceAdapterTests.java @@ -20,7 +20,7 @@ import java.sql.Connection; import java.sql.SQLException; import javax.sql.DataSource; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseBuilderTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseBuilderTests.java index 8222a8566f3..fe0effcdfdf 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseBuilderTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseBuilderTests.java @@ -16,7 +16,7 @@ package org.springframework.jdbc.datasource.embedded; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.io.ClassRelativeResourceLoader; import org.springframework.jdbc.core.JdbcTemplate; diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseFactoryBeanTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseFactoryBeanTests.java index 973125ed0eb..f9dc0c3d228 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseFactoryBeanTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseFactoryBeanTests.java @@ -18,7 +18,7 @@ package org.springframework.jdbc.datasource.embedded; import javax.sql.DataSource; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.io.ClassRelativeResourceLoader; import org.springframework.core.io.Resource; diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseFactoryTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseFactoryTests.java index c811a4a4fd0..7f7b7fdf96f 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseFactoryTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/embedded/EmbeddedDatabaseFactoryTests.java @@ -18,7 +18,7 @@ package org.springframework.jdbc.datasource.embedded; import java.sql.Connection; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.jdbc.datasource.init.DatabasePopulator; diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/init/AbstractDatabaseInitializationTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/init/AbstractDatabaseInitializationTests.java index 6c2e9dd360d..80c523bc2ce 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/init/AbstractDatabaseInitializationTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/init/AbstractDatabaseInitializationTests.java @@ -16,8 +16,8 @@ package org.springframework.jdbc.datasource.init; -import org.junit.After; -import org.junit.Before; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; import org.springframework.core.io.ClassRelativeResourceLoader; import org.springframework.core.io.Resource; @@ -46,13 +46,13 @@ public abstract class AbstractDatabaseInitializationTests { JdbcTemplate jdbcTemplate; - @Before + @BeforeEach public void setUp() { db = new EmbeddedDatabaseBuilder().setType(getEmbeddedDatabaseType()).build(); jdbcTemplate = new JdbcTemplate(db); } - @After + @AfterEach public void shutDown() { if (TransactionSynchronizationManager.isSynchronizationActive()) { TransactionSynchronizationManager.clear(); diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/init/AbstractDatabasePopulatorTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/init/AbstractDatabasePopulatorTests.java index c36205ef78a..ff8401f3e38 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/init/AbstractDatabasePopulatorTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/init/AbstractDatabasePopulatorTests.java @@ -19,7 +19,8 @@ package org.springframework.jdbc.datasource.init; import java.sql.Connection; import java.sql.SQLException; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Timeout; import org.springframework.jdbc.datasource.DataSourceUtils; import org.springframework.transaction.support.TransactionSynchronizationManager; @@ -36,7 +37,7 @@ import static org.mockito.Mockito.verify; * @author Sam Brannen * @author Oliver Gierke */ -public abstract class AbstractDatabasePopulatorTests extends AbstractDatabaseInitializationTests { +abstract class AbstractDatabasePopulatorTests extends AbstractDatabaseInitializationTests { private static final String COUNT_DAVE_SQL = "select COUNT(NAME) from T_TEST where NAME='Dave'"; @@ -46,7 +47,7 @@ public abstract class AbstractDatabasePopulatorTests extends AbstractDatabaseIni @Test - public void scriptWithSingleLineCommentsAndFailedDrop() throws Exception { + void scriptWithSingleLineCommentsAndFailedDrop() throws Exception { databasePopulator.addScript(resource("db-schema-failed-drop-comments.sql")); databasePopulator.addScript(resource("db-test-data.sql")); databasePopulator.setIgnoreFailedDrops(true); @@ -55,7 +56,7 @@ public abstract class AbstractDatabasePopulatorTests extends AbstractDatabaseIni } @Test - public void scriptWithStandardEscapedLiteral() throws Exception { + void scriptWithStandardEscapedLiteral() throws Exception { databasePopulator.addScript(defaultSchema()); databasePopulator.addScript(resource("db-test-data-escaped-literal.sql")); DatabasePopulatorUtils.execute(databasePopulator, db); @@ -63,7 +64,7 @@ public abstract class AbstractDatabasePopulatorTests extends AbstractDatabaseIni } @Test - public void scriptWithMySqlEscapedLiteral() throws Exception { + void scriptWithMySqlEscapedLiteral() throws Exception { databasePopulator.addScript(defaultSchema()); databasePopulator.addScript(resource("db-test-data-mysql-escaped-literal.sql")); DatabasePopulatorUtils.execute(databasePopulator, db); @@ -71,7 +72,7 @@ public abstract class AbstractDatabasePopulatorTests extends AbstractDatabaseIni } @Test - public void scriptWithMultipleStatements() throws Exception { + void scriptWithMultipleStatements() throws Exception { databasePopulator.addScript(defaultSchema()); databasePopulator.addScript(resource("db-test-data-multiple.sql")); DatabasePopulatorUtils.execute(databasePopulator, db); @@ -80,7 +81,7 @@ public abstract class AbstractDatabasePopulatorTests extends AbstractDatabaseIni } @Test - public void scriptWithMultipleStatementsAndLongSeparator() throws Exception { + void scriptWithMultipleStatementsAndLongSeparator() throws Exception { databasePopulator.addScript(defaultSchema()); databasePopulator.addScript(resource("db-test-data-endings.sql")); databasePopulator.setSeparator("@@"); @@ -90,7 +91,7 @@ public abstract class AbstractDatabasePopulatorTests extends AbstractDatabaseIni } @Test - public void scriptWithMultipleStatementsAndWhitespaceSeparator() throws Exception { + void scriptWithMultipleStatementsAndWhitespaceSeparator() throws Exception { databasePopulator.addScript(defaultSchema()); databasePopulator.addScript(resource("db-test-data-whitespace.sql")); databasePopulator.setSeparator("/\n"); @@ -100,7 +101,7 @@ public abstract class AbstractDatabasePopulatorTests extends AbstractDatabaseIni } @Test - public void scriptWithMultipleStatementsAndNewlineSeparator() throws Exception { + void scriptWithMultipleStatementsAndNewlineSeparator() throws Exception { databasePopulator.addScript(defaultSchema()); databasePopulator.addScript(resource("db-test-data-newline.sql")); DatabasePopulatorUtils.execute(databasePopulator, db); @@ -109,7 +110,7 @@ public abstract class AbstractDatabasePopulatorTests extends AbstractDatabaseIni } @Test - public void scriptWithMultipleStatementsAndMultipleNewlineSeparator() throws Exception { + void scriptWithMultipleStatementsAndMultipleNewlineSeparator() throws Exception { databasePopulator.addScript(defaultSchema()); databasePopulator.addScript(resource("db-test-data-multi-newline.sql")); databasePopulator.setSeparator("\n\n"); @@ -119,7 +120,7 @@ public abstract class AbstractDatabasePopulatorTests extends AbstractDatabaseIni } @Test - public void scriptWithEolBetweenTokens() throws Exception { + void scriptWithEolBetweenTokens() throws Exception { databasePopulator.addScript(usersSchema()); databasePopulator.addScript(resource("users-data.sql")); DatabasePopulatorUtils.execute(databasePopulator, db); @@ -127,7 +128,7 @@ public abstract class AbstractDatabasePopulatorTests extends AbstractDatabaseIni } @Test - public void scriptWithCommentsWithinStatements() throws Exception { + void scriptWithCommentsWithinStatements() throws Exception { databasePopulator.addScript(usersSchema()); databasePopulator.addScript(resource("users-data-with-comments.sql")); DatabasePopulatorUtils.execute(databasePopulator, db); @@ -135,7 +136,7 @@ public abstract class AbstractDatabasePopulatorTests extends AbstractDatabaseIni } @Test - public void scriptWithoutStatementSeparator() throws Exception { + void scriptWithoutStatementSeparator() throws Exception { databasePopulator.setSeparator(ScriptUtils.EOF_STATEMENT_SEPARATOR); databasePopulator.addScript(resource("drop-users-schema.sql")); databasePopulator.addScript(resource("users-schema-without-separator.sql")); @@ -146,7 +147,7 @@ public abstract class AbstractDatabasePopulatorTests extends AbstractDatabaseIni } @Test - public void constructorWithMultipleScriptResources() throws Exception { + void constructorWithMultipleScriptResources() throws Exception { final ResourceDatabasePopulator populator = new ResourceDatabasePopulator(usersSchema(), resource("users-data-with-comments.sql")); DatabasePopulatorUtils.execute(populator, db); @@ -154,7 +155,7 @@ public abstract class AbstractDatabasePopulatorTests extends AbstractDatabaseIni } @Test - public void scriptWithSelectStatements() throws Exception { + void scriptWithSelectStatements() throws Exception { databasePopulator.addScript(defaultSchema()); databasePopulator.addScript(resource("db-test-data-select.sql")); DatabasePopulatorUtils.execute(databasePopulator, db); @@ -166,7 +167,7 @@ public abstract class AbstractDatabasePopulatorTests extends AbstractDatabaseIni * See SPR-9457 */ @Test - public void usesBoundConnectionIfAvailable() throws SQLException { + void usesBoundConnectionIfAvailable() throws SQLException { TransactionSynchronizationManager.initSynchronization(); Connection connection = DataSourceUtils.getConnection(db); DatabasePopulator populator = mock(DatabasePopulator.class); @@ -177,8 +178,9 @@ public abstract class AbstractDatabasePopulatorTests extends AbstractDatabaseIni /** * See SPR-9781 */ - @Test(timeout = 1000) - public void executesHugeScriptInReasonableTime() throws SQLException { + @Test + @Timeout(1) + void executesHugeScriptInReasonableTime() throws SQLException { databasePopulator.addScript(defaultSchema()); databasePopulator.addScript(resource("db-test-data-huge.sql")); DatabasePopulatorUtils.execute(databasePopulator, db); diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/init/CompositeDatabasePopulatorTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/init/CompositeDatabasePopulatorTests.java index 534d9eccd5a..d24c7dfed70 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/init/CompositeDatabasePopulatorTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/init/CompositeDatabasePopulatorTests.java @@ -21,7 +21,7 @@ import java.sql.SQLException; import java.util.LinkedHashSet; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/init/H2DatabasePopulatorTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/init/H2DatabasePopulatorTests.java index 1c5b49c4041..e61ebab4aa6 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/init/H2DatabasePopulatorTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/init/H2DatabasePopulatorTests.java @@ -16,20 +16,19 @@ package org.springframework.jdbc.datasource.init; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; import static org.assertj.core.api.Assertions.assertThat; - - /** * @author Sam Brannen * @since 4.0.3 */ -public class H2DatabasePopulatorTests extends AbstractDatabasePopulatorTests { +class H2DatabasePopulatorTests extends AbstractDatabasePopulatorTests { + @Override protected EmbeddedDatabaseType getEmbeddedDatabaseType() { return EmbeddedDatabaseType.H2; } @@ -40,7 +39,7 @@ public class H2DatabasePopulatorTests extends AbstractDatabasePopulatorTests { * @since 5.0 */ @Test - public void scriptWithH2Alias() throws Exception { + void scriptWithH2Alias() throws Exception { databasePopulator.addScript(usersSchema()); databasePopulator.addScript(resource("db-test-data-h2-alias.sql")); // Set statement separator to double newline so that ";" is not diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/init/ResourceDatabasePopulatorTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/init/ResourceDatabasePopulatorTests.java index 4f12b8560cd..deca1410457 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/init/ResourceDatabasePopulatorTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/init/ResourceDatabasePopulatorTests.java @@ -16,7 +16,7 @@ package org.springframework.jdbc.datasource.init; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.springframework.core.io.Resource; diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/init/ScriptUtilsIntegrationTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/init/ScriptUtilsIntegrationTests.java index 4c99e7f6cc6..bb7aa44d843 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/init/ScriptUtilsIntegrationTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/init/ScriptUtilsIntegrationTests.java @@ -18,8 +18,8 @@ package org.springframework.jdbc.datasource.init; import java.sql.SQLException; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType; @@ -38,7 +38,7 @@ public class ScriptUtilsIntegrationTests extends AbstractDatabaseInitializationT return EmbeddedDatabaseType.HSQL; } - @Before + @BeforeEach public void setUpSchema() throws SQLException { executeSqlScript(db.getConnection(), usersSchema()); } diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/init/ScriptUtilsUnitTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/init/ScriptUtilsUnitTests.java index 2922bbae4d1..f57adece236 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/init/ScriptUtilsUnitTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/init/ScriptUtilsUnitTests.java @@ -19,7 +19,7 @@ package org.springframework.jdbc.datasource.init; import java.util.ArrayList; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.support.EncodedResource; diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/lookup/BeanFactoryDataSourceLookupTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/lookup/BeanFactoryDataSourceLookupTests.java index 524e7ac12a8..5c6a203b490 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/lookup/BeanFactoryDataSourceLookupTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/lookup/BeanFactoryDataSourceLookupTests.java @@ -18,7 +18,7 @@ package org.springframework.jdbc.datasource.lookup; import javax.sql.DataSource; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanNotOfRequiredTypeException; diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/lookup/JndiDataSourceLookupTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/lookup/JndiDataSourceLookupTests.java index 33e4f84e095..741a100de1b 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/lookup/JndiDataSourceLookupTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/lookup/JndiDataSourceLookupTests.java @@ -19,7 +19,7 @@ package org.springframework.jdbc.datasource.lookup; import javax.naming.NamingException; import javax.sql.DataSource; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/lookup/MapDataSourceLookupTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/lookup/MapDataSourceLookupTests.java index ffb28069860..9e86fc6beac 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/lookup/MapDataSourceLookupTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/lookup/MapDataSourceLookupTests.java @@ -20,7 +20,7 @@ import java.util.HashMap; import java.util.Map; import javax.sql.DataSource; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/object/BatchSqlUpdateTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/object/BatchSqlUpdateTests.java index 1cc00856647..2f7047b10f2 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/object/BatchSqlUpdateTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/object/BatchSqlUpdateTests.java @@ -22,7 +22,7 @@ import java.sql.PreparedStatement; import java.sql.Types; import javax.sql.DataSource; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.jdbc.core.SqlParameter; diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/object/GenericSqlQueryTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/object/GenericSqlQueryTests.java index ad6ee1212c8..fe838f5a798 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/object/GenericSqlQueryTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/object/GenericSqlQueryTests.java @@ -26,8 +26,8 @@ import java.util.List; import java.util.Map; import javax.sql.DataSource; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; @@ -58,7 +58,7 @@ public class GenericSqlQueryTests { private ResultSet resultSet; - @Before + @BeforeEach public void setUp() throws Exception { this.beanFactory = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(this.beanFactory).loadBeanDefinitions( diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/object/GenericStoredProcedureTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/object/GenericStoredProcedureTests.java index 196b4c9f795..854c2847d40 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/object/GenericStoredProcedureTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/object/GenericStoredProcedureTests.java @@ -23,7 +23,7 @@ import java.util.HashMap; import java.util.Map; import javax.sql.DataSource; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/object/RdbmsOperationTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/object/RdbmsOperationTests.java index 1014dc4e172..fdcc4c6f444 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/object/RdbmsOperationTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/object/RdbmsOperationTests.java @@ -21,7 +21,7 @@ import java.util.HashMap; import java.util.Map; import javax.sql.DataSource; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.dao.InvalidDataAccessApiUsageException; import org.springframework.jdbc.core.JdbcTemplate; diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/object/SqlQueryTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/object/SqlQueryTests.java index 666ac15eb75..3e40f63176f 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/object/SqlQueryTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/object/SqlQueryTests.java @@ -29,8 +29,8 @@ import java.util.List; import java.util.Map; import javax.sql.DataSource; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.dao.IncorrectResultSizeDataAccessException; import org.springframework.dao.InvalidDataAccessApiUsageException; @@ -90,7 +90,7 @@ public class SqlQueryTests { private ResultSet resultSet; - @Before + @BeforeEach public void setUp() throws Exception { this.connection = mock(Connection.class); this.dataSource = mock(DataSource.class); diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/object/SqlUpdateTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/object/SqlUpdateTests.java index ca95483ccd9..3c3c074ceb2 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/object/SqlUpdateTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/object/SqlUpdateTests.java @@ -26,9 +26,9 @@ import java.util.HashMap; import java.util.Map; import javax.sql.DataSource; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.jdbc.JdbcUpdateAffectedIncorrectNumberOfRowsException; import org.springframework.jdbc.core.SqlParameter; @@ -80,7 +80,7 @@ public class SqlUpdateTests { private ResultSetMetaData resultSetMetaData; - @Before + @BeforeEach public void setUp() throws Exception { dataSource = mock(DataSource.class); connection = mock(Connection.class); @@ -90,7 +90,7 @@ public class SqlUpdateTests { given(dataSource.getConnection()).willReturn(connection); } - @After + @AfterEach public void verifyClosed() throws Exception { verify(preparedStatement).close(); verify(connection).close(); diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/object/StoredProcedureTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/object/StoredProcedureTests.java index de3ca838077..1602e87b840 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/object/StoredProcedureTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/object/StoredProcedureTests.java @@ -28,9 +28,9 @@ import java.util.List; import java.util.Map; import javax.sql.DataSource; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.dao.DataAccessException; import org.springframework.dao.InvalidDataAccessApiUsageException; @@ -73,7 +73,7 @@ public class StoredProcedureTests { private boolean verifyClosedAfter = true; - @Before + @BeforeEach public void setup() throws Exception { dataSource = mock(DataSource.class); connection = mock(Connection.class); @@ -82,7 +82,7 @@ public class StoredProcedureTests { given(callableStatement.getConnection()).willReturn(connection); } - @After + @AfterEach public void verifyClosed() throws Exception { if (verifyClosedAfter) { verify(callableStatement).close(); diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/support/CustomSQLExceptionTranslatorRegistrarTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/support/CustomSQLExceptionTranslatorRegistrarTests.java index 6001786ad79..4eb3947f509 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/support/CustomSQLExceptionTranslatorRegistrarTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/support/CustomSQLExceptionTranslatorRegistrarTests.java @@ -18,7 +18,7 @@ package org.springframework.jdbc.support; import java.sql.SQLException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.dao.DataAccessException; diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/support/DataFieldMaxValueIncrementerTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/support/DataFieldMaxValueIncrementerTests.java index 5fe3e41acb4..b91c9345614 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/support/DataFieldMaxValueIncrementerTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/support/DataFieldMaxValueIncrementerTests.java @@ -22,7 +22,7 @@ import java.sql.SQLException; import java.sql.Statement; import javax.sql.DataSource; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.jdbc.support.incrementer.HanaSequenceMaxValueIncrementer; import org.springframework.jdbc.support.incrementer.HsqlMaxValueIncrementer; diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/support/DefaultLobHandlerTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/support/DefaultLobHandlerTests.java index 4f9b5df7725..6343ffad427 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/support/DefaultLobHandlerTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/support/DefaultLobHandlerTests.java @@ -25,7 +25,7 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.jdbc.support.lob.DefaultLobHandler; import org.springframework.jdbc.support.lob.LobCreator; diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/support/JdbcUtilsTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/support/JdbcUtilsTests.java index 43bdb2660b3..70051932c94 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/support/JdbcUtilsTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/support/JdbcUtilsTests.java @@ -18,7 +18,7 @@ package org.springframework.jdbc.support; import java.sql.Types; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/support/KeyHolderTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/support/KeyHolderTests.java index 8bb38b025e7..26c6d943f1c 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/support/KeyHolderTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/support/KeyHolderTests.java @@ -19,7 +19,7 @@ package org.springframework.jdbc.support; import java.util.HashMap; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.dao.DataRetrievalFailureException; import org.springframework.dao.InvalidDataAccessApiUsageException; diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/support/SQLErrorCodeSQLExceptionTranslatorTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/support/SQLErrorCodeSQLExceptionTranslatorTests.java index 2bddf3d8f91..cef07433d31 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/support/SQLErrorCodeSQLExceptionTranslatorTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/support/SQLErrorCodeSQLExceptionTranslatorTests.java @@ -20,7 +20,7 @@ import java.sql.BatchUpdateException; import java.sql.DataTruncation; import java.sql.SQLException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.dao.CannotAcquireLockException; import org.springframework.dao.CannotSerializeTransactionException; diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/support/SQLErrorCodesFactoryTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/support/SQLErrorCodesFactoryTests.java index 13279760945..a23728ba31b 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/support/SQLErrorCodesFactoryTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/support/SQLErrorCodesFactoryTests.java @@ -22,7 +22,7 @@ import java.sql.SQLException; import java.util.Arrays; import javax.sql.DataSource; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/support/SQLExceptionCustomTranslatorTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/support/SQLExceptionCustomTranslatorTests.java index 14e9aec8549..8d46c0f578d 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/support/SQLExceptionCustomTranslatorTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/support/SQLExceptionCustomTranslatorTests.java @@ -18,7 +18,7 @@ package org.springframework.jdbc.support; import java.sql.SQLException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.dao.DataAccessException; import org.springframework.dao.TransientDataAccessResourceException; diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/support/SQLExceptionSubclassTranslatorTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/support/SQLExceptionSubclassTranslatorTests.java index 8ae02516b79..f599303aaae 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/support/SQLExceptionSubclassTranslatorTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/support/SQLExceptionSubclassTranslatorTests.java @@ -18,7 +18,7 @@ package org.springframework.jdbc.support; import java.sql.SQLException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.dao.ConcurrencyFailureException; import org.springframework.dao.DataAccessResourceFailureException; diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/support/SQLStateExceptionTranslatorTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/support/SQLStateExceptionTranslatorTests.java index 05078a91fce..0a712bc4265 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/support/SQLStateExceptionTranslatorTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/support/SQLStateExceptionTranslatorTests.java @@ -18,7 +18,7 @@ package org.springframework.jdbc.support; import java.sql.SQLException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.jdbc.BadSqlGrammarException; import org.springframework.jdbc.UncategorizedSQLException; diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/support/SQLStateSQLExceptionTranslatorTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/support/SQLStateSQLExceptionTranslatorTests.java index 32fcac97e2f..c4556319cce 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/support/SQLStateSQLExceptionTranslatorTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/support/SQLStateSQLExceptionTranslatorTests.java @@ -18,7 +18,7 @@ package org.springframework.jdbc.support; import java.sql.SQLException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.dao.ConcurrencyFailureException; import org.springframework.dao.DataAccessException; diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/support/rowset/ResultSetWrappingRowSetTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/support/rowset/ResultSetWrappingRowSetTests.java index b7f5d78cefc..06ca4946598 100644 --- a/spring-jdbc/src/test/java/org/springframework/jdbc/support/rowset/ResultSetWrappingRowSetTests.java +++ b/spring-jdbc/src/test/java/org/springframework/jdbc/support/rowset/ResultSetWrappingRowSetTests.java @@ -25,8 +25,8 @@ import java.sql.SQLException; import java.sql.Time; import java.sql.Timestamp; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.jdbc.InvalidResultSetAccessException; @@ -45,7 +45,7 @@ public class ResultSetWrappingRowSetTests { private ResultSetWrappingSqlRowSet rowSet; - @Before + @BeforeEach public void setup() throws Exception { resultSet = mock(ResultSet.class); rowSet = new ResultSetWrappingSqlRowSet(resultSet); 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 41e106b617a..e19f4627dba 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 @@ -16,13 +16,14 @@ package org.springframework.jdbc.core +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.Test -import java.sql.* +import org.junit.jupiter.api.Test /** * Mock object based tests for [JdbcOperations] Kotlin extensions 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 b88d28a1912..27d3e070355 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors + * 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. @@ -16,10 +16,11 @@ package org.springframework.jdbc.core.namedparam -import org.junit.Assert.assertEquals -import org.junit.Test import java.sql.JDBCType +import org.junit.Assert.assertEquals +import org.junit.jupiter.api.Test + /** * Tests for [MapSqlParameterSource] Kotlin extensions. * @@ -50,4 +51,5 @@ class MapSqlParameterSourceExtensionsTests { assertEquals(JDBCType.INTEGER.vendorTypeNumber, source.getSqlType("foo")) assertEquals("INT", source.getTypeName("foo")) } -} \ No newline at end of file + +} diff --git a/spring-jms/src/test/java/org/springframework/jms/annotation/AbstractJmsAnnotationDrivenTests.java b/spring-jms/src/test/java/org/springframework/jms/annotation/AbstractJmsAnnotationDrivenTests.java index 0383fef3887..db94122ca4a 100644 --- a/spring-jms/src/test/java/org/springframework/jms/annotation/AbstractJmsAnnotationDrivenTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/annotation/AbstractJmsAnnotationDrivenTests.java @@ -20,7 +20,7 @@ import java.lang.reflect.Method; import javax.jms.JMSException; import javax.jms.Session; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.ApplicationContext; import org.springframework.jms.StubTextMessage; diff --git a/spring-jms/src/test/java/org/springframework/jms/annotation/AnnotationDrivenNamespaceTests.java b/spring-jms/src/test/java/org/springframework/jms/annotation/AnnotationDrivenNamespaceTests.java index 4101b11f800..030acedaba4 100644 --- a/spring-jms/src/test/java/org/springframework/jms/annotation/AnnotationDrivenNamespaceTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/annotation/AnnotationDrivenNamespaceTests.java @@ -19,7 +19,7 @@ package org.springframework.jms.annotation; import javax.jms.JMSException; import javax.jms.MessageListener; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; diff --git a/spring-jms/src/test/java/org/springframework/jms/annotation/EnableJmsTests.java b/spring-jms/src/test/java/org/springframework/jms/annotation/EnableJmsTests.java index 0547fc5b091..b584bb493ab 100644 --- a/spring-jms/src/test/java/org/springframework/jms/annotation/EnableJmsTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/annotation/EnableJmsTests.java @@ -21,7 +21,7 @@ import java.lang.annotation.RetentionPolicy; import javax.jms.JMSException; import javax.jms.MessageListener; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanCreationException; import org.springframework.context.ConfigurableApplicationContext; diff --git a/spring-jms/src/test/java/org/springframework/jms/annotation/JmsListenerAnnotationBeanPostProcessorTests.java b/spring-jms/src/test/java/org/springframework/jms/annotation/JmsListenerAnnotationBeanPostProcessorTests.java index a1802e00bd1..54ecb8ee281 100644 --- a/spring-jms/src/test/java/org/springframework/jms/annotation/JmsListenerAnnotationBeanPostProcessorTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/annotation/JmsListenerAnnotationBeanPostProcessorTests.java @@ -22,7 +22,7 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import java.lang.reflect.Method; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.support.AopUtils; import org.springframework.beans.factory.BeanCreationException; diff --git a/spring-jms/src/test/java/org/springframework/jms/config/JmsListenerContainerFactoryIntegrationTests.java b/spring-jms/src/test/java/org/springframework/jms/config/JmsListenerContainerFactoryIntegrationTests.java index b769a3f86c7..bac32b0f979 100644 --- a/spring-jms/src/test/java/org/springframework/jms/config/JmsListenerContainerFactoryIntegrationTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/config/JmsListenerContainerFactoryIntegrationTests.java @@ -25,8 +25,8 @@ import javax.jms.MessageListener; import javax.jms.Session; import javax.jms.TextMessage; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.aop.framework.ProxyFactory; import org.springframework.beans.factory.support.StaticListableBeanFactory; @@ -58,7 +58,7 @@ public class JmsListenerContainerFactoryIntegrationTests { private JmsEndpointSampleInterface listener = sample; - @Before + @BeforeEach public void setup() { initializeFactory(factory); } diff --git a/spring-jms/src/test/java/org/springframework/jms/config/JmsListenerContainerFactoryTests.java b/spring-jms/src/test/java/org/springframework/jms/config/JmsListenerContainerFactoryTests.java index 84a3502de5b..865a0edc08f 100644 --- a/spring-jms/src/test/java/org/springframework/jms/config/JmsListenerContainerFactoryTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/config/JmsListenerContainerFactoryTests.java @@ -21,7 +21,7 @@ import javax.jms.MessageListener; import javax.jms.Session; import javax.transaction.TransactionManager; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.DirectFieldAccessor; import org.springframework.jms.StubConnectionFactory; diff --git a/spring-jms/src/test/java/org/springframework/jms/config/JmsListenerEndpointRegistrarTests.java b/spring-jms/src/test/java/org/springframework/jms/config/JmsListenerEndpointRegistrarTests.java index 986fce8e55d..40be2cabd9e 100644 --- a/spring-jms/src/test/java/org/springframework/jms/config/JmsListenerEndpointRegistrarTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/config/JmsListenerEndpointRegistrarTests.java @@ -16,8 +16,8 @@ package org.springframework.jms.config; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.StaticListableBeanFactory; @@ -37,7 +37,7 @@ public class JmsListenerEndpointRegistrarTests { private final JmsListenerContainerTestFactory containerFactory = new JmsListenerContainerTestFactory(); - @Before + @BeforeEach public void setup() { this.registrar.setEndpointRegistry(this.registry); this.registrar.setBeanFactory(new StaticListableBeanFactory()); diff --git a/spring-jms/src/test/java/org/springframework/jms/config/JmsListenerEndpointRegistryTests.java b/spring-jms/src/test/java/org/springframework/jms/config/JmsListenerEndpointRegistryTests.java index bb8a8bac3e9..85f1810eab7 100644 --- a/spring-jms/src/test/java/org/springframework/jms/config/JmsListenerEndpointRegistryTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/config/JmsListenerEndpointRegistryTests.java @@ -16,7 +16,7 @@ package org.springframework.jms.config; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; diff --git a/spring-jms/src/test/java/org/springframework/jms/config/JmsListenerEndpointTests.java b/spring-jms/src/test/java/org/springframework/jms/config/JmsListenerEndpointTests.java index 86b9c822281..fa93a7f257c 100644 --- a/spring-jms/src/test/java/org/springframework/jms/config/JmsListenerEndpointTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/config/JmsListenerEndpointTests.java @@ -18,7 +18,7 @@ package org.springframework.jms.config; import javax.jms.MessageListener; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.DirectFieldAccessor; import org.springframework.jms.listener.DefaultMessageListenerContainer; diff --git a/spring-jms/src/test/java/org/springframework/jms/config/JmsNamespaceHandlerTests.java b/spring-jms/src/test/java/org/springframework/jms/config/JmsNamespaceHandlerTests.java index 8a165a39565..6051f65377d 100644 --- a/spring-jms/src/test/java/org/springframework/jms/config/JmsNamespaceHandlerTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/config/JmsNamespaceHandlerTests.java @@ -25,9 +25,9 @@ import javax.jms.Message; import javax.jms.MessageListener; import javax.jms.TextMessage; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.DirectFieldAccessor; import org.springframework.beans.factory.config.BeanDefinition; @@ -67,12 +67,12 @@ public class JmsNamespaceHandlerTests { private ToolingTestApplicationContext context; - @Before + @BeforeEach public void setUp() throws Exception { this.context = new ToolingTestApplicationContext("jmsNamespaceHandlerTests.xml", getClass()); } - @After + @AfterEach public void tearDown() throws Exception { this.context.close(); } diff --git a/spring-jms/src/test/java/org/springframework/jms/config/MethodJmsListenerEndpointTests.java b/spring-jms/src/test/java/org/springframework/jms/config/MethodJmsListenerEndpointTests.java index 60546cd96fb..d938b4e35e6 100644 --- a/spring-jms/src/test/java/org/springframework/jms/config/MethodJmsListenerEndpointTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/config/MethodJmsListenerEndpointTests.java @@ -29,10 +29,9 @@ import javax.jms.QueueSender; import javax.jms.Session; import javax.jms.TextMessage; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TestName; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; import org.springframework.beans.DirectFieldAccessor; import org.springframework.beans.factory.support.StaticListableBeanFactory; @@ -71,8 +70,9 @@ import static org.mockito.Mockito.verify; /** * @author Stephane Nicoll + * @author Sam Brannen */ -public class MethodJmsListenerEndpointTests { +class MethodJmsListenerEndpointTests { private final DefaultMessageHandlerMethodFactory factory = new DefaultMessageHandlerMethodFactory(); @@ -80,19 +80,18 @@ public class MethodJmsListenerEndpointTests { private final JmsEndpointSampleBean sample = new JmsEndpointSampleBean(); + private String methodName; - @Rule - public final TestName name = new TestName(); - - @Before - public void setup() { + @BeforeEach + void setup(TestInfo testInfo) { + this.methodName = testInfo.getTestMethod().get().getName(); initializeFactory(this.factory); } @Test - public void createMessageListenerNoFactory() { + void createMessageListenerNoFactory() { MethodJmsListenerEndpoint endpoint = new MethodJmsListenerEndpoint(); endpoint.setBean(this); endpoint.setMethod(getTestMethod()); @@ -102,7 +101,7 @@ public class MethodJmsListenerEndpointTests { } @Test - public void createMessageListener() { + void createMessageListener() { MethodJmsListenerEndpoint endpoint = new MethodJmsListenerEndpoint(); endpoint.setBean(this); endpoint.setMethod(getTestMethod()); @@ -112,7 +111,7 @@ public class MethodJmsListenerEndpointTests { } @Test - public void setExtraCollaborators() { + void setExtraCollaborators() { MessageConverter messageConverter = mock(MessageConverter.class); DestinationResolver destinationResolver = mock(DestinationResolver.class); this.container.setMessageConverter(messageConverter); @@ -126,7 +125,7 @@ public class MethodJmsListenerEndpointTests { } @Test - public void resolveMessageAndSession() throws JMSException { + void resolveMessageAndSession() throws JMSException { MessagingMessageListenerAdapter listener = createDefaultInstance(javax.jms.Message.class, Session.class); Session session = mock(Session.class); @@ -135,7 +134,7 @@ public class MethodJmsListenerEndpointTests { } @Test - public void resolveGenericMessage() throws JMSException { + void resolveGenericMessage() throws JMSException { MessagingMessageListenerAdapter listener = createDefaultInstance(Message.class); Session session = mock(Session.class); @@ -144,7 +143,7 @@ public class MethodJmsListenerEndpointTests { } @Test - public void resolveHeaderAndPayload() throws JMSException { + void resolveHeaderAndPayload() throws JMSException { MessagingMessageListenerAdapter listener = createDefaultInstance(String.class, int.class); Session session = mock(Session.class); @@ -155,7 +154,7 @@ public class MethodJmsListenerEndpointTests { } @Test - public void resolveCustomHeaderNameAndPayload() throws JMSException { + void resolveCustomHeaderNameAndPayload() throws JMSException { MessagingMessageListenerAdapter listener = createDefaultInstance(String.class, int.class); Session session = mock(Session.class); @@ -166,7 +165,7 @@ public class MethodJmsListenerEndpointTests { } @Test - public void resolveCustomHeaderNameAndPayloadWithHeaderNameSet() throws JMSException { + void resolveCustomHeaderNameAndPayloadWithHeaderNameSet() throws JMSException { MessagingMessageListenerAdapter listener = createDefaultInstance(String.class, int.class); Session session = mock(Session.class); @@ -177,7 +176,7 @@ public class MethodJmsListenerEndpointTests { } @Test - public void resolveHeaders() throws JMSException { + void resolveHeaders() throws JMSException { MessagingMessageListenerAdapter listener = createDefaultInstance(String.class, Map.class); Session session = mock(Session.class); @@ -189,7 +188,7 @@ public class MethodJmsListenerEndpointTests { } @Test - public void resolveMessageHeaders() throws JMSException { + void resolveMessageHeaders() throws JMSException { MessagingMessageListenerAdapter listener = createDefaultInstance(MessageHeaders.class); Session session = mock(Session.class); @@ -201,7 +200,7 @@ public class MethodJmsListenerEndpointTests { } @Test - public void resolveJmsMessageHeaderAccessor() throws JMSException { + void resolveJmsMessageHeaderAccessor() throws JMSException { MessagingMessageListenerAdapter listener = createDefaultInstance(JmsMessageHeaderAccessor.class); Session session = mock(Session.class); @@ -213,7 +212,7 @@ public class MethodJmsListenerEndpointTests { } @Test - public void resolveObjectPayload() throws JMSException { + void resolveObjectPayload() throws JMSException { MessagingMessageListenerAdapter listener = createDefaultInstance(MyBean.class); MyBean myBean = new MyBean(); myBean.name = "myBean name"; @@ -227,7 +226,7 @@ public class MethodJmsListenerEndpointTests { } @Test - public void resolveConvertedPayload() throws JMSException { + void resolveConvertedPayload() throws JMSException { MessagingMessageListenerAdapter listener = createDefaultInstance(Integer.class); Session session = mock(Session.class); @@ -237,7 +236,7 @@ public class MethodJmsListenerEndpointTests { } @Test - public void processAndReply() throws JMSException { + void processAndReply() throws JMSException { MessagingMessageListenerAdapter listener = createDefaultInstance(String.class); String body = "echo text"; String correlationId = "link-1234"; @@ -261,7 +260,7 @@ public class MethodJmsListenerEndpointTests { } @Test - public void processAndReplyWithSendToQueue() throws JMSException { + void processAndReplyWithSendToQueue() throws JMSException { String methodName = "processAndReplyWithSendTo"; SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(); MessagingMessageListenerAdapter listener = createInstance(this.factory, @@ -271,7 +270,7 @@ public class MethodJmsListenerEndpointTests { } @Test - public void processFromTopicAndReplyWithSendToQueue() throws JMSException { + void processFromTopicAndReplyWithSendToQueue() throws JMSException { String methodName = "processAndReplyWithSendTo"; SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(); container.setPubSubDomain(true); @@ -283,7 +282,7 @@ public class MethodJmsListenerEndpointTests { } @Test - public void processAndReplyWithSendToTopic() throws JMSException { + void processAndReplyWithSendToTopic() throws JMSException { String methodName = "processAndReplyWithSendTo"; SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(); container.setPubSubDomain(true); @@ -294,7 +293,7 @@ public class MethodJmsListenerEndpointTests { } @Test - public void processFromQueueAndReplyWithSendToTopic() throws JMSException { + void processFromQueueAndReplyWithSendToTopic() throws JMSException { String methodName = "processAndReplyWithSendTo"; SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(); container.setReplyPubSubDomain(true); @@ -305,14 +304,14 @@ public class MethodJmsListenerEndpointTests { } @Test - public void processAndReplyWithDefaultSendTo() throws JMSException { + void processAndReplyWithDefaultSendTo() throws JMSException { MessagingMessageListenerAdapter listener = createDefaultInstance(String.class); processAndReplyWithSendTo(listener, "defaultReply", false); assertDefaultListenerMethodInvocation(); } @Test - public void processAndReplyWithCustomReplyQosSettings() throws JMSException { + void processAndReplyWithCustomReplyQosSettings() throws JMSException { String methodName = "processAndReplyWithSendTo"; SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(); QosSettings replyQosSettings = new QosSettings(1, 6, 6000); @@ -324,7 +323,7 @@ public class MethodJmsListenerEndpointTests { } @Test - public void processAndReplyWithNullReplyQosSettings() throws JMSException { + void processAndReplyWithNullReplyQosSettings() throws JMSException { String methodName = "processAndReplyWithSendTo"; SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(); container.setReplyQosSettings(null); @@ -374,7 +373,7 @@ public class MethodJmsListenerEndpointTests { } @Test - public void emptySendTo() throws JMSException { + void emptySendTo() throws JMSException { MessagingMessageListenerAdapter listener = createDefaultInstance(String.class); TextMessage reply = mock(TextMessage.class); @@ -387,7 +386,7 @@ public class MethodJmsListenerEndpointTests { } @Test - public void invalidSendTo() { + void invalidSendTo() { assertThatIllegalStateException().isThrownBy(() -> createDefaultInstance(String.class)) .withMessageContaining("firstDestination") @@ -395,7 +394,7 @@ public class MethodJmsListenerEndpointTests { } @Test - public void validatePayloadValid() throws JMSException { + void validatePayloadValid() throws JMSException { String methodName = "validatePayload"; DefaultMessageHandlerMethodFactory customFactory = new DefaultMessageHandlerMethodFactory(); @@ -410,7 +409,7 @@ public class MethodJmsListenerEndpointTests { } @Test - public void validatePayloadInvalid() throws JMSException { + void validatePayloadInvalid() throws JMSException { DefaultMessageHandlerMethodFactory customFactory = new DefaultMessageHandlerMethodFactory(); customFactory.setValidator(testValidator("invalid value")); @@ -427,7 +426,7 @@ public class MethodJmsListenerEndpointTests { // failure scenario @Test - public void invalidPayloadType() throws JMSException { + void invalidPayloadType() throws JMSException { MessagingMessageListenerAdapter listener = createDefaultInstance(Integer.class); Session session = mock(Session.class); @@ -439,7 +438,7 @@ public class MethodJmsListenerEndpointTests { } @Test - public void invalidMessagePayloadType() throws JMSException { + void invalidMessagePayloadType() throws JMSException { MessagingMessageListenerAdapter listener = createDefaultInstance(Message.class); Session session = mock(Session.class); @@ -479,11 +478,11 @@ public class MethodJmsListenerEndpointTests { } private Method getDefaultListenerMethod(Class... parameterTypes) { - return getListenerMethod(this.name.getMethodName(), parameterTypes); + return getListenerMethod(this.methodName, parameterTypes); } private void assertDefaultListenerMethodInvocation() { - assertListenerMethodInvocation(this.sample, this.name.getMethodName()); + assertListenerMethodInvocation(this.sample, this.methodName); } private void assertListenerMethodInvocation(JmsEndpointSampleBean bean, String methodName) { @@ -512,7 +511,7 @@ public class MethodJmsListenerEndpointTests { } private Method getTestMethod() { - return ReflectionUtils.findMethod(MethodJmsListenerEndpointTests.class, this.name.getMethodName()); + return ReflectionUtils.findMethod(MethodJmsListenerEndpointTests.class, this.methodName); } diff --git a/spring-jms/src/test/java/org/springframework/jms/config/SimpleJmsListenerEndpointTests.java b/spring-jms/src/test/java/org/springframework/jms/config/SimpleJmsListenerEndpointTests.java index adfdfa7838a..b8ef640a60c 100644 --- a/spring-jms/src/test/java/org/springframework/jms/config/SimpleJmsListenerEndpointTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/config/SimpleJmsListenerEndpointTests.java @@ -18,7 +18,7 @@ package org.springframework.jms.config; import javax.jms.MessageListener; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.jms.listener.SimpleMessageListenerContainer; import org.springframework.jms.listener.adapter.MessageListenerAdapter; diff --git a/spring-jms/src/test/java/org/springframework/jms/connection/JmsTransactionManagerTests.java b/spring-jms/src/test/java/org/springframework/jms/connection/JmsTransactionManagerTests.java index 704f38b0fe4..ae0878a29df 100644 --- a/spring-jms/src/test/java/org/springframework/jms/connection/JmsTransactionManagerTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/connection/JmsTransactionManagerTests.java @@ -24,8 +24,8 @@ import javax.jms.Message; import javax.jms.MessageProducer; import javax.jms.Session; -import org.junit.After; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; import org.springframework.jms.StubQueue; import org.springframework.jms.core.JmsTemplate; @@ -51,7 +51,7 @@ import static org.mockito.Mockito.verify; */ public class JmsTransactionManagerTests { - @After + @AfterEach public void verifyTransactionSynchronizationManagerState() { assertThat(TransactionSynchronizationManager.getResourceMap().isEmpty()).isTrue(); assertThat(TransactionSynchronizationManager.isSynchronizationActive()).isFalse(); diff --git a/spring-jms/src/test/java/org/springframework/jms/connection/SingleConnectionFactoryTests.java b/spring-jms/src/test/java/org/springframework/jms/connection/SingleConnectionFactoryTests.java index 2a857daa0f6..85a6126dde2 100644 --- a/spring-jms/src/test/java/org/springframework/jms/connection/SingleConnectionFactoryTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/connection/SingleConnectionFactoryTests.java @@ -28,7 +28,7 @@ import javax.jms.TopicConnection; import javax.jms.TopicConnectionFactory; import javax.jms.TopicSession; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; diff --git a/spring-jms/src/test/java/org/springframework/jms/core/JmsMessagingTemplateTests.java b/spring-jms/src/test/java/org/springframework/jms/core/JmsMessagingTemplateTests.java index c6720499d34..a1dda4dfca0 100644 --- a/spring-jms/src/test/java/org/springframework/jms/core/JmsMessagingTemplateTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/core/JmsMessagingTemplateTests.java @@ -26,13 +26,13 @@ import javax.jms.MessageNotWriteableException; import javax.jms.Session; import javax.jms.TextMessage; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.mockito.stubbing.Answer; import org.springframework.beans.DirectFieldAccessor; @@ -65,7 +65,7 @@ import static org.mockito.Mockito.verify; * * @author Stephane Nicoll */ -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class JmsMessagingTemplateTests { @Captor @@ -77,7 +77,7 @@ public class JmsMessagingTemplateTests { private JmsMessagingTemplate messagingTemplate; - @Before + @BeforeEach public void setup() { this.messagingTemplate = new JmsMessagingTemplate(this.jmsTemplate); } diff --git a/spring-jms/src/test/java/org/springframework/jms/core/JmsTemplateTests.java b/spring-jms/src/test/java/org/springframework/jms/core/JmsTemplateTests.java index 9180c34858d..91464914b54 100644 --- a/spring-jms/src/test/java/org/springframework/jms/core/JmsTemplateTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/core/JmsTemplateTests.java @@ -33,8 +33,8 @@ import javax.jms.TemporaryQueue; import javax.jms.TextMessage; import javax.naming.Context; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.jms.InvalidClientIDException; import org.springframework.jms.InvalidDestinationException; @@ -75,7 +75,7 @@ import static org.mockito.Mockito.verify; * @author Mark Pollack * @author Stephane Nicoll */ -public class JmsTemplateTests { +class JmsTemplateTests { private Context jndiContext; @@ -93,8 +93,8 @@ public class JmsTemplateTests { /** * Create the mock objects for testing. */ - @Before - public void setupMocks() throws Exception { + @BeforeEach + void setupMocks() throws Exception { this.jndiContext = mock(Context.class); this.connectionFactory = mock(ConnectionFactory.class); this.connection = mock(Connection.class); @@ -135,7 +135,7 @@ public class JmsTemplateTests { @Test - public void testExceptionStackTrace() { + void testExceptionStackTrace() { JMSException jmsEx = new JMSException("could not connect"); Exception innerEx = new Exception("host not found"); jmsEx.setLinkedException(innerEx); @@ -148,7 +148,7 @@ public class JmsTemplateTests { } @Test - public void testProducerCallback() throws Exception { + void testProducerCallback() throws Exception { JmsTemplate template = createTemplate(); template.setConnectionFactory(this.connectionFactory); @@ -168,7 +168,7 @@ public class JmsTemplateTests { } @Test - public void testProducerCallbackWithIdAndTimestampDisabled() throws Exception { + void testProducerCallbackWithIdAndTimestampDisabled() throws Exception { JmsTemplate template = createTemplate(); template.setConnectionFactory(this.connectionFactory); template.setMessageIdEnabled(false); @@ -195,7 +195,7 @@ public class JmsTemplateTests { * Test the method execute(SessionCallback action). */ @Test - public void testSessionCallback() throws Exception { + void testSessionCallback() throws Exception { JmsTemplate template = createTemplate(); template.setConnectionFactory(this.connectionFactory); @@ -212,7 +212,7 @@ public class JmsTemplateTests { } @Test - public void testSessionCallbackWithinSynchronizedTransaction() throws Exception { + void testSessionCallbackWithinSynchronizedTransaction() throws Exception { SingleConnectionFactory scf = new SingleConnectionFactory(this.connectionFactory); JmsTemplate template = createTemplate(); template.setConnectionFactory(scf); @@ -272,7 +272,7 @@ public class JmsTemplateTests { * send(Destination d, MessageCreator messageCreator) */ @Test - public void testSendDestination() throws Exception { + void testSendDestination() throws Exception { doTestSendDestination(true, false, true, false); } @@ -281,7 +281,7 @@ public class JmsTemplateTests { * send(String d, MessageCreator messageCreator) */ @Test - public void testSendDestinationName() throws Exception { + void testSendDestinationName() throws Exception { doTestSendDestination(false, false, true, false); } @@ -290,7 +290,7 @@ public class JmsTemplateTests { * send(Destination d, MessageCreator messageCreator) using QOS parameters. */ @Test - public void testSendDestinationWithQOS() throws Exception { + void testSendDestinationWithQOS() throws Exception { doTestSendDestination(true, false, false, true); } @@ -299,7 +299,7 @@ public class JmsTemplateTests { * send(String d, MessageCreator messageCreator) using QOS parameters. */ @Test - public void testSendDestinationNameWithQOS() throws Exception { + void testSendDestinationNameWithQOS() throws Exception { doTestSendDestination(false, false, false, true); } @@ -307,7 +307,7 @@ public class JmsTemplateTests { * Test sending to the default destination. */ @Test - public void testSendDefaultDestination() throws Exception { + void testSendDefaultDestination() throws Exception { doTestSendDestination(true, true, true, true); } @@ -315,7 +315,7 @@ public class JmsTemplateTests { * Test sending to the default destination name. */ @Test - public void testSendDefaultDestinationName() throws Exception { + void testSendDefaultDestinationName() throws Exception { doTestSendDestination(false, true, true, true); } @@ -323,7 +323,7 @@ public class JmsTemplateTests { * Test sending to the default destination using explicit QOS parameters. */ @Test - public void testSendDefaultDestinationWithQOS() throws Exception { + void testSendDefaultDestinationWithQOS() throws Exception { doTestSendDestination(true, true, false, false); } @@ -331,7 +331,7 @@ public class JmsTemplateTests { * Test sending to the default destination name using explicit QOS parameters. */ @Test - public void testSendDefaultDestinationNameWithQOS() throws Exception { + void testSendDefaultDestinationNameWithQOS() throws Exception { doTestSendDestination(false, true, false, false); } @@ -421,7 +421,7 @@ public class JmsTemplateTests { } @Test - public void testConverter() throws Exception { + void testConverter() throws Exception { JmsTemplate template = createTemplate(); template.setConnectionFactory(this.connectionFactory); template.setMessageConverter(new SimpleMessageConverter()); @@ -445,87 +445,87 @@ public class JmsTemplateTests { } @Test - public void testReceiveDefaultDestination() throws Exception { + void testReceiveDefaultDestination() throws Exception { doTestReceive(true, true, false, false, false, false, JmsTemplate.RECEIVE_TIMEOUT_INDEFINITE_WAIT); } @Test - public void testReceiveDefaultDestinationName() throws Exception { + void testReceiveDefaultDestinationName() throws Exception { doTestReceive(false, true, false, false, false, false, JmsTemplate.RECEIVE_TIMEOUT_INDEFINITE_WAIT); } @Test - public void testReceiveDestination() throws Exception { + void testReceiveDestination() throws Exception { doTestReceive(true, false, false, false, false, true, JmsTemplate.RECEIVE_TIMEOUT_INDEFINITE_WAIT); } @Test - public void testReceiveDestinationWithClientAcknowledge() throws Exception { + void testReceiveDestinationWithClientAcknowledge() throws Exception { doTestReceive(true, false, false, true, false, false, 1000); } @Test - public void testReceiveDestinationName() throws Exception { + void testReceiveDestinationName() throws Exception { doTestReceive(false, false, false, false, false, true, 1000); } @Test - public void testReceiveDefaultDestinationWithSelector() throws Exception { + void testReceiveDefaultDestinationWithSelector() throws Exception { doTestReceive(true, true, false, false, true, true, 1000); } @Test - public void testReceiveDefaultDestinationNameWithSelector() throws Exception { + void testReceiveDefaultDestinationNameWithSelector() throws Exception { doTestReceive(false, true, false, false, true, true, JmsTemplate.RECEIVE_TIMEOUT_NO_WAIT); } @Test - public void testReceiveDestinationWithSelector() throws Exception { + void testReceiveDestinationWithSelector() throws Exception { doTestReceive(true, false, false, false, true, false, 1000); } @Test - public void testReceiveDestinationWithClientAcknowledgeWithSelector() throws Exception { + void testReceiveDestinationWithClientAcknowledgeWithSelector() throws Exception { doTestReceive(true, false, false, true, true, true, JmsTemplate.RECEIVE_TIMEOUT_INDEFINITE_WAIT); } @Test - public void testReceiveDestinationNameWithSelector() throws Exception { + void testReceiveDestinationNameWithSelector() throws Exception { doTestReceive(false, false, false, false, true, false, JmsTemplate.RECEIVE_TIMEOUT_NO_WAIT); } @Test - public void testReceiveAndConvertDefaultDestination() throws Exception { + void testReceiveAndConvertDefaultDestination() throws Exception { doTestReceive(true, true, true, false, false, false, 1000); } @Test - public void testReceiveAndConvertDefaultDestinationName() throws Exception { + void testReceiveAndConvertDefaultDestinationName() throws Exception { doTestReceive(false, true, true, false, false, false, 1000); } @Test - public void testReceiveAndConvertDestinationName() throws Exception { + void testReceiveAndConvertDestinationName() throws Exception { doTestReceive(false, false, true, false, false, true, JmsTemplate.RECEIVE_TIMEOUT_INDEFINITE_WAIT); } @Test - public void testReceiveAndConvertDestination() throws Exception { + void testReceiveAndConvertDestination() throws Exception { doTestReceive(true, false, true, false, false, true, 1000); } @Test - public void testReceiveAndConvertDefaultDestinationWithSelector() throws Exception { + void testReceiveAndConvertDefaultDestinationWithSelector() throws Exception { doTestReceive(true, true, true, false, true, true, JmsTemplate.RECEIVE_TIMEOUT_NO_WAIT); } @Test - public void testReceiveAndConvertDestinationNameWithSelector() throws Exception { + void testReceiveAndConvertDestinationNameWithSelector() throws Exception { doTestReceive(false, false, true, false, true, true, JmsTemplate.RECEIVE_TIMEOUT_INDEFINITE_WAIT); } @Test - public void testReceiveAndConvertDestinationWithSelector() throws Exception { + void testReceiveAndConvertDestinationWithSelector() throws Exception { doTestReceive(true, false, true, false, true, false, 1000); } @@ -636,22 +636,22 @@ public class JmsTemplateTests { } @Test - public void testSendAndReceiveDefaultDestination() throws Exception { + void testSendAndReceiveDefaultDestination() throws Exception { doTestSendAndReceive(true, true, 1000L); } @Test - public void testSendAndReceiveDefaultDestinationName() throws Exception { + void testSendAndReceiveDefaultDestinationName() throws Exception { doTestSendAndReceive(false, true, 1000L); } @Test - public void testSendAndReceiveDestination() throws Exception { + void testSendAndReceiveDestination() throws Exception { doTestSendAndReceive(true, false, 1000L); } @Test - public void testSendAndReceiveDestinationName() throws Exception { + void testSendAndReceiveDestinationName() throws Exception { doTestSendAndReceive(false, false, 1000L); } @@ -719,67 +719,67 @@ public class JmsTemplateTests { } @Test - public void testIllegalStateException() throws Exception { + void testIllegalStateException() throws Exception { doTestJmsException(new javax.jms.IllegalStateException(""), org.springframework.jms.IllegalStateException.class); } @Test - public void testInvalidClientIDException() throws Exception { + void testInvalidClientIDException() throws Exception { doTestJmsException(new javax.jms.InvalidClientIDException(""), InvalidClientIDException.class); } @Test - public void testInvalidDestinationException() throws Exception { + void testInvalidDestinationException() throws Exception { doTestJmsException(new javax.jms.InvalidDestinationException(""), InvalidDestinationException.class); } @Test - public void testInvalidSelectorException() throws Exception { + void testInvalidSelectorException() throws Exception { doTestJmsException(new javax.jms.InvalidSelectorException(""), InvalidSelectorException.class); } @Test - public void testJmsSecurityException() throws Exception { + void testJmsSecurityException() throws Exception { doTestJmsException(new javax.jms.JMSSecurityException(""), JmsSecurityException.class); } @Test - public void testMessageEOFException() throws Exception { + void testMessageEOFException() throws Exception { doTestJmsException(new javax.jms.MessageEOFException(""), MessageEOFException.class); } @Test - public void testMessageFormatException() throws Exception { + void testMessageFormatException() throws Exception { doTestJmsException(new javax.jms.MessageFormatException(""), MessageFormatException.class); } @Test - public void testMessageNotReadableException() throws Exception { + void testMessageNotReadableException() throws Exception { doTestJmsException(new javax.jms.MessageNotReadableException(""), MessageNotReadableException.class); } @Test - public void testMessageNotWriteableException() throws Exception { + void testMessageNotWriteableException() throws Exception { doTestJmsException(new javax.jms.MessageNotWriteableException(""), MessageNotWriteableException.class); } @Test - public void testResourceAllocationException() throws Exception { + void testResourceAllocationException() throws Exception { doTestJmsException(new javax.jms.ResourceAllocationException(""), ResourceAllocationException.class); } @Test - public void testTransactionInProgressException() throws Exception { + void testTransactionInProgressException() throws Exception { doTestJmsException(new javax.jms.TransactionInProgressException(""), TransactionInProgressException.class); } @Test - public void testTransactionRolledBackException() throws Exception { + void testTransactionRolledBackException() throws Exception { doTestJmsException(new javax.jms.TransactionRolledBackException(""), TransactionRolledBackException.class); } @Test - public void testUncategorizedJmsException() throws Exception { + void testUncategorizedJmsException() throws Exception { doTestJmsException(new javax.jms.JMSException(""), UncategorizedJmsException.class); } diff --git a/spring-jms/src/test/java/org/springframework/jms/core/JmsTemplateTransactedTests.java b/spring-jms/src/test/java/org/springframework/jms/core/JmsTemplateTransactedTests.java index 617cc730b8d..db51d87d132 100644 --- a/spring-jms/src/test/java/org/springframework/jms/core/JmsTemplateTransactedTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/core/JmsTemplateTransactedTests.java @@ -18,6 +18,8 @@ package org.springframework.jms.core; import javax.jms.Session; +import org.junit.jupiter.api.BeforeEach; + import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; @@ -26,13 +28,14 @@ import static org.mockito.Mockito.mock; * @author Stephane Nicoll * @since 06.01.2005 */ -public class JmsTemplateTransactedTests extends JmsTemplateTests { +class JmsTemplateTransactedTests extends JmsTemplateTests { private Session localSession; @Override - public void setupMocks() throws Exception { + @BeforeEach + void setupMocks() throws Exception { super.setupMocks(); this.localSession = mock(Session.class); given(this.connection.createSession(false, Session.AUTO_ACKNOWLEDGE)).willReturn(this.localSession); diff --git a/spring-jms/src/test/java/org/springframework/jms/core/support/JmsGatewaySupportTests.java b/spring-jms/src/test/java/org/springframework/jms/core/support/JmsGatewaySupportTests.java index 9d2c5dbe615..5b95a94fd0b 100644 --- a/spring-jms/src/test/java/org/springframework/jms/core/support/JmsGatewaySupportTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/core/support/JmsGatewaySupportTests.java @@ -19,7 +19,7 @@ import java.util.ArrayList; import java.util.List; import javax.jms.ConnectionFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.jms.core.JmsTemplate; diff --git a/spring-jms/src/test/java/org/springframework/jms/listener/DefaultMessageListenerContainerTests.java b/spring-jms/src/test/java/org/springframework/jms/listener/DefaultMessageListenerContainerTests.java index 6b9118db3c3..e655211fea3 100644 --- a/spring-jms/src/test/java/org/springframework/jms/listener/DefaultMessageListenerContainerTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/listener/DefaultMessageListenerContainerTests.java @@ -23,7 +23,7 @@ import javax.jms.ConnectionFactory; import javax.jms.Destination; import javax.jms.JMSException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; diff --git a/spring-jms/src/test/java/org/springframework/jms/listener/SimpleMessageListenerContainerTests.java b/spring-jms/src/test/java/org/springframework/jms/listener/SimpleMessageListenerContainerTests.java index 52be6935aec..594ca6caa77 100644 --- a/spring-jms/src/test/java/org/springframework/jms/listener/SimpleMessageListenerContainerTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/listener/SimpleMessageListenerContainerTests.java @@ -27,7 +27,7 @@ import javax.jms.MessageConsumer; import javax.jms.MessageListener; import javax.jms.Session; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.support.GenericApplicationContext; import org.springframework.core.task.TaskExecutor; diff --git a/spring-jms/src/test/java/org/springframework/jms/listener/adapter/JmsResponseTests.java b/spring-jms/src/test/java/org/springframework/jms/listener/adapter/JmsResponseTests.java index b33ef3a23fa..b373b061a9b 100644 --- a/spring-jms/src/test/java/org/springframework/jms/listener/adapter/JmsResponseTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/listener/adapter/JmsResponseTests.java @@ -20,7 +20,7 @@ import javax.jms.Destination; import javax.jms.JMSException; import javax.jms.Session; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.jms.support.destination.DestinationResolver; diff --git a/spring-jms/src/test/java/org/springframework/jms/listener/adapter/MessageListenerAdapterTests.java b/spring-jms/src/test/java/org/springframework/jms/listener/adapter/MessageListenerAdapterTests.java index 6cbe1bfb88d..e4901c19d99 100644 --- a/spring-jms/src/test/java/org/springframework/jms/listener/adapter/MessageListenerAdapterTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/listener/adapter/MessageListenerAdapterTests.java @@ -30,7 +30,7 @@ import javax.jms.QueueSession; import javax.jms.Session; import javax.jms.TextMessage; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; diff --git a/spring-jms/src/test/java/org/springframework/jms/listener/adapter/MessagingMessageListenerAdapterTests.java b/spring-jms/src/test/java/org/springframework/jms/listener/adapter/MessagingMessageListenerAdapterTests.java index 3437ceafd5f..b78bd659f66 100644 --- a/spring-jms/src/test/java/org/springframework/jms/listener/adapter/MessagingMessageListenerAdapterTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/listener/adapter/MessagingMessageListenerAdapterTests.java @@ -29,8 +29,8 @@ import javax.jms.TextMessage; import javax.jms.Topic; import com.fasterxml.jackson.annotation.JsonView; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.StaticListableBeanFactory; import org.springframework.jms.StubTextMessage; @@ -67,7 +67,7 @@ public class MessagingMessageListenerAdapterTests { private final SampleBean sample = new SampleBean(); - @Before + @BeforeEach public void setup() { initializeFactory(factory); } diff --git a/spring-jms/src/test/java/org/springframework/jms/listener/endpoint/DefaultJmsActivationSpecFactoryTests.java b/spring-jms/src/test/java/org/springframework/jms/listener/endpoint/DefaultJmsActivationSpecFactoryTests.java index 75ec188fc1a..32e9400b7c1 100644 --- a/spring-jms/src/test/java/org/springframework/jms/listener/endpoint/DefaultJmsActivationSpecFactoryTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/listener/endpoint/DefaultJmsActivationSpecFactoryTests.java @@ -19,7 +19,7 @@ package org.springframework.jms.listener.endpoint; import javax.jms.Destination; import javax.jms.Session; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.jca.StubResourceAdapter; import org.springframework.jms.StubQueue; diff --git a/spring-jms/src/test/java/org/springframework/jms/listener/endpoint/JmsMessageEndpointManagerTests.java b/spring-jms/src/test/java/org/springframework/jms/listener/endpoint/JmsMessageEndpointManagerTests.java index f233bb89b4a..22239b5af92 100644 --- a/spring-jms/src/test/java/org/springframework/jms/listener/endpoint/JmsMessageEndpointManagerTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/listener/endpoint/JmsMessageEndpointManagerTests.java @@ -16,7 +16,7 @@ package org.springframework.jms.listener.endpoint; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.jms.support.QosSettings; diff --git a/spring-jms/src/test/java/org/springframework/jms/remoting/JmsInvokerTests.java b/spring-jms/src/test/java/org/springframework/jms/remoting/JmsInvokerTests.java index 56f41f3f050..f03d3324067 100644 --- a/spring-jms/src/test/java/org/springframework/jms/remoting/JmsInvokerTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/remoting/JmsInvokerTests.java @@ -31,8 +31,8 @@ import javax.jms.QueueConnectionFactory; import javax.jms.QueueSession; import javax.jms.Session; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.jms.support.converter.MessageConversionException; import org.springframework.jms.support.converter.SimpleMessageConverter; @@ -61,7 +61,7 @@ public class JmsInvokerTests { private Queue mockQueue; - @Before + @BeforeEach public void setUpMocks() throws Exception { mockConnectionFactory = mock(QueueConnectionFactory.class); mockConnection = mock(QueueConnection.class); diff --git a/spring-jms/src/test/java/org/springframework/jms/support/JmsAccessorTests.java b/spring-jms/src/test/java/org/springframework/jms/support/JmsAccessorTests.java index b0778ba445a..bb1710043e5 100644 --- a/spring-jms/src/test/java/org/springframework/jms/support/JmsAccessorTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/support/JmsAccessorTests.java @@ -18,7 +18,7 @@ package org.springframework.jms.support; import javax.jms.Session; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-jms/src/test/java/org/springframework/jms/support/JmsMessageHeaderAccessorTests.java b/spring-jms/src/test/java/org/springframework/jms/support/JmsMessageHeaderAccessorTests.java index cc0b71d928e..2217a7deb7b 100644 --- a/spring-jms/src/test/java/org/springframework/jms/support/JmsMessageHeaderAccessorTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/support/JmsMessageHeaderAccessorTests.java @@ -20,7 +20,7 @@ import java.util.Map; import javax.jms.Destination; import javax.jms.JMSException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.jms.StubTextMessage; import org.springframework.messaging.Message; diff --git a/spring-jms/src/test/java/org/springframework/jms/support/SimpleJmsHeaderMapperTests.java b/spring-jms/src/test/java/org/springframework/jms/support/SimpleJmsHeaderMapperTests.java index 44e6ea65e04..7e41747866e 100644 --- a/spring-jms/src/test/java/org/springframework/jms/support/SimpleJmsHeaderMapperTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/support/SimpleJmsHeaderMapperTests.java @@ -22,7 +22,7 @@ import javax.jms.DeliveryMode; import javax.jms.Destination; import javax.jms.JMSException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.jms.StubTextMessage; import org.springframework.messaging.Message; diff --git a/spring-jms/src/test/java/org/springframework/jms/support/SimpleMessageConverterTests.java b/spring-jms/src/test/java/org/springframework/jms/support/SimpleMessageConverterTests.java index 2e68dd6bbbb..536c863005c 100644 --- a/spring-jms/src/test/java/org/springframework/jms/support/SimpleMessageConverterTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/support/SimpleMessageConverterTests.java @@ -28,7 +28,7 @@ import javax.jms.ObjectMessage; import javax.jms.Session; import javax.jms.TextMessage; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; diff --git a/spring-jms/src/test/java/org/springframework/jms/support/converter/MappingJackson2MessageConverterTests.java b/spring-jms/src/test/java/org/springframework/jms/support/converter/MappingJackson2MessageConverterTests.java index 66419419ce7..e4797233729 100644 --- a/spring-jms/src/test/java/org/springframework/jms/support/converter/MappingJackson2MessageConverterTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/support/converter/MappingJackson2MessageConverterTests.java @@ -28,8 +28,8 @@ import javax.jms.Session; import javax.jms.TextMessage; import com.fasterxml.jackson.annotation.JsonView; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; @@ -55,7 +55,7 @@ public class MappingJackson2MessageConverterTests { private Session sessionMock; - @Before + @BeforeEach public void setup() { sessionMock = mock(Session.class); converter = new MappingJackson2MessageConverter(); diff --git a/spring-jms/src/test/java/org/springframework/jms/support/converter/MarshallingMessageConverterTests.java b/spring-jms/src/test/java/org/springframework/jms/support/converter/MarshallingMessageConverterTests.java index e9410d7e46a..b0c23cd0bff 100644 --- a/spring-jms/src/test/java/org/springframework/jms/support/converter/MarshallingMessageConverterTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/support/converter/MarshallingMessageConverterTests.java @@ -22,8 +22,8 @@ import javax.jms.TextMessage; import javax.xml.transform.Result; import javax.xml.transform.Source; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.oxm.Marshaller; import org.springframework.oxm.Unmarshaller; @@ -49,7 +49,7 @@ public class MarshallingMessageConverterTests { private Session sessionMock; - @Before + @BeforeEach public void setup() throws Exception { marshallerMock = mock(Marshaller.class); unmarshallerMock = mock(Unmarshaller.class); diff --git a/spring-jms/src/test/java/org/springframework/jms/support/converter/MessagingMessageConverterTests.java b/spring-jms/src/test/java/org/springframework/jms/support/converter/MessagingMessageConverterTests.java index dc43c080acf..eaba78bf91e 100644 --- a/spring-jms/src/test/java/org/springframework/jms/support/converter/MessagingMessageConverterTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/support/converter/MessagingMessageConverterTests.java @@ -22,7 +22,7 @@ import javax.jms.ObjectMessage; import javax.jms.Session; import javax.jms.TextMessage; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.jms.StubTextMessage; import org.springframework.messaging.Message; diff --git a/spring-jms/src/test/java/org/springframework/jms/support/destination/DynamicDestinationResolverTests.java b/spring-jms/src/test/java/org/springframework/jms/support/destination/DynamicDestinationResolverTests.java index 84345e9c4c9..0a11c2e186b 100644 --- a/spring-jms/src/test/java/org/springframework/jms/support/destination/DynamicDestinationResolverTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/support/destination/DynamicDestinationResolverTests.java @@ -24,7 +24,7 @@ import javax.jms.Session; import javax.jms.Topic; import javax.jms.TopicSession; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.jms.StubQueue; import org.springframework.jms.StubTopic; diff --git a/spring-jms/src/test/java/org/springframework/jms/support/destination/JmsDestinationAccessorTests.java b/spring-jms/src/test/java/org/springframework/jms/support/destination/JmsDestinationAccessorTests.java index b5d55cc51e7..24e1777ca42 100644 --- a/spring-jms/src/test/java/org/springframework/jms/support/destination/JmsDestinationAccessorTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/support/destination/JmsDestinationAccessorTests.java @@ -18,7 +18,7 @@ package org.springframework.jms.support.destination; import javax.jms.ConnectionFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-jms/src/test/java/org/springframework/jms/support/destination/JndiDestinationResolverTests.java b/spring-jms/src/test/java/org/springframework/jms/support/destination/JndiDestinationResolverTests.java index ca13d3f6ec3..29003335868 100644 --- a/spring-jms/src/test/java/org/springframework/jms/support/destination/JndiDestinationResolverTests.java +++ b/spring-jms/src/test/java/org/springframework/jms/support/destination/JndiDestinationResolverTests.java @@ -20,7 +20,7 @@ import javax.jms.Destination; import javax.jms.Session; import javax.naming.NamingException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.jms.StubTopic; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/MessageHeadersTests.java b/spring-messaging/src/test/java/org/springframework/messaging/MessageHeadersTests.java index 0267e2e9a9f..eb1e3278cbb 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/MessageHeadersTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/MessageHeadersTests.java @@ -23,7 +23,7 @@ import java.util.Set; import java.util.UUID; import java.util.concurrent.atomic.AtomicLong; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.util.SerializationTestUtils; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/converter/DefaultContentTypeResolverTests.java b/spring-messaging/src/test/java/org/springframework/messaging/converter/DefaultContentTypeResolverTests.java index 6382f4aa3be..7863c76a706 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/converter/DefaultContentTypeResolverTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/converter/DefaultContentTypeResolverTests.java @@ -20,8 +20,8 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.messaging.MessageHeaders; import org.springframework.util.InvalidMimeTypeException; @@ -41,7 +41,7 @@ public class DefaultContentTypeResolverTests { private DefaultContentTypeResolver resolver; - @Before + @BeforeEach public void setup() { this.resolver = new DefaultContentTypeResolver(); } diff --git a/spring-messaging/src/test/java/org/springframework/messaging/converter/GenericMessageConverterTests.java b/spring-messaging/src/test/java/org/springframework/messaging/converter/GenericMessageConverterTests.java index 98b66b2b1e6..1e39544a789 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/converter/GenericMessageConverterTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/converter/GenericMessageConverterTests.java @@ -18,7 +18,7 @@ package org.springframework.messaging.converter; import java.util.Locale; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.convert.ConversionException; import org.springframework.core.convert.ConversionService; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/converter/MappingJackson2MessageConverterTests.java b/spring-messaging/src/test/java/org/springframework/messaging/converter/MappingJackson2MessageConverterTests.java index bd4eff692fc..efca6b26fec 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/converter/MappingJackson2MessageConverterTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/converter/MappingJackson2MessageConverterTests.java @@ -25,7 +25,7 @@ import java.util.Map; import com.fasterxml.jackson.annotation.JsonView; import com.fasterxml.jackson.databind.DeserializationFeature; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.MethodParameter; import org.springframework.messaging.Message; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/converter/MarshallingMessageConverterTests.java b/spring-messaging/src/test/java/org/springframework/messaging/converter/MarshallingMessageConverterTests.java index 9f18d6fbe66..dc1e7653308 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/converter/MarshallingMessageConverterTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/converter/MarshallingMessageConverterTests.java @@ -20,8 +20,8 @@ import java.io.IOException; import java.nio.charset.StandardCharsets; import javax.xml.bind.annotation.XmlRootElement; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.xmlunit.diff.DifferenceEvaluator; import org.springframework.messaging.Message; @@ -44,7 +44,7 @@ public class MarshallingMessageConverterTests { private MarshallingMessageConverter converter; - @Before + @BeforeEach public void createMarshaller() throws Exception { Jaxb2Marshaller marshaller = new Jaxb2Marshaller(); marshaller.setClassesToBeBound(MyBean.class); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/converter/MessageConverterTests.java b/spring-messaging/src/test/java/org/springframework/messaging/converter/MessageConverterTests.java index fd2dcb0d2dc..ecc62c210a3 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/converter/MessageConverterTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/converter/MessageConverterTests.java @@ -22,7 +22,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.lang.Nullable; import org.springframework.messaging.Message; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/converter/SimpleMessageConverterTests.java b/spring-messaging/src/test/java/org/springframework/messaging/converter/SimpleMessageConverterTests.java index b28fc94f26a..80fd5456d61 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/converter/SimpleMessageConverterTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/converter/SimpleMessageConverterTests.java @@ -18,7 +18,7 @@ package org.springframework.messaging.converter; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.messaging.Message; import org.springframework.messaging.MessageHeaders; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/converter/StringMessageConverterTests.java b/spring-messaging/src/test/java/org/springframework/messaging/converter/StringMessageConverterTests.java index d151c237e6c..f6be00b9715 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/converter/StringMessageConverterTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/converter/StringMessageConverterTests.java @@ -20,7 +20,7 @@ import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.messaging.Message; import org.springframework.messaging.MessageHeaders; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/core/CachingDestinationResolverTests.java b/spring-messaging/src/test/java/org/springframework/messaging/core/CachingDestinationResolverTests.java index 60f20e0c7af..9d2140889b2 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/core/CachingDestinationResolverTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/core/CachingDestinationResolverTests.java @@ -16,7 +16,7 @@ package org.springframework.messaging.core; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/core/DestinationResolvingMessagingTemplateTests.java b/spring-messaging/src/test/java/org/springframework/messaging/core/DestinationResolvingMessagingTemplateTests.java index e6f9186a651..1fb3dc98203 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/core/DestinationResolvingMessagingTemplateTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/core/DestinationResolvingMessagingTemplateTests.java @@ -20,8 +20,8 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.messaging.Message; import org.springframework.messaging.MessageChannel; @@ -47,7 +47,7 @@ public class DestinationResolvingMessagingTemplateTests { private TestMessagePostProcessor postProcessor; - @Before + @BeforeEach public void setup() { TestMessageChannelDestinationResolver resolver = new TestMessageChannelDestinationResolver(); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/core/GenericMessagingTemplateTests.java b/spring-messaging/src/test/java/org/springframework/messaging/core/GenericMessagingTemplateTests.java index ff77007911a..e2b3c4602b9 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/core/GenericMessagingTemplateTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/core/GenericMessagingTemplateTests.java @@ -21,8 +21,8 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.messaging.Message; import org.springframework.messaging.MessageChannel; @@ -61,7 +61,7 @@ public class GenericMessagingTemplateTests { private ThreadPoolTaskExecutor executor; - @Before + @BeforeEach public void setup() { this.messageChannel = new StubMessageChannel(); this.template = new GenericMessagingTemplate(); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/core/MessageReceivingTemplateTests.java b/spring-messaging/src/test/java/org/springframework/messaging/core/MessageReceivingTemplateTests.java index 6ef71bd4130..6efb4d67ce7 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/core/MessageReceivingTemplateTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/core/MessageReceivingTemplateTests.java @@ -18,8 +18,8 @@ package org.springframework.messaging.core; import java.io.Writer; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.convert.ConversionFailedException; import org.springframework.messaging.Message; @@ -42,7 +42,7 @@ public class MessageReceivingTemplateTests { private TestMessagingTemplate template; - @Before + @BeforeEach public void setup() { this.template = new TestMessagingTemplate(); } diff --git a/spring-messaging/src/test/java/org/springframework/messaging/core/MessageRequestReplyTemplateTests.java b/spring-messaging/src/test/java/org/springframework/messaging/core/MessageRequestReplyTemplateTests.java index 76679e17ee8..e4e70aeb925 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/core/MessageRequestReplyTemplateTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/core/MessageRequestReplyTemplateTests.java @@ -19,8 +19,8 @@ package org.springframework.messaging.core; import java.util.Collections; import java.util.Map; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.messaging.Message; import org.springframework.messaging.support.GenericMessage; @@ -44,7 +44,7 @@ public class MessageRequestReplyTemplateTests { private Map headers; - @Before + @BeforeEach public void setup() { this.template = new TestMessagingTemplate(); this.postProcessor = new TestMessagePostProcessor(); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/core/MessageSendingTemplateTests.java b/spring-messaging/src/test/java/org/springframework/messaging/core/MessageSendingTemplateTests.java index ab7b2ee765e..ba3724d2137 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/core/MessageSendingTemplateTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/core/MessageSendingTemplateTests.java @@ -21,8 +21,8 @@ import java.util.Arrays; import java.util.HashMap; import java.util.Map; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.messaging.Message; import org.springframework.messaging.MessageHeaders; @@ -54,7 +54,7 @@ public class MessageSendingTemplateTests { private Map headers; - @Before + @BeforeEach public void setup() { this.template = new TestMessageSendingTemplate(); this.postProcessor = new TestMessagePostProcessor(); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/handler/DestinationPatternsMessageConditionTests.java b/spring-messaging/src/test/java/org/springframework/messaging/handler/DestinationPatternsMessageConditionTests.java index 41c7d9cf79e..51963c5b456 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/handler/DestinationPatternsMessageConditionTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/handler/DestinationPatternsMessageConditionTests.java @@ -16,7 +16,7 @@ package org.springframework.messaging.handler; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.messaging.Message; import org.springframework.messaging.support.MessageBuilder; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/reactive/DestinationVariableMethodArgumentResolverTests.java b/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/reactive/DestinationVariableMethodArgumentResolverTests.java index 97185f893a1..0e2bff89908 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/reactive/DestinationVariableMethodArgumentResolverTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/reactive/DestinationVariableMethodArgumentResolverTests.java @@ -20,7 +20,7 @@ import java.time.Duration; import java.util.HashMap; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.MethodParameter; import org.springframework.core.convert.support.DefaultConversionService; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/reactive/HeaderMethodArgumentResolverTests.java b/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/reactive/HeaderMethodArgumentResolverTests.java index e4c62ac40e9..45d89dc8a3a 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/reactive/HeaderMethodArgumentResolverTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/reactive/HeaderMethodArgumentResolverTests.java @@ -21,8 +21,8 @@ import java.util.List; import java.util.Map; import java.util.Optional; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.context.support.GenericApplicationContext; import org.springframework.core.MethodParameter; @@ -50,7 +50,7 @@ public class HeaderMethodArgumentResolverTests { private final ResolvableMethod resolvable = ResolvableMethod.on(getClass()).named("handleMessage").build(); - @Before + @BeforeEach public void setup() { GenericApplicationContext context = new GenericApplicationContext(); context.refresh(); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/reactive/HeadersMethodArgumentResolverTests.java b/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/reactive/HeadersMethodArgumentResolverTests.java index 2eca6191a8d..91b60209b07 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/reactive/HeadersMethodArgumentResolverTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/reactive/HeadersMethodArgumentResolverTests.java @@ -20,7 +20,7 @@ import java.time.Duration; import java.util.Collections; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.MethodParameter; import org.springframework.messaging.Message; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/reactive/MessageMappingMessageHandlerTests.java b/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/reactive/MessageMappingMessageHandlerTests.java index 6bf5ad3d6e6..14e6c0f66be 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/reactive/MessageMappingMessageHandlerTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/reactive/MessageMappingMessageHandlerTests.java @@ -20,7 +20,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/reactive/PayloadMethodArgumentResolverTests.java b/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/reactive/PayloadMethodArgumentResolverTests.java index 06ea2f9e92c..49f68f66c0a 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/reactive/PayloadMethodArgumentResolverTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/reactive/PayloadMethodArgumentResolverTests.java @@ -22,7 +22,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.reactivestreams.Publisher; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/support/AnnotationExceptionHandlerMethodResolverTests.java b/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/support/AnnotationExceptionHandlerMethodResolverTests.java index d0173fed3c7..b0210ffd998 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/support/AnnotationExceptionHandlerMethodResolverTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/support/AnnotationExceptionHandlerMethodResolverTests.java @@ -21,7 +21,7 @@ import java.io.IOException; import java.net.BindException; import java.net.SocketException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.messaging.handler.annotation.MessageExceptionHandler; import org.springframework.stereotype.Controller; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/support/DefaultMessageHandlerMethodFactoryTests.java b/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/support/DefaultMessageHandlerMethodFactoryTests.java index 34c59860577..f9290bf0faa 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/support/DefaultMessageHandlerMethodFactoryTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/support/DefaultMessageHandlerMethodFactoryTests.java @@ -24,9 +24,7 @@ import java.util.List; import java.util.Locale; import java.util.Map; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TestName; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.StaticListableBeanFactory; import org.springframework.core.MethodParameter; @@ -56,9 +54,6 @@ public class DefaultMessageHandlerMethodFactoryTests { private final SampleBean sample = new SampleBean(); - @Rule - public final TestName name = new TestName(); - @Test public void customConversion() throws Exception { diff --git a/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/support/DestinationVariableMethodArgumentResolverTests.java b/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/support/DestinationVariableMethodArgumentResolverTests.java index b71c9b86f41..77335caf2e5 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/support/DestinationVariableMethodArgumentResolverTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/support/DestinationVariableMethodArgumentResolverTests.java @@ -19,7 +19,7 @@ package org.springframework.messaging.handler.annotation.support; import java.util.HashMap; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.MethodParameter; import org.springframework.core.convert.support.DefaultConversionService; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/support/HeaderMethodArgumentResolverTests.java b/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/support/HeaderMethodArgumentResolverTests.java index 89dbeeb5cd0..503ef454ed8 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/support/HeaderMethodArgumentResolverTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/support/HeaderMethodArgumentResolverTests.java @@ -20,8 +20,8 @@ import java.util.List; import java.util.Map; import java.util.Optional; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.context.support.GenericApplicationContext; import org.springframework.core.MethodParameter; @@ -52,7 +52,7 @@ public class HeaderMethodArgumentResolverTests { private final ResolvableMethod resolvable = ResolvableMethod.on(getClass()).named("handleMessage").build(); - @Before + @BeforeEach public void setup() { GenericApplicationContext context = new GenericApplicationContext(); context.refresh(); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/support/HeadersMethodArgumentResolverTests.java b/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/support/HeadersMethodArgumentResolverTests.java index c58b4692bc9..0a30c4af464 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/support/HeadersMethodArgumentResolverTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/support/HeadersMethodArgumentResolverTests.java @@ -19,7 +19,7 @@ package org.springframework.messaging.handler.annotation.support; import java.util.Collections; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.MethodParameter; import org.springframework.messaging.Message; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/support/MessageMethodArgumentResolverTests.java b/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/support/MessageMethodArgumentResolverTests.java index 641d774d4b8..5ab097e537a 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/support/MessageMethodArgumentResolverTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/support/MessageMethodArgumentResolverTests.java @@ -19,8 +19,8 @@ package org.springframework.messaging.handler.annotation.support; import java.lang.reflect.Method; import java.util.Locale; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.MethodParameter; import org.springframework.messaging.Message; @@ -51,7 +51,7 @@ public class MessageMethodArgumentResolverTests { private Method method; - @Before + @BeforeEach public void setup() throws Exception { this.method = MessageMethodArgumentResolverTests.class.getDeclaredMethod("handle", Message.class, Message.class, Message.class, Message.class, ErrorMessage.class, Message.class); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/support/PayloadMethodArgumentResolverTests.java b/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/support/PayloadMethodArgumentResolverTests.java index 3c91c83bc62..2e71ce8815e 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/support/PayloadMethodArgumentResolverTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/handler/annotation/support/PayloadMethodArgumentResolverTests.java @@ -23,8 +23,8 @@ import java.lang.annotation.Target; import java.lang.reflect.Method; import java.util.Locale; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.LocalVariableTableParameterNameDiscoverer; import org.springframework.core.MethodParameter; @@ -68,7 +68,7 @@ public class PayloadMethodArgumentResolverTests { private MethodParameter paramValidated; - @Before + @BeforeEach public void setup() throws Exception { this.resolver = new PayloadMethodArgumentResolver(new StringMessageConverter(), testValidator()); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/InvocableHandlerMethodTests.java b/spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/InvocableHandlerMethodTests.java index 91c50900aa3..45e78feeff0 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/InvocableHandlerMethodTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/InvocableHandlerMethodTests.java @@ -18,7 +18,7 @@ package org.springframework.messaging.handler.invocation; import java.lang.reflect.Method; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.MethodParameter; import org.springframework.lang.Nullable; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/MethodMessageHandlerTests.java b/spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/MethodMessageHandlerTests.java index 7df777e0a48..eb9283ad22f 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/MethodMessageHandlerTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/MethodMessageHandlerTests.java @@ -26,8 +26,8 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.context.support.StaticApplicationContext; import org.springframework.messaging.Message; @@ -59,7 +59,7 @@ public class MethodMessageHandlerTests { private TestController testController; - @Before + @BeforeEach public void setup() { List destinationPrefixes = Arrays.asList("/test"); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/reactive/EncoderMethodReturnValueHandlerTests.java b/spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/reactive/EncoderMethodReturnValueHandlerTests.java index a0e30490610..c5e2e806ca8 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/reactive/EncoderMethodReturnValueHandlerTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/reactive/EncoderMethodReturnValueHandlerTests.java @@ -18,7 +18,7 @@ package org.springframework.messaging.handler.invocation.reactive; import java.util.Collections; import io.reactivex.Completable; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/reactive/InvocableHandlerMethodTests.java b/spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/reactive/InvocableHandlerMethodTests.java index e8091e27d70..3f19a54ada9 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/reactive/InvocableHandlerMethodTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/reactive/InvocableHandlerMethodTests.java @@ -22,7 +22,7 @@ import java.util.ArrayList; import java.util.List; import java.util.concurrent.atomic.AtomicReference; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/reactive/MethodMessageHandlerTests.java b/spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/reactive/MethodMessageHandlerTests.java index 229ef2227b1..be505f7ffe8 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/reactive/MethodMessageHandlerTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/handler/invocation/reactive/MethodMessageHandlerTests.java @@ -25,7 +25,7 @@ import java.util.Map; import java.util.Set; import java.util.function.Consumer; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.reactivestreams.Publisher; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/DefaultMetadataExtractorTests.java b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/DefaultMetadataExtractorTests.java index 5dc24409d64..a95eef7589a 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/DefaultMetadataExtractorTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/DefaultMetadataExtractorTests.java @@ -21,9 +21,9 @@ import java.util.Map; import io.netty.buffer.PooledByteBufAllocator; import io.rsocket.Payload; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.codec.ByteArrayDecoder; import org.springframework.core.codec.StringDecoder; @@ -52,14 +52,14 @@ public class DefaultMetadataExtractorTests { private DefaultMetadataExtractor extractor; - @Before + @BeforeEach public void setUp() { DataBufferFactory bufferFactory = new LeakAwareNettyDataBufferFactory(PooledByteBufAllocator.DEFAULT); this.strategies = RSocketStrategies.builder().dataBufferFactory(bufferFactory).build(); this.extractor = new DefaultMetadataExtractor(StringDecoder.allMimeTypes()); } - @After + @AfterEach public void tearDown() throws InterruptedException { DataBufferFactory bufferFactory = this.strategies.dataBufferFactory(); ((LeakAwareNettyDataBufferFactory) bufferFactory).checkForLeaks(Duration.ofSeconds(5)); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/DefaultRSocketRequesterBuilderTests.java b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/DefaultRSocketRequesterBuilderTests.java index 96f774fa401..cc3f0f98ebc 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/DefaultRSocketRequesterBuilderTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/DefaultRSocketRequesterBuilderTests.java @@ -29,8 +29,8 @@ import io.rsocket.DuplexConnection; import io.rsocket.RSocketFactory; import io.rsocket.frame.decoder.PayloadDecoder; import io.rsocket.transport.ClientTransport; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.reactivestreams.Publisher; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -68,7 +68,7 @@ public class DefaultRSocketRequesterBuilderTests { private final TestRSocketFactoryConfigurer rsocketFactoryConfigurer = new TestRSocketFactoryConfigurer(); - @Before + @BeforeEach public void setup() { this.transport = mock(ClientTransport.class); given(this.transport.connect(anyInt())).willReturn(Mono.just(this.connection)); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/DefaultRSocketRequesterTests.java b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/DefaultRSocketRequesterTests.java index a9f38f00548..9eb480fdc33 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/DefaultRSocketRequesterTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/DefaultRSocketRequesterTests.java @@ -28,8 +28,8 @@ import io.reactivex.Observable; import io.reactivex.Single; import io.rsocket.AbstractRSocket; import io.rsocket.Payload; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.reactivestreams.Publisher; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -64,7 +64,7 @@ public class DefaultRSocketRequesterTests { private final DefaultDataBufferFactory bufferFactory = new DefaultDataBufferFactory(); - @Before + @BeforeEach public void setUp() { this.rsocket = new TestRSocket(); this.requester = RSocketRequester.wrap(this.rsocket, TEXT_PLAIN, TEXT_PLAIN, this.strategies); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/DefaultRSocketStrategiesTests.java b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/DefaultRSocketStrategiesTests.java index dbc2480b144..6d230e95414 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/DefaultRSocketStrategiesTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/DefaultRSocketStrategiesTests.java @@ -15,7 +15,7 @@ */ package org.springframework.messaging.rsocket; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.ReactiveAdapterRegistry; import org.springframework.core.codec.ByteArrayDecoder; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/MetadataEncoderTests.java b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/MetadataEncoderTests.java index cf1635a3d6b..ab7c37d6ea3 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/MetadataEncoderTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/MetadataEncoderTests.java @@ -23,7 +23,7 @@ import java.util.Map; import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufAllocator; import io.rsocket.metadata.CompositeMetadata; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DefaultDataBufferFactory; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/PayloadUtilsTests.java b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/PayloadUtilsTests.java index 0377ac4fdf6..904032a29da 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/PayloadUtilsTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/PayloadUtilsTests.java @@ -22,8 +22,8 @@ import io.netty.buffer.PooledByteBufAllocator; import io.rsocket.Payload; import io.rsocket.util.ByteBufPayload; import io.rsocket.util.DefaultPayload; -import org.junit.After; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; import org.springframework.core.io.buffer.DataBuffer; import org.springframework.core.io.buffer.DataBufferUtils; @@ -47,7 +47,7 @@ public class PayloadUtilsTests { private DefaultDataBufferFactory defaultBufferFactory = new DefaultDataBufferFactory(); - @After + @AfterEach public void tearDown() throws Exception { this.nettyBufferFactory.checkForLeaks(Duration.ofSeconds(5)); } diff --git a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/RSocketBufferLeakTests.java b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/RSocketBufferLeakTests.java index 76be98cef14..8d8bcb07fd4 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/RSocketBufferLeakTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/RSocketBufferLeakTests.java @@ -31,11 +31,11 @@ import io.rsocket.frame.decoder.PayloadDecoder; import io.rsocket.plugins.RSocketInterceptor; import io.rsocket.transport.netty.server.CloseableChannel; import io.rsocket.transport.netty.server.TcpServerTransport; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.reactivestreams.Publisher; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -70,7 +70,7 @@ public class RSocketBufferLeakTests { private static RSocketRequester requester; - @BeforeClass + @BeforeAll @SuppressWarnings("ConstantConditions") public static void setupOnce() { @@ -93,20 +93,20 @@ public class RSocketBufferLeakTests { .block(); } - @AfterClass + @AfterAll public static void tearDownOnce() { requester.rsocket().dispose(); server.dispose(); } - @Before + @BeforeEach public void setUp() { getLeakAwareNettyDataBufferFactory().reset(); payloadInterceptor.reset(); } - @After + @AfterEach public void tearDown() throws InterruptedException { getLeakAwareNettyDataBufferFactory().checkForLeaks(Duration.ofSeconds(5)); payloadInterceptor.checkForLeaks(); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/RSocketClientToServerIntegrationTests.java b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/RSocketClientToServerIntegrationTests.java index 58f807d6c61..ed51978a7cd 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/RSocketClientToServerIntegrationTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/RSocketClientToServerIntegrationTests.java @@ -23,9 +23,9 @@ import io.rsocket.SocketAcceptor; import io.rsocket.frame.decoder.PayloadDecoder; import io.rsocket.transport.netty.server.CloseableChannel; import io.rsocket.transport.netty.server.TcpServerTransport; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.core.publisher.ReplayProcessor; @@ -57,7 +57,7 @@ public class RSocketClientToServerIntegrationTests { private static RSocketRequester requester; - @BeforeClass + @BeforeAll @SuppressWarnings("ConstantConditions") public static void setupOnce() { @@ -79,7 +79,7 @@ public class RSocketClientToServerIntegrationTests { .block(); } - @AfterClass + @AfterAll public static void tearDownOnce() { requester.rsocket().dispose(); server.dispose(); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/RSocketServerToClientIntegrationTests.java b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/RSocketServerToClientIntegrationTests.java index ef8e4da03ec..4cc9eecb2b2 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/RSocketServerToClientIntegrationTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/RSocketServerToClientIntegrationTests.java @@ -23,9 +23,9 @@ import io.rsocket.SocketAcceptor; import io.rsocket.frame.decoder.PayloadDecoder; import io.rsocket.transport.netty.server.CloseableChannel; import io.rsocket.transport.netty.server.TcpServerTransport; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.core.publisher.MonoProcessor; @@ -54,7 +54,7 @@ public class RSocketServerToClientIntegrationTests { private static CloseableChannel server; - @BeforeClass + @BeforeAll @SuppressWarnings("ConstantConditions") public static void setupOnce() { @@ -70,7 +70,7 @@ public class RSocketServerToClientIntegrationTests { .block(); } - @AfterClass + @AfterAll public static void tearDownOnce() { server.dispose(); } diff --git a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/annotation/support/RSocketFrameTypeMessageConditionTests.java b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/annotation/support/RSocketFrameTypeMessageConditionTests.java index 0cc751479c6..417baf1274e 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/annotation/support/RSocketFrameTypeMessageConditionTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/annotation/support/RSocketFrameTypeMessageConditionTests.java @@ -19,7 +19,7 @@ package org.springframework.messaging.rsocket.annotation.support; import java.util.Arrays; import io.rsocket.frame.FrameType; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.lang.Nullable; import org.springframework.messaging.Message; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/annotation/support/RSocketMessageHandlerTests.java b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/annotation/support/RSocketMessageHandlerTests.java index 91f0917842b..52c124e0790 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/rsocket/annotation/support/RSocketMessageHandlerTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/rsocket/annotation/support/RSocketMessageHandlerTests.java @@ -20,7 +20,7 @@ import java.util.Collections; import java.util.Map; import io.rsocket.frame.FrameType; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.ReactiveAdapterRegistry; import org.springframework.core.codec.ByteArrayDecoder; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/SimpAttributesContextHolderTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/SimpAttributesContextHolderTests.java index 6c31899caab..ed76ea88e1e 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/SimpAttributesContextHolderTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/SimpAttributesContextHolderTests.java @@ -19,9 +19,9 @@ package org.springframework.messaging.simp; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.messaging.Message; import org.springframework.messaging.support.GenericMessage; @@ -47,13 +47,13 @@ public class SimpAttributesContextHolderTests { private SimpAttributes simpAttributes; - @Before + @BeforeEach public void setUp() { Map map = new ConcurrentHashMap<>(); this.simpAttributes = new SimpAttributes("session1", map); } - @After + @AfterEach public void tearDown() { SimpAttributesContextHolder.resetAttributes(); } diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/SimpAttributesTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/SimpAttributesTests.java index 660a5f96754..ca82639fc04 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/SimpAttributesTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/SimpAttributesTests.java @@ -19,7 +19,7 @@ package org.springframework.messaging.simp; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/SimpMessageHeaderAccessorTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/SimpMessageHeaderAccessorTests.java index 9cfbc10723a..99d166fa02f 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/SimpMessageHeaderAccessorTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/SimpMessageHeaderAccessorTests.java @@ -20,7 +20,7 @@ import java.security.Principal; import java.util.Collections; import java.util.function.Consumer; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/SimpMessageTypeMessageConditionTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/SimpMessageTypeMessageConditionTests.java index f3876c56576..6cc84346d5d 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/SimpMessageTypeMessageConditionTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/SimpMessageTypeMessageConditionTests.java @@ -16,7 +16,7 @@ package org.springframework.messaging.simp; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.messaging.Message; import org.springframework.messaging.support.MessageBuilder; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/SimpMessagingTemplateTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/SimpMessagingTemplateTests.java index 70c103dc74e..7b4343aac88 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/SimpMessagingTemplateTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/SimpMessagingTemplateTests.java @@ -22,8 +22,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.messaging.Message; import org.springframework.messaging.MessageHeaders; @@ -49,7 +49,7 @@ public class SimpMessagingTemplateTests { private StubMessageChannel messageChannel; - @Before + @BeforeEach public void setup() { this.messageChannel = new StubMessageChannel(); this.messagingTemplate = new SimpMessagingTemplate(this.messageChannel); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/SimpSessionScopeTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/SimpSessionScopeTests.java index 18c1253fe79..6089f0c42a2 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/SimpSessionScopeTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/SimpSessionScopeTests.java @@ -18,9 +18,9 @@ package org.springframework.messaging.simp; import java.util.concurrent.ConcurrentHashMap; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.springframework.beans.factory.ObjectFactory; @@ -46,7 +46,7 @@ public class SimpSessionScopeTests { private SimpAttributes simpAttributes; - @Before + @BeforeEach public void setUp() { this.scope = new SimpSessionScope(); this.objectFactory = Mockito.mock(ObjectFactory.class); @@ -54,7 +54,7 @@ public class SimpSessionScopeTests { SimpAttributesContextHolder.setAttributes(this.simpAttributes); } - @After + @AfterEach public void tearDown() { SimpAttributesContextHolder.resetAttributes(); } diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/annotation/support/SendToMethodReturnValueHandlerTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/annotation/support/SendToMethodReturnValueHandlerTests.java index c8c1892b009..032044f4091 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/annotation/support/SendToMethodReturnValueHandlerTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/annotation/support/SendToMethodReturnValueHandlerTests.java @@ -26,13 +26,13 @@ import java.util.Map; import javax.security.auth.Subject; import com.fasterxml.jackson.annotation.JsonView; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.core.MethodParameter; import org.springframework.core.annotation.AliasFor; @@ -69,7 +69,7 @@ import static org.mockito.Mockito.verify; * @author Sebastien Deleuze * @author Stephane Nicoll */ -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class SendToMethodReturnValueHandlerTests { private static final MimeType MIME_TYPE = new MimeType("text", "plain", StandardCharsets.UTF_8); @@ -120,7 +120,7 @@ public class SendToMethodReturnValueHandlerTests { } - @Before + @BeforeEach public void setup() throws Exception { SimpMessagingTemplate messagingTemplate = new SimpMessagingTemplate(this.messageChannel); messagingTemplate.setMessageConverter(new StringMessageConverter()); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/annotation/support/SimpAnnotationMethodMessageHandlerTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/annotation/support/SimpAnnotationMethodMessageHandlerTests.java index a7c8a31e9b6..4672127e0d2 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/annotation/support/SimpAnnotationMethodMessageHandlerTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/annotation/support/SimpAnnotationMethodMessageHandlerTests.java @@ -25,13 +25,13 @@ import java.util.Optional; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ConcurrentHashMap; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import reactor.core.publisher.EmitterProcessor; import reactor.core.publisher.Flux; import reactor.core.publisher.FluxProcessor; @@ -81,7 +81,7 @@ import static org.mockito.Mockito.verify; * @author Brian Clozel * @author Sebastien Deleuze */ -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class SimpAnnotationMethodMessageHandlerTests { private static final String TEST_INVALID_VALUE = "invalidValue"; @@ -101,7 +101,7 @@ public class SimpAnnotationMethodMessageHandlerTests { private TestController testController = new TestController(); - @Before + @BeforeEach public void setup() { SimpMessagingTemplate brokerTemplate = new SimpMessagingTemplate(this.channel); brokerTemplate.setMessageConverter(this.converter); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/annotation/support/SubscriptionMethodReturnValueHandlerTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/annotation/support/SubscriptionMethodReturnValueHandlerTests.java index 546154da61f..26b24fbe8e8 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/annotation/support/SubscriptionMethodReturnValueHandlerTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/annotation/support/SubscriptionMethodReturnValueHandlerTests.java @@ -21,13 +21,13 @@ import java.nio.charset.StandardCharsets; import java.security.Principal; import com.fasterxml.jackson.annotation.JsonView; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.core.MethodParameter; import org.springframework.messaging.Message; @@ -58,7 +58,7 @@ import static org.mockito.Mockito.verify; * @author Rossen Stoyanchev * @author Sebastien Deleuze */ -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class SubscriptionMethodReturnValueHandlerTests { public static final MimeType MIME_TYPE = new MimeType("text", "plain", StandardCharsets.UTF_8); @@ -85,7 +85,7 @@ public class SubscriptionMethodReturnValueHandlerTests { private MethodParameter subscribeEventJsonViewReturnType; - @Before + @BeforeEach public void setup() throws Exception { SimpMessagingTemplate messagingTemplate = new SimpMessagingTemplate(this.messageChannel); messagingTemplate.setMessageConverter(new StringMessageConverter()); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/broker/BrokerMessageHandlerTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/broker/BrokerMessageHandlerTests.java index a8a5e014a90..90183650c8a 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/broker/BrokerMessageHandlerTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/broker/BrokerMessageHandlerTests.java @@ -21,7 +21,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.ApplicationEvent; import org.springframework.context.ApplicationEventPublisher; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/broker/DefaultSubscriptionRegistryTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/broker/DefaultSubscriptionRegistryTests.java index 1342b2cfda1..b0ce3f56102 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/broker/DefaultSubscriptionRegistryTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/broker/DefaultSubscriptionRegistryTests.java @@ -22,7 +22,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.messaging.Message; import org.springframework.messaging.simp.SimpMessageHeaderAccessor; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/broker/OrderedMessageSenderTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/broker/OrderedMessageSenderTests.java index 8d95371bdee..c1fffb0a1a3 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/broker/OrderedMessageSenderTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/broker/OrderedMessageSenderTests.java @@ -23,9 +23,9 @@ import java.util.concurrent.atomic.AtomicReference; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.messaging.simp.SimpMessageHeaderAccessor; import org.springframework.messaging.simp.SimpMessageType; @@ -51,7 +51,7 @@ public class OrderedMessageSenderTests { private ThreadPoolTaskExecutor executor; - @Before + @BeforeEach public void setup() { this.executor = new ThreadPoolTaskExecutor(); this.executor.setCorePoolSize(Runtime.getRuntime().availableProcessors() * 2); @@ -65,7 +65,7 @@ public class OrderedMessageSenderTests { } - @After + @AfterEach public void tearDown() { this.executor.shutdown(); } diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/broker/SimpleBrokerMessageHandlerTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/broker/SimpleBrokerMessageHandlerTests.java index 5c717424846..cae2ac4e387 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/broker/SimpleBrokerMessageHandlerTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/broker/SimpleBrokerMessageHandlerTests.java @@ -21,13 +21,13 @@ import java.util.Collections; import java.util.List; import java.util.concurrent.ScheduledFuture; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.messaging.Message; import org.springframework.messaging.MessageChannel; @@ -57,7 +57,7 @@ import static org.mockito.Mockito.verifyNoMoreInteractions; * @author Rossen Stoyanchev * @since 4.0 */ -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) @SuppressWarnings("unchecked") public class SimpleBrokerMessageHandlerTests { @@ -80,7 +80,7 @@ public class SimpleBrokerMessageHandlerTests { ArgumentCaptor> messageCaptor; - @Before + @BeforeEach public void setup() { this.messageHandler = new SimpleBrokerMessageHandler( this.clientInChannel, this.clientOutChannel, this.brokerChannel, Collections.emptyList()); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/config/MessageBrokerConfigurationTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/config/MessageBrokerConfigurationTests.java index 5864d57e5d2..779c1de0526 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/config/MessageBrokerConfigurationTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/config/MessageBrokerConfigurationTests.java @@ -22,7 +22,7 @@ import java.util.List; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/config/StompBrokerRelayRegistrationTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/config/StompBrokerRelayRegistrationTests.java index 687fcc3ea29..462c43e7942 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/config/StompBrokerRelayRegistrationTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/config/StompBrokerRelayRegistrationTests.java @@ -16,7 +16,7 @@ package org.springframework.messaging.simp.config; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.messaging.MessageChannel; import org.springframework.messaging.StubMessageChannel; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/BufferingStompDecoderTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/BufferingStompDecoderTests.java index c8358c52e18..80d20b8a24f 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/BufferingStompDecoderTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/BufferingStompDecoderTests.java @@ -21,7 +21,7 @@ import java.nio.charset.StandardCharsets; import java.util.Collections; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.messaging.Message; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/DefaultStompSessionTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/DefaultStompSessionTests.java index 451a2ef11b7..1b744a278fd 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/DefaultStompSessionTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/DefaultStompSessionTests.java @@ -23,13 +23,13 @@ import java.util.Map; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.atomic.AtomicReference; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; import org.springframework.messaging.Message; import org.springframework.messaging.MessageDeliveryException; @@ -64,7 +64,7 @@ import static org.mockito.Mockito.verifyNoMoreInteractions; * * @author Rossen Stoyanchev */ -@RunWith(MockitoJUnitRunner.class) +@MockitoSettings(strictness = Strictness.LENIENT) public class DefaultStompSessionTests { private DefaultStompSession session; @@ -82,7 +82,7 @@ public class DefaultStompSessionTests { private ArgumentCaptor> messageCaptor; - @Before + @BeforeEach public void setUp() { this.connectHeaders = new StompHeaders(); this.session = new DefaultStompSession(this.sessionHandler, this.connectHeaders); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/ReactorNettyTcpStompClientTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/ReactorNettyTcpStompClientTests.java index 8313c9f589c..4bf79b57d2d 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/ReactorNettyTcpStompClientTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/ReactorNettyTcpStompClientTests.java @@ -26,11 +26,10 @@ import java.util.concurrent.TimeUnit; import org.apache.activemq.broker.BrokerService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TestName; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; import org.springframework.lang.Nullable; import org.springframework.messaging.converter.StringMessageConverter; @@ -46,23 +45,21 @@ import static org.assertj.core.api.Assertions.assertThat; * Integration tests for {@link ReactorNettyTcpStompClient}. * * @author Rossen Stoyanchev + * @author Sam Brannen */ public class ReactorNettyTcpStompClientTests { private static final Log logger = LogFactory.getLog(ReactorNettyTcpStompClientTests.class); - @Rule - public final TestName testName = new TestName(); private BrokerService activeMQBroker; private ReactorNettyTcpStompClient client; - @Before - public void setUp() throws Exception { - - logger.debug("Setting up before '" + this.testName.getMethodName() + "'"); + @BeforeEach + public void setUp(TestInfo testInfo) throws Exception { + logger.debug("Setting up before '" + testInfo.getTestMethod().get().getName() + "'"); int port = SocketUtils.findAvailableTcpPort(61613); @@ -83,7 +80,7 @@ public class ReactorNettyTcpStompClientTests { this.client.setTaskScheduler(taskScheduler); } - @After + @AfterEach public void tearDown() throws Exception { try { this.client.shutdown(); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompBrokerRelayMessageHandlerIntegrationTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompBrokerRelayMessageHandlerIntegrationTests.java index 7883c7e852f..bb0bcc0e2bc 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompBrokerRelayMessageHandlerIntegrationTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompBrokerRelayMessageHandlerIntegrationTests.java @@ -28,11 +28,10 @@ import java.util.concurrent.TimeUnit; import org.apache.activemq.broker.BrokerService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TestName; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; import org.springframework.context.ApplicationEvent; import org.springframework.context.ApplicationEventPublisher; @@ -56,12 +55,10 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; * Integration tests for {@link StompBrokerRelayMessageHandler} running against ActiveMQ. * * @author Rossen Stoyanchev + * @author Sam Brannen */ public class StompBrokerRelayMessageHandlerIntegrationTests { - @Rule - public final TestName testName = new TestName(); - private static final Log logger = LogFactory.getLog(StompBrokerRelayMessageHandlerIntegrationTests.class); private StompBrokerRelayMessageHandler relay; @@ -77,9 +74,10 @@ public class StompBrokerRelayMessageHandlerIntegrationTests { private int port; - @Before - public void setup() throws Exception { - logger.debug("Setting up before '" + this.testName.getMethodName() + "'"); + @BeforeEach + public void setUp(TestInfo testInfo) throws Exception { + logger.debug("Setting up before '" + testInfo.getTestMethod().get().getName() + "'"); + this.port = SocketUtils.findAvailableTcpPort(61613); this.responseChannel = new ExecutorSubscribableChannel(); this.responseHandler = new TestMessageHandler(); @@ -114,7 +112,7 @@ public class StompBrokerRelayMessageHandlerIntegrationTests { this.eventPublisher.expectBrokerAvailabilityEvent(true); } - @After + @AfterEach public void stop() throws Exception { try { logger.debug("STOMP broker relay stats: " + this.relay.getStatsInfo()); @@ -133,6 +131,7 @@ public class StompBrokerRelayMessageHandlerIntegrationTests { } final CountDownLatch latch = new CountDownLatch(1); this.activeMQBroker.addShutdownHook(new Runnable() { + @Override public void run() { latch.countDown(); } diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompBrokerRelayMessageHandlerTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompBrokerRelayMessageHandlerTests.java index f330a1696e0..3bf8372f841 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompBrokerRelayMessageHandlerTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompBrokerRelayMessageHandlerTests.java @@ -21,8 +21,8 @@ import java.util.Collections; import java.util.List; import java.util.concurrent.Callable; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; import org.springframework.messaging.Message; @@ -59,7 +59,7 @@ public class StompBrokerRelayMessageHandlerTests { private StubTcpOperations tcpClient; - @Before + @BeforeEach public void setup() { this.outboundChannel = new StubMessageChannel(); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompClientSupportTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompClientSupportTests.java index 9beff04582a..c4cf1f118b6 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompClientSupportTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompClientSupportTests.java @@ -16,7 +16,7 @@ package org.springframework.messaging.simp.stomp; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompCommandTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompCommandTests.java index 9e66fb4e277..870c8240bdd 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompCommandTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompCommandTests.java @@ -21,7 +21,7 @@ import java.util.Collection; import java.util.EnumMap; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.messaging.simp.SimpMessageType; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompDecoderTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompDecoderTests.java index bf520856151..35734d0ea54 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompDecoderTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompDecoderTests.java @@ -20,7 +20,7 @@ import java.io.UnsupportedEncodingException; import java.nio.ByteBuffer; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.messaging.Message; import org.springframework.messaging.simp.SimpMessageType; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompEncoderTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompEncoderTests.java index 2e6f421d3b9..67aa7cbc6b2 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompEncoderTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompEncoderTests.java @@ -16,7 +16,7 @@ package org.springframework.messaging.simp.stomp; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.messaging.Message; import org.springframework.messaging.support.MessageBuilder; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompHeaderAccessorTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompHeaderAccessorTests.java index 5c0d825bb36..340a27b6931 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompHeaderAccessorTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompHeaderAccessorTests.java @@ -21,7 +21,7 @@ import java.nio.charset.StandardCharsets; import java.util.List; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.messaging.Message; import org.springframework.messaging.MessageHeaders; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/user/DefaultUserDestinationResolverTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/user/DefaultUserDestinationResolverTests.java index defb90ca692..c2887f5d1b2 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/user/DefaultUserDestinationResolverTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/user/DefaultUserDestinationResolverTests.java @@ -18,8 +18,8 @@ package org.springframework.messaging.simp.user; import java.security.Principal; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.messaging.Message; import org.springframework.messaging.simp.SimpMessageHeaderAccessor; @@ -45,7 +45,7 @@ public class DefaultUserDestinationResolverTests { private SimpUserRegistry registry; - @Before + @BeforeEach public void setup() { TestSimpUser simpUser = new TestSimpUser("joe"); simpUser.addSessions(new TestSimpSession("123")); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/user/MultiServerUserRegistryTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/user/MultiServerUserRegistryTests.java index d4b155fa92f..9bbc42b7a0f 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/user/MultiServerUserRegistryTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/user/MultiServerUserRegistryTests.java @@ -22,8 +22,8 @@ import java.util.HashSet; import java.util.Iterator; import java.util.Set; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.springframework.messaging.Message; @@ -48,7 +48,7 @@ public class MultiServerUserRegistryTests { private MessageConverter converter; - @Before + @BeforeEach public void setup() throws Exception { this.localRegistry = Mockito.mock(SimpUserRegistry.class); this.registry = new MultiServerUserRegistry(this.localRegistry); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/user/UserDestinationMessageHandlerTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/user/UserDestinationMessageHandlerTests.java index f23a3c7f4ad..381da723e34 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/user/UserDestinationMessageHandlerTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/user/UserDestinationMessageHandlerTests.java @@ -18,8 +18,8 @@ package org.springframework.messaging.simp.user; import java.nio.charset.StandardCharsets; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; import org.mockito.Mockito; @@ -54,7 +54,7 @@ public class UserDestinationMessageHandlerTests { private SubscribableChannel brokerChannel; - @Before + @BeforeEach public void setup() { this.registry = mock(SimpUserRegistry.class); this.brokerChannel = mock(SubscribableChannel.class); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/simp/user/UserRegistryMessageHandlerTests.java b/spring-messaging/src/test/java/org/springframework/messaging/simp/user/UserRegistryMessageHandlerTests.java index 88df34ce00e..98f2caea15b 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/simp/user/UserRegistryMessageHandlerTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/simp/user/UserRegistryMessageHandlerTests.java @@ -21,12 +21,12 @@ import java.util.Collections; import java.util.HashSet; import java.util.concurrent.ScheduledFuture; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentCaptor; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.messaging.Message; import org.springframework.messaging.MessageChannel; @@ -50,7 +50,7 @@ import static org.mockito.Mockito.verifyNoMoreInteractions; * User tests for {@link UserRegistryMessageHandler}. * @author Rossen Stoyanchev */ -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class UserRegistryMessageHandlerTests { private UserRegistryMessageHandler handler; @@ -69,9 +69,8 @@ public class UserRegistryMessageHandlerTests { private TaskScheduler taskScheduler; - @Before + @BeforeEach public void setUp() throws Exception { - given(this.brokerChannel.send(any())).willReturn(true); this.converter = new MappingJackson2MessageConverter(); SimpMessagingTemplate brokerTemplate = new SimpMessagingTemplate(this.brokerChannel); @@ -108,6 +107,7 @@ public class UserRegistryMessageHandlerTests { @Test public void broadcastRegistry() throws Exception { + given(this.brokerChannel.send(any())).willReturn(true); TestSimpUser simpUser1 = new TestSimpUser("joe"); TestSimpUser simpUser2 = new TestSimpUser("jane"); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/support/ChannelInterceptorTests.java b/spring-messaging/src/test/java/org/springframework/messaging/support/ChannelInterceptorTests.java index caeac9086df..500c02a38f8 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/support/ChannelInterceptorTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/support/ChannelInterceptorTests.java @@ -21,8 +21,8 @@ import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.messaging.Message; import org.springframework.messaging.MessageChannel; @@ -44,7 +44,7 @@ public class ChannelInterceptorTests { private TestMessageHandler messageHandler; - @Before + @BeforeEach public void setup() { this.channel = new ExecutorSubscribableChannel(); this.messageHandler = new TestMessageHandler(); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/support/ErrorMessageTests.java b/spring-messaging/src/test/java/org/springframework/messaging/support/ErrorMessageTests.java index 33f19f92371..9ac44ce2c13 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/support/ErrorMessageTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/support/ErrorMessageTests.java @@ -16,7 +16,7 @@ package org.springframework.messaging.support; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/support/ExecutorSubscribableChannelTests.java b/spring-messaging/src/test/java/org/springframework/messaging/support/ExecutorSubscribableChannelTests.java index 8853a25ee29..adebe99a85c 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/support/ExecutorSubscribableChannelTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/support/ExecutorSubscribableChannelTests.java @@ -18,12 +18,12 @@ package org.springframework.messaging.support; import java.util.concurrent.atomic.AtomicInteger; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.core.task.TaskExecutor; import org.springframework.messaging.Message; @@ -46,7 +46,7 @@ import static org.mockito.Mockito.verifyZeroInteractions; * * @author Phillip Webb */ -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class ExecutorSubscribableChannelTests { private ExecutorSubscribableChannel channel = new ExecutorSubscribableChannel(); diff --git a/spring-messaging/src/test/java/org/springframework/messaging/support/MessageBuilderTests.java b/spring-messaging/src/test/java/org/springframework/messaging/support/MessageBuilderTests.java index ff9c4050c9e..e0a0b8ccb06 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/support/MessageBuilderTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/support/MessageBuilderTests.java @@ -21,7 +21,7 @@ import java.util.HashMap; import java.util.Map; import java.util.UUID; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.messaging.Message; import org.springframework.messaging.MessageHeaders; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/support/MessageHeaderAccessorTests.java b/spring-messaging/src/test/java/org/springframework/messaging/support/MessageHeaderAccessorTests.java index 0d20a605ea6..99a32034011 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/support/MessageHeaderAccessorTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/support/MessageHeaderAccessorTests.java @@ -22,7 +22,7 @@ import java.util.HashMap; import java.util.Map; import java.util.UUID; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.messaging.Message; import org.springframework.messaging.MessageHeaders; diff --git a/spring-messaging/src/test/java/org/springframework/messaging/support/NativeMessageHeaderAccessorTests.java b/spring-messaging/src/test/java/org/springframework/messaging/support/NativeMessageHeaderAccessorTests.java index bcb131577ce..3902a06b47c 100644 --- a/spring-messaging/src/test/java/org/springframework/messaging/support/NativeMessageHeaderAccessorTests.java +++ b/spring-messaging/src/test/java/org/springframework/messaging/support/NativeMessageHeaderAccessorTests.java @@ -22,7 +22,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.messaging.Message; import org.springframework.util.LinkedMultiValueMap; diff --git a/spring-messaging/src/test/kotlin/org/springframework/messaging/rsocket/RSocketClientToServerCoroutinesIntegrationTests.kt b/spring-messaging/src/test/kotlin/org/springframework/messaging/rsocket/RSocketClientToServerCoroutinesIntegrationTests.kt index 179d04b944a..326a0650d7d 100644 --- a/spring-messaging/src/test/kotlin/org/springframework/messaging/rsocket/RSocketClientToServerCoroutinesIntegrationTests.kt +++ b/spring-messaging/src/test/kotlin/org/springframework/messaging/rsocket/RSocketClientToServerCoroutinesIntegrationTests.kt @@ -26,9 +26,9 @@ import kotlinx.coroutines.delay import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.map -import org.junit.AfterClass -import org.junit.BeforeClass -import org.junit.Test +import org.junit.jupiter.api.AfterAll +import org.junit.jupiter.api.BeforeAll +import org.junit.jupiter.api.Test import org.springframework.context.annotation.AnnotationConfigApplicationContext import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration @@ -194,7 +194,7 @@ class RSocketClientToServerCoroutinesIntegrationTests { private lateinit var requester: RSocketRequester - @BeforeClass + @BeforeAll @JvmStatic fun setupOnce() { context = AnnotationConfigApplicationContext(ServerConfig::class.java) @@ -214,7 +214,7 @@ class RSocketClientToServerCoroutinesIntegrationTests { .block()!! } - @AfterClass + @AfterAll @JvmStatic fun tearDownOnce() { requester.rsocket().dispose() 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 f1693f60c18..aefa3e21bb7 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 @@ -7,7 +7,7 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.toList import kotlinx.coroutines.runBlocking import org.junit.Assert.assertEquals -import org.junit.Test +import org.junit.jupiter.api.Test import org.mockito.ArgumentMatchers.anyInt import org.reactivestreams.Publisher import org.springframework.core.ParameterizedTypeReference @@ -136,4 +136,5 @@ class RSocketRequesterExtensionsTests { assertEquals(listOf("foo", "bar"), responseSpec.retrieveFlux().collectList().block()) } } + } 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 f38efadc380..99e442df09d 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 @@ -20,8 +20,8 @@ import io.mockk.mockk import java.util.Collections import java.util.HashMap -import org.junit.Before -import org.junit.Test +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Test import org.springframework.context.support.StaticApplicationContext import org.springframework.messaging.Message @@ -47,7 +47,6 @@ import org.springframework.messaging.handler.annotation.MessageExceptionHandler */ class SimpAnnotationMethodMessageHandlerKotlinTests { - lateinit var messageHandler: TestSimpAnnotationMethodMessageHandler lateinit var testController: TestController @@ -56,7 +55,7 @@ class SimpAnnotationMethodMessageHandlerKotlinTests { val converter = mockk(relaxed = true) - @Before + @BeforeEach fun setup() { val brokerTemplate = SimpMessagingTemplate(channel) brokerTemplate.messageConverter = converter diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/AbstractContainerEntityManagerFactoryIntegrationTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/AbstractContainerEntityManagerFactoryIntegrationTests.java index e010ff7e995..dbcf58e12fc 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/AbstractContainerEntityManagerFactoryIntegrationTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/AbstractContainerEntityManagerFactoryIntegrationTests.java @@ -23,7 +23,7 @@ import javax.persistence.FlushModeType; import javax.persistence.NoResultException; import javax.persistence.Query; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.orm.jpa.domain.DriversLicense; import org.springframework.orm.jpa.domain.Person; diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/AbstractEntityManagerFactoryBeanTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/AbstractEntityManagerFactoryBeanTests.java index e6c80d23ba4..3220e271bf2 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/AbstractEntityManagerFactoryBeanTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/AbstractEntityManagerFactoryBeanTests.java @@ -20,8 +20,8 @@ import javax.persistence.EntityManagerFactory; import javax.persistence.PersistenceException; import javax.persistence.spi.PersistenceUnitInfo; -import org.junit.After; -import org.junit.Before; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; import org.springframework.transaction.support.TransactionSynchronizationManager; @@ -40,12 +40,12 @@ public abstract class AbstractEntityManagerFactoryBeanTests { protected static EntityManagerFactory mockEmf; - @Before + @BeforeEach public void setUp() throws Exception { mockEmf = mock(EntityManagerFactory.class); } - @After + @AfterEach public void tearDown() throws Exception { assertThat(TransactionSynchronizationManager.getResourceMap().isEmpty()).isTrue(); assertThat(TransactionSynchronizationManager.isSynchronizationActive()).isFalse(); diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/AbstractEntityManagerFactoryIntegrationTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/AbstractEntityManagerFactoryIntegrationTests.java index ebbb7fb53c8..56a6d288a5e 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/AbstractEntityManagerFactoryIntegrationTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/AbstractEntityManagerFactoryIntegrationTests.java @@ -21,9 +21,9 @@ import javax.persistence.EntityManagerFactory; import javax.persistence.Query; import javax.sql.DataSource; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ConfigurableApplicationContext; @@ -87,7 +87,7 @@ public abstract class AbstractEntityManagerFactoryIntegrationTests { } - @Before + @BeforeEach public void setup() { if (applicationContext == null) { applicationContext = new ClassPathXmlApplicationContext(getConfigLocations()); @@ -103,7 +103,7 @@ public abstract class AbstractEntityManagerFactoryIntegrationTests { return ECLIPSELINK_CONFIG_LOCATIONS; } - @After + @AfterEach public void cleanup() { if (this.transactionStatus != null && !this.transactionStatus.isCompleted()) { endTransaction(); @@ -115,7 +115,7 @@ public abstract class AbstractEntityManagerFactoryIntegrationTests { assertThat(TransactionSynchronizationManager.isActualTransactionActive()).isFalse(); } - @AfterClass + @AfterAll public static void closeContext() { if (applicationContext != null) { applicationContext.close(); diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/ApplicationManagedEntityManagerIntegrationTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/ApplicationManagedEntityManagerIntegrationTests.java index 4bef06a7137..99efffcff8e 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/ApplicationManagedEntityManagerIntegrationTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/ApplicationManagedEntityManagerIntegrationTests.java @@ -22,7 +22,7 @@ import javax.persistence.EntityManager; import javax.persistence.Query; import javax.persistence.TransactionRequiredException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.orm.jpa.domain.Person; diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/ContainerManagedEntityManagerIntegrationTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/ContainerManagedEntityManagerIntegrationTests.java index 5c7342dc0b6..bccc8bf19cd 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/ContainerManagedEntityManagerIntegrationTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/ContainerManagedEntityManagerIntegrationTests.java @@ -23,7 +23,7 @@ import javax.persistence.PersistenceException; import javax.persistence.Query; import javax.persistence.TransactionRequiredException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.DataAccessException; diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/DefaultJpaDialectTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/DefaultJpaDialectTests.java index 364df9bda1d..fedb323fba7 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/DefaultJpaDialectTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/DefaultJpaDialectTests.java @@ -20,7 +20,7 @@ import javax.persistence.EntityManager; import javax.persistence.EntityTransaction; import javax.persistence.OptimisticLockException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.transaction.TransactionDefinition; import org.springframework.transaction.TransactionException; diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/EntityManagerFactoryBeanSupportTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/EntityManagerFactoryBeanSupportTests.java index c6ed3c7ba3a..76aa7b144f5 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/EntityManagerFactoryBeanSupportTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/EntityManagerFactoryBeanSupportTests.java @@ -16,7 +16,7 @@ package org.springframework.orm.jpa; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.mockito.Mockito.verify; diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/EntityManagerFactoryUtilsTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/EntityManagerFactoryUtilsTests.java index 68faca24708..4525931ed53 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/EntityManagerFactoryUtilsTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/EntityManagerFactoryUtilsTests.java @@ -26,7 +26,7 @@ import javax.persistence.OptimisticLockException; import javax.persistence.PersistenceException; import javax.persistence.TransactionRequiredException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.dao.DataAccessException; import org.springframework.dao.DataIntegrityViolationException; diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/JpaTransactionManagerTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/JpaTransactionManagerTests.java index 7e07ce41020..8642798e34e 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/JpaTransactionManagerTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/JpaTransactionManagerTests.java @@ -23,9 +23,9 @@ import javax.persistence.EntityManagerFactory; import javax.persistence.EntityTransaction; import javax.persistence.RollbackException; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.transaction.InvalidIsolationLevelException; import org.springframework.transaction.TransactionDefinition; @@ -64,7 +64,7 @@ public class JpaTransactionManagerTests { private TransactionTemplate tt; - @Before + @BeforeEach public void setup() { factory = mock(EntityManagerFactory.class); manager = mock(EntityManager.class); @@ -78,7 +78,7 @@ public class JpaTransactionManagerTests { given(manager.isOpen()).willReturn(true); } - @After + @AfterEach public void verifyTransactionSynchronizationManagerState() { assertThat(TransactionSynchronizationManager.getResourceMap().isEmpty()).isTrue(); assertThat(TransactionSynchronizationManager.isSynchronizationActive()).isFalse(); diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/LocalContainerEntityManagerFactoryBeanTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/LocalContainerEntityManagerFactoryBeanTests.java index f47ff67f992..fa2fe9fa145 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/LocalContainerEntityManagerFactoryBeanTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/LocalContainerEntityManagerFactoryBeanTests.java @@ -28,7 +28,7 @@ import javax.persistence.spi.PersistenceUnitInfo; import javax.persistence.spi.PersistenceUnitTransactionType; import javax.persistence.spi.ProviderUtil; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.dao.DataAccessException; diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/LocalEntityManagerFactoryBeanTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/LocalEntityManagerFactoryBeanTests.java index ea113cefec4..e34329a265f 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/LocalEntityManagerFactoryBeanTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/LocalEntityManagerFactoryBeanTests.java @@ -23,8 +23,8 @@ import javax.persistence.spi.PersistenceProvider; import javax.persistence.spi.PersistenceUnitInfo; import javax.persistence.spi.ProviderUtil; -import org.junit.After; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.verify; @@ -42,7 +42,7 @@ public class LocalEntityManagerFactoryBeanTests extends AbstractEntityManagerFac private static Map actualProps; - @After + @AfterEach public void verifyClosed() throws Exception { verify(mockEmf).close(); } diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/SharedEntityManagerCreatorTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/SharedEntityManagerCreatorTests.java index 440402cacb5..86df24330b8 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/SharedEntityManagerCreatorTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/SharedEntityManagerCreatorTests.java @@ -23,9 +23,9 @@ import javax.persistence.Query; import javax.persistence.StoredProcedureQuery; import javax.persistence.TransactionRequiredException; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.junit.MockitoJUnitRunner; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; @@ -43,7 +43,7 @@ import static org.mockito.Mockito.withSettings; * @author Oliver Gierke * @author Juergen Hoeller */ -@RunWith(MockitoJUnitRunner.StrictStubs.class) +@ExtendWith(MockitoExtension.class) public class SharedEntityManagerCreatorTests { @Test diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/eclipselink/EclipseLinkEntityManagerFactoryIntegrationTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/eclipselink/EclipseLinkEntityManagerFactoryIntegrationTests.java index 4e9b94c7477..1a5af522f61 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/eclipselink/EclipseLinkEntityManagerFactoryIntegrationTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/eclipselink/EclipseLinkEntityManagerFactoryIntegrationTests.java @@ -17,7 +17,7 @@ package org.springframework.orm.jpa.eclipselink; import org.eclipse.persistence.jpa.JpaEntityManager; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.orm.jpa.AbstractContainerEntityManagerFactoryIntegrationTests; import org.springframework.orm.jpa.EntityManagerFactoryInfo; diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/hibernate/HibernateEntityManagerFactoryIntegrationTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/hibernate/HibernateEntityManagerFactoryIntegrationTests.java index 2a8f3986be6..03206c523ce 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/hibernate/HibernateEntityManagerFactoryIntegrationTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/hibernate/HibernateEntityManagerFactoryIntegrationTests.java @@ -21,7 +21,7 @@ import javax.persistence.EntityManager; import org.hibernate.FlushMode; import org.hibernate.Session; import org.hibernate.SessionFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.framework.ProxyFactory; import org.springframework.aop.target.SingletonTargetSource; diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/hibernate/HibernateMultiEntityManagerFactoryIntegrationTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/hibernate/HibernateMultiEntityManagerFactoryIntegrationTests.java index 684cbeda5ae..169babc3352 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/hibernate/HibernateMultiEntityManagerFactoryIntegrationTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/hibernate/HibernateMultiEntityManagerFactoryIntegrationTests.java @@ -19,7 +19,7 @@ package org.springframework.orm.jpa.hibernate; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.orm.jpa.AbstractContainerEntityManagerFactoryIntegrationTests; diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/hibernate/HibernateNativeEntityManagerFactoryIntegrationTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/hibernate/HibernateNativeEntityManagerFactoryIntegrationTests.java index 787c7b757c3..317b43067e7 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/hibernate/HibernateNativeEntityManagerFactoryIntegrationTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/hibernate/HibernateNativeEntityManagerFactoryIntegrationTests.java @@ -21,7 +21,7 @@ import java.util.List; import org.hibernate.FlushMode; import org.hibernate.SessionFactory; import org.hibernate.query.Query; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/hibernate/HibernateNativeEntityManagerFactorySpringBeanContainerIntegrationTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/hibernate/HibernateNativeEntityManagerFactorySpringBeanContainerIntegrationTests.java index 8004adb75b0..5eb4055b417 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/hibernate/HibernateNativeEntityManagerFactorySpringBeanContainerIntegrationTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/hibernate/HibernateNativeEntityManagerFactorySpringBeanContainerIntegrationTests.java @@ -24,7 +24,7 @@ import org.hibernate.resource.beans.container.spi.ContainedBean; import org.hibernate.resource.beans.spi.BeanInstanceProducer; import org.hibernate.resource.beans.spi.ManagedBeanRegistry; import org.hibernate.service.ServiceRegistry; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.annotation.Autowired; diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/persistenceunit/DefaultPersistenceUnitManagerTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/persistenceunit/DefaultPersistenceUnitManagerTests.java index 338fad786c8..149a28ad557 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/persistenceunit/DefaultPersistenceUnitManagerTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/persistenceunit/DefaultPersistenceUnitManagerTests.java @@ -16,7 +16,7 @@ package org.springframework.orm.jpa.persistenceunit; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.index.CandidateComponentsTestClassLoader; import org.springframework.core.io.ClassPathResource; diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/persistenceunit/PersistenceXmlParsingTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/persistenceunit/PersistenceXmlParsingTests.java index c46deddb0e5..f252ba6f13c 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/persistenceunit/PersistenceXmlParsingTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/persistenceunit/PersistenceXmlParsingTests.java @@ -24,8 +24,8 @@ import javax.persistence.spi.PersistenceUnitInfo; import javax.persistence.spi.PersistenceUnitTransactionType; import javax.sql.DataSource; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; @@ -253,7 +253,7 @@ public class PersistenceXmlParsingTests { assertThat(info[0].excludeUnlistedClasses()).as("Exclude unlisted should default false in 1.0.").isFalse(); } - @Ignore // not doing schema parsing anymore for JPA 2.0 compatibility + @Disabled // not doing schema parsing anymore for JPA 2.0 compatibility @Test public void testInvalidPersistence() throws Exception { PersistenceUnitReader reader = new PersistenceUnitReader( @@ -263,7 +263,7 @@ public class PersistenceXmlParsingTests { reader.readPersistenceUnitInfos(resource)); } - @Ignore // not doing schema parsing anymore for JPA 2.0 compatibility + @Disabled // not doing schema parsing anymore for JPA 2.0 compatibility @Test public void testNoSchemaPersistence() throws Exception { PersistenceUnitReader reader = new PersistenceUnitReader( diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/support/OpenEntityManagerInViewTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/support/OpenEntityManagerInViewTests.java index 8ee732a57af..6af6353d8c0 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/support/OpenEntityManagerInViewTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/support/OpenEntityManagerInViewTests.java @@ -28,9 +28,9 @@ import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.task.SimpleAsyncTaskExecutor; import org.springframework.mock.web.test.MockAsyncContext; @@ -75,7 +75,7 @@ public class OpenEntityManagerInViewTests { private ServletWebRequest webRequest; - @Before + @BeforeEach public void setUp() throws Exception { factory = mock(EntityManagerFactory.class); manager = mock(EntityManager.class); @@ -88,7 +88,7 @@ public class OpenEntityManagerInViewTests { this.webRequest = new ServletWebRequest(this.request); } - @After + @AfterEach public void tearDown() throws Exception { assertThat(TransactionSynchronizationManager.getResourceMap().isEmpty()).isTrue(); assertThat(TransactionSynchronizationManager.isSynchronizationActive()).isFalse(); diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/support/PersistenceContextTransactionTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/support/PersistenceContextTransactionTests.java index 4c4c054caad..9d5fc76147a 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/support/PersistenceContextTransactionTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/support/PersistenceContextTransactionTests.java @@ -23,9 +23,9 @@ import javax.persistence.PersistenceContext; import javax.persistence.PersistenceContextType; import javax.persistence.SynchronizationType; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.lang.Nullable; import org.springframework.orm.jpa.JpaTransactionManager; @@ -56,7 +56,7 @@ public class PersistenceContextTransactionTests { private EntityManagerHoldingBean bean; - @Before + @BeforeEach public void setup() { factory = mock(EntityManagerFactory.class); manager = mock(EntityManager.class); @@ -83,7 +83,7 @@ public class PersistenceContextTransactionTests { assertThat(TransactionSynchronizationManager.isSynchronizationActive()).isFalse(); } - @After + @AfterEach public void clear() { assertThat(TransactionSynchronizationManager.getResourceMap().isEmpty()).isTrue(); assertThat(TransactionSynchronizationManager.isSynchronizationActive()).isFalse(); diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/support/PersistenceInjectionIntegrationTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/support/PersistenceInjectionIntegrationTests.java index 2cf1bd2b5fd..4596d4c3581 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/support/PersistenceInjectionIntegrationTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/support/PersistenceInjectionIntegrationTests.java @@ -16,7 +16,7 @@ package org.springframework.orm.jpa.support; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.orm.jpa.AbstractEntityManagerFactoryIntegrationTests; diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/support/PersistenceInjectionTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/support/PersistenceInjectionTests.java index 13f9d0f0f76..3664b0d52bc 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/support/PersistenceInjectionTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/support/PersistenceInjectionTests.java @@ -30,8 +30,8 @@ import javax.persistence.PersistenceContextType; import javax.persistence.PersistenceProperty; import javax.persistence.PersistenceUnit; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.support.DefaultListableBeanFactory; @@ -336,7 +336,7 @@ public class PersistenceInjectionTests extends AbstractEntityManagerFactoryBeanT } @Test - @Ignore + @Disabled public void testPersistenceUnitsFromJndi() { EntityManager mockEm = mock(EntityManager.class); given(mockEmf.createEntityManager()).willReturn(mockEm); diff --git a/spring-orm/src/test/java/org/springframework/orm/jpa/support/SharedEntityManagerFactoryTests.java b/spring-orm/src/test/java/org/springframework/orm/jpa/support/SharedEntityManagerFactoryTests.java index 2bae2217219..4e344c18300 100644 --- a/spring-orm/src/test/java/org/springframework/orm/jpa/support/SharedEntityManagerFactoryTests.java +++ b/spring-orm/src/test/java/org/springframework/orm/jpa/support/SharedEntityManagerFactoryTests.java @@ -19,7 +19,7 @@ package org.springframework.orm.jpa.support; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.orm.jpa.EntityManagerHolder; import org.springframework.orm.jpa.EntityManagerProxy; diff --git a/spring-oxm/src/test/java/org/springframework/oxm/AbstractMarshallerTests.java b/spring-oxm/src/test/java/org/springframework/oxm/AbstractMarshallerTests.java index fc3e19a3046..4a1b23f23e5 100644 --- a/spring-oxm/src/test/java/org/springframework/oxm/AbstractMarshallerTests.java +++ b/spring-oxm/src/test/java/org/springframework/oxm/AbstractMarshallerTests.java @@ -28,8 +28,8 @@ import javax.xml.transform.dom.DOMResult; import javax.xml.transform.stax.StAXResult; import javax.xml.transform.stream.StreamResult; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.w3c.dom.Attr; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -54,7 +54,7 @@ public abstract class AbstractMarshallerTests { protected Object flights; - @Before + @BeforeEach public final void setUp() throws Exception { marshaller = createMarshaller(); flights = createFlights(); diff --git a/spring-oxm/src/test/java/org/springframework/oxm/AbstractUnmarshallerTests.java b/spring-oxm/src/test/java/org/springframework/oxm/AbstractUnmarshallerTests.java index c756f043e38..bae8444b044 100644 --- a/spring-oxm/src/test/java/org/springframework/oxm/AbstractUnmarshallerTests.java +++ b/spring-oxm/src/test/java/org/springframework/oxm/AbstractUnmarshallerTests.java @@ -30,8 +30,8 @@ import javax.xml.transform.sax.SAXSource; import javax.xml.transform.stax.StAXSource; import javax.xml.transform.stream.StreamSource; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Text; @@ -54,7 +54,7 @@ public abstract class AbstractUnmarshallerTests { "" + "42"; - @Before + @BeforeEach public final void setUp() throws Exception { unmarshaller = createUnmarshaller(); } diff --git a/spring-oxm/src/test/java/org/springframework/oxm/config/OxmNamespaceHandlerTests.java b/spring-oxm/src/test/java/org/springframework/oxm/config/OxmNamespaceHandlerTests.java index 6aacdba3743..315f9fb2c62 100644 --- a/spring-oxm/src/test/java/org/springframework/oxm/config/OxmNamespaceHandlerTests.java +++ b/spring-oxm/src/test/java/org/springframework/oxm/config/OxmNamespaceHandlerTests.java @@ -16,7 +16,7 @@ package org.springframework.oxm.config; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; diff --git a/spring-oxm/src/test/java/org/springframework/oxm/jaxb/Jaxb2MarshallerTests.java b/spring-oxm/src/test/java/org/springframework/oxm/jaxb/Jaxb2MarshallerTests.java index 6a74339b4b0..918e5924ff0 100644 --- a/spring-oxm/src/test/java/org/springframework/oxm/jaxb/Jaxb2MarshallerTests.java +++ b/spring-oxm/src/test/java/org/springframework/oxm/jaxb/Jaxb2MarshallerTests.java @@ -34,7 +34,7 @@ import javax.xml.transform.sax.SAXSource; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; import org.mockito.InOrder; import org.xml.sax.Attributes; diff --git a/spring-oxm/src/test/java/org/springframework/oxm/jaxb/Jaxb2UnmarshallerTests.java b/spring-oxm/src/test/java/org/springframework/oxm/jaxb/Jaxb2UnmarshallerTests.java index e5cffa098a3..928a324d60a 100644 --- a/spring-oxm/src/test/java/org/springframework/oxm/jaxb/Jaxb2UnmarshallerTests.java +++ b/spring-oxm/src/test/java/org/springframework/oxm/jaxb/Jaxb2UnmarshallerTests.java @@ -27,7 +27,7 @@ import javax.xml.stream.XMLStreamReader; import javax.xml.transform.Source; import javax.xml.transform.stream.StreamSource; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; diff --git a/spring-oxm/src/test/java/org/springframework/oxm/jibx/JibxMarshallerTests.java b/spring-oxm/src/test/java/org/springframework/oxm/jibx/JibxMarshallerTests.java index 6777076f330..5155b3f5966 100644 --- a/spring-oxm/src/test/java/org/springframework/oxm/jibx/JibxMarshallerTests.java +++ b/spring-oxm/src/test/java/org/springframework/oxm/jibx/JibxMarshallerTests.java @@ -19,15 +19,15 @@ package org.springframework.oxm.jibx; import java.io.StringWriter; import javax.xml.transform.stream.StreamResult; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.EnabledOnJre; import org.springframework.oxm.AbstractMarshallerTests; import org.springframework.tests.XmlContent; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.condition.JRE.JAVA_8; /** * NOTE: These tests fail under Eclipse/IDEA because JiBX binding does not occur by @@ -37,15 +37,9 @@ import static org.junit.Assume.assumeTrue; * @author Sam Brannen */ @Deprecated +@EnabledOnJre(JAVA_8) // JiBX compiler is currently not compatible with JDK 9 public class JibxMarshallerTests extends AbstractMarshallerTests { - @BeforeClass - public static void compilerAssumptions() { - // JiBX compiler is currently not compatible with JDK 9 - assumeTrue(System.getProperty("java.version").startsWith("1.8.")); - } - - @Override protected JibxMarshaller createMarshaller() throws Exception { JibxMarshaller marshaller = new JibxMarshaller(); diff --git a/spring-oxm/src/test/java/org/springframework/oxm/jibx/JibxUnmarshallerTests.java b/spring-oxm/src/test/java/org/springframework/oxm/jibx/JibxUnmarshallerTests.java index dad6e158c9f..feacb9e625d 100644 --- a/spring-oxm/src/test/java/org/springframework/oxm/jibx/JibxUnmarshallerTests.java +++ b/spring-oxm/src/test/java/org/springframework/oxm/jibx/JibxUnmarshallerTests.java @@ -19,13 +19,13 @@ package org.springframework.oxm.jibx; import java.io.ByteArrayInputStream; import javax.xml.transform.stream.StreamSource; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.EnabledOnJre; import org.springframework.oxm.AbstractUnmarshallerTests; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.condition.JRE.JAVA_8; /** * NOTE: These tests fail under Eclipse/IDEA because JiBX binding does @@ -35,6 +35,7 @@ import static org.junit.Assume.assumeTrue; * @author Sam Brannen */ @Deprecated +@EnabledOnJre(JAVA_8) // JiBX compiler is currently not compatible with JDK 9 public class JibxUnmarshallerTests extends AbstractUnmarshallerTests { protected static final String INPUT_STRING_WITH_SPECIAL_CHARACTERS = @@ -42,13 +43,6 @@ public class JibxUnmarshallerTests extends AbstractUnmarshallerTestsAir Libert\u00e942"; - @BeforeClass - public static void compilerAssumptions() { - // JiBX compiler is currently not compatible with JDK 9 - assumeTrue(System.getProperty("java.version").startsWith("1.8.")); - } - - @Override protected JibxMarshaller createUnmarshaller() throws Exception { JibxMarshaller unmarshaller = new JibxMarshaller(); diff --git a/spring-oxm/src/test/java/org/springframework/oxm/xstream/XStreamMarshallerTests.java b/spring-oxm/src/test/java/org/springframework/oxm/xstream/XStreamMarshallerTests.java index dad66873fdd..6b1cd82e2d4 100644 --- a/spring-oxm/src/test/java/org/springframework/oxm/xstream/XStreamMarshallerTests.java +++ b/spring-oxm/src/test/java/org/springframework/oxm/xstream/XStreamMarshallerTests.java @@ -43,9 +43,8 @@ import com.thoughtworks.xstream.io.HierarchicalStreamWriter; import com.thoughtworks.xstream.io.json.JettisonMappedXmlDriver; import com.thoughtworks.xstream.io.json.JsonHierarchicalStreamDriver; import com.thoughtworks.xstream.io.json.JsonWriter; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.InOrder; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -78,7 +77,7 @@ public class XStreamMarshallerTests { private Flight flight; - @Before + @BeforeEach public void createMarshaller() { marshaller = new XStreamMarshaller(); Map aliases = new HashMap<>(); @@ -236,7 +235,6 @@ public class XStreamMarshallerTests { } @Test - @Ignore("Fails on JDK 8 build 108") public void aliasesByTypeStringClassMap() throws Exception { Map> aliases = new HashMap<>(); aliases.put("flight", Flight.class); @@ -250,7 +248,6 @@ public class XStreamMarshallerTests { } @Test - @Ignore("Fails on JDK 8 build 108") public void aliasesByTypeStringStringMap() throws Exception { Map aliases = new HashMap<>(); aliases.put("flight", Flight.class.getName()); diff --git a/spring-oxm/src/test/java/org/springframework/oxm/xstream/XStreamUnmarshallerTests.java b/spring-oxm/src/test/java/org/springframework/oxm/xstream/XStreamUnmarshallerTests.java index cc7787811f1..9c10527b621 100644 --- a/spring-oxm/src/test/java/org/springframework/oxm/xstream/XStreamUnmarshallerTests.java +++ b/spring-oxm/src/test/java/org/springframework/oxm/xstream/XStreamUnmarshallerTests.java @@ -28,8 +28,8 @@ import javax.xml.transform.Source; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamSource; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.w3c.dom.Document; import org.xml.sax.InputSource; @@ -46,7 +46,7 @@ public class XStreamUnmarshallerTests { private XStreamMarshaller unmarshaller; - @Before + @BeforeEach public void createUnmarshaller() throws Exception { unmarshaller = new XStreamMarshaller(); Map> aliases = new HashMap<>(); diff --git a/spring-test/src/test/java/org/springframework/test/context/jdbc/PopulatedSchemaDatabaseConfig.java b/spring-test/src/test/java/org/springframework/test/context/jdbc/PopulatedSchemaDatabaseConfig.java index dee10825079..ed302b99138 100644 --- a/spring-test/src/test/java/org/springframework/test/context/jdbc/PopulatedSchemaDatabaseConfig.java +++ b/spring-test/src/test/java/org/springframework/test/context/jdbc/PopulatedSchemaDatabaseConfig.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * 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. @@ -43,7 +43,7 @@ public class PopulatedSchemaDatabaseConfig { @Bean public DataSource dataSource() { return new EmbeddedDatabaseBuilder()// - .setName("populated-sql-scripts-test-db")// + .generateUniqueName(true) .addScript("classpath:/org/springframework/test/context/jdbc/schema.sql") // .build(); } diff --git a/spring-tx/src/test/java/org/springframework/dao/annotation/PersistenceExceptionTranslationAdvisorTests.java b/spring-tx/src/test/java/org/springframework/dao/annotation/PersistenceExceptionTranslationAdvisorTests.java index 014c485d1bc..516808ed5a1 100644 --- a/spring-tx/src/test/java/org/springframework/dao/annotation/PersistenceExceptionTranslationAdvisorTests.java +++ b/spring-tx/src/test/java/org/springframework/dao/annotation/PersistenceExceptionTranslationAdvisorTests.java @@ -22,7 +22,7 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import javax.persistence.PersistenceException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.framework.ProxyFactory; import org.springframework.dao.DataAccessException; diff --git a/spring-tx/src/test/java/org/springframework/dao/annotation/PersistenceExceptionTranslationPostProcessorTests.java b/spring-tx/src/test/java/org/springframework/dao/annotation/PersistenceExceptionTranslationPostProcessorTests.java index 0480b0e75c5..a0955948113 100644 --- a/spring-tx/src/test/java/org/springframework/dao/annotation/PersistenceExceptionTranslationPostProcessorTests.java +++ b/spring-tx/src/test/java/org/springframework/dao/annotation/PersistenceExceptionTranslationPostProcessorTests.java @@ -21,7 +21,7 @@ import javax.persistence.PersistenceException; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator; import org.springframework.aop.framework.Advised; diff --git a/spring-tx/src/test/java/org/springframework/dao/support/ChainedPersistenceExceptionTranslatorTests.java b/spring-tx/src/test/java/org/springframework/dao/support/ChainedPersistenceExceptionTranslatorTests.java index d9b52bc4392..a4d5e24ae93 100644 --- a/spring-tx/src/test/java/org/springframework/dao/support/ChainedPersistenceExceptionTranslatorTests.java +++ b/spring-tx/src/test/java/org/springframework/dao/support/ChainedPersistenceExceptionTranslatorTests.java @@ -16,7 +16,7 @@ package org.springframework.dao.support; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.dao.InvalidDataAccessApiUsageException; import org.springframework.dao.OptimisticLockingFailureException; diff --git a/spring-tx/src/test/java/org/springframework/dao/support/DataAccessUtilsTests.java b/spring-tx/src/test/java/org/springframework/dao/support/DataAccessUtilsTests.java index d523469291b..8bf3d80876c 100644 --- a/spring-tx/src/test/java/org/springframework/dao/support/DataAccessUtilsTests.java +++ b/spring-tx/src/test/java/org/springframework/dao/support/DataAccessUtilsTests.java @@ -24,7 +24,7 @@ import java.util.HashSet; import java.util.Map; import java.util.function.Consumer; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.dao.DataAccessException; import org.springframework.dao.IncorrectResultSizeDataAccessException; diff --git a/spring-tx/src/test/java/org/springframework/jca/cci/CciLocalTransactionTests.java b/spring-tx/src/test/java/org/springframework/jca/cci/CciLocalTransactionTests.java index 471e0cb8eb5..0c027d11c8e 100644 --- a/spring-tx/src/test/java/org/springframework/jca/cci/CciLocalTransactionTests.java +++ b/spring-tx/src/test/java/org/springframework/jca/cci/CciLocalTransactionTests.java @@ -24,7 +24,7 @@ import javax.resource.cci.InteractionSpec; import javax.resource.cci.LocalTransaction; import javax.resource.cci.Record; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.dao.DataRetrievalFailureException; import org.springframework.jca.cci.connection.CciLocalTransactionManager; diff --git a/spring-tx/src/test/java/org/springframework/jca/cci/CciTemplateTests.java b/spring-tx/src/test/java/org/springframework/jca/cci/CciTemplateTests.java index f2945ebd96a..703adc129da 100644 --- a/spring-tx/src/test/java/org/springframework/jca/cci/CciTemplateTests.java +++ b/spring-tx/src/test/java/org/springframework/jca/cci/CciTemplateTests.java @@ -30,7 +30,7 @@ import javax.resource.cci.Record; import javax.resource.cci.RecordFactory; import javax.resource.cci.ResultSet; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.jca.cci.connection.ConnectionSpecConnectionFactoryAdapter; import org.springframework.jca.cci.connection.NotSupportedRecordFactory; diff --git a/spring-tx/src/test/java/org/springframework/jca/cci/EisOperationTests.java b/spring-tx/src/test/java/org/springframework/jca/cci/EisOperationTests.java index 9446a240ec6..4775f45bad7 100644 --- a/spring-tx/src/test/java/org/springframework/jca/cci/EisOperationTests.java +++ b/spring-tx/src/test/java/org/springframework/jca/cci/EisOperationTests.java @@ -24,7 +24,7 @@ import javax.resource.cci.InteractionSpec; import javax.resource.cci.Record; import javax.resource.cci.RecordFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.jca.cci.core.RecordCreator; import org.springframework.jca.cci.object.MappingRecordOperation; diff --git a/spring-tx/src/test/java/org/springframework/jca/support/LocalConnectionFactoryBeanTests.java b/spring-tx/src/test/java/org/springframework/jca/support/LocalConnectionFactoryBeanTests.java index a44f7303562..37511b7dfaa 100644 --- a/spring-tx/src/test/java/org/springframework/jca/support/LocalConnectionFactoryBeanTests.java +++ b/spring-tx/src/test/java/org/springframework/jca/support/LocalConnectionFactoryBeanTests.java @@ -19,7 +19,7 @@ package org.springframework.jca.support; import javax.resource.spi.ConnectionManager; import javax.resource.spi.ManagedConnectionFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-tx/src/test/java/org/springframework/transaction/JndiJtaTransactionManagerTests.java b/spring-tx/src/test/java/org/springframework/transaction/JndiJtaTransactionManagerTests.java index e6398450402..4d83607cbcf 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/JndiJtaTransactionManagerTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/JndiJtaTransactionManagerTests.java @@ -20,8 +20,8 @@ import javax.transaction.Status; import javax.transaction.TransactionManager; import javax.transaction.UserTransaction; -import org.junit.After; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; import org.springframework.tests.mock.jndi.ExpectedLookupTemplate; import org.springframework.transaction.jta.JtaTransactionManager; @@ -218,7 +218,7 @@ public class JndiJtaTransactionManagerTests { * Prevent any side-effects due to this test modifying ThreadLocals that might * affect subsequent tests when all tests are run in the same JVM, as with Eclipse. */ - @After + @AfterEach public void tearDown() { assertThat(TransactionSynchronizationManager.getResourceMap().isEmpty()).isTrue(); assertThat(TransactionSynchronizationManager.isSynchronizationActive()).isFalse(); diff --git a/spring-tx/src/test/java/org/springframework/transaction/JtaTransactionManagerTests.java b/spring-tx/src/test/java/org/springframework/transaction/JtaTransactionManagerTests.java index 0d926773133..2bb3a64b199 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/JtaTransactionManagerTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/JtaTransactionManagerTests.java @@ -26,8 +26,8 @@ import javax.transaction.Transaction; import javax.transaction.TransactionManager; import javax.transaction.UserTransaction; -import org.junit.After; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; import org.springframework.dao.OptimisticLockingFailureException; import org.springframework.tests.transaction.MockJtaTransaction; @@ -1190,7 +1190,7 @@ public class JtaTransactionManagerTests { * Prevent any side-effects due to this test modifying ThreadLocals that might * affect subsequent tests when all tests are run in the same JVM, as with Eclipse. */ - @After + @AfterEach public void tearDown() { assertThat(TransactionSynchronizationManager.getResourceMap().isEmpty()).isTrue(); assertThat(TransactionSynchronizationManager.isSynchronizationActive()).isFalse(); diff --git a/spring-tx/src/test/java/org/springframework/transaction/TransactionSupportTests.java b/spring-tx/src/test/java/org/springframework/transaction/TransactionSupportTests.java index bad883eebf9..5d2087367ad 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/TransactionSupportTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/TransactionSupportTests.java @@ -16,8 +16,8 @@ package org.springframework.transaction; -import org.junit.After; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; import org.springframework.transaction.support.DefaultTransactionDefinition; import org.springframework.transaction.support.DefaultTransactionStatus; @@ -283,7 +283,7 @@ public class TransactionSupportTests { } - @After + @AfterEach public void clear() { assertThat(TransactionSynchronizationManager.getResourceMap().isEmpty()).isTrue(); assertThat(TransactionSynchronizationManager.isSynchronizationActive()).isFalse(); diff --git a/spring-tx/src/test/java/org/springframework/transaction/TxNamespaceHandlerEventTests.java b/spring-tx/src/test/java/org/springframework/transaction/TxNamespaceHandlerEventTests.java index f68cc8e9193..84eefc1d4b2 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/TxNamespaceHandlerEventTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/TxNamespaceHandlerEventTests.java @@ -16,8 +16,8 @@ package org.springframework.transaction; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.parsing.BeanComponentDefinition; import org.springframework.beans.factory.parsing.ComponentDefinition; @@ -40,7 +40,7 @@ public class TxNamespaceHandlerEventTests { private CollectingReaderEventListener eventListener = new CollectingReaderEventListener(); - @Before + @BeforeEach public void setUp() throws Exception { XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(this.beanFactory); reader.setEventListener(this.eventListener); diff --git a/spring-tx/src/test/java/org/springframework/transaction/TxNamespaceHandlerTests.java b/spring-tx/src/test/java/org/springframework/transaction/TxNamespaceHandlerTests.java index ca2c1dfcdb9..ac6b14e3b43 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/TxNamespaceHandlerTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/TxNamespaceHandlerTests.java @@ -18,8 +18,8 @@ package org.springframework.transaction; import java.lang.reflect.Method; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.aop.support.AopUtils; import org.springframework.context.ApplicationContext; @@ -46,7 +46,7 @@ public class TxNamespaceHandlerTests { private Method setAgeMethod; - @Before + @BeforeEach public void setup() throws Exception { this.context = new ClassPathXmlApplicationContext("txNamespaceHandlerTests.xml", getClass()); this.getAgeMethod = ITestBean.class.getMethod("getAge"); diff --git a/spring-tx/src/test/java/org/springframework/transaction/annotation/AnnotationTransactionAttributeSourceTests.java b/spring-tx/src/test/java/org/springframework/transaction/annotation/AnnotationTransactionAttributeSourceTests.java index db11d054398..653766cbd27 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/annotation/AnnotationTransactionAttributeSourceTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/annotation/AnnotationTransactionAttributeSourceTests.java @@ -25,7 +25,7 @@ import javax.ejb.TransactionAttributeType; import groovy.lang.GroovyObject; import groovy.lang.MetaClass; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.framework.Advised; import org.springframework.aop.framework.ProxyFactory; diff --git a/spring-tx/src/test/java/org/springframework/transaction/annotation/AnnotationTransactionInterceptorTests.java b/spring-tx/src/test/java/org/springframework/transaction/annotation/AnnotationTransactionInterceptorTests.java index 8c1f45a7fd0..561c41d6e76 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/annotation/AnnotationTransactionInterceptorTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/annotation/AnnotationTransactionInterceptorTests.java @@ -17,7 +17,7 @@ package org.springframework.transaction.annotation; import io.vavr.control.Try; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.framework.ProxyFactory; import org.springframework.tests.transaction.CallCountingTransactionManager; diff --git a/spring-tx/src/test/java/org/springframework/transaction/annotation/AnnotationTransactionNamespaceHandlerTests.java b/spring-tx/src/test/java/org/springframework/transaction/annotation/AnnotationTransactionNamespaceHandlerTests.java index d7e52a2dfb2..035f2925d4b 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/annotation/AnnotationTransactionNamespaceHandlerTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/annotation/AnnotationTransactionNamespaceHandlerTests.java @@ -22,8 +22,8 @@ import java.util.Map; import javax.management.MBeanServer; import javax.management.ObjectName; -import org.junit.After; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; import org.springframework.aop.support.AopUtils; import org.springframework.context.ConfigurableApplicationContext; @@ -48,7 +48,7 @@ public class AnnotationTransactionNamespaceHandlerTests { private final ConfigurableApplicationContext context = new ClassPathXmlApplicationContext( "org/springframework/transaction/annotation/annotationTransactionNamespaceHandlerTests.xml"); - @After + @AfterEach public void tearDown() { this.context.close(); } diff --git a/spring-tx/src/test/java/org/springframework/transaction/annotation/EnableTransactionManagementTests.java b/spring-tx/src/test/java/org/springframework/transaction/annotation/EnableTransactionManagementTests.java index ed0f58aea91..be89cce0bff 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/annotation/EnableTransactionManagementTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/annotation/EnableTransactionManagementTests.java @@ -19,7 +19,7 @@ package org.springframework.transaction.annotation; import java.util.Collection; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.support.AopUtils; import org.springframework.beans.factory.annotation.Autowired; diff --git a/spring-tx/src/test/java/org/springframework/transaction/config/AnnotationDrivenTests.java b/spring-tx/src/test/java/org/springframework/transaction/config/AnnotationDrivenTests.java index 8f58b2656f8..e172b7d7e8d 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/config/AnnotationDrivenTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/config/AnnotationDrivenTests.java @@ -20,7 +20,7 @@ import java.io.Serializable; import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInvocation; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.support.AopUtils; import org.springframework.beans.factory.support.RootBeanDefinition; diff --git a/spring-tx/src/test/java/org/springframework/transaction/event/ApplicationListenerMethodTransactionalAdapterTests.java b/spring-tx/src/test/java/org/springframework/transaction/event/ApplicationListenerMethodTransactionalAdapterTests.java index 7d020043c3e..234f52d518d 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/event/ApplicationListenerMethodTransactionalAdapterTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/event/ApplicationListenerMethodTransactionalAdapterTests.java @@ -18,7 +18,7 @@ package org.springframework.transaction.event; import java.lang.reflect.Method; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.PayloadApplicationEvent; import org.springframework.context.event.ApplicationListenerMethodAdapter; diff --git a/spring-tx/src/test/java/org/springframework/transaction/event/TransactionalEventListenerTests.java b/spring-tx/src/test/java/org/springframework/transaction/event/TransactionalEventListenerTests.java index 80cc0318637..edb5a8494f4 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/event/TransactionalEventListenerTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/event/TransactionalEventListenerTests.java @@ -26,8 +26,8 @@ import java.util.Collections; import java.util.List; import java.util.Map; -import org.junit.After; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationEventPublisher; @@ -71,7 +71,7 @@ public class TransactionalEventListenerTests { private TransactionTemplate transactionTemplate; - @After + @AfterEach public void closeContext() { if (this.context != null) { this.context.close(); diff --git a/spring-tx/src/test/java/org/springframework/transaction/interceptor/AbstractReactiveTransactionAspectTests.java b/spring-tx/src/test/java/org/springframework/transaction/interceptor/AbstractReactiveTransactionAspectTests.java index 3ffde417f65..9e8ea48ff6d 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/interceptor/AbstractReactiveTransactionAspectTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/interceptor/AbstractReactiveTransactionAspectTests.java @@ -18,8 +18,8 @@ package org.springframework.transaction.interceptor; import java.lang.reflect.Method; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.reactivestreams.Publisher; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; @@ -54,7 +54,7 @@ public abstract class AbstractReactiveTransactionAspectTests { protected Method exceptionalMethod; - @Before + @BeforeEach public void setup() throws Exception { getNameMethod = TestBean.class.getMethod("getName"); setNameMethod = TestBean.class.getMethod("setName", String.class); diff --git a/spring-tx/src/test/java/org/springframework/transaction/interceptor/AbstractTransactionAspectTests.java b/spring-tx/src/test/java/org/springframework/transaction/interceptor/AbstractTransactionAspectTests.java index aa180bb4de8..7ecc3e59851 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/interceptor/AbstractTransactionAspectTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/interceptor/AbstractTransactionAspectTests.java @@ -18,8 +18,8 @@ package org.springframework.transaction.interceptor; import java.lang.reflect.Method; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.dao.OptimisticLockingFailureException; import org.springframework.tests.sample.beans.ITestBean; @@ -65,7 +65,7 @@ public abstract class AbstractTransactionAspectTests { protected Method exceptionalMethod; - @Before + @BeforeEach public void setup() throws Exception { getNameMethod = ITestBean.class.getMethod("getName"); setNameMethod = ITestBean.class.getMethod("setName", String.class); diff --git a/spring-tx/src/test/java/org/springframework/transaction/interceptor/BeanFactoryTransactionTests.java b/spring-tx/src/test/java/org/springframework/transaction/interceptor/BeanFactoryTransactionTests.java index b9590307c08..6d5c9b0f8f0 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/interceptor/BeanFactoryTransactionTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/interceptor/BeanFactoryTransactionTests.java @@ -22,8 +22,8 @@ import java.util.Map; import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInvocation; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.aop.support.AopUtils; import org.springframework.aop.support.StaticMethodMatcherPointcut; @@ -59,7 +59,7 @@ public class BeanFactoryTransactionTests { private DefaultListableBeanFactory factory; - @Before + @BeforeEach public void setUp() { this.factory = new DefaultListableBeanFactory(); new XmlBeanDefinitionReader(this.factory).loadBeanDefinitions( diff --git a/spring-tx/src/test/java/org/springframework/transaction/interceptor/RollbackRuleTests.java b/spring-tx/src/test/java/org/springframework/transaction/interceptor/RollbackRuleTests.java index f7d8235a9fc..9d05c6d0e03 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/interceptor/RollbackRuleTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/interceptor/RollbackRuleTests.java @@ -18,7 +18,7 @@ package org.springframework.transaction.interceptor; import java.io.IOException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.FatalBeanException; diff --git a/spring-tx/src/test/java/org/springframework/transaction/interceptor/RuleBasedTransactionAttributeTests.java b/spring-tx/src/test/java/org/springframework/transaction/interceptor/RuleBasedTransactionAttributeTests.java index 19bccddda3a..24fee1a2b3f 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/interceptor/RuleBasedTransactionAttributeTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/interceptor/RuleBasedTransactionAttributeTests.java @@ -22,7 +22,7 @@ import java.util.Collections; import java.util.LinkedList; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.transaction.TransactionDefinition; diff --git a/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeEditorTests.java b/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeEditorTests.java index dd533f1b9ee..4614f2648a3 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeEditorTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeEditorTests.java @@ -19,7 +19,7 @@ package org.springframework.transaction.interceptor; import java.io.IOException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.transaction.TransactionDefinition; diff --git a/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeSourceAdvisorTests.java b/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeSourceAdvisorTests.java index 0314dea89c6..213a591cf22 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeSourceAdvisorTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeSourceAdvisorTests.java @@ -18,7 +18,7 @@ package org.springframework.transaction.interceptor; import java.util.Properties; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.util.SerializationTestUtils; diff --git a/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeSourceEditorTests.java b/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeSourceEditorTests.java index 64db541ce67..cd7d824e6d4 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeSourceEditorTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeSourceEditorTests.java @@ -18,7 +18,7 @@ package org.springframework.transaction.interceptor; import java.lang.reflect.Method; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.transaction.TransactionDefinition; diff --git a/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeSourceTests.java b/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeSourceTests.java index 50eda6547c5..d61dfda71be 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeSourceTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionAttributeSourceTests.java @@ -19,7 +19,7 @@ package org.springframework.transaction.interceptor; import java.io.IOException; import java.util.Properties; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.transaction.TransactionDefinition; diff --git a/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionInterceptorTests.java b/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionInterceptorTests.java index 84944c296c3..082bc473427 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionInterceptorTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/interceptor/TransactionInterceptorTests.java @@ -19,7 +19,7 @@ package org.springframework.transaction.interceptor; import java.io.Serializable; import java.util.Properties; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.framework.ProxyFactory; import org.springframework.beans.factory.BeanFactory; diff --git a/spring-tx/src/test/java/org/springframework/transaction/jta/WebSphereUowTransactionManagerTests.java b/spring-tx/src/test/java/org/springframework/transaction/jta/WebSphereUowTransactionManagerTests.java index 27a698a7af9..54d263b1829 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/jta/WebSphereUowTransactionManagerTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/jta/WebSphereUowTransactionManagerTests.java @@ -23,7 +23,7 @@ import javax.transaction.UserTransaction; import com.ibm.wsspi.uow.UOWAction; import com.ibm.wsspi.uow.UOWException; import com.ibm.wsspi.uow.UOWManager; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.dao.OptimisticLockingFailureException; import org.springframework.tests.mock.jndi.ExpectedLookupTemplate; diff --git a/spring-tx/src/test/java/org/springframework/transaction/reactive/ReactiveTransactionSupportTests.java b/spring-tx/src/test/java/org/springframework/transaction/reactive/ReactiveTransactionSupportTests.java index e99d958a70a..b67f5bf8a4a 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/reactive/ReactiveTransactionSupportTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/reactive/ReactiveTransactionSupportTests.java @@ -16,7 +16,7 @@ package org.springframework.transaction.reactive; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; diff --git a/spring-tx/src/test/java/org/springframework/transaction/reactive/TransactionalOperatorTests.java b/spring-tx/src/test/java/org/springframework/transaction/reactive/TransactionalOperatorTests.java index f4eea955c4f..12de331a8b2 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/reactive/TransactionalOperatorTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/reactive/TransactionalOperatorTests.java @@ -16,7 +16,7 @@ package org.springframework.transaction.reactive; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; diff --git a/spring-tx/src/test/java/org/springframework/transaction/support/JtaTransactionManagerSerializationTests.java b/spring-tx/src/test/java/org/springframework/transaction/support/JtaTransactionManagerSerializationTests.java index d2030317dc5..978dc018d54 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/support/JtaTransactionManagerSerializationTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/support/JtaTransactionManagerSerializationTests.java @@ -19,7 +19,7 @@ package org.springframework.transaction.support; import javax.transaction.TransactionManager; import javax.transaction.UserTransaction; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.tests.mock.jndi.SimpleNamingContextBuilder; import org.springframework.transaction.jta.JtaTransactionManager; diff --git a/spring-tx/src/test/java/org/springframework/transaction/support/SimpleTransactionScopeTests.java b/spring-tx/src/test/java/org/springframework/transaction/support/SimpleTransactionScopeTests.java index 460030b0870..bab321b2454 100644 --- a/spring-tx/src/test/java/org/springframework/transaction/support/SimpleTransactionScopeTests.java +++ b/spring-tx/src/test/java/org/springframework/transaction/support/SimpleTransactionScopeTests.java @@ -19,7 +19,7 @@ package org.springframework.transaction.support; import java.util.HashSet; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.support.GenericBeanDefinition; diff --git a/spring-web/src/test/java/org/springframework/http/CacheControlTests.java b/spring-web/src/test/java/org/springframework/http/CacheControlTests.java index 5490ff54604..6da839902b2 100644 --- a/spring-web/src/test/java/org/springframework/http/CacheControlTests.java +++ b/spring-web/src/test/java/org/springframework/http/CacheControlTests.java @@ -19,7 +19,7 @@ package org.springframework.http; import java.time.Duration; import java.util.concurrent.TimeUnit; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/http/ContentDispositionTests.java b/spring-web/src/test/java/org/springframework/http/ContentDispositionTests.java index 4654aeb1189..13acce90a02 100644 --- a/spring-web/src/test/java/org/springframework/http/ContentDispositionTests.java +++ b/spring-web/src/test/java/org/springframework/http/ContentDispositionTests.java @@ -22,7 +22,7 @@ import java.nio.charset.StandardCharsets; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.util.ReflectionUtils; diff --git a/spring-web/src/test/java/org/springframework/http/HttpEntityTests.java b/spring-web/src/test/java/org/springframework/http/HttpEntityTests.java index 98497a25ded..7b97e86afd7 100644 --- a/spring-web/src/test/java/org/springframework/http/HttpEntityTests.java +++ b/spring-web/src/test/java/org/springframework/http/HttpEntityTests.java @@ -18,7 +18,7 @@ package org.springframework.http; import java.net.URI; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; diff --git a/spring-web/src/test/java/org/springframework/http/HttpHeadersTests.java b/spring-web/src/test/java/org/springframework/http/HttpHeadersTests.java index 27a6c1e2f46..15367f54ae7 100644 --- a/spring-web/src/test/java/org/springframework/http/HttpHeadersTests.java +++ b/spring-web/src/test/java/org/springframework/http/HttpHeadersTests.java @@ -34,7 +34,7 @@ import java.util.List; import java.util.Locale; import java.util.TimeZone; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-web/src/test/java/org/springframework/http/HttpRangeTests.java b/spring-web/src/test/java/org/springframework/http/HttpRangeTests.java index fe1d461b0aa..0c5b701c6ac 100644 --- a/spring-web/src/test/java/org/springframework/http/HttpRangeTests.java +++ b/spring-web/src/test/java/org/springframework/http/HttpRangeTests.java @@ -21,7 +21,7 @@ import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.io.ByteArrayResource; import org.springframework.core.io.InputStreamResource; diff --git a/spring-web/src/test/java/org/springframework/http/HttpStatusTests.java b/spring-web/src/test/java/org/springframework/http/HttpStatusTests.java index ca7b3b69ed4..311b01c9b46 100644 --- a/spring-web/src/test/java/org/springframework/http/HttpStatusTests.java +++ b/spring-web/src/test/java/org/springframework/http/HttpStatusTests.java @@ -19,8 +19,8 @@ package org.springframework.http; import java.util.LinkedHashMap; import java.util.Map; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; @@ -32,7 +32,7 @@ public class HttpStatusTests { private Map statusCodes = new LinkedHashMap<>(); - @Before + @BeforeEach public void createStatusCodes() { statusCodes.put(100, "CONTINUE"); statusCodes.put(101, "SWITCHING_PROTOCOLS"); diff --git a/spring-web/src/test/java/org/springframework/http/MediaTypeFactoryTests.java b/spring-web/src/test/java/org/springframework/http/MediaTypeFactoryTests.java index 251995d9a86..58dcb5d1657 100644 --- a/spring-web/src/test/java/org/springframework/http/MediaTypeFactoryTests.java +++ b/spring-web/src/test/java/org/springframework/http/MediaTypeFactoryTests.java @@ -16,7 +16,7 @@ package org.springframework.http; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.io.Resource; diff --git a/spring-web/src/test/java/org/springframework/http/MediaTypeTests.java b/spring-web/src/test/java/org/springframework/http/MediaTypeTests.java index 83885f6124a..8849ff7ba42 100644 --- a/spring-web/src/test/java/org/springframework/http/MediaTypeTests.java +++ b/spring-web/src/test/java/org/springframework/http/MediaTypeTests.java @@ -22,7 +22,7 @@ import java.util.Comparator; import java.util.List; import java.util.Random; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.convert.ConversionService; import org.springframework.core.convert.support.DefaultConversionService; diff --git a/spring-web/src/test/java/org/springframework/http/RequestEntityTests.java b/spring-web/src/test/java/org/springframework/http/RequestEntityTests.java index cc058dab6f9..9b2996d4644 100644 --- a/spring-web/src/test/java/org/springframework/http/RequestEntityTests.java +++ b/spring-web/src/test/java/org/springframework/http/RequestEntityTests.java @@ -24,7 +24,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.ParameterizedTypeReference; import org.springframework.web.util.UriTemplate; diff --git a/spring-web/src/test/java/org/springframework/http/ResponseCookieTests.java b/spring-web/src/test/java/org/springframework/http/ResponseCookieTests.java index 1eaf88bfc8a..083bc68fac0 100644 --- a/spring-web/src/test/java/org/springframework/http/ResponseCookieTests.java +++ b/spring-web/src/test/java/org/springframework/http/ResponseCookieTests.java @@ -18,7 +18,7 @@ package org.springframework.http; import java.time.Duration; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/http/ResponseEntityTests.java b/spring-web/src/test/java/org/springframework/http/ResponseEntityTests.java index fbf36362fa0..c75841ab8a4 100644 --- a/spring-web/src/test/java/org/springframework/http/ResponseEntityTests.java +++ b/spring-web/src/test/java/org/springframework/http/ResponseEntityTests.java @@ -22,7 +22,7 @@ import java.util.List; import java.util.Optional; import java.util.concurrent.TimeUnit; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/http/client/AbstractAsyncHttpRequestFactoryTestCase.java b/spring-web/src/test/java/org/springframework/http/client/AbstractAsyncHttpRequestFactoryTests.java similarity index 97% rename from spring-web/src/test/java/org/springframework/http/client/AbstractAsyncHttpRequestFactoryTestCase.java rename to spring-web/src/test/java/org/springframework/http/client/AbstractAsyncHttpRequestFactoryTests.java index 4039ccbda61..980fe77c0bf 100644 --- a/spring-web/src/test/java/org/springframework/http/client/AbstractAsyncHttpRequestFactoryTestCase.java +++ b/spring-web/src/test/java/org/springframework/http/client/AbstractAsyncHttpRequestFactoryTests.java @@ -22,9 +22,9 @@ import java.util.Arrays; import java.util.Locale; import java.util.concurrent.Future; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.InitializingBean; @@ -41,12 +41,12 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; @SuppressWarnings("deprecation") -public abstract class AbstractAsyncHttpRequestFactoryTestCase extends AbstractMockWebServerTestCase { +public abstract class AbstractAsyncHttpRequestFactoryTests extends AbstractMockWebServerTests { protected AsyncClientHttpRequestFactory factory; - @Before + @BeforeEach public final void createFactory() throws Exception { this.factory = createRequestFactory(); if (this.factory instanceof InitializingBean) { @@ -54,7 +54,7 @@ public abstract class AbstractAsyncHttpRequestFactoryTestCase extends AbstractMo } } - @After + @AfterEach public final void destroyFactory() throws Exception { if (this.factory instanceof DisposableBean) { ((DisposableBean) this.factory).destroy(); diff --git a/spring-web/src/test/java/org/springframework/http/client/AbstractHttpRequestFactoryTestCase.java b/spring-web/src/test/java/org/springframework/http/client/AbstractHttpRequestFactoryTests.java similarity index 96% rename from spring-web/src/test/java/org/springframework/http/client/AbstractHttpRequestFactoryTestCase.java rename to spring-web/src/test/java/org/springframework/http/client/AbstractHttpRequestFactoryTests.java index 21a5931d557..7538e2e6eb2 100644 --- a/spring-web/src/test/java/org/springframework/http/client/AbstractHttpRequestFactoryTestCase.java +++ b/spring-web/src/test/java/org/springframework/http/client/AbstractHttpRequestFactoryTests.java @@ -21,9 +21,9 @@ import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.Locale; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.InitializingBean; @@ -40,12 +40,12 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException; /** * @author Arjen Poutsma */ -public abstract class AbstractHttpRequestFactoryTestCase extends AbstractMockWebServerTestCase { +public abstract class AbstractHttpRequestFactoryTests extends AbstractMockWebServerTests { protected ClientHttpRequestFactory factory; - @Before + @BeforeEach public final void createFactory() throws Exception { factory = createRequestFactory(); if (factory instanceof InitializingBean) { @@ -53,7 +53,7 @@ public abstract class AbstractHttpRequestFactoryTestCase extends AbstractMockWeb } } - @After + @AfterEach public final void destroyFactory() throws Exception { if (factory instanceof DisposableBean) { ((DisposableBean) factory).destroy(); diff --git a/spring-web/src/test/java/org/springframework/http/client/AbstractMockWebServerTestCase.java b/spring-web/src/test/java/org/springframework/http/client/AbstractMockWebServerTests.java similarity index 95% rename from spring-web/src/test/java/org/springframework/http/client/AbstractMockWebServerTestCase.java rename to spring-web/src/test/java/org/springframework/http/client/AbstractMockWebServerTests.java index 0139b734f81..cbef27287d4 100644 --- a/spring-web/src/test/java/org/springframework/http/client/AbstractMockWebServerTestCase.java +++ b/spring-web/src/test/java/org/springframework/http/client/AbstractMockWebServerTests.java @@ -22,19 +22,18 @@ import okhttp3.mockwebserver.Dispatcher; import okhttp3.mockwebserver.MockResponse; import okhttp3.mockwebserver.MockWebServer; import okhttp3.mockwebserver.RecordedRequest; -import org.junit.After; -import org.junit.Before; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; import org.springframework.http.MediaType; import org.springframework.util.StringUtils; import static org.assertj.core.api.Assertions.assertThat; - /** * @author Brian Clozel */ -public class AbstractMockWebServerTestCase { +public abstract class AbstractMockWebServerTests { private MockWebServer server; @@ -45,7 +44,7 @@ public class AbstractMockWebServerTestCase { protected static final MediaType textContentType = new MediaType("text", "plain", Collections.singletonMap("charset", "UTF-8")); - @Before + @BeforeEach public void setUp() throws Exception { this.server = new MockWebServer(); this.server.setDispatcher(new TestDispatcher()); @@ -54,7 +53,7 @@ public class AbstractMockWebServerTestCase { this.baseUrl = "http://localhost:" + this.port; } - @After + @AfterEach public void tearDown() throws Exception { this.server.shutdown(); } diff --git a/spring-web/src/test/java/org/springframework/http/client/BufferedSimpleAsyncHttpRequestFactoryTests.java b/spring-web/src/test/java/org/springframework/http/client/BufferedSimpleAsyncHttpRequestFactoryTests.java index d0de70b83cb..f019ddd797b 100644 --- a/spring-web/src/test/java/org/springframework/http/client/BufferedSimpleAsyncHttpRequestFactoryTests.java +++ b/spring-web/src/test/java/org/springframework/http/client/BufferedSimpleAsyncHttpRequestFactoryTests.java @@ -18,13 +18,13 @@ package org.springframework.http.client; import java.net.ProtocolException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.task.AsyncListenableTaskExecutor; import org.springframework.core.task.SimpleAsyncTaskExecutor; import org.springframework.http.HttpMethod; -public class BufferedSimpleAsyncHttpRequestFactoryTests extends AbstractAsyncHttpRequestFactoryTestCase { +public class BufferedSimpleAsyncHttpRequestFactoryTests extends AbstractAsyncHttpRequestFactoryTests { @SuppressWarnings("deprecation") @Override diff --git a/spring-web/src/test/java/org/springframework/http/client/BufferedSimpleHttpRequestFactoryTests.java b/spring-web/src/test/java/org/springframework/http/client/BufferedSimpleHttpRequestFactoryTests.java index 97dd5f73684..dbea824c20c 100644 --- a/spring-web/src/test/java/org/springframework/http/client/BufferedSimpleHttpRequestFactoryTests.java +++ b/spring-web/src/test/java/org/springframework/http/client/BufferedSimpleHttpRequestFactoryTests.java @@ -23,13 +23,13 @@ import java.net.HttpURLConnection; import java.net.ProtocolException; import java.net.URL; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpMethod; import static org.assertj.core.api.Assertions.assertThat; -public class BufferedSimpleHttpRequestFactoryTests extends AbstractHttpRequestFactoryTestCase { +public class BufferedSimpleHttpRequestFactoryTests extends AbstractHttpRequestFactoryTests { @Override protected ClientHttpRequestFactory createRequestFactory() { diff --git a/spring-web/src/test/java/org/springframework/http/client/BufferingClientHttpRequestFactoryTests.java b/spring-web/src/test/java/org/springframework/http/client/BufferingClientHttpRequestFactoryTests.java index 309283a1c97..b3c272324b4 100644 --- a/spring-web/src/test/java/org/springframework/http/client/BufferingClientHttpRequestFactoryTests.java +++ b/spring-web/src/test/java/org/springframework/http/client/BufferingClientHttpRequestFactoryTests.java @@ -19,7 +19,7 @@ package org.springframework.http.client; import java.net.URI; import java.util.Arrays; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; @@ -27,7 +27,7 @@ import org.springframework.util.FileCopyUtils; import static org.assertj.core.api.Assertions.assertThat; -public class BufferingClientHttpRequestFactoryTests extends AbstractHttpRequestFactoryTestCase { +public class BufferingClientHttpRequestFactoryTests extends AbstractHttpRequestFactoryTests { @Override protected ClientHttpRequestFactory createRequestFactory() { diff --git a/spring-web/src/test/java/org/springframework/http/client/HttpComponentsAsyncClientHttpRequestFactoryTests.java b/spring-web/src/test/java/org/springframework/http/client/HttpComponentsAsyncClientHttpRequestFactoryTests.java index fddded68fbb..7ae09ce8696 100644 --- a/spring-web/src/test/java/org/springframework/http/client/HttpComponentsAsyncClientHttpRequestFactoryTests.java +++ b/spring-web/src/test/java/org/springframework/http/client/HttpComponentsAsyncClientHttpRequestFactoryTests.java @@ -22,7 +22,7 @@ import org.apache.http.client.config.RequestConfig; import org.apache.http.client.protocol.HttpClientContext; import org.apache.http.impl.nio.client.CloseableHttpAsyncClient; import org.apache.http.impl.nio.client.HttpAsyncClientBuilder; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpMethod; @@ -33,7 +33,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Stephane Nicoll */ @SuppressWarnings("deprecation") -public class HttpComponentsAsyncClientHttpRequestFactoryTests extends AbstractAsyncHttpRequestFactoryTestCase { +public class HttpComponentsAsyncClientHttpRequestFactoryTests extends AbstractAsyncHttpRequestFactoryTests { @Override protected AsyncClientHttpRequestFactory createRequestFactory() { diff --git a/spring-web/src/test/java/org/springframework/http/client/HttpComponentsClientHttpRequestFactoryTests.java b/spring-web/src/test/java/org/springframework/http/client/HttpComponentsClientHttpRequestFactoryTests.java index 458d8b30f7e..d2cd49cda77 100644 --- a/spring-web/src/test/java/org/springframework/http/client/HttpComponentsClientHttpRequestFactoryTests.java +++ b/spring-web/src/test/java/org/springframework/http/client/HttpComponentsClientHttpRequestFactoryTests.java @@ -26,7 +26,7 @@ import org.apache.http.client.methods.HttpUriRequest; import org.apache.http.client.protocol.HttpClientContext; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpMethod; @@ -38,7 +38,7 @@ import static org.mockito.Mockito.withSettings; /** * @author Stephane Nicoll */ -public class HttpComponentsClientHttpRequestFactoryTests extends AbstractHttpRequestFactoryTestCase { +public class HttpComponentsClientHttpRequestFactoryTests extends AbstractHttpRequestFactoryTests { @Override protected ClientHttpRequestFactory createRequestFactory() { diff --git a/spring-web/src/test/java/org/springframework/http/client/InterceptingClientHttpRequestFactoryTests.java b/spring-web/src/test/java/org/springframework/http/client/InterceptingClientHttpRequestFactoryTests.java index 5fee92cb947..82a3e79cb4c 100644 --- a/spring-web/src/test/java/org/springframework/http/client/InterceptingClientHttpRequestFactoryTests.java +++ b/spring-web/src/test/java/org/springframework/http/client/InterceptingClientHttpRequestFactoryTests.java @@ -26,7 +26,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; diff --git a/spring-web/src/test/java/org/springframework/http/client/InterceptingStreamingHttpComponentsTests.java b/spring-web/src/test/java/org/springframework/http/client/InterceptingStreamingHttpComponentsTests.java index beb407f679c..18b0cdf649b 100644 --- a/spring-web/src/test/java/org/springframework/http/client/InterceptingStreamingHttpComponentsTests.java +++ b/spring-web/src/test/java/org/springframework/http/client/InterceptingStreamingHttpComponentsTests.java @@ -16,14 +16,14 @@ package org.springframework.http.client; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpMethod; /** * @author Juergen Hoeller */ -public class InterceptingStreamingHttpComponentsTests extends AbstractHttpRequestFactoryTestCase { +public class InterceptingStreamingHttpComponentsTests extends AbstractHttpRequestFactoryTests { @Override protected ClientHttpRequestFactory createRequestFactory() { diff --git a/spring-web/src/test/java/org/springframework/http/client/MultipartBodyBuilderTests.java b/spring-web/src/test/java/org/springframework/http/client/MultipartBodyBuilderTests.java index 25ce6f4d5a3..cadff157596 100644 --- a/spring-web/src/test/java/org/springframework/http/client/MultipartBodyBuilderTests.java +++ b/spring-web/src/test/java/org/springframework/http/client/MultipartBodyBuilderTests.java @@ -16,7 +16,7 @@ package org.springframework.http.client; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.reactivestreams.Publisher; import reactor.core.publisher.Flux; diff --git a/spring-web/src/test/java/org/springframework/http/client/Netty4AsyncClientHttpRequestFactoryTests.java b/spring-web/src/test/java/org/springframework/http/client/Netty4AsyncClientHttpRequestFactoryTests.java index c6ce0b41eac..87ed2ae399a 100644 --- a/spring-web/src/test/java/org/springframework/http/client/Netty4AsyncClientHttpRequestFactoryTests.java +++ b/spring-web/src/test/java/org/springframework/http/client/Netty4AsyncClientHttpRequestFactoryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * 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. @@ -18,26 +18,26 @@ package org.springframework.http.client; import io.netty.channel.EventLoopGroup; import io.netty.channel.nio.NioEventLoopGroup; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpMethod; /** * @author Arjen Poutsma */ -public class Netty4AsyncClientHttpRequestFactoryTests extends AbstractAsyncHttpRequestFactoryTestCase { +public class Netty4AsyncClientHttpRequestFactoryTests extends AbstractAsyncHttpRequestFactoryTests { private static EventLoopGroup eventLoopGroup; - @BeforeClass + @BeforeAll public static void createEventLoopGroup() { eventLoopGroup = new NioEventLoopGroup(); } - @AfterClass + @AfterAll public static void shutdownEventLoopGroup() throws InterruptedException { eventLoopGroup.shutdownGracefully().sync(); } diff --git a/spring-web/src/test/java/org/springframework/http/client/Netty4ClientHttpRequestFactoryTests.java b/spring-web/src/test/java/org/springframework/http/client/Netty4ClientHttpRequestFactoryTests.java index f7035e8798a..bfc087f8480 100644 --- a/spring-web/src/test/java/org/springframework/http/client/Netty4ClientHttpRequestFactoryTests.java +++ b/spring-web/src/test/java/org/springframework/http/client/Netty4ClientHttpRequestFactoryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * 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. @@ -18,26 +18,26 @@ package org.springframework.http.client; import io.netty.channel.EventLoopGroup; import io.netty.channel.nio.NioEventLoopGroup; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpMethod; /** * @author Arjen Poutsma */ -public class Netty4ClientHttpRequestFactoryTests extends AbstractHttpRequestFactoryTestCase { +public class Netty4ClientHttpRequestFactoryTests extends AbstractHttpRequestFactoryTests { private static EventLoopGroup eventLoopGroup; - @BeforeClass + @BeforeAll public static void createEventLoopGroup() { eventLoopGroup = new NioEventLoopGroup(); } - @AfterClass + @AfterAll public static void shutdownEventLoopGroup() throws InterruptedException { eventLoopGroup.shutdownGracefully().sync(); } diff --git a/spring-web/src/test/java/org/springframework/http/client/NoOutputStreamingBufferedSimpleHttpRequestFactoryTests.java b/spring-web/src/test/java/org/springframework/http/client/NoOutputStreamingBufferedSimpleHttpRequestFactoryTests.java index 7bc41ea7d44..af7de98d61e 100644 --- a/spring-web/src/test/java/org/springframework/http/client/NoOutputStreamingBufferedSimpleHttpRequestFactoryTests.java +++ b/spring-web/src/test/java/org/springframework/http/client/NoOutputStreamingBufferedSimpleHttpRequestFactoryTests.java @@ -17,7 +17,7 @@ package org.springframework.http.client; -public class NoOutputStreamingBufferedSimpleHttpRequestFactoryTests extends AbstractHttpRequestFactoryTestCase { +public class NoOutputStreamingBufferedSimpleHttpRequestFactoryTests extends AbstractHttpRequestFactoryTests { @Override protected ClientHttpRequestFactory createRequestFactory() { diff --git a/spring-web/src/test/java/org/springframework/http/client/NoOutputStreamingStreamingSimpleHttpRequestFactoryTests.java b/spring-web/src/test/java/org/springframework/http/client/NoOutputStreamingStreamingSimpleHttpRequestFactoryTests.java index b1d0c9368a0..fba97743533 100644 --- a/spring-web/src/test/java/org/springframework/http/client/NoOutputStreamingStreamingSimpleHttpRequestFactoryTests.java +++ b/spring-web/src/test/java/org/springframework/http/client/NoOutputStreamingStreamingSimpleHttpRequestFactoryTests.java @@ -17,7 +17,7 @@ package org.springframework.http.client; -public class NoOutputStreamingStreamingSimpleHttpRequestFactoryTests extends AbstractHttpRequestFactoryTestCase { +public class NoOutputStreamingStreamingSimpleHttpRequestFactoryTests extends AbstractHttpRequestFactoryTests { @Override protected ClientHttpRequestFactory createRequestFactory() { diff --git a/spring-web/src/test/java/org/springframework/http/client/OkHttp3AsyncClientHttpRequestFactoryTests.java b/spring-web/src/test/java/org/springframework/http/client/OkHttp3AsyncClientHttpRequestFactoryTests.java index c2dfeae1b57..541b7bd693c 100644 --- a/spring-web/src/test/java/org/springframework/http/client/OkHttp3AsyncClientHttpRequestFactoryTests.java +++ b/spring-web/src/test/java/org/springframework/http/client/OkHttp3AsyncClientHttpRequestFactoryTests.java @@ -16,14 +16,14 @@ package org.springframework.http.client; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpMethod; /** * @author Roy Clarkson */ -public class OkHttp3AsyncClientHttpRequestFactoryTests extends AbstractAsyncHttpRequestFactoryTestCase { +public class OkHttp3AsyncClientHttpRequestFactoryTests extends AbstractAsyncHttpRequestFactoryTests { @SuppressWarnings("deprecation") @Override diff --git a/spring-web/src/test/java/org/springframework/http/client/OkHttp3ClientHttpRequestFactoryTests.java b/spring-web/src/test/java/org/springframework/http/client/OkHttp3ClientHttpRequestFactoryTests.java index d7d51e6e39e..9f1b6a1751e 100644 --- a/spring-web/src/test/java/org/springframework/http/client/OkHttp3ClientHttpRequestFactoryTests.java +++ b/spring-web/src/test/java/org/springframework/http/client/OkHttp3ClientHttpRequestFactoryTests.java @@ -16,14 +16,14 @@ package org.springframework.http.client; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpMethod; /** * @author Roy Clarkson */ -public class OkHttp3ClientHttpRequestFactoryTests extends AbstractHttpRequestFactoryTestCase { +public class OkHttp3ClientHttpRequestFactoryTests extends AbstractHttpRequestFactoryTests { @Override protected ClientHttpRequestFactory createRequestFactory() { diff --git a/spring-web/src/test/java/org/springframework/http/client/SimpleClientHttpRequestFactoryTests.java b/spring-web/src/test/java/org/springframework/http/client/SimpleClientHttpRequestFactoryTests.java index baf55a957ec..f698b01728b 100644 --- a/spring-web/src/test/java/org/springframework/http/client/SimpleClientHttpRequestFactoryTests.java +++ b/spring-web/src/test/java/org/springframework/http/client/SimpleClientHttpRequestFactoryTests.java @@ -18,7 +18,7 @@ package org.springframework.http.client; import java.net.HttpURLConnection; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpHeaders; diff --git a/spring-web/src/test/java/org/springframework/http/client/SimpleClientHttpResponseTests.java b/spring-web/src/test/java/org/springframework/http/client/SimpleClientHttpResponseTests.java index 2b03dfe1d2a..616f81b2ea7 100644 --- a/spring-web/src/test/java/org/springframework/http/client/SimpleClientHttpResponseTests.java +++ b/spring-web/src/test/java/org/springframework/http/client/SimpleClientHttpResponseTests.java @@ -22,7 +22,7 @@ import java.io.InputStream; import java.net.HttpURLConnection; import java.nio.charset.StandardCharsets; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.util.StreamUtils; diff --git a/spring-web/src/test/java/org/springframework/http/client/StreamingHttpComponentsClientHttpRequestFactoryTests.java b/spring-web/src/test/java/org/springframework/http/client/StreamingHttpComponentsClientHttpRequestFactoryTests.java index 87709896222..50576aa0268 100644 --- a/spring-web/src/test/java/org/springframework/http/client/StreamingHttpComponentsClientHttpRequestFactoryTests.java +++ b/spring-web/src/test/java/org/springframework/http/client/StreamingHttpComponentsClientHttpRequestFactoryTests.java @@ -16,14 +16,14 @@ package org.springframework.http.client; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpMethod; /** * @author Arjen Poutsma */ -public class StreamingHttpComponentsClientHttpRequestFactoryTests extends AbstractHttpRequestFactoryTestCase { +public class StreamingHttpComponentsClientHttpRequestFactoryTests extends AbstractHttpRequestFactoryTests { @Override protected ClientHttpRequestFactory createRequestFactory() { diff --git a/spring-web/src/test/java/org/springframework/http/client/StreamingSimpleClientHttpRequestFactoryTests.java b/spring-web/src/test/java/org/springframework/http/client/StreamingSimpleClientHttpRequestFactoryTests.java index c6bad90bb17..9bc295a2537 100644 --- a/spring-web/src/test/java/org/springframework/http/client/StreamingSimpleClientHttpRequestFactoryTests.java +++ b/spring-web/src/test/java/org/springframework/http/client/StreamingSimpleClientHttpRequestFactoryTests.java @@ -21,8 +21,8 @@ import java.net.URI; import java.util.Collections; import java.util.Random; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; @@ -33,7 +33,7 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Arjen Poutsma */ -public class StreamingSimpleClientHttpRequestFactoryTests extends AbstractHttpRequestFactoryTestCase { +public class StreamingSimpleClientHttpRequestFactoryTests extends AbstractHttpRequestFactoryTests { @Override protected ClientHttpRequestFactory createRequestFactory() { @@ -69,7 +69,7 @@ public class StreamingSimpleClientHttpRequestFactoryTests extends AbstractHttpRe } @Test - @Ignore + @Disabled public void largeFileUpload() throws Exception { Random rnd = new Random(); ClientHttpResponse response = null; diff --git a/spring-web/src/test/java/org/springframework/http/client/reactive/ReactorResourceFactoryTests.java b/spring-web/src/test/java/org/springframework/http/client/reactive/ReactorResourceFactoryTests.java index e7c84c9674a..0eb7cb13f14 100644 --- a/spring-web/src/test/java/org/springframework/http/client/reactive/ReactorResourceFactoryTests.java +++ b/spring-web/src/test/java/org/springframework/http/client/reactive/ReactorResourceFactoryTests.java @@ -17,7 +17,7 @@ package org.springframework.http.client.reactive; import java.util.concurrent.atomic.AtomicBoolean; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.netty.http.HttpResources; import reactor.netty.resources.ConnectionProvider; import reactor.netty.resources.LoopResources; diff --git a/spring-web/src/test/java/org/springframework/http/client/support/BasicAuthorizationInterceptorTests.java b/spring-web/src/test/java/org/springframework/http/client/support/BasicAuthorizationInterceptorTests.java index 704ee4b2479..133051e0776 100644 --- a/spring-web/src/test/java/org/springframework/http/client/support/BasicAuthorizationInterceptorTests.java +++ b/spring-web/src/test/java/org/springframework/http/client/support/BasicAuthorizationInterceptorTests.java @@ -18,7 +18,7 @@ package org.springframework.http.client.support; import java.net.URI; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.DirectFieldAccessor; import org.springframework.http.HttpMethod; diff --git a/spring-web/src/test/java/org/springframework/http/client/support/InterceptingHttpAccessorTests.java b/spring-web/src/test/java/org/springframework/http/client/support/InterceptingHttpAccessorTests.java index ca621af0f7e..407ce43d77a 100644 --- a/spring-web/src/test/java/org/springframework/http/client/support/InterceptingHttpAccessorTests.java +++ b/spring-web/src/test/java/org/springframework/http/client/support/InterceptingHttpAccessorTests.java @@ -19,7 +19,7 @@ package org.springframework.http.client.support; import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.Ordered; import org.springframework.core.annotation.Order; diff --git a/spring-web/src/test/java/org/springframework/http/client/support/ProxyFactoryBeanTests.java b/spring-web/src/test/java/org/springframework/http/client/support/ProxyFactoryBeanTests.java index c9308bd94a2..0f2f8aa4574 100644 --- a/spring-web/src/test/java/org/springframework/http/client/support/ProxyFactoryBeanTests.java +++ b/spring-web/src/test/java/org/springframework/http/client/support/ProxyFactoryBeanTests.java @@ -19,8 +19,8 @@ package org.springframework.http.client.support; import java.net.InetSocketAddress; import java.net.Proxy; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; @@ -32,7 +32,7 @@ public class ProxyFactoryBeanTests { ProxyFactoryBean factoryBean; - @Before + @BeforeEach public void setUp() { factoryBean = new ProxyFactoryBean(); } diff --git a/spring-web/src/test/java/org/springframework/http/codec/CancelWithoutDemandCodecTests.java b/spring-web/src/test/java/org/springframework/http/codec/CancelWithoutDemandCodecTests.java index 509e1355422..9b50f64516f 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/CancelWithoutDemandCodecTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/CancelWithoutDemandCodecTests.java @@ -21,8 +21,8 @@ import java.util.List; import java.util.function.Supplier; import com.google.protobuf.Message; -import org.junit.After; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; import org.reactivestreams.Publisher; import org.reactivestreams.Subscription; import reactor.core.publisher.BaseSubscriber; @@ -56,7 +56,7 @@ public class CancelWithoutDemandCodecTests { private final LeakAwareDataBufferFactory bufferFactory = new LeakAwareDataBufferFactory(); - @After + @AfterEach public void tearDown() throws Exception { this.bufferFactory.checkForLeaks(); } diff --git a/spring-web/src/test/java/org/springframework/http/codec/EncoderHttpMessageWriterTests.java b/spring-web/src/test/java/org/springframework/http/codec/EncoderHttpMessageWriterTests.java index 87a98a98052..07bb4de0e2b 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/EncoderHttpMessageWriterTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/EncoderHttpMessageWriterTests.java @@ -24,11 +24,11 @@ import java.util.Collections; import java.util.List; import java.util.Map; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; @@ -54,11 +54,12 @@ import static org.springframework.http.MediaType.TEXT_XML; /** * Unit tests for {@link EncoderHttpMessageWriter}. + * * @author Rossen Stoyanchev * @author Brian Clozel */ -@RunWith(MockitoJUnitRunner.class) -public class EncoderHttpMessageWriterTests { +@MockitoSettings(strictness = Strictness.LENIENT) +class EncoderHttpMessageWriterTests { private static final Map NO_HINTS = Collections.emptyMap(); @@ -74,14 +75,14 @@ public class EncoderHttpMessageWriterTests { @Test - public void getWritableMediaTypes() { + void getWritableMediaTypes() { configureEncoder(MimeTypeUtils.TEXT_HTML, MimeTypeUtils.TEXT_XML); HttpMessageWriter writer = new EncoderHttpMessageWriter<>(this.encoder); assertThat(writer.getWritableMediaTypes()).isEqualTo(Arrays.asList(TEXT_HTML, TEXT_XML)); } @Test - public void canWrite() { + void canWrite() { configureEncoder(MimeTypeUtils.TEXT_HTML); HttpMessageWriter writer = new EncoderHttpMessageWriter<>(this.encoder); given(this.encoder.canEncode(forClass(String.class), TEXT_HTML)).willReturn(true); @@ -91,7 +92,7 @@ public class EncoderHttpMessageWriterTests { } @Test - public void useNegotiatedMediaType() { + void useNegotiatedMediaType() { configureEncoder(TEXT_PLAIN); HttpMessageWriter writer = new EncoderHttpMessageWriter<>(this.encoder); writer.write(Flux.empty(), forClass(String.class), TEXT_PLAIN, this.response, NO_HINTS); @@ -101,7 +102,7 @@ public class EncoderHttpMessageWriterTests { } @Test - public void useDefaultMediaType() { + void useDefaultMediaType() { testDefaultMediaType(null); testDefaultMediaType(new MediaType("text", "*")); testDefaultMediaType(new MediaType("*", "*")); @@ -119,7 +120,7 @@ public class EncoderHttpMessageWriterTests { } @Test - public void useDefaultMediaTypeCharset() { + void useDefaultMediaTypeCharset() { configureEncoder(TEXT_PLAIN_UTF_8, TEXT_HTML); HttpMessageWriter writer = new EncoderHttpMessageWriter<>(this.encoder); writer.write(Flux.empty(), forClass(String.class), TEXT_HTML, response, NO_HINTS); @@ -129,7 +130,7 @@ public class EncoderHttpMessageWriterTests { } @Test - public void useNegotiatedMediaTypeCharset() { + void useNegotiatedMediaTypeCharset() { MediaType negotiatedMediaType = new MediaType("text", "html", ISO_8859_1); configureEncoder(TEXT_PLAIN_UTF_8, TEXT_HTML); HttpMessageWriter writer = new EncoderHttpMessageWriter<>(this.encoder); @@ -140,7 +141,7 @@ public class EncoderHttpMessageWriterTests { } @Test - public void useHttpOutputMessageMediaType() { + void useHttpOutputMessageMediaType() { MediaType outputMessageMediaType = MediaType.TEXT_HTML; this.response.getHeaders().setContentType(outputMessageMediaType); @@ -153,7 +154,7 @@ public class EncoderHttpMessageWriterTests { } @Test - public void setContentLengthForMonoBody() { + void setContentLengthForMonoBody() { DefaultDataBufferFactory factory = new DefaultDataBufferFactory(); DataBuffer buffer = factory.wrap("body".getBytes(StandardCharsets.UTF_8)); configureEncoder(buffer, MimeTypeUtils.TEXT_PLAIN); @@ -164,7 +165,7 @@ public class EncoderHttpMessageWriterTests { } @Test // gh-22952 - public void monoBodyDoesNotCancelEncodedFlux() { + void monoBodyDoesNotCancelEncodedFlux() { Mono inputStream = Mono.just("body") .doOnCancel(() -> { throw new AssertionError("Cancel signal not expected"); @@ -175,7 +176,7 @@ public class EncoderHttpMessageWriterTests { } @Test // SPR-17220 - public void emptyBodyWritten() { + void emptyBodyWritten() { configureEncoder(MimeTypeUtils.TEXT_PLAIN); HttpMessageWriter writer = new EncoderHttpMessageWriter<>(this.encoder); writer.write(Mono.empty(), forClass(String.class), TEXT_PLAIN, this.response, NO_HINTS).block(); @@ -184,7 +185,7 @@ public class EncoderHttpMessageWriterTests { } @Test // gh-22936 - public void isStreamingMediaType() throws InvocationTargetException, IllegalAccessException { + void isStreamingMediaType() throws InvocationTargetException, IllegalAccessException { configureEncoder(TEXT_HTML); MediaType streamingMediaType = new MediaType(TEXT_PLAIN, Collections.singletonMap("streaming", "true")); given(this.encoder.getStreamingMediaTypes()).willReturn(Arrays.asList(streamingMediaType)); diff --git a/spring-web/src/test/java/org/springframework/http/codec/FormHttpMessageReaderTests.java b/spring-web/src/test/java/org/springframework/http/codec/FormHttpMessageReaderTests.java index 6012fa19ada..79bd99807c5 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/FormHttpMessageReaderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/FormHttpMessageReaderTests.java @@ -20,7 +20,7 @@ import java.nio.charset.StandardCharsets; import java.util.List; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.reactivestreams.Publisher; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; diff --git a/spring-web/src/test/java/org/springframework/http/codec/FormHttpMessageWriterTests.java b/spring-web/src/test/java/org/springframework/http/codec/FormHttpMessageWriterTests.java index 2357391b9fe..9ff128a457a 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/FormHttpMessageWriterTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/FormHttpMessageWriterTests.java @@ -20,7 +20,7 @@ import java.nio.charset.StandardCharsets; import java.util.Map; import java.util.function.Consumer; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; diff --git a/spring-web/src/test/java/org/springframework/http/codec/ResourceHttpMessageWriterTests.java b/spring-web/src/test/java/org/springframework/http/codec/ResourceHttpMessageWriterTests.java index aab3cb7116c..4ca926aaf1f 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/ResourceHttpMessageWriterTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/ResourceHttpMessageWriterTests.java @@ -21,7 +21,7 @@ import java.util.Collections; import java.util.List; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; diff --git a/spring-web/src/test/java/org/springframework/http/codec/ServerSentEventHttpMessageReaderTests.java b/spring-web/src/test/java/org/springframework/http/codec/ServerSentEventHttpMessageReaderTests.java index 306278e87b6..2113fd6f7e3 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/ServerSentEventHttpMessageReaderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/ServerSentEventHttpMessageReaderTests.java @@ -20,7 +20,7 @@ import java.nio.charset.StandardCharsets; import java.time.Duration; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; diff --git a/spring-web/src/test/java/org/springframework/http/codec/cbor/Jackson2CborDecoderTests.java b/spring-web/src/test/java/org/springframework/http/codec/cbor/Jackson2CborDecoderTests.java index 5cb4fcf5887..3d4487c7731 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/cbor/Jackson2CborDecoderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/cbor/Jackson2CborDecoderTests.java @@ -21,7 +21,7 @@ import java.util.List; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Flux; import org.springframework.core.ResolvableType; diff --git a/spring-web/src/test/java/org/springframework/http/codec/cbor/Jackson2CborEncoderTests.java b/spring-web/src/test/java/org/springframework/http/codec/cbor/Jackson2CborEncoderTests.java index d17310b8a6c..29749bc5157 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/cbor/Jackson2CborEncoderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/cbor/Jackson2CborEncoderTests.java @@ -21,7 +21,7 @@ import java.io.UncheckedIOException; import java.util.function.Consumer; import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Flux; import org.springframework.core.ResolvableType; diff --git a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonDecoderTests.java b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonDecoderTests.java index fc2b1aceff2..6f3611a404b 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonDecoderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonDecoderTests.java @@ -28,7 +28,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; diff --git a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonEncoderTests.java b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonEncoderTests.java index 8a1e6317e62..b3af0b6138e 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonEncoderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonEncoderTests.java @@ -26,7 +26,7 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; diff --git a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2SmileDecoderTests.java b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2SmileDecoderTests.java index 1725b4c6533..762aea61454 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2SmileDecoderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2SmileDecoderTests.java @@ -21,7 +21,7 @@ import java.util.List; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Flux; import org.springframework.core.ResolvableType; diff --git a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2SmileEncoderTests.java b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2SmileEncoderTests.java index b2d774a3f61..bee9c3814ad 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2SmileEncoderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2SmileEncoderTests.java @@ -23,7 +23,7 @@ import java.util.List; import java.util.function.Consumer; import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; diff --git a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2TokenizerTests.java b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2TokenizerTests.java index dffeeabb10c..686488241b0 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2TokenizerTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/json/Jackson2TokenizerTests.java @@ -27,8 +27,8 @@ import com.fasterxml.jackson.core.TreeNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.util.TokenBuffer; import org.json.JSONException; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.skyscreamer.jsonassert.JSONAssert; import reactor.core.publisher.Flux; import reactor.test.StepVerifier; @@ -52,7 +52,7 @@ public class Jackson2TokenizerTests extends AbstractLeakCheckingTestCase { private ObjectMapper objectMapper; - @Before + @BeforeEach public void createParser() { this.jsonFactory = new JsonFactory(); this.objectMapper = new ObjectMapper(this.jsonFactory); diff --git a/spring-web/src/test/java/org/springframework/http/codec/multipart/MultipartHttpMessageWriterTests.java b/spring-web/src/test/java/org/springframework/http/codec/multipart/MultipartHttpMessageWriterTests.java index af07aa25126..1601819bbac 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/multipart/MultipartHttpMessageWriterTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/multipart/MultipartHttpMessageWriterTests.java @@ -23,7 +23,7 @@ import java.util.Collections; import java.util.List; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.core.publisher.UnicastProcessor; diff --git a/spring-web/src/test/java/org/springframework/http/codec/multipart/SynchronossPartHttpMessageReaderTests.java b/spring-web/src/test/java/org/springframework/http/codec/multipart/SynchronossPartHttpMessageReaderTests.java index e287dcf5d28..b9fc46381ab 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/multipart/SynchronossPartHttpMessageReaderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/multipart/SynchronossPartHttpMessageReaderTests.java @@ -20,7 +20,7 @@ import java.io.File; import java.time.Duration; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; diff --git a/spring-web/src/test/java/org/springframework/http/codec/protobuf/ProtobufDecoderTests.java b/spring-web/src/test/java/org/springframework/http/codec/protobuf/ProtobufDecoderTests.java index f842a86831a..ee1e56f4e32 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/protobuf/ProtobufDecoderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/protobuf/ProtobufDecoderTests.java @@ -20,7 +20,7 @@ import java.io.IOException; import java.util.Arrays; import com.google.protobuf.Message; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; diff --git a/spring-web/src/test/java/org/springframework/http/codec/protobuf/ProtobufEncoderTests.java b/spring-web/src/test/java/org/springframework/http/codec/protobuf/ProtobufEncoderTests.java index 50d37e28ef0..3f97f903fc5 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/protobuf/ProtobufEncoderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/protobuf/ProtobufEncoderTests.java @@ -21,7 +21,7 @@ import java.io.UncheckedIOException; import java.util.function.Consumer; import com.google.protobuf.Message; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; diff --git a/spring-web/src/test/java/org/springframework/http/codec/support/ClientCodecConfigurerTests.java b/spring-web/src/test/java/org/springframework/http/codec/support/ClientCodecConfigurerTests.java index 62b41befdaf..c66fc19eec5 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/support/ClientCodecConfigurerTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/support/ClientCodecConfigurerTests.java @@ -23,7 +23,7 @@ import java.util.Collections; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Flux; import org.springframework.core.ResolvableType; diff --git a/spring-web/src/test/java/org/springframework/http/codec/support/CodecConfigurerTests.java b/spring-web/src/test/java/org/springframework/http/codec/support/CodecConfigurerTests.java index a3cadd4e234..1a27f640002 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/support/CodecConfigurerTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/support/CodecConfigurerTests.java @@ -20,7 +20,7 @@ import java.util.List; import java.util.concurrent.atomic.AtomicInteger; import com.google.protobuf.ExtensionRegistry; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.ResolvableType; import org.springframework.core.codec.ByteArrayDecoder; diff --git a/spring-web/src/test/java/org/springframework/http/codec/support/ServerCodecConfigurerTests.java b/spring-web/src/test/java/org/springframework/http/codec/support/ServerCodecConfigurerTests.java index 2e9851d7aa8..777f8f51bca 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/support/ServerCodecConfigurerTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/support/ServerCodecConfigurerTests.java @@ -23,7 +23,7 @@ import java.util.Collections; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Flux; import org.springframework.core.ResolvableType; diff --git a/spring-web/src/test/java/org/springframework/http/codec/xml/Jaxb2XmlDecoderTests.java b/spring-web/src/test/java/org/springframework/http/codec/xml/Jaxb2XmlDecoderTests.java index 43e1c3e0100..91b740c5ff2 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/xml/Jaxb2XmlDecoderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/xml/Jaxb2XmlDecoderTests.java @@ -22,7 +22,7 @@ import java.util.List; import javax.xml.namespace.QName; import javax.xml.stream.events.XMLEvent; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; diff --git a/spring-web/src/test/java/org/springframework/http/codec/xml/Jaxb2XmlEncoderTests.java b/spring-web/src/test/java/org/springframework/http/codec/xml/Jaxb2XmlEncoderTests.java index 5d2711b1ae5..b7c4abd16ef 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/xml/Jaxb2XmlEncoderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/xml/Jaxb2XmlEncoderTests.java @@ -23,7 +23,7 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElements; import javax.xml.bind.annotation.XmlRootElement; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; diff --git a/spring-web/src/test/java/org/springframework/http/codec/xml/XmlEventDecoderTests.java b/spring-web/src/test/java/org/springframework/http/codec/xml/XmlEventDecoderTests.java index 33340d6d0ac..e5729014baf 100644 --- a/spring-web/src/test/java/org/springframework/http/codec/xml/XmlEventDecoderTests.java +++ b/spring-web/src/test/java/org/springframework/http/codec/xml/XmlEventDecoderTests.java @@ -20,7 +20,7 @@ import java.nio.charset.StandardCharsets; import java.util.Collections; import javax.xml.stream.events.XMLEvent; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; diff --git a/spring-web/src/test/java/org/springframework/http/converter/BufferedImageHttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/BufferedImageHttpMessageConverterTests.java index 3bea616317d..9c1eced8332 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/BufferedImageHttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/BufferedImageHttpMessageConverterTests.java @@ -21,8 +21,8 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import javax.imageio.ImageIO; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; @@ -42,7 +42,7 @@ public class BufferedImageHttpMessageConverterTests { private BufferedImageHttpMessageConverter converter; - @Before + @BeforeEach public void setUp() { converter = new BufferedImageHttpMessageConverter(); } diff --git a/spring-web/src/test/java/org/springframework/http/converter/ByteArrayHttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/ByteArrayHttpMessageConverterTests.java index 194e9c80541..d868e2666ee 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/ByteArrayHttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/ByteArrayHttpMessageConverterTests.java @@ -18,8 +18,8 @@ package org.springframework.http.converter; import java.io.IOException; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.http.MediaType; import org.springframework.http.MockHttpInputMessage; @@ -32,7 +32,7 @@ public class ByteArrayHttpMessageConverterTests { private ByteArrayHttpMessageConverter converter; - @Before + @BeforeEach public void setUp() { converter = new ByteArrayHttpMessageConverter(); } diff --git a/spring-web/src/test/java/org/springframework/http/converter/FormHttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/FormHttpMessageConverterTests.java index e2f023704a5..87b688144c0 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/FormHttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/FormHttpMessageConverterTests.java @@ -31,7 +31,7 @@ import org.apache.commons.fileupload.FileItemFactory; import org.apache.commons.fileupload.FileUpload; import org.apache.commons.fileupload.RequestContext; import org.apache.commons.fileupload.disk.DiskFileItemFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; diff --git a/spring-web/src/test/java/org/springframework/http/converter/HttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/HttpMessageConverterTests.java index e37c5768b77..b149b729d8d 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/HttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/HttpMessageConverterTests.java @@ -18,7 +18,7 @@ package org.springframework.http.converter; import java.io.IOException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpInputMessage; import org.springframework.http.HttpOutputMessage; diff --git a/spring-web/src/test/java/org/springframework/http/converter/ObjectToStringHttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/ObjectToStringHttpMessageConverterTests.java index 52bbbe3f5a1..77eed699994 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/ObjectToStringHttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/ObjectToStringHttpMessageConverterTests.java @@ -22,8 +22,8 @@ import java.nio.charset.StandardCharsets; import java.util.Date; import java.util.Locale; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.convert.ConversionService; import org.springframework.core.convert.support.DefaultConversionService; @@ -52,7 +52,7 @@ public class ObjectToStringHttpMessageConverterTests { private ServletServerHttpResponse response; - @Before + @BeforeEach public void setup() { ConversionService conversionService = new DefaultConversionService(); this.converter = new ObjectToStringHttpMessageConverter(conversionService); diff --git a/spring-web/src/test/java/org/springframework/http/converter/ResourceHttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/ResourceHttpMessageConverterTests.java index 20b5b6d35a0..efc1163bd75 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/ResourceHttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/ResourceHttpMessageConverterTests.java @@ -21,7 +21,7 @@ import java.io.IOException; import java.io.InputStream; import java.util.Arrays; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.io.ByteArrayResource; import org.springframework.core.io.ClassPathResource; diff --git a/spring-web/src/test/java/org/springframework/http/converter/ResourceRegionHttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/ResourceRegionHttpMessageConverterTests.java index 7f9e0b1dfb0..67e21fd45e5 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/ResourceRegionHttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/ResourceRegionHttpMessageConverterTests.java @@ -23,7 +23,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.mockito.BDDMockito; import org.mockito.Mockito; diff --git a/spring-web/src/test/java/org/springframework/http/converter/StringHttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/StringHttpMessageConverterTests.java index e51a8ebce1f..8c66bc4de96 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/StringHttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/StringHttpMessageConverterTests.java @@ -19,8 +19,8 @@ package org.springframework.http.converter; import java.io.IOException; import java.nio.charset.StandardCharsets; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; @@ -42,7 +42,7 @@ public class StringHttpMessageConverterTests { private MockHttpOutputMessage outputMessage; - @Before + @BeforeEach public void setUp() { this.converter = new StringHttpMessageConverter(); this.outputMessage = new MockHttpOutputMessage(); diff --git a/spring-web/src/test/java/org/springframework/http/converter/feed/AtomFeedHttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/feed/AtomFeedHttpMessageConverterTests.java index 67e95276c43..bf2956f1b4b 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/feed/AtomFeedHttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/feed/AtomFeedHttpMessageConverterTests.java @@ -25,8 +25,8 @@ import java.util.List; import com.rometools.rome.feed.atom.Entry; import com.rometools.rome.feed.atom.Feed; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.xml.sax.SAXException; import org.xmlunit.diff.DefaultNodeMatcher; import org.xmlunit.diff.ElementSelectors; @@ -47,7 +47,7 @@ public class AtomFeedHttpMessageConverterTests { private AtomFeedHttpMessageConverter converter; - @Before + @BeforeEach public void setUp() { converter = new AtomFeedHttpMessageConverter(); } diff --git a/spring-web/src/test/java/org/springframework/http/converter/feed/RssChannelHttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/feed/RssChannelHttpMessageConverterTests.java index 5e3fbb01c4a..ea48f352317 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/feed/RssChannelHttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/feed/RssChannelHttpMessageConverterTests.java @@ -25,8 +25,8 @@ import java.util.List; import com.rometools.rome.feed.rss.Channel; import com.rometools.rome.feed.rss.Item; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.xml.sax.SAXException; import org.springframework.http.MediaType; @@ -44,7 +44,7 @@ public class RssChannelHttpMessageConverterTests { private RssChannelHttpMessageConverter converter; - @Before + @BeforeEach public void setUp() { converter = new RssChannelHttpMessageConverter(); } diff --git a/spring-web/src/test/java/org/springframework/http/converter/json/GsonFactoryBeanTests.java b/spring-web/src/test/java/org/springframework/http/converter/json/GsonFactoryBeanTests.java index 2fa1aa51cfc..51d0e986502 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/json/GsonFactoryBeanTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/json/GsonFactoryBeanTests.java @@ -20,7 +20,7 @@ import java.util.Calendar; import java.util.Date; import com.google.gson.Gson; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/http/converter/json/GsonHttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/json/GsonHttpMessageConverterTests.java index aa72ece2117..aa2c777ae4c 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/json/GsonHttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/json/GsonHttpMessageConverterTests.java @@ -26,7 +26,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.skyscreamer.jsonassert.JSONAssert; import org.springframework.core.ParameterizedTypeReference; diff --git a/spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilderTests.java b/spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilderTests.java index c9fd2b95bf6..6abfffe527b 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilderTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilderTests.java @@ -78,7 +78,7 @@ import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import kotlin.ranges.IntRange; import org.joda.time.DateTime; import org.joda.time.DateTimeZone; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.FatalBeanException; import org.springframework.util.StringUtils; diff --git a/spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperFactoryBeanTests.java b/spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperFactoryBeanTests.java index d207e7c8a75..5794c543e57 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperFactoryBeanTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/json/Jackson2ObjectMapperFactoryBeanTests.java @@ -60,7 +60,7 @@ import com.fasterxml.jackson.dataformat.smile.SmileFactory; import com.fasterxml.jackson.dataformat.xml.XmlMapper; import org.joda.time.DateTime; import org.joda.time.DateTimeZone; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.FatalBeanException; diff --git a/spring-web/src/test/java/org/springframework/http/converter/json/JsonbHttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/json/JsonbHttpMessageConverterTests.java index a862f52ddb9..e929dcb67c5 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/json/JsonbHttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/json/JsonbHttpMessageConverterTests.java @@ -26,7 +26,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.skyscreamer.jsonassert.JSONAssert; import org.springframework.core.ParameterizedTypeReference; diff --git a/spring-web/src/test/java/org/springframework/http/converter/json/MappingJackson2HttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/json/MappingJackson2HttpMessageConverterTests.java index 2a1b9bf9aea..7cd38eefb92 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/json/MappingJackson2HttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/json/MappingJackson2HttpMessageConverterTests.java @@ -31,7 +31,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ser.FilterProvider; import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter; import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.skyscreamer.jsonassert.JSONAssert; import org.springframework.core.ParameterizedTypeReference; diff --git a/spring-web/src/test/java/org/springframework/http/converter/json/SpringHandlerInstantiatorTests.java b/spring-web/src/test/java/org/springframework/http/converter/json/SpringHandlerInstantiatorTests.java index a5e27def477..5bd5860a3ea 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/json/SpringHandlerInstantiatorTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/json/SpringHandlerInstantiatorTests.java @@ -47,8 +47,8 @@ import com.fasterxml.jackson.databind.jsontype.TypeIdResolver; import com.fasterxml.jackson.databind.jsontype.TypeSerializer; import com.fasterxml.jackson.databind.jsontype.impl.StdTypeResolverBuilder; import com.fasterxml.jackson.databind.type.TypeFactory; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor; @@ -69,7 +69,7 @@ public class SpringHandlerInstantiatorTests { private ObjectMapper objectMapper; - @Before + @BeforeEach public void setup() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor(); diff --git a/spring-web/src/test/java/org/springframework/http/converter/protobuf/ProtobufHttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/protobuf/ProtobufHttpMessageConverterTests.java index 47855a18ef0..26106e13d3d 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/protobuf/ProtobufHttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/protobuf/ProtobufHttpMessageConverterTests.java @@ -22,8 +22,8 @@ import java.nio.charset.Charset; import com.google.protobuf.ExtensionRegistry; import com.google.protobuf.Message; import com.google.protobuf.util.JsonFormat; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.http.MediaType; import org.springframework.http.MockHttpInputMessage; @@ -57,7 +57,7 @@ public class ProtobufHttpMessageConverterTests { private Msg testMsg; - @Before + @BeforeEach public void setup() { this.registryInitializer = mock(ExtensionRegistryInitializer.class); this.extensionRegistry = mock(ExtensionRegistry.class); diff --git a/spring-web/src/test/java/org/springframework/http/converter/protobuf/ProtobufJsonFormatHttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/protobuf/ProtobufJsonFormatHttpMessageConverterTests.java index af4825418f4..296efbd8b3b 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/protobuf/ProtobufJsonFormatHttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/protobuf/ProtobufJsonFormatHttpMessageConverterTests.java @@ -21,7 +21,7 @@ import java.io.IOException; import com.google.protobuf.ExtensionRegistry; import com.google.protobuf.Message; import com.google.protobuf.util.JsonFormat; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.MediaType; import org.springframework.http.MockHttpInputMessage; diff --git a/spring-web/src/test/java/org/springframework/http/converter/smile/MappingJackson2SmileHttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/smile/MappingJackson2SmileHttpMessageConverterTests.java index c493456546c..2cbb22bdef3 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/smile/MappingJackson2SmileHttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/smile/MappingJackson2SmileHttpMessageConverterTests.java @@ -20,7 +20,7 @@ import java.io.IOException; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.smile.SmileFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.MediaType; import org.springframework.http.MockHttpInputMessage; diff --git a/spring-web/src/test/java/org/springframework/http/converter/xml/Jaxb2CollectionHttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/xml/Jaxb2CollectionHttpMessageConverterTests.java index 61e7a43727f..32ab91107b1 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/xml/Jaxb2CollectionHttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/xml/Jaxb2CollectionHttpMessageConverterTests.java @@ -26,8 +26,8 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; import javax.xml.stream.XMLInputFactory; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.ParameterizedTypeReference; import org.springframework.core.io.ClassPathResource; @@ -57,7 +57,7 @@ public class Jaxb2CollectionHttpMessageConverterTests { private Type typeSetType; - @Before + @BeforeEach public void setup() { converter = new Jaxb2CollectionHttpMessageConverter>(); rootElementListType = new ParameterizedTypeReference>() {}.getType(); diff --git a/spring-web/src/test/java/org/springframework/http/converter/xml/Jaxb2RootElementHttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/xml/Jaxb2RootElementHttpMessageConverterTests.java index c849b95a037..bf0d950a24e 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/xml/Jaxb2RootElementHttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/xml/Jaxb2RootElementHttpMessageConverterTests.java @@ -26,8 +26,8 @@ import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.adapters.XmlAdapter; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.xmlunit.diff.DifferenceEvaluator; import org.springframework.aop.framework.AdvisedSupport; @@ -64,7 +64,7 @@ public class Jaxb2RootElementHttpMessageConverterTests { private RootElement rootElementCglib; - @Before + @BeforeEach public void setup() { converter = new Jaxb2RootElementHttpMessageConverter(); rootElement = new RootElement(); diff --git a/spring-web/src/test/java/org/springframework/http/converter/xml/MappingJackson2XmlHttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/xml/MappingJackson2XmlHttpMessageConverterTests.java index b267a21c40d..15412951579 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/xml/MappingJackson2XmlHttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/xml/MappingJackson2XmlHttpMessageConverterTests.java @@ -21,7 +21,7 @@ import java.nio.charset.StandardCharsets; import com.fasterxml.jackson.annotation.JsonView; import com.fasterxml.jackson.dataformat.xml.XmlMapper; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.io.ClassPathResource; import org.springframework.http.MediaType; diff --git a/spring-web/src/test/java/org/springframework/http/converter/xml/MarshallingHttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/xml/MarshallingHttpMessageConverterTests.java index f24d4655615..b3f95c9c81b 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/xml/MarshallingHttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/xml/MarshallingHttpMessageConverterTests.java @@ -19,7 +19,7 @@ package org.springframework.http.converter.xml; import javax.xml.transform.Result; import javax.xml.transform.stream.StreamSource; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.TypeMismatchException; import org.springframework.http.MediaType; diff --git a/spring-web/src/test/java/org/springframework/http/converter/xml/SourceHttpMessageConverterTests.java b/spring-web/src/test/java/org/springframework/http/converter/xml/SourceHttpMessageConverterTests.java index 77269ff17f3..7f4c8b13cf0 100644 --- a/spring-web/src/test/java/org/springframework/http/converter/xml/SourceHttpMessageConverterTests.java +++ b/spring-web/src/test/java/org/springframework/http/converter/xml/SourceHttpMessageConverterTests.java @@ -29,8 +29,8 @@ import javax.xml.transform.sax.SAXSource; import javax.xml.transform.stax.StAXSource; import javax.xml.transform.stream.StreamSource; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.xml.sax.InputSource; @@ -63,7 +63,7 @@ public class SourceHttpMessageConverterTests { private String bodyExternal; - @Before + @BeforeEach public void setup() throws IOException { converter = new SourceHttpMessageConverter<>(); Resource external = new ClassPathResource("external.txt", getClass()); diff --git a/spring-web/src/test/java/org/springframework/http/server/DefaultPathContainerTests.java b/spring-web/src/test/java/org/springframework/http/server/DefaultPathContainerTests.java index a2efeb7fd04..06bdc692437 100644 --- a/spring-web/src/test/java/org/springframework/http/server/DefaultPathContainerTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/DefaultPathContainerTests.java @@ -20,7 +20,7 @@ import java.util.Collections; import java.util.List; import java.util.stream.Collectors; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.server.PathContainer.PathSegment; import org.springframework.util.LinkedMultiValueMap; diff --git a/spring-web/src/test/java/org/springframework/http/server/DefaultRequestPathTests.java b/spring-web/src/test/java/org/springframework/http/server/DefaultRequestPathTests.java index fbfa40fc340..941edb6e51f 100644 --- a/spring-web/src/test/java/org/springframework/http/server/DefaultRequestPathTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/DefaultRequestPathTests.java @@ -17,7 +17,7 @@ package org.springframework.http.server; import java.net.URI; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/http/server/ServletServerHttpRequestTests.java b/spring-web/src/test/java/org/springframework/http/server/ServletServerHttpRequestTests.java index 57bcb989e8b..771d468ca26 100644 --- a/spring-web/src/test/java/org/springframework/http/server/ServletServerHttpRequestTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/ServletServerHttpRequestTests.java @@ -22,8 +22,8 @@ import java.net.URISyntaxException; import java.nio.charset.StandardCharsets; import java.util.List; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; @@ -44,7 +44,7 @@ public class ServletServerHttpRequestTests { private MockHttpServletRequest mockRequest; - @Before + @BeforeEach public void create() { mockRequest = new MockHttpServletRequest(); request = new ServletServerHttpRequest(mockRequest); diff --git a/spring-web/src/test/java/org/springframework/http/server/ServletServerHttpResponseTests.java b/spring-web/src/test/java/org/springframework/http/server/ServletServerHttpResponseTests.java index eb1fab9ac48..1048847e105 100644 --- a/spring-web/src/test/java/org/springframework/http/server/ServletServerHttpResponseTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/ServletServerHttpResponseTests.java @@ -20,8 +20,8 @@ import java.nio.charset.StandardCharsets; import java.util.Collections; import java.util.List; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; @@ -43,7 +43,7 @@ public class ServletServerHttpResponseTests { private MockHttpServletResponse mockResponse; - @Before + @BeforeEach public void create() throws Exception { mockResponse = new MockHttpServletResponse(); response = new ServletServerHttpResponse(mockResponse); diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/AbstractHttpHandlerIntegrationTests.java b/spring-web/src/test/java/org/springframework/http/server/reactive/AbstractHttpHandlerIntegrationTests.java index 1f6c6d658d4..88a1048bd77 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/AbstractHttpHandlerIntegrationTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/reactive/AbstractHttpHandlerIntegrationTests.java @@ -17,14 +17,20 @@ package org.springframework.http.server.reactive; import java.io.File; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; import java.time.Duration; +import java.util.stream.Stream; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.junit.After; -import org.junit.Before; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.api.extension.TestExecutionExceptionHandler; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import reactor.core.publisher.Flux; import org.springframework.http.server.reactive.bootstrap.HttpServer; @@ -32,32 +38,49 @@ import org.springframework.http.server.reactive.bootstrap.JettyHttpServer; import org.springframework.http.server.reactive.bootstrap.ReactorHttpServer; import org.springframework.http.server.reactive.bootstrap.TomcatHttpServer; import org.springframework.http.server.reactive.bootstrap.UndertowHttpServer; +import org.springframework.util.StringUtils; +import org.springframework.web.client.HttpServerErrorException; -@RunWith(Parameterized.class) public abstract class AbstractHttpHandlerIntegrationTests { - protected Log logger = LogFactory.getLog(getClass()); + /** + * Custom JUnit Jupiter extension that handles exceptions thrown by test methods. + * + *

If the test method throws an {@link HttpServerErrorException}, this + * extension will throw an {@link AssertionError} that wraps the + * {@code HttpServerErrorException} using the + * {@link HttpServerErrorException#getResponseBodyAsString() response body} + * as the failure message. + * + *

This mechanism provides an actually meaningful failure message if the + * test fails due to an {@code AssertionError} on the server. + */ + @RegisterExtension + TestExecutionExceptionHandler serverErrorToAssertionErrorConverter = (context, throwable) -> { + if (throwable instanceof HttpServerErrorException) { + HttpServerErrorException ex = (HttpServerErrorException) throwable; + String responseBody = ex.getResponseBodyAsString(); + if (StringUtils.hasText(responseBody)) { + String prefix = AssertionError.class.getName() + ": "; + if (responseBody.startsWith(prefix)) { + responseBody = responseBody.substring(prefix.length()); + } + throw new AssertionError(responseBody, ex); + } + } + // Else throw as-is in order to comply with the contract of TestExecutionExceptionHandler. + throw throwable; + }; + + protected final Log logger = LogFactory.getLog(getClass()); + + protected HttpServer server; protected int port; - @Parameterized.Parameter(0) - public HttpServer server; - - - @Parameterized.Parameters(name = "server [{0}]") - public static Object[][] arguments() { - File base = new File(System.getProperty("java.io.tmpdir")); - return new Object[][] { - {new JettyHttpServer()}, - {new ReactorHttpServer()}, - {new TomcatHttpServer(base.getAbsolutePath())}, - {new UndertowHttpServer()} - }; - } - - @Before - public void setup() throws Exception { + protected void startServer(HttpServer httpServer) throws Exception { + this.server = httpServer; this.server.setHandler(createHttpHandler()); this.server.afterPropertiesSet(); this.server.start(); @@ -66,8 +89,8 @@ public abstract class AbstractHttpHandlerIntegrationTests { this.port = this.server.getPort(); } - @After - public void tearDown() throws Exception { + @AfterEach + void stopServer() { this.server.stop(); this.port = 0; } @@ -92,4 +115,23 @@ public abstract class AbstractHttpHandlerIntegrationTests { return Flux.interval(period).take(count).onBackpressureBuffer(count); } + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.METHOD) + @ParameterizedTest(name = "{0}") + @MethodSource("org.springframework.http.server.reactive.AbstractHttpHandlerIntegrationTests#httpServers()") + // public for Kotlin + public @interface ParameterizedHttpServerTest { + } + + static Stream httpServers() { + File base = new File(System.getProperty("java.io.tmpdir")); + return Stream.of( + new JettyHttpServer(), + new ReactorHttpServer(), + new TomcatHttpServer(base.getAbsolutePath()), + new UndertowHttpServer() + ); + } + } diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/AsyncIntegrationTests.java b/spring-web/src/test/java/org/springframework/http/server/reactive/AsyncIntegrationTests.java index d9b1644325d..dbe943e0522 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/AsyncIntegrationTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/reactive/AsyncIntegrationTests.java @@ -19,8 +19,6 @@ package org.springframework.http.server.reactive; import java.net.URI; import java.time.Duration; -import org.junit.Ignore; -import org.junit.Test; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.core.scheduler.Scheduler; @@ -30,16 +28,16 @@ import org.springframework.core.io.buffer.DataBufferFactory; import org.springframework.core.io.buffer.DefaultDataBufferFactory; import org.springframework.http.RequestEntity; import org.springframework.http.ResponseEntity; +import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.web.client.RestTemplate; import static org.assertj.core.api.Assertions.assertThat; - /** * @author Stephane Maldini * @since 5.0 */ -public class AsyncIntegrationTests extends AbstractHttpHandlerIntegrationTests { +class AsyncIntegrationTests extends AbstractHttpHandlerIntegrationTests { private final Scheduler asyncGroup = Schedulers.parallel(); @@ -51,12 +49,12 @@ public class AsyncIntegrationTests extends AbstractHttpHandlerIntegrationTests { return new AsyncHandler(); } - @Test - @Ignore // TODO: fragile due to socket failures - public void basicTest() throws Exception { + @ParameterizedHttpServerTest + void basicTest(HttpServer httpServer) throws Exception { + startServer(httpServer); + URI url = new URI("http://localhost:" + port); - ResponseEntity response = new RestTemplate().exchange( - RequestEntity.get(url).build(), String.class); + ResponseEntity response = new RestTemplate().exchange(RequestEntity.get(url).build(), String.class); assertThat(response.getBody()).isEqualTo("hello"); } diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/ChannelSendOperatorTests.java b/spring-web/src/test/java/org/springframework/http/server/reactive/ChannelSendOperatorTests.java index 0a81e34d397..6c5918a13cd 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/ChannelSendOperatorTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/reactive/ChannelSendOperatorTests.java @@ -24,8 +24,7 @@ import java.util.List; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.reactivestreams.Publisher; import org.reactivestreams.Subscriber; import org.reactivestreams.Subscription; @@ -46,13 +45,7 @@ import static org.assertj.core.api.Assertions.assertThat; */ public class ChannelSendOperatorTests { - private OneByOneAsyncWriter writer; - - - @Before - public void setUp() throws Exception { - this.writer = new OneByOneAsyncWriter(); - } + private final OneByOneAsyncWriter writer = new OneByOneAsyncWriter(); @Test diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/ContextPathCompositeHandlerTests.java b/spring-web/src/test/java/org/springframework/http/server/reactive/ContextPathCompositeHandlerTests.java index 8670068e70a..26d5298dca9 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/ContextPathCompositeHandlerTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/reactive/ContextPathCompositeHandlerTests.java @@ -23,7 +23,7 @@ import java.util.HashMap; import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; import org.springframework.http.HttpStatus; diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/CookieIntegrationTests.java b/spring-web/src/test/java/org/springframework/http/server/reactive/CookieIntegrationTests.java index 6c24fea1b7a..7474abc09fb 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/CookieIntegrationTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/reactive/CookieIntegrationTests.java @@ -21,15 +21,13 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; import reactor.core.publisher.Mono; import org.springframework.http.HttpCookie; import org.springframework.http.RequestEntity; import org.springframework.http.ResponseCookie; import org.springframework.http.ResponseEntity; +import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.web.client.RestTemplate; import static org.assertj.core.api.Assertions.assertThat; @@ -37,7 +35,6 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Rossen Stoyanchev */ -@RunWith(Parameterized.class) public class CookieIntegrationTests extends AbstractHttpHandlerIntegrationTests { private final CookieHandler cookieHandler = new CookieHandler(); @@ -49,8 +46,10 @@ public class CookieIntegrationTests extends AbstractHttpHandlerIntegrationTests } - @Test - public void basicTest() throws Exception { + @ParameterizedHttpServerTest + public void basicTest(HttpServer httpServer) throws Exception { + startServer(httpServer); + URI url = new URI("http://localhost:" + port); String header = "SID=31d4d96e407aad42; lang=en-US"; ResponseEntity response = new RestTemplate().exchange( diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/EchoHandlerIntegrationTests.java b/spring-web/src/test/java/org/springframework/http/server/reactive/EchoHandlerIntegrationTests.java index 66ae60ad9e2..d26b650a9ed 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/EchoHandlerIntegrationTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/reactive/EchoHandlerIntegrationTests.java @@ -19,11 +19,11 @@ package org.springframework.http.server.reactive; import java.net.URI; import java.util.Random; -import org.junit.Test; import reactor.core.publisher.Mono; import org.springframework.http.RequestEntity; import org.springframework.http.ResponseEntity; +import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.web.client.RestTemplate; import static org.assertj.core.api.Assertions.assertThat; @@ -44,8 +44,10 @@ public class EchoHandlerIntegrationTests extends AbstractHttpHandlerIntegrationT } - @Test - public void echo() throws Exception { + @ParameterizedHttpServerTest + public void echo(HttpServer httpServer) throws Exception { + startServer(httpServer); + RestTemplate restTemplate = new RestTemplate(); byte[] body = randomBytes(); @@ -72,4 +74,5 @@ public class EchoHandlerIntegrationTests extends AbstractHttpHandlerIntegrationT return response.writeWith(request.getBody()); } } + } diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/ErrorHandlerIntegrationTests.java b/spring-web/src/test/java/org/springframework/http/server/reactive/ErrorHandlerIntegrationTests.java index ac4b8ce4a28..6cc09505b37 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/ErrorHandlerIntegrationTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/reactive/ErrorHandlerIntegrationTests.java @@ -18,12 +18,12 @@ package org.springframework.http.server.reactive; import java.net.URI; -import org.junit.Test; import reactor.core.publisher.Mono; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.http.client.ClientHttpResponse; +import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.web.client.ResponseErrorHandler; import org.springframework.web.client.RestTemplate; @@ -32,7 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Arjen Poutsma */ -public class ErrorHandlerIntegrationTests extends AbstractHttpHandlerIntegrationTests { +class ErrorHandlerIntegrationTests extends AbstractHttpHandlerIntegrationTests { private final ErrorHandler handler = new ErrorHandler(); @@ -43,8 +43,10 @@ public class ErrorHandlerIntegrationTests extends AbstractHttpHandlerIntegration } - @Test - public void responseBodyError() throws Exception { + @ParameterizedHttpServerTest + void responseBodyError(HttpServer httpServer) throws Exception { + startServer(httpServer); + RestTemplate restTemplate = new RestTemplate(); restTemplate.setErrorHandler(NO_OP_ERROR_HANDLER); @@ -54,8 +56,10 @@ public class ErrorHandlerIntegrationTests extends AbstractHttpHandlerIntegration assertThat(response.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR); } - @Test - public void handlingError() throws Exception { + @ParameterizedHttpServerTest + void handlingError(HttpServer httpServer) throws Exception { + startServer(httpServer); + RestTemplate restTemplate = new RestTemplate(); restTemplate.setErrorHandler(NO_OP_ERROR_HANDLER); @@ -65,8 +69,9 @@ public class ErrorHandlerIntegrationTests extends AbstractHttpHandlerIntegration assertThat(response.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR); } - @Test // SPR-15560 - public void emptyPathSegments() throws Exception { + @ParameterizedHttpServerTest // SPR-15560 + void emptyPathSegments(HttpServer httpServer) throws Exception { + startServer(httpServer); RestTemplate restTemplate = new RestTemplate(); restTemplate.setErrorHandler(NO_OP_ERROR_HANDLER); diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/HeadersAdaptersTests.java b/spring-web/src/test/java/org/springframework/http/server/reactive/HeadersAdaptersTests.java index 60bdb168be3..5292b29b29d 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/HeadersAdaptersTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/reactive/HeadersAdaptersTests.java @@ -16,97 +16,99 @@ package org.springframework.http.server.reactive; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; import java.util.Arrays; import java.util.Locale; +import java.util.stream.Stream; import io.netty.handler.codec.http.DefaultHttpHeaders; import io.undertow.util.HeaderMap; import org.apache.tomcat.util.http.MimeHeaders; import org.eclipse.jetty.http.HttpFields; -import org.junit.After; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.springframework.util.CollectionUtils; import org.springframework.util.LinkedCaseInsensitiveMap; import org.springframework.util.MultiValueMap; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.params.provider.Arguments.arguments; /** * Unit tests for {@code HeadersAdapters} {@code MultiValueMap} implementations. * * @author Brian Clozel + * @author Sam Brannen */ -@RunWith(Parameterized.class) -public class HeadersAdaptersTests { - - @Parameterized.Parameter(0) - public MultiValueMap headers; - - @Parameterized.Parameters(name = "headers [{0}]") - public static Object[][] arguments() { - return new Object[][] { - {CollectionUtils.toMultiValueMap( - new LinkedCaseInsensitiveMap<>(8, Locale.ENGLISH))}, - {new NettyHeadersAdapter(new DefaultHttpHeaders())}, - {new TomcatHeadersAdapter(new MimeHeaders())}, - {new UndertowHeadersAdapter(new HeaderMap())}, - {new JettyHeadersAdapter(new HttpFields())} - }; +class HeadersAdaptersTests { + + @ParameterizedHeadersTest + void getWithUnknownHeaderShouldReturnNull(String displayName, MultiValueMap headers) { + assertThat(headers.get("Unknown")).isNull(); } - @After - public void tearDown() { - this.headers.clear(); + @ParameterizedHeadersTest + void getFirstWithUnknownHeaderShouldReturnNull(String displayName, MultiValueMap headers) { + assertThat(headers.getFirst("Unknown")).isNull(); } - @Test - public void getWithUnknownHeaderShouldReturnNull() { - assertThat(this.headers.get("Unknown")).isNull(); + @ParameterizedHeadersTest + void sizeWithMultipleValuesForHeaderShouldCountHeaders(String displayName, MultiValueMap headers) { + headers.add("TestHeader", "first"); + headers.add("TestHeader", "second"); + assertThat(headers.size()).isEqualTo(1); } - @Test - public void getFirstWithUnknownHeaderShouldReturnNull() { - assertThat(this.headers.getFirst("Unknown")).isNull(); + @ParameterizedHeadersTest + void keySetShouldNotDuplicateHeaderNames(String displayName, MultiValueMap headers) { + headers.add("TestHeader", "first"); + headers.add("OtherHeader", "test"); + headers.add("TestHeader", "second"); + assertThat(headers.keySet().size()).isEqualTo(2); } - @Test - public void sizeWithMultipleValuesForHeaderShouldCountHeaders() { - this.headers.add("TestHeader", "first"); - this.headers.add("TestHeader", "second"); - assertThat(this.headers.size()).isEqualTo(1); + @ParameterizedHeadersTest + void containsKeyShouldBeCaseInsensitive(String displayName, MultiValueMap headers) { + headers.add("TestHeader", "first"); + assertThat(headers.containsKey("testheader")).isTrue(); } - @Test - public void keySetShouldNotDuplicateHeaderNames() { - this.headers.add("TestHeader", "first"); - this.headers.add("OtherHeader", "test"); - this.headers.add("TestHeader", "second"); - assertThat(this.headers.keySet().size()).isEqualTo(2); + @ParameterizedHeadersTest + void addShouldKeepOrdering(String displayName, MultiValueMap headers) { + headers.add("TestHeader", "first"); + headers.add("TestHeader", "second"); + assertThat(headers.getFirst("TestHeader")).isEqualTo("first"); + assertThat(headers.get("TestHeader").get(0)).isEqualTo("first"); } - @Test - public void containsKeyShouldBeCaseInsensitive() { - this.headers.add("TestHeader", "first"); - assertThat(this.headers.containsKey("testheader")).isTrue(); + @ParameterizedHeadersTest + void putShouldOverrideExisting(String displayName, MultiValueMap headers) { + headers.add("TestHeader", "first"); + headers.put("TestHeader", Arrays.asList("override")); + assertThat(headers.getFirst("TestHeader")).isEqualTo("override"); + assertThat(headers.get("TestHeader").size()).isEqualTo(1); } - @Test - public void addShouldKeepOrdering() { - this.headers.add("TestHeader", "first"); - this.headers.add("TestHeader", "second"); - assertThat(this.headers.getFirst("TestHeader")).isEqualTo("first"); - assertThat(this.headers.get("TestHeader").get(0)).isEqualTo("first"); + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.METHOD) + @ParameterizedTest(name = "{0}") + @MethodSource("headers") + @interface ParameterizedHeadersTest { } - @Test - public void putShouldOverrideExisting() { - this.headers.add("TestHeader", "first"); - this.headers.put("TestHeader", Arrays.asList("override")); - assertThat(this.headers.getFirst("TestHeader")).isEqualTo("override"); - assertThat(this.headers.get("TestHeader").size()).isEqualTo(1); + static Stream headers() { + return Stream.of( + arguments("Map", CollectionUtils.toMultiValueMap(new LinkedCaseInsensitiveMap<>(8, Locale.ENGLISH))), + arguments("Netty", new NettyHeadersAdapter(new DefaultHttpHeaders())), + arguments("Tomcat", new TomcatHeadersAdapter(new MimeHeaders())), + arguments("Undertow", new UndertowHeadersAdapter(new HeaderMap())), + arguments("Jetty", new JettyHeadersAdapter(new HttpFields())) + ); } } diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/ListenerReadPublisherTests.java b/spring-web/src/test/java/org/springframework/http/server/reactive/ListenerReadPublisherTests.java index fc4bb1e6952..92d5a42d186 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/ListenerReadPublisherTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/reactive/ListenerReadPublisherTests.java @@ -16,8 +16,8 @@ package org.springframework.http.server.reactive; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.reactivestreams.Subscriber; import org.reactivestreams.Subscription; @@ -39,7 +39,7 @@ public class ListenerReadPublisherTests { private final TestSubscriber subscriber = new TestSubscriber(); - @Before + @BeforeEach public void setup() { this.publisher.subscribe(this.subscriber); } diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/ListenerWriteProcessorTests.java b/spring-web/src/test/java/org/springframework/http/server/reactive/ListenerWriteProcessorTests.java index 7786ab4adab..fece119d011 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/ListenerWriteProcessorTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/reactive/ListenerWriteProcessorTests.java @@ -20,8 +20,8 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.reactivestreams.Subscriber; import org.reactivestreams.Subscription; @@ -44,7 +44,7 @@ public class ListenerWriteProcessorTests { private final TestSubscription subscription = new TestSubscription(); - @Before + @BeforeEach public void setup() { this.processor.subscribe(this.resultSubscriber); this.processor.onSubscribe(this.subscription); diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/MultipartIntegrationTests.java b/spring-web/src/test/java/org/springframework/http/server/reactive/MultipartIntegrationTests.java index af6b71c04b5..3b763ba7296 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/MultipartIntegrationTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/reactive/MultipartIntegrationTests.java @@ -18,7 +18,6 @@ package org.springframework.http.server.reactive; import java.net.URI; -import org.junit.Test; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; @@ -33,6 +32,7 @@ import org.springframework.http.ResponseEntity; import org.springframework.http.codec.multipart.FilePart; import org.springframework.http.codec.multipart.FormFieldPart; import org.springframework.http.codec.multipart.Part; +import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import org.springframework.web.client.RestTemplate; @@ -45,15 +45,17 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Sebastien Deleuze */ -public class MultipartIntegrationTests extends AbstractHttpHandlerIntegrationTests { +class MultipartIntegrationTests extends AbstractHttpHandlerIntegrationTests { @Override protected HttpHandler createHttpHandler() { return new HttpWebHandlerAdapter(new CheckRequestHandler()); } - @Test - public void getFormParts() throws Exception { + @ParameterizedHttpServerTest + void getFormParts(HttpServer httpServer) throws Exception { + startServer(httpServer); + RestTemplate restTemplate = new RestTemplate(); RequestEntity> request = RequestEntity .post(new URI("http://localhost:" + port + "/form-parts")) @@ -76,7 +78,7 @@ public class MultipartIntegrationTests extends AbstractHttpHandlerIntegrationTes } - public static class CheckRequestHandler implements WebHandler { + static class CheckRequestHandler implements WebHandler { @Override public Mono handle(ServerWebExchange exchange) { diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/RandomHandlerIntegrationTests.java b/spring-web/src/test/java/org/springframework/http/server/reactive/RandomHandlerIntegrationTests.java index 7a53879209d..1467027e0ea 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/RandomHandlerIntegrationTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/reactive/RandomHandlerIntegrationTests.java @@ -19,7 +19,6 @@ package org.springframework.http.server.reactive; import java.net.URI; import java.util.Random; -import org.junit.Test; import org.reactivestreams.Publisher; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -29,6 +28,7 @@ import org.springframework.core.io.buffer.DataBufferFactory; import org.springframework.core.io.buffer.DefaultDataBufferFactory; import org.springframework.http.RequestEntity; import org.springframework.http.ResponseEntity; +import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.web.client.RestTemplate; import static org.assertj.core.api.Assertions.assertThat; @@ -36,11 +36,11 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Arjen Poutsma */ -public class RandomHandlerIntegrationTests extends AbstractHttpHandlerIntegrationTests { +class RandomHandlerIntegrationTests extends AbstractHttpHandlerIntegrationTests { - public static final int REQUEST_SIZE = 4096 * 3; + private static final int REQUEST_SIZE = 4096 * 3; - public static final int RESPONSE_SIZE = 1024 * 4; + private static final int RESPONSE_SIZE = 1024 * 4; private final Random rnd = new Random(); @@ -55,8 +55,10 @@ public class RandomHandlerIntegrationTests extends AbstractHttpHandlerIntegratio } - @Test - public void random() throws Throwable { + @ParameterizedHttpServerTest + void random(HttpServer httpServer) throws Exception { + startServer(httpServer); + // TODO: fix Reactor support RestTemplate restTemplate = new RestTemplate(); @@ -79,7 +81,7 @@ public class RandomHandlerIntegrationTests extends AbstractHttpHandlerIntegratio private class RandomHandler implements HttpHandler { - public static final int CHUNKS = 16; + static final int CHUNKS = 16; @Override public Mono handle(ServerHttpRequest request, ServerHttpResponse response) { diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpRequestIntegrationTests.java b/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpRequestIntegrationTests.java index 799600479ee..b108e797fa6 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpRequestIntegrationTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpRequestIntegrationTests.java @@ -18,12 +18,12 @@ package org.springframework.http.server.reactive; import java.net.URI; -import org.junit.Test; import reactor.core.publisher.Mono; import org.springframework.http.HttpStatus; import org.springframework.http.RequestEntity; import org.springframework.http.ResponseEntity; +import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.web.client.RestTemplate; import static org.assertj.core.api.Assertions.assertThat; @@ -31,15 +31,18 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Sebastien Deleuze */ -public class ServerHttpRequestIntegrationTests extends AbstractHttpHandlerIntegrationTests { +class ServerHttpRequestIntegrationTests extends AbstractHttpHandlerIntegrationTests { @Override protected CheckRequestHandler createHttpHandler() { return new CheckRequestHandler(); } - @Test - public void checkUri() throws Exception { + + @ParameterizedHttpServerTest + void checkUri(HttpServer httpServer) throws Exception { + startServer(httpServer); + URI url = new URI("http://localhost:" + port + "/foo?param=bar"); RequestEntity request = RequestEntity.post(url).build(); ResponseEntity response = new RestTemplate().exchange(request, Void.class); @@ -47,7 +50,7 @@ public class ServerHttpRequestIntegrationTests extends AbstractHttpHandlerIntegr } - public static class CheckRequestHandler implements HttpHandler { + static class CheckRequestHandler implements HttpHandler { @Override public Mono handle(ServerHttpRequest request, ServerHttpResponse response) { diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpRequestTests.java b/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpRequestTests.java index c0f860c55b9..aa9e7ef89e0 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpRequestTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpRequestTests.java @@ -24,7 +24,7 @@ import javax.servlet.AsyncContext; import javax.servlet.ReadListener; import javax.servlet.ServletInputStream; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.io.buffer.DefaultDataBufferFactory; import org.springframework.http.HttpMethod; diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpResponseTests.java b/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpResponseTests.java index b384efc74db..acc7b4bd71d 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpResponseTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpResponseTests.java @@ -21,7 +21,7 @@ import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.reactivestreams.Publisher; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpsRequestIntegrationTests.java b/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpsRequestIntegrationTests.java index 3c28fd29347..cda8ce2b212 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpsRequestIntegrationTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/reactive/ServerHttpsRequestIntegrationTests.java @@ -24,11 +24,9 @@ import org.apache.http.conn.ssl.TrustSelfSignedStrategy; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.ssl.SSLContextBuilder; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; import org.springframework.http.HttpStatus; @@ -43,27 +41,21 @@ import static org.assertj.core.api.Assertions.assertThat; /** * HTTPS-specific integration test for {@link ServerHttpRequest}. + * * @author Arjen Poutsma + * @author Sam Brannen */ -@RunWith(Parameterized.class) -public class ServerHttpsRequestIntegrationTests { +class ServerHttpsRequestIntegrationTests { - private int port; + private final HttpServer server = new ReactorHttpsServer(); - @Parameterized.Parameter(0) - public HttpServer server; + private int port; private RestTemplate restTemplate; - @Parameterized.Parameters(name = "server [{0}]") - public static Object[][] arguments() { - return new Object[][]{ - {new ReactorHttpsServer()}, - }; - } - @Before - public void setup() throws Exception { + @BeforeEach + void startServer() throws Exception { this.server.setHandler(new CheckRequestHandler()); this.server.afterPropertiesSet(); this.server.start(); @@ -82,21 +74,21 @@ public class ServerHttpsRequestIntegrationTests { this.restTemplate = new RestTemplate(requestFactory); } - @After - public void tearDown() throws Exception { + @AfterEach + void stopServer() { this.server.stop(); - this.port = 0; } @Test - public void checkUri() throws Exception { + void checkUri() throws Exception { URI url = new URI("https://localhost:" + port + "/foo?param=bar"); RequestEntity request = RequestEntity.post(url).build(); ResponseEntity response = this.restTemplate.exchange(request, Void.class); assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); } - public static class CheckRequestHandler implements HttpHandler { + + private static class CheckRequestHandler implements HttpHandler { @Override public Mono handle(ServerHttpRequest request, ServerHttpResponse response) { diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/WriteOnlyHandlerIntegrationTests.java b/spring-web/src/test/java/org/springframework/http/server/reactive/WriteOnlyHandlerIntegrationTests.java index aefceae1895..a7be114968c 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/WriteOnlyHandlerIntegrationTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/reactive/WriteOnlyHandlerIntegrationTests.java @@ -20,13 +20,13 @@ import java.net.URI; import java.nio.charset.StandardCharsets; import java.util.Random; -import org.junit.Test; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import org.springframework.core.io.buffer.DataBuffer; import org.springframework.http.RequestEntity; import org.springframework.http.ResponseEntity; +import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.web.client.RestTemplate; import static org.assertj.core.api.Assertions.assertThat; @@ -35,11 +35,11 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Violeta Georgieva * @since 5.0 */ -public class WriteOnlyHandlerIntegrationTests extends AbstractHttpHandlerIntegrationTests { +class WriteOnlyHandlerIntegrationTests extends AbstractHttpHandlerIntegrationTests { private static final int REQUEST_SIZE = 4096 * 3; - private Random rnd = new Random(); + private final Random rnd = new Random(); private byte[] body; @@ -49,8 +49,10 @@ public class WriteOnlyHandlerIntegrationTests extends AbstractHttpHandlerIntegra return new WriteOnlyHandler(); } - @Test - public void writeOnly() throws Exception { + @ParameterizedHttpServerTest + void writeOnly(HttpServer httpServer) throws Exception { + startServer(httpServer); + RestTemplate restTemplate = new RestTemplate(); this.body = randomBytes(); @@ -69,7 +71,7 @@ public class WriteOnlyHandlerIntegrationTests extends AbstractHttpHandlerIntegra } - public class WriteOnlyHandler implements HttpHandler { + class WriteOnlyHandler implements HttpHandler { @Override public Mono handle(ServerHttpRequest request, ServerHttpResponse response) { diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/ZeroCopyIntegrationTests.java b/spring-web/src/test/java/org/springframework/http/server/reactive/ZeroCopyIntegrationTests.java index 05687e99663..f2db7fe7efa 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/ZeroCopyIntegrationTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/reactive/ZeroCopyIntegrationTests.java @@ -19,7 +19,6 @@ package org.springframework.http.server.reactive; import java.io.File; import java.net.URI; -import org.junit.Test; import reactor.core.publisher.Mono; import org.springframework.core.io.ClassPathResource; @@ -28,6 +27,7 @@ import org.springframework.http.MediaType; import org.springframework.http.RequestEntity; import org.springframework.http.ResponseEntity; import org.springframework.http.ZeroCopyHttpOutputMessage; +import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.http.server.reactive.bootstrap.ReactorHttpServer; import org.springframework.http.server.reactive.bootstrap.UndertowHttpServer; import org.springframework.web.client.RestTemplate; @@ -49,8 +49,10 @@ public class ZeroCopyIntegrationTests extends AbstractHttpHandlerIntegrationTest } - @Test - public void zeroCopy() throws Exception { + @ParameterizedHttpServerTest + public void zeroCopy(HttpServer httpServer) throws Exception { + startServer(httpServer); + // Zero-copy only does not support servlet assumeTrue(server instanceof ReactorHttpServer || server instanceof UndertowHttpServer); diff --git a/spring-web/src/test/java/org/springframework/remoting/caucho/CauchoRemotingTests.java b/spring-web/src/test/java/org/springframework/remoting/caucho/CauchoRemotingTests.java index d2d52a12d84..5eafdf98ed2 100644 --- a/spring-web/src/test/java/org/springframework/remoting/caucho/CauchoRemotingTests.java +++ b/spring-web/src/test/java/org/springframework/remoting/caucho/CauchoRemotingTests.java @@ -21,7 +21,7 @@ import java.net.InetSocketAddress; import com.caucho.hessian.client.HessianProxyFactory; import com.sun.net.httpserver.HttpServer; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.framework.ProxyFactory; import org.springframework.remoting.RemoteAccessException; diff --git a/spring-web/src/test/java/org/springframework/remoting/httpinvoker/HttpComponentsHttpInvokerRequestExecutorTests.java b/spring-web/src/test/java/org/springframework/remoting/httpinvoker/HttpComponentsHttpInvokerRequestExecutorTests.java index f017f8a925a..c5d486f05e6 100644 --- a/spring-web/src/test/java/org/springframework/remoting/httpinvoker/HttpComponentsHttpInvokerRequestExecutorTests.java +++ b/spring-web/src/test/java/org/springframework/remoting/httpinvoker/HttpComponentsHttpInvokerRequestExecutorTests.java @@ -24,7 +24,7 @@ import org.apache.http.client.methods.Configurable; import org.apache.http.client.methods.HttpPost; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; diff --git a/spring-web/src/test/java/org/springframework/remoting/httpinvoker/HttpInvokerFactoryBeanIntegrationTests.java b/spring-web/src/test/java/org/springframework/remoting/httpinvoker/HttpInvokerFactoryBeanIntegrationTests.java index a60a886aaab..62844ab6a65 100644 --- a/spring-web/src/test/java/org/springframework/remoting/httpinvoker/HttpInvokerFactoryBeanIntegrationTests.java +++ b/spring-web/src/test/java/org/springframework/remoting/httpinvoker/HttpInvokerFactoryBeanIntegrationTests.java @@ -16,7 +16,7 @@ package org.springframework.remoting.httpinvoker; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.annotation.Autowired; diff --git a/spring-web/src/test/java/org/springframework/remoting/httpinvoker/HttpInvokerTests.java b/spring-web/src/test/java/org/springframework/remoting/httpinvoker/HttpInvokerTests.java index 881b150fd8a..7b2ae05c54b 100644 --- a/spring-web/src/test/java/org/springframework/remoting/httpinvoker/HttpInvokerTests.java +++ b/spring-web/src/test/java/org/springframework/remoting/httpinvoker/HttpInvokerTests.java @@ -33,7 +33,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.aopalliance.intercept.MethodInvocation; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanClassLoaderAware; import org.springframework.mock.web.test.MockHttpServletRequest; diff --git a/spring-web/src/test/java/org/springframework/remoting/jaxws/JaxWsSupportTests.java b/spring-web/src/test/java/org/springframework/remoting/jaxws/JaxWsSupportTests.java index 6dd47eaeb79..7211a9bfd89 100644 --- a/spring-web/src/test/java/org/springframework/remoting/jaxws/JaxWsSupportTests.java +++ b/spring-web/src/test/java/org/springframework/remoting/jaxws/JaxWsSupportTests.java @@ -27,7 +27,7 @@ import javax.xml.ws.WebServiceFeature; import javax.xml.ws.WebServiceRef; import javax.xml.ws.soap.AddressingFeature; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.support.GenericBeanDefinition; diff --git a/spring-web/src/test/java/org/springframework/web/accept/ContentNegotiationManagerFactoryBeanTests.java b/spring-web/src/test/java/org/springframework/web/accept/ContentNegotiationManagerFactoryBeanTests.java index 062505e2f73..b8443d9812f 100644 --- a/spring-web/src/test/java/org/springframework/web/accept/ContentNegotiationManagerFactoryBeanTests.java +++ b/spring-web/src/test/java/org/springframework/web/accept/ContentNegotiationManagerFactoryBeanTests.java @@ -22,8 +22,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.http.MediaType; import org.springframework.mock.web.test.MockHttpServletRequest; @@ -50,7 +50,7 @@ public class ContentNegotiationManagerFactoryBeanTests { private MockHttpServletRequest servletRequest; - @Before + @BeforeEach public void setup() { TestServletContext servletContext = new TestServletContext(); servletContext.getMimeTypes().put("foo", "application/foo"); diff --git a/spring-web/src/test/java/org/springframework/web/accept/HeaderContentNegotiationStrategyTests.java b/spring-web/src/test/java/org/springframework/web/accept/HeaderContentNegotiationStrategyTests.java index d32024dea0b..2ee89454f66 100644 --- a/spring-web/src/test/java/org/springframework/web/accept/HeaderContentNegotiationStrategyTests.java +++ b/spring-web/src/test/java/org/springframework/web/accept/HeaderContentNegotiationStrategyTests.java @@ -18,7 +18,7 @@ package org.springframework.web.accept; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.MediaType; import org.springframework.mock.web.test.MockHttpServletRequest; diff --git a/spring-web/src/test/java/org/springframework/web/accept/MappingContentNegotiationStrategyTests.java b/spring-web/src/test/java/org/springframework/web/accept/MappingContentNegotiationStrategyTests.java index a4e6f630f2e..b416be68471 100644 --- a/spring-web/src/test/java/org/springframework/web/accept/MappingContentNegotiationStrategyTests.java +++ b/spring-web/src/test/java/org/springframework/web/accept/MappingContentNegotiationStrategyTests.java @@ -20,7 +20,7 @@ import java.util.Collections; import java.util.List; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.MediaType; import org.springframework.web.context.request.NativeWebRequest; diff --git a/spring-web/src/test/java/org/springframework/web/accept/MappingMediaTypeFileExtensionResolverTests.java b/spring-web/src/test/java/org/springframework/web/accept/MappingMediaTypeFileExtensionResolverTests.java index 42e1a63a81d..300dadf7e4a 100644 --- a/spring-web/src/test/java/org/springframework/web/accept/MappingMediaTypeFileExtensionResolverTests.java +++ b/spring-web/src/test/java/org/springframework/web/accept/MappingMediaTypeFileExtensionResolverTests.java @@ -20,7 +20,7 @@ import java.util.Collections; import java.util.List; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.MediaType; diff --git a/spring-web/src/test/java/org/springframework/web/accept/PathExtensionContentNegotiationStrategyTests.java b/spring-web/src/test/java/org/springframework/web/accept/PathExtensionContentNegotiationStrategyTests.java index c3f63306aeb..633e66add1d 100644 --- a/spring-web/src/test/java/org/springframework/web/accept/PathExtensionContentNegotiationStrategyTests.java +++ b/spring-web/src/test/java/org/springframework/web/accept/PathExtensionContentNegotiationStrategyTests.java @@ -20,8 +20,8 @@ import java.util.Collections; import java.util.List; import java.util.Map; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.http.MediaType; import org.springframework.mock.web.test.MockHttpServletRequest; @@ -45,7 +45,7 @@ public class PathExtensionContentNegotiationStrategyTests { private MockHttpServletRequest servletRequest; - @Before + @BeforeEach public void setup() { this.servletRequest = new MockHttpServletRequest(); this.webRequest = new ServletWebRequest(servletRequest); diff --git a/spring-web/src/test/java/org/springframework/web/bind/EscapedErrorsTests.java b/spring-web/src/test/java/org/springframework/web/bind/EscapedErrorsTests.java index 30691e89c8c..d5d39bf0bb1 100644 --- a/spring-web/src/test/java/org/springframework/web/bind/EscapedErrorsTests.java +++ b/spring-web/src/test/java/org/springframework/web/bind/EscapedErrorsTests.java @@ -16,7 +16,7 @@ package org.springframework.web.bind; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.tests.sample.beans.TestBean; import org.springframework.validation.BindException; diff --git a/spring-web/src/test/java/org/springframework/web/bind/ServletRequestDataBinderTests.java b/spring-web/src/test/java/org/springframework/web/bind/ServletRequestDataBinderTests.java index 3b5a4bc46b6..72779020932 100644 --- a/spring-web/src/test/java/org/springframework/web/bind/ServletRequestDataBinderTests.java +++ b/spring-web/src/test/java/org/springframework/web/bind/ServletRequestDataBinderTests.java @@ -21,7 +21,7 @@ import java.util.Arrays; import java.util.HashMap; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.PropertyValue; import org.springframework.beans.PropertyValues; diff --git a/spring-web/src/test/java/org/springframework/web/bind/ServletRequestUtilsTests.java b/spring-web/src/test/java/org/springframework/web/bind/ServletRequestUtilsTests.java index 7cbbdb82eb5..fc2bd6d01bb 100644 --- a/spring-web/src/test/java/org/springframework/web/bind/ServletRequestUtilsTests.java +++ b/spring-web/src/test/java/org/springframework/web/bind/ServletRequestUtilsTests.java @@ -16,7 +16,7 @@ package org.springframework.web.bind; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.tests.Assume; diff --git a/spring-web/src/test/java/org/springframework/web/bind/support/WebExchangeDataBinderTests.java b/spring-web/src/test/java/org/springframework/web/bind/support/WebExchangeDataBinderTests.java index f5896e9d88f..1c60a62ab0d 100644 --- a/spring-web/src/test/java/org/springframework/web/bind/support/WebExchangeDataBinderTests.java +++ b/spring-web/src/test/java/org/springframework/web/bind/support/WebExchangeDataBinderTests.java @@ -22,8 +22,8 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; import org.springframework.core.io.ClassPathResource; @@ -57,7 +57,7 @@ public class WebExchangeDataBinderTests { private WebExchangeDataBinder binder; - @Before + @BeforeEach public void setup() throws Exception { this.testBean = new TestBean(); this.binder = new WebExchangeDataBinder(this.testBean, "person"); diff --git a/spring-web/src/test/java/org/springframework/web/bind/support/WebRequestDataBinderIntegrationTests.java b/spring-web/src/test/java/org/springframework/web/bind/support/WebRequestDataBinderIntegrationTests.java index b4978d830fa..3432c6c9455 100644 --- a/spring-web/src/test/java/org/springframework/web/bind/support/WebRequestDataBinderIntegrationTests.java +++ b/spring-web/src/test/java/org/springframework/web/bind/support/WebRequestDataBinderIntegrationTests.java @@ -28,9 +28,9 @@ import org.eclipse.jetty.server.NetworkConnector; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletHolder; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; @@ -62,7 +62,7 @@ public class WebRequestDataBinderIntegrationTests { protected static MediaType contentType; - @BeforeClass + @BeforeAll public static void startJettyServer() throws Exception { // Let server pick its own random, available port. jettyServer = new Server(0); @@ -87,7 +87,7 @@ public class WebRequestDataBinderIntegrationTests { baseUrl = "http://localhost:" + connector.getLocalPort(); } - @AfterClass + @AfterAll public static void stopJettyServer() throws Exception { if (jettyServer != null) { jettyServer.stop(); diff --git a/spring-web/src/test/java/org/springframework/web/bind/support/WebRequestDataBinderTests.java b/spring-web/src/test/java/org/springframework/web/bind/support/WebRequestDataBinderTests.java index 6810255e5ae..de2efa993d2 100644 --- a/spring-web/src/test/java/org/springframework/web/bind/support/WebRequestDataBinderTests.java +++ b/spring-web/src/test/java/org/springframework/web/bind/support/WebRequestDataBinderTests.java @@ -23,7 +23,7 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.PropertyValue; import org.springframework.beans.PropertyValues; diff --git a/spring-web/src/test/java/org/springframework/web/client/AbstractMockWebServerTestCase.java b/spring-web/src/test/java/org/springframework/web/client/AbstractMockWebServerTests.java similarity index 98% rename from spring-web/src/test/java/org/springframework/web/client/AbstractMockWebServerTestCase.java rename to spring-web/src/test/java/org/springframework/web/client/AbstractMockWebServerTests.java index bfcf7653af5..a141941665c 100644 --- a/spring-web/src/test/java/org/springframework/web/client/AbstractMockWebServerTestCase.java +++ b/spring-web/src/test/java/org/springframework/web/client/AbstractMockWebServerTests.java @@ -26,8 +26,8 @@ import okhttp3.mockwebserver.MockResponse; import okhttp3.mockwebserver.MockWebServer; import okhttp3.mockwebserver.RecordedRequest; import okio.Buffer; -import org.junit.After; -import org.junit.Before; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; import org.springframework.http.MediaType; @@ -42,7 +42,7 @@ import static org.springframework.http.MediaType.MULTIPART_MIXED; * @author Brian Clozel * @author Sam Brannen */ -public class AbstractMockWebServerTestCase { +abstract class AbstractMockWebServerTests { protected static final MediaType MULTIPART_RELATED = new MediaType("multipart", "related"); @@ -58,16 +58,16 @@ public class AbstractMockWebServerTestCase { protected String baseUrl; - @Before - public void setUp() throws Exception { + @BeforeEach + void setUp() throws Exception { this.server.setDispatcher(new TestDispatcher()); this.server.start(); this.port = this.server.getPort(); this.baseUrl = "http://localhost:" + this.port; } - @After - public void tearDown() throws Exception { + @AfterEach + void tearDown() throws Exception { this.server.shutdown(); } diff --git a/spring-web/src/test/java/org/springframework/web/client/AsyncRestTemplateIntegrationTests.java b/spring-web/src/test/java/org/springframework/web/client/AsyncRestTemplateIntegrationTests.java index e76f91b32c0..245172958b2 100644 --- a/spring-web/src/test/java/org/springframework/web/client/AsyncRestTemplateIntegrationTests.java +++ b/spring-web/src/test/java/org/springframework/web/client/AsyncRestTemplateIntegrationTests.java @@ -27,7 +27,7 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; @@ -65,7 +65,7 @@ import static org.assertj.core.api.Assertions.fail; * @author Sebastien Deleuze */ @SuppressWarnings("deprecation") -public class AsyncRestTemplateIntegrationTests extends AbstractMockWebServerTestCase { +public class AsyncRestTemplateIntegrationTests extends AbstractMockWebServerTests { private final AsyncRestTemplate template = new AsyncRestTemplate( new org.springframework.http.client.HttpComponentsAsyncClientHttpRequestFactory()); diff --git a/spring-web/src/test/java/org/springframework/web/client/DefaultResponseErrorHandlerHttpStatusTests.java b/spring-web/src/test/java/org/springframework/web/client/DefaultResponseErrorHandlerHttpStatusTests.java index 076c54ea4a1..e69d6807421 100644 --- a/spring-web/src/test/java/org/springframework/web/client/DefaultResponseErrorHandlerHttpStatusTests.java +++ b/spring-web/src/test/java/org/springframework/web/client/DefaultResponseErrorHandlerHttpStatusTests.java @@ -16,10 +16,9 @@ package org.springframework.web.client; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; @@ -51,60 +50,56 @@ import static org.springframework.http.HttpStatus.UNPROCESSABLE_ENTITY; * Unit tests for {@link DefaultResponseErrorHandler} handling of specific * HTTP status codes. */ -@RunWith(Parameterized.class) -public class DefaultResponseErrorHandlerHttpStatusTests { - - @Parameters(name = "error: [{0}], exception: [{1}]") - public static Object[][] errorCodes() { - return new Object[][]{ - // 4xx - {BAD_REQUEST, HttpClientErrorException.BadRequest.class}, - {UNAUTHORIZED, HttpClientErrorException.Unauthorized.class}, - {FORBIDDEN, HttpClientErrorException.Forbidden.class}, - {NOT_FOUND, HttpClientErrorException.NotFound.class}, - {METHOD_NOT_ALLOWED, HttpClientErrorException.MethodNotAllowed.class}, - {NOT_ACCEPTABLE, HttpClientErrorException.NotAcceptable.class}, - {CONFLICT, HttpClientErrorException.Conflict.class}, - {TOO_MANY_REQUESTS, HttpClientErrorException.TooManyRequests.class}, - {UNPROCESSABLE_ENTITY, HttpClientErrorException.UnprocessableEntity.class}, - {I_AM_A_TEAPOT, HttpClientErrorException.class}, - // 5xx - {INTERNAL_SERVER_ERROR, HttpServerErrorException.InternalServerError.class}, - {NOT_IMPLEMENTED, HttpServerErrorException.NotImplemented.class}, - {BAD_GATEWAY, HttpServerErrorException.BadGateway.class}, - {SERVICE_UNAVAILABLE, HttpServerErrorException.ServiceUnavailable.class}, - {GATEWAY_TIMEOUT, HttpServerErrorException.GatewayTimeout.class}, - {HTTP_VERSION_NOT_SUPPORTED, HttpServerErrorException.class} - }; - } - - @Parameterized.Parameter - public HttpStatus httpStatus; - - @Parameterized.Parameter(1) - public Class expectedExceptionClass; +class DefaultResponseErrorHandlerHttpStatusTests { private final DefaultResponseErrorHandler handler = new DefaultResponseErrorHandler(); private final ClientHttpResponse response = mock(ClientHttpResponse.class); - @Test - public void hasErrorTrue() throws Exception { - given(this.response.getRawStatusCode()).willReturn(this.httpStatus.value()); + @ParameterizedTest(name = "error: [{0}], exception: [{1}]") + @DisplayName("hasError() returns true") + @MethodSource("errorCodes") + void hasErrorTrue(HttpStatus httpStatus, Class expectedExceptionClass) throws Exception { + given(this.response.getRawStatusCode()).willReturn(httpStatus.value()); assertThat(this.handler.hasError(this.response)).isTrue(); } - @Test - public void handleErrorException() throws Exception { + @ParameterizedTest(name = "error: [{0}], exception: [{1}]") + @DisplayName("handleError() throws an exception") + @MethodSource("errorCodes") + void handleErrorException(HttpStatus httpStatus, Class expectedExceptionClass) throws Exception { HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.TEXT_PLAIN); - given(this.response.getRawStatusCode()).willReturn(this.httpStatus.value()); + given(this.response.getRawStatusCode()).willReturn(httpStatus.value()); given(this.response.getHeaders()).willReturn(headers); assertThatExceptionOfType(expectedExceptionClass).isThrownBy(() -> this.handler.handleError(this.response)); } + static Object[][] errorCodes() { + return new Object[][]{ + // 4xx + {BAD_REQUEST, HttpClientErrorException.BadRequest.class}, + {UNAUTHORIZED, HttpClientErrorException.Unauthorized.class}, + {FORBIDDEN, HttpClientErrorException.Forbidden.class}, + {NOT_FOUND, HttpClientErrorException.NotFound.class}, + {METHOD_NOT_ALLOWED, HttpClientErrorException.MethodNotAllowed.class}, + {NOT_ACCEPTABLE, HttpClientErrorException.NotAcceptable.class}, + {CONFLICT, HttpClientErrorException.Conflict.class}, + {TOO_MANY_REQUESTS, HttpClientErrorException.TooManyRequests.class}, + {UNPROCESSABLE_ENTITY, HttpClientErrorException.UnprocessableEntity.class}, + {I_AM_A_TEAPOT, HttpClientErrorException.class}, + // 5xx + {INTERNAL_SERVER_ERROR, HttpServerErrorException.InternalServerError.class}, + {NOT_IMPLEMENTED, HttpServerErrorException.NotImplemented.class}, + {BAD_GATEWAY, HttpServerErrorException.BadGateway.class}, + {SERVICE_UNAVAILABLE, HttpServerErrorException.ServiceUnavailable.class}, + {GATEWAY_TIMEOUT, HttpServerErrorException.GatewayTimeout.class}, + {HTTP_VERSION_NOT_SUPPORTED, HttpServerErrorException.class} + }; + } + } diff --git a/spring-web/src/test/java/org/springframework/web/client/DefaultResponseErrorHandlerTests.java b/spring-web/src/test/java/org/springframework/web/client/DefaultResponseErrorHandlerTests.java index 8a2abeb95b2..e9f78260937 100644 --- a/spring-web/src/test/java/org/springframework/web/client/DefaultResponseErrorHandlerTests.java +++ b/spring-web/src/test/java/org/springframework/web/client/DefaultResponseErrorHandlerTests.java @@ -20,7 +20,7 @@ import java.io.ByteArrayInputStream; import java.io.IOException; import java.nio.charset.StandardCharsets; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; diff --git a/spring-web/src/test/java/org/springframework/web/client/ExtractingResponseErrorHandlerTests.java b/spring-web/src/test/java/org/springframework/web/client/ExtractingResponseErrorHandlerTests.java index 4f7b613c4f2..622a3873439 100644 --- a/spring-web/src/test/java/org/springframework/web/client/ExtractingResponseErrorHandlerTests.java +++ b/spring-web/src/test/java/org/springframework/web/client/ExtractingResponseErrorHandlerTests.java @@ -20,8 +20,8 @@ import java.io.ByteArrayInputStream; import java.nio.charset.StandardCharsets; import java.util.Collections; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; @@ -45,7 +45,7 @@ public class ExtractingResponseErrorHandlerTests { private final ClientHttpResponse response = mock(ClientHttpResponse.class); - @Before + @BeforeEach public void setup() { HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(); this.errorHandler = new ExtractingResponseErrorHandler( diff --git a/spring-web/src/test/java/org/springframework/web/client/HttpMessageConverterExtractorTests.java b/spring-web/src/test/java/org/springframework/web/client/HttpMessageConverterExtractorTests.java index 45329d15f59..2374a0d9548 100644 --- a/spring-web/src/test/java/org/springframework/web/client/HttpMessageConverterExtractorTests.java +++ b/spring-web/src/test/java/org/springframework/web/client/HttpMessageConverterExtractorTests.java @@ -22,7 +22,7 @@ import java.lang.reflect.Type; import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.ParameterizedTypeReference; import org.springframework.http.HttpHeaders; diff --git a/spring-web/src/test/java/org/springframework/web/client/HttpStatusCodeExceptionTests.java b/spring-web/src/test/java/org/springframework/web/client/HttpStatusCodeExceptionTests.java index 5080566e24d..8223e73f9ef 100644 --- a/spring-web/src/test/java/org/springframework/web/client/HttpStatusCodeExceptionTests.java +++ b/spring-web/src/test/java/org/springframework/web/client/HttpStatusCodeExceptionTests.java @@ -23,7 +23,7 @@ import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.nio.charset.StandardCharsets; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpStatus; diff --git a/spring-web/src/test/java/org/springframework/web/client/RestTemplateIntegrationTests.java b/spring-web/src/test/java/org/springframework/web/client/RestTemplateIntegrationTests.java index 666cc27ede8..ae7363445ba 100644 --- a/spring-web/src/test/java/org/springframework/web/client/RestTemplateIntegrationTests.java +++ b/spring-web/src/test/java/org/springframework/web/client/RestTemplateIntegrationTests.java @@ -16,29 +16,25 @@ package org.springframework.web.client; -import java.io.UnsupportedEncodingException; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; import java.net.URI; -import java.net.URISyntaxException; import java.nio.charset.StandardCharsets; import java.util.ArrayList; -import java.util.Arrays; import java.util.EnumSet; import java.util.List; import java.util.Set; +import java.util.stream.Stream; import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonView; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TestRule; -import org.junit.runner.Description; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; -import org.junit.runners.model.Statement; +import org.junit.jupiter.api.extension.RegisterExtension; +import org.junit.jupiter.api.extension.TestExecutionExceptionHandler; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.springframework.core.ParameterizedTypeReference; import org.springframework.core.io.ClassPathResource; @@ -82,74 +78,76 @@ import static org.springframework.http.MediaType.MULTIPART_MIXED; * @author Brian Clozel * @author Sam Brannen */ -@RunWith(Parameterized.class) -public class RestTemplateIntegrationTests extends AbstractMockWebServerTestCase { +class RestTemplateIntegrationTests extends AbstractMockWebServerTests { + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.METHOD) + @ParameterizedTest + @MethodSource("clientHttpRequestFactories") + @interface ParameterizedRestTemplateTest { + } + + @SuppressWarnings("deprecation") + static Stream clientHttpRequestFactories() { + return Stream.of( + new SimpleClientHttpRequestFactory(), + new HttpComponentsClientHttpRequestFactory(), + new org.springframework.http.client.Netty4ClientHttpRequestFactory(), + new OkHttp3ClientHttpRequestFactory() + ); + } + private RestTemplate template; + private ClientHttpRequestFactory clientHttpRequestFactory; + + /** - * Custom JUnit 4 rule that executes the supplied {@code Statement} in a - * try-catch block. + * Custom JUnit Jupiter extension that handles exceptions thrown by test methods. * - *

If the statement throws an {@link HttpServerErrorException}, this rule will - * throw an {@link AssertionError} that wraps the {@code HttpServerErrorException} - * using the {@link HttpServerErrorException#getResponseBodyAsString() response body} + *

If the test method throws an {@link HttpServerErrorException}, this + * extension will throw an {@link AssertionError} that wraps the + * {@code HttpServerErrorException} using the + * {@link HttpServerErrorException#getResponseBodyAsString() response body} * as the failure message. * *

This mechanism provides an actually meaningful failure message if the * test fails due to an {@code AssertionError} on the server. */ - @Rule - public TestRule serverErrorToAssertionErrorConverter = (Statement next, Description description) -> { - return new Statement() { - - @Override - public void evaluate() throws Throwable { - try { - next.evaluate(); - } - catch (HttpServerErrorException ex) { - String responseBody = ex.getResponseBodyAsString(); - String prefix = AssertionError.class.getName() + ": "; - if (responseBody.startsWith(prefix)) { - responseBody = responseBody.substring(prefix.length()); - } - throw new AssertionError(responseBody, ex); - } + @RegisterExtension + TestExecutionExceptionHandler serverErrorToAssertionErrorConverter = (context, throwable) -> { + if (throwable instanceof HttpServerErrorException) { + HttpServerErrorException ex = (HttpServerErrorException) throwable; + String responseBody = ex.getResponseBodyAsString(); + String prefix = AssertionError.class.getName() + ": "; + if (responseBody.startsWith(prefix)) { + responseBody = responseBody.substring(prefix.length()); } - }; + throw new AssertionError(responseBody, ex); + } + // Else throw as-is in order to comply with the contract of TestExecutionExceptionHandler. + throw throwable; }; - @Parameter - public ClientHttpRequestFactory clientHttpRequestFactory; - - @SuppressWarnings("deprecation") - @Parameters(name = "{0}") - public static Iterable data() { - return Arrays.asList( - new SimpleClientHttpRequestFactory(), - new HttpComponentsClientHttpRequestFactory(), - new org.springframework.http.client.Netty4ClientHttpRequestFactory(), - new OkHttp3ClientHttpRequestFactory() - ); - } - - - @Before - public void setupClient() { + private void setUpClient(ClientHttpRequestFactory clientHttpRequestFactory) { + this.clientHttpRequestFactory = clientHttpRequestFactory; this.template = new RestTemplate(this.clientHttpRequestFactory); } + @ParameterizedRestTemplateTest + void getString(ClientHttpRequestFactory clientHttpRequestFactory) { + setUpClient(clientHttpRequestFactory); - @Test - public void getString() { String s = template.getForObject(baseUrl + "/{method}", String.class, "get"); assertThat(s).as("Invalid content").isEqualTo(helloWorld); } - @Test - public void getEntity() { + @ParameterizedRestTemplateTest + void getEntity(ClientHttpRequestFactory clientHttpRequestFactory) { + setUpClient(clientHttpRequestFactory); + ResponseEntity entity = template.getForEntity(baseUrl + "/{method}", String.class, "get"); assertThat(entity.getBody()).as("Invalid content").isEqualTo(helloWorld); assertThat(entity.getHeaders().isEmpty()).as("No headers").isFalse(); @@ -157,20 +155,26 @@ public class RestTemplateIntegrationTests extends AbstractMockWebServerTestCase assertThat(entity.getStatusCode()).as("Invalid status code").isEqualTo(HttpStatus.OK); } - @Test - public void getNoResponse() { + @ParameterizedRestTemplateTest + void getNoResponse(ClientHttpRequestFactory clientHttpRequestFactory) { + setUpClient(clientHttpRequestFactory); + String s = template.getForObject(baseUrl + "/get/nothing", String.class); assertThat(s).as("Invalid content").isNull(); } - @Test - public void getNoContentTypeHeader() throws UnsupportedEncodingException { + @ParameterizedRestTemplateTest + void getNoContentTypeHeader(ClientHttpRequestFactory clientHttpRequestFactory) throws Exception { + setUpClient(clientHttpRequestFactory); + byte[] bytes = template.getForObject(baseUrl + "/get/nocontenttype", byte[].class); assertThat(bytes).as("Invalid content").isEqualTo(helloWorld.getBytes("UTF-8")); } - @Test - public void getNoContent() { + @ParameterizedRestTemplateTest + void getNoContent(ClientHttpRequestFactory clientHttpRequestFactory) { + setUpClient(clientHttpRequestFactory); + String s = template.getForObject(baseUrl + "/status/nocontent", String.class); assertThat(s).as("Invalid content").isNull(); @@ -179,8 +183,10 @@ public class RestTemplateIntegrationTests extends AbstractMockWebServerTestCase assertThat(entity.getBody()).as("Invalid content").isNull(); } - @Test - public void getNotModified() { + @ParameterizedRestTemplateTest + void getNotModified(ClientHttpRequestFactory clientHttpRequestFactory) { + setUpClient(clientHttpRequestFactory); + String s = template.getForObject(baseUrl + "/status/notmodified", String.class); assertThat(s).as("Invalid content").isNull(); @@ -189,14 +195,18 @@ public class RestTemplateIntegrationTests extends AbstractMockWebServerTestCase assertThat(entity.getBody()).as("Invalid content").isNull(); } - @Test - public void postForLocation() throws URISyntaxException { + @ParameterizedRestTemplateTest + void postForLocation(ClientHttpRequestFactory clientHttpRequestFactory) throws Exception { + setUpClient(clientHttpRequestFactory); + URI location = template.postForLocation(baseUrl + "/{method}", helloWorld, "post"); assertThat(location).as("Invalid location").isEqualTo(new URI(baseUrl + "/post/1")); } - @Test - public void postForLocationEntity() throws URISyntaxException { + @ParameterizedRestTemplateTest + void postForLocationEntity(ClientHttpRequestFactory clientHttpRequestFactory) throws Exception { + setUpClient(clientHttpRequestFactory); + HttpHeaders entityHeaders = new HttpHeaders(); entityHeaders.setContentType(new MediaType("text", "plain", StandardCharsets.ISO_8859_1)); HttpEntity entity = new HttpEntity<>(helloWorld, entityHeaders); @@ -204,14 +214,18 @@ public class RestTemplateIntegrationTests extends AbstractMockWebServerTestCase assertThat(location).as("Invalid location").isEqualTo(new URI(baseUrl + "/post/1")); } - @Test - public void postForObject() throws URISyntaxException { + @ParameterizedRestTemplateTest + void postForObject(ClientHttpRequestFactory clientHttpRequestFactory) throws Exception { + setUpClient(clientHttpRequestFactory); + String s = template.postForObject(baseUrl + "/{method}", helloWorld, String.class, "post"); assertThat(s).as("Invalid content").isEqualTo(helloWorld); } - @Test - public void patchForObject() throws URISyntaxException { + @ParameterizedRestTemplateTest + void patchForObject(ClientHttpRequestFactory clientHttpRequestFactory) throws Exception { + setUpClient(clientHttpRequestFactory); + // JDK client does not support the PATCH method assumeFalse(this.clientHttpRequestFactory instanceof SimpleClientHttpRequestFactory); @@ -219,8 +233,10 @@ public class RestTemplateIntegrationTests extends AbstractMockWebServerTestCase assertThat(s).as("Invalid content").isEqualTo(helloWorld); } - @Test - public void notFound() { + @ParameterizedRestTemplateTest + void notFound(ClientHttpRequestFactory clientHttpRequestFactory) { + setUpClient(clientHttpRequestFactory); + assertThatExceptionOfType(HttpClientErrorException.class).isThrownBy(() -> template.execute(baseUrl + "/status/notfound", HttpMethod.GET, null, null)) .satisfies(ex -> { @@ -230,8 +246,10 @@ public class RestTemplateIntegrationTests extends AbstractMockWebServerTestCase }); } - @Test - public void badRequest() { + @ParameterizedRestTemplateTest + void badRequest(ClientHttpRequestFactory clientHttpRequestFactory) { + setUpClient(clientHttpRequestFactory); + assertThatExceptionOfType(HttpClientErrorException.class).isThrownBy(() -> template.execute(baseUrl + "/status/badrequest", HttpMethod.GET, null, null)) .satisfies(ex -> { @@ -240,8 +258,10 @@ public class RestTemplateIntegrationTests extends AbstractMockWebServerTestCase }); } - @Test - public void serverError() { + @ParameterizedRestTemplateTest + void serverError(ClientHttpRequestFactory clientHttpRequestFactory) { + setUpClient(clientHttpRequestFactory); + assertThatExceptionOfType(HttpServerErrorException.class).isThrownBy(() -> template.execute(baseUrl + "/status/server", HttpMethod.GET, null, null)) .satisfies(ex -> { @@ -251,14 +271,18 @@ public class RestTemplateIntegrationTests extends AbstractMockWebServerTestCase }); } - @Test - public void optionsForAllow() throws URISyntaxException { + @ParameterizedRestTemplateTest + void optionsForAllow(ClientHttpRequestFactory clientHttpRequestFactory) throws Exception { + setUpClient(clientHttpRequestFactory); + Set allowed = template.optionsForAllow(new URI(baseUrl + "/get")); assertThat(allowed).as("Invalid response").isEqualTo(EnumSet.of(HttpMethod.GET, HttpMethod.OPTIONS, HttpMethod.HEAD, HttpMethod.TRACE)); } - @Test - public void uri() throws InterruptedException, URISyntaxException { + @ParameterizedRestTemplateTest + void uri(ClientHttpRequestFactory clientHttpRequestFactory) throws Exception { + setUpClient(clientHttpRequestFactory); + String result = template.getForObject(baseUrl + "/uri/{query}", String.class, "Z\u00fcrich"); assertThat(result).as("Invalid request URI").isEqualTo("/uri/Z%C3%BCrich"); @@ -269,20 +293,26 @@ public class RestTemplateIntegrationTests extends AbstractMockWebServerTestCase assertThat(result).as("Invalid request URI").isEqualTo("/uri/query=T%C5%8Dky%C5%8D"); } - @Test - public void multipartFormData() { + @ParameterizedRestTemplateTest + void multipartFormData(ClientHttpRequestFactory clientHttpRequestFactory) { + setUpClient(clientHttpRequestFactory); + template.postForLocation(baseUrl + "/multipartFormData", createMultipartParts()); } - @Test - public void multipartMixed() throws Exception { + @ParameterizedRestTemplateTest + void multipartMixed(ClientHttpRequestFactory clientHttpRequestFactory) throws Exception { + setUpClient(clientHttpRequestFactory); + HttpHeaders requestHeaders = new HttpHeaders(); requestHeaders.setContentType(MULTIPART_MIXED); template.postForLocation(baseUrl + "/multipartMixed", new HttpEntity<>(createMultipartParts(), requestHeaders)); } - @Test - public void multipartRelated() { + @ParameterizedRestTemplateTest + void multipartRelated(ClientHttpRequestFactory clientHttpRequestFactory) { + setUpClient(clientHttpRequestFactory); + addSupportedMediaTypeToFormHttpMessageConverter(MULTIPART_RELATED); HttpHeaders requestHeaders = new HttpHeaders(); @@ -309,8 +339,10 @@ public class RestTemplateIntegrationTests extends AbstractMockWebServerTestCase .addSupportedMediaTypes(mediaType); } - @Test - public void form() { + @ParameterizedRestTemplateTest + void form(ClientHttpRequestFactory clientHttpRequestFactory) { + setUpClient(clientHttpRequestFactory); + MultiValueMap form = new LinkedMultiValueMap<>(); form.add("name 1", "value 1"); form.add("name 2", "value 2+1"); @@ -319,8 +351,10 @@ public class RestTemplateIntegrationTests extends AbstractMockWebServerTestCase template.postForLocation(baseUrl + "/form", form); } - @Test - public void exchangeGet() throws Exception { + @ParameterizedRestTemplateTest + void exchangeGet(ClientHttpRequestFactory clientHttpRequestFactory) throws Exception { + setUpClient(clientHttpRequestFactory); + HttpHeaders requestHeaders = new HttpHeaders(); requestHeaders.set("MyHeader", "MyValue"); HttpEntity requestEntity = new HttpEntity<>(requestHeaders); @@ -329,8 +363,10 @@ public class RestTemplateIntegrationTests extends AbstractMockWebServerTestCase assertThat(response.getBody()).as("Invalid content").isEqualTo(helloWorld); } - @Test - public void exchangePost() throws Exception { + @ParameterizedRestTemplateTest + void exchangePost(ClientHttpRequestFactory clientHttpRequestFactory) throws Exception { + setUpClient(clientHttpRequestFactory); + HttpHeaders requestHeaders = new HttpHeaders(); requestHeaders.set("MyHeader", "MyValue"); requestHeaders.setContentType(MediaType.TEXT_PLAIN); @@ -340,8 +376,10 @@ public class RestTemplateIntegrationTests extends AbstractMockWebServerTestCase assertThat(result.hasBody()).isFalse(); } - @Test - public void jsonPostForObject() throws URISyntaxException { + @ParameterizedRestTemplateTest + void jsonPostForObject(ClientHttpRequestFactory clientHttpRequestFactory) throws Exception { + setUpClient(clientHttpRequestFactory); + HttpHeaders entityHeaders = new HttpHeaders(); entityHeaders.setContentType(new MediaType("application", "json", StandardCharsets.UTF_8)); MySampleBean bean = new MySampleBean(); @@ -355,8 +393,10 @@ public class RestTemplateIntegrationTests extends AbstractMockWebServerTestCase assertThat(s.contains("\"without\":\"without\"")).isTrue(); } - @Test - public void jsonPostForObjectWithJacksonView() throws URISyntaxException { + @ParameterizedRestTemplateTest + void jsonPostForObjectWithJacksonView(ClientHttpRequestFactory clientHttpRequestFactory) throws Exception { + setUpClient(clientHttpRequestFactory); + HttpHeaders entityHeaders = new HttpHeaders(); entityHeaders.setContentType(new MediaType("application", "json", StandardCharsets.UTF_8)); MySampleBean bean = new MySampleBean("with", "with", "without"); @@ -369,14 +409,18 @@ public class RestTemplateIntegrationTests extends AbstractMockWebServerTestCase assertThat(s.contains("\"without\":\"without\"")).isFalse(); } - @Test // SPR-12123 - public void serverPort() { + @ParameterizedRestTemplateTest // SPR-12123 + void serverPort(ClientHttpRequestFactory clientHttpRequestFactory) { + setUpClient(clientHttpRequestFactory); + String s = template.getForObject("http://localhost:{port}/get", String.class, port); assertThat(s).as("Invalid content").isEqualTo(helloWorld); } - @Test // SPR-13154 - public void jsonPostForObjectWithJacksonTypeInfoList() throws URISyntaxException { + @ParameterizedRestTemplateTest // SPR-13154 + void jsonPostForObjectWithJacksonTypeInfoList(ClientHttpRequestFactory clientHttpRequestFactory) throws Exception { + setUpClient(clientHttpRequestFactory); + List list = new ArrayList<>(); list.add(new Foo("foo")); list.add(new Bar("bar")); @@ -390,8 +434,10 @@ public class RestTemplateIntegrationTests extends AbstractMockWebServerTestCase assertThat(content.contains("\"type\":\"bar\"")).isTrue(); } - @Test // SPR-15015 - public void postWithoutBody() throws Exception { + @ParameterizedRestTemplateTest // SPR-15015 + void postWithoutBody(ClientHttpRequestFactory clientHttpRequestFactory) throws Exception { + setUpClient(clientHttpRequestFactory); + assertThat(template.postForObject(baseUrl + "/jsonpost", null, String.class)).isNull(); } diff --git a/spring-web/src/test/java/org/springframework/web/client/RestTemplateTests.java b/spring-web/src/test/java/org/springframework/web/client/RestTemplateTests.java index 62b1c2e1e49..7648eab8b1a 100644 --- a/spring-web/src/test/java/org/springframework/web/client/RestTemplateTests.java +++ b/spring-web/src/test/java/org/springframework/web/client/RestTemplateTests.java @@ -27,8 +27,8 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.ParameterizedTypeReference; import org.springframework.http.HttpEntity; @@ -90,7 +90,7 @@ public class RestTemplateTests { private HttpMessageConverter converter; - @Before + @BeforeEach public void setup() { requestFactory = mock(ClientHttpRequestFactory.class); request = mock(ClientHttpRequest.class); diff --git a/spring-web/src/test/java/org/springframework/web/context/ContextLoaderInitializerTests.java b/spring-web/src/test/java/org/springframework/web/context/ContextLoaderInitializerTests.java index 3cd28430f16..6a93e5f18c3 100644 --- a/spring-web/src/test/java/org/springframework/web/context/ContextLoaderInitializerTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/ContextLoaderInitializerTests.java @@ -20,8 +20,8 @@ import java.util.EventListener; import javax.servlet.ServletContextEvent; import javax.servlet.ServletException; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockServletContext; import org.springframework.web.context.support.StaticWebApplicationContext; @@ -44,7 +44,7 @@ public class ContextLoaderInitializerTests { private EventListener eventListener; - @Before + @BeforeEach public void setUp() throws Exception { servletContext = new MyMockServletContext(); initializer = new MyContextLoaderInitializer(); diff --git a/spring-web/src/test/java/org/springframework/web/context/request/RequestAndSessionScopedBeanTests.java b/spring-web/src/test/java/org/springframework/web/context/request/RequestAndSessionScopedBeanTests.java index 6c9597b3e68..c3d0178a969 100644 --- a/spring-web/src/test/java/org/springframework/web/context/request/RequestAndSessionScopedBeanTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/request/RequestAndSessionScopedBeanTests.java @@ -18,7 +18,7 @@ package org.springframework.web.context.request; import javax.servlet.http.HttpServletRequest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.support.RootBeanDefinition; diff --git a/spring-web/src/test/java/org/springframework/web/context/request/RequestContextListenerTests.java b/spring-web/src/test/java/org/springframework/web/context/request/RequestContextListenerTests.java index 72b95e4d803..a8b4166151c 100644 --- a/spring-web/src/test/java/org/springframework/web/context/request/RequestContextListenerTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/request/RequestContextListenerTests.java @@ -18,7 +18,7 @@ package org.springframework.web.context.request; import javax.servlet.ServletRequestEvent; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.task.MockRunnable; import org.springframework.mock.web.test.MockHttpServletRequest; diff --git a/spring-web/src/test/java/org/springframework/web/context/request/RequestScopeTests.java b/spring-web/src/test/java/org/springframework/web/context/request/RequestScopeTests.java index d65a6a5697a..902475d381d 100644 --- a/spring-web/src/test/java/org/springframework/web/context/request/RequestScopeTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/request/RequestScopeTests.java @@ -16,9 +16,9 @@ package org.springframework.web.context.request; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.BeanCurrentlyInCreationException; @@ -46,7 +46,7 @@ public class RequestScopeTests { private final DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory(); - @Before + @BeforeEach public void setup() throws Exception { this.beanFactory.registerScope("request", new RequestScope()); this.beanFactory.setBeanExpressionResolver(new StandardBeanExpressionResolver()); @@ -55,7 +55,7 @@ public class RequestScopeTests { this.beanFactory.preInstantiateSingletons(); } - @After + @AfterEach public void resetRequestAttributes() { RequestContextHolder.setRequestAttributes(null); } diff --git a/spring-web/src/test/java/org/springframework/web/context/request/RequestScopedProxyTests.java b/spring-web/src/test/java/org/springframework/web/context/request/RequestScopedProxyTests.java index 2d67993ca68..f021e0be4c0 100644 --- a/spring-web/src/test/java/org/springframework/web/context/request/RequestScopedProxyTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/request/RequestScopedProxyTests.java @@ -16,8 +16,8 @@ package org.springframework.web.context.request; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.aop.support.AopUtils; import org.springframework.beans.factory.config.BeanDefinition; @@ -41,7 +41,7 @@ public class RequestScopedProxyTests { private final DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory(); - @Before + @BeforeEach public void setup() { this.beanFactory.registerScope("request", new RequestScope()); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(this.beanFactory); diff --git a/spring-web/src/test/java/org/springframework/web/context/request/ServletRequestAttributesTests.java b/spring-web/src/test/java/org/springframework/web/context/request/ServletRequestAttributesTests.java index 2d3fa4d2a97..7b869cb0439 100644 --- a/spring-web/src/test/java/org/springframework/web/context/request/ServletRequestAttributesTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/request/ServletRequestAttributesTests.java @@ -21,7 +21,7 @@ import java.math.BigInteger; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockHttpSession; diff --git a/spring-web/src/test/java/org/springframework/web/context/request/ServletWebRequestHttpMethodsTests.java b/spring-web/src/test/java/org/springframework/web/context/request/ServletWebRequestHttpMethodsTests.java index d07c4069f4a..d5a39c39b01 100644 --- a/spring-web/src/test/java/org/springframework/web/context/request/ServletWebRequestHttpMethodsTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/request/ServletWebRequestHttpMethodsTests.java @@ -16,16 +16,15 @@ package org.springframework.web.context.request; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; import java.time.ZonedDateTime; -import java.util.Arrays; import java.util.Date; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockHttpServletResponse; @@ -39,42 +38,25 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Juergen Hoeller * @author Brian Clozel * @author Markus Malkusch + * @author Sam Brannen */ -@RunWith(Parameterized.class) public class ServletWebRequestHttpMethodsTests { private static final String CURRENT_TIME = "Wed, 9 Apr 2014 09:57:42 GMT"; - private MockHttpServletRequest servletRequest; + private final MockHttpServletRequest servletRequest = new MockHttpServletRequest(); - private MockHttpServletResponse servletResponse; + private final MockHttpServletResponse servletResponse = new MockHttpServletResponse(); - private ServletWebRequest request; + private final ServletWebRequest request = new ServletWebRequest(servletRequest, servletResponse); - private Date currentDate; + private final Date currentDate = new Date(); - @Parameter - public String method; - @Parameters(name = "{0}") - static public Iterable safeMethods() { - return Arrays.asList(new Object[][] { - {"GET"}, {"HEAD"} - }); - } - - - @Before - public void setup() { - currentDate = new Date(); - servletRequest = new MockHttpServletRequest(method, "https://example.org"); - servletResponse = new MockHttpServletResponse(); - request = new ServletWebRequest(servletRequest, servletResponse); - } + @ParameterizedHttpMethodTest + public void checkNotModifiedNon2xxStatus(String method) { + setUpRequest(method); - - @Test - public void checkNotModifiedNon2xxStatus() { long epochTime = currentDate.getTime(); servletRequest.addHeader("If-Modified-Since", epochTime); servletResponse.setStatus(304); @@ -84,8 +66,10 @@ public class ServletWebRequestHttpMethodsTests { assertThat(servletResponse.getHeader("Last-Modified")).isNull(); } - @Test // SPR-13516 - public void checkNotModifiedInvalidStatus() { + @ParameterizedHttpMethodTest // SPR-13516 + public void checkNotModifiedInvalidStatus(String method) { + setUpRequest(method); + long epochTime = currentDate.getTime(); servletRequest.addHeader("If-Modified-Since", epochTime); servletResponse.setStatus(0); @@ -93,8 +77,10 @@ public class ServletWebRequestHttpMethodsTests { assertThat(request.checkNotModified(epochTime)).isFalse(); } - @Test // SPR-14559 - public void checkNotModifiedInvalidIfNoneMatchHeader() { + @ParameterizedHttpMethodTest // SPR-14559 + public void checkNotModifiedInvalidIfNoneMatchHeader(String method) { + setUpRequest(method); + String etag = "\"etagvalue\""; servletRequest.addHeader("If-None-Match", "missingquotes"); assertThat(request.checkNotModified(etag)).isFalse(); @@ -102,8 +88,10 @@ public class ServletWebRequestHttpMethodsTests { assertThat(servletResponse.getHeader("ETag")).isEqualTo(etag); } - @Test - public void checkNotModifiedHeaderAlreadySet() { + @ParameterizedHttpMethodTest + public void checkNotModifiedHeaderAlreadySet(String method) { + setUpRequest(method); + long epochTime = currentDate.getTime(); servletRequest.addHeader("If-Modified-Since", epochTime); servletResponse.addHeader("Last-Modified", CURRENT_TIME); @@ -114,8 +102,10 @@ public class ServletWebRequestHttpMethodsTests { assertThat(servletResponse.getHeader("Last-Modified")).isEqualTo(CURRENT_TIME); } - @Test - public void checkNotModifiedTimestamp() { + @ParameterizedHttpMethodTest + public void checkNotModifiedTimestamp(String method) { + setUpRequest(method); + long epochTime = currentDate.getTime(); servletRequest.addHeader("If-Modified-Since", epochTime); @@ -124,8 +114,10 @@ public class ServletWebRequestHttpMethodsTests { assertThat(servletResponse.getDateHeader("Last-Modified") / 1000).isEqualTo(currentDate.getTime() / 1000); } - @Test - public void checkModifiedTimestamp() { + @ParameterizedHttpMethodTest + public void checkModifiedTimestamp(String method) { + setUpRequest(method); + long oneMinuteAgo = currentDate.getTime() - (1000 * 60); servletRequest.addHeader("If-Modified-Since", oneMinuteAgo); @@ -134,8 +126,10 @@ public class ServletWebRequestHttpMethodsTests { assertThat(servletResponse.getDateHeader("Last-Modified") / 1000).isEqualTo(currentDate.getTime() / 1000); } - @Test - public void checkNotModifiedETag() { + @ParameterizedHttpMethodTest + public void checkNotModifiedETag(String method) { + setUpRequest(method); + String etag = "\"Foo\""; servletRequest.addHeader("If-None-Match", etag); @@ -144,8 +138,10 @@ public class ServletWebRequestHttpMethodsTests { assertThat(servletResponse.getHeader("ETag")).isEqualTo(etag); } - @Test - public void checkNotModifiedETagWithSeparatorChars() { + @ParameterizedHttpMethodTest + public void checkNotModifiedETagWithSeparatorChars(String method) { + setUpRequest(method); + String etag = "\"Foo, Bar\""; servletRequest.addHeader("If-None-Match", etag); @@ -155,8 +151,10 @@ public class ServletWebRequestHttpMethodsTests { } - @Test - public void checkModifiedETag() { + @ParameterizedHttpMethodTest + public void checkModifiedETag(String method) { + setUpRequest(method); + String currentETag = "\"Foo\""; String oldETag = "Bar"; servletRequest.addHeader("If-None-Match", oldETag); @@ -166,8 +164,10 @@ public class ServletWebRequestHttpMethodsTests { assertThat(servletResponse.getHeader("ETag")).isEqualTo(currentETag); } - @Test - public void checkNotModifiedUnpaddedETag() { + @ParameterizedHttpMethodTest + public void checkNotModifiedUnpaddedETag(String method) { + setUpRequest(method); + String etag = "Foo"; String paddedETag = String.format("\"%s\"", etag); servletRequest.addHeader("If-None-Match", paddedETag); @@ -177,8 +177,10 @@ public class ServletWebRequestHttpMethodsTests { assertThat(servletResponse.getHeader("ETag")).isEqualTo(paddedETag); } - @Test - public void checkModifiedUnpaddedETag() { + @ParameterizedHttpMethodTest + public void checkModifiedUnpaddedETag(String method) { + setUpRequest(method); + String currentETag = "Foo"; String oldETag = "Bar"; servletRequest.addHeader("If-None-Match", oldETag); @@ -188,8 +190,10 @@ public class ServletWebRequestHttpMethodsTests { assertThat(servletResponse.getHeader("ETag")).isEqualTo(String.format("\"%s\"", currentETag)); } - @Test - public void checkNotModifiedWildcardIsIgnored() { + @ParameterizedHttpMethodTest + public void checkNotModifiedWildcardIsIgnored(String method) { + setUpRequest(method); + String etag = "\"Foo\""; servletRequest.addHeader("If-None-Match", "*"); @@ -198,8 +202,10 @@ public class ServletWebRequestHttpMethodsTests { assertThat(servletResponse.getHeader("ETag")).isEqualTo(etag); } - @Test - public void checkNotModifiedETagAndTimestamp() { + @ParameterizedHttpMethodTest + public void checkNotModifiedETagAndTimestamp(String method) { + setUpRequest(method); + String etag = "\"Foo\""; servletRequest.addHeader("If-None-Match", etag); servletRequest.addHeader("If-Modified-Since", currentDate.getTime()); @@ -210,8 +216,10 @@ public class ServletWebRequestHttpMethodsTests { assertThat(servletResponse.getDateHeader("Last-Modified") / 1000).isEqualTo(currentDate.getTime() / 1000); } - @Test // SPR-14224 - public void checkNotModifiedETagAndModifiedTimestamp() { + @ParameterizedHttpMethodTest // SPR-14224 + public void checkNotModifiedETagAndModifiedTimestamp(String method) { + setUpRequest(method); + String etag = "\"Foo\""; servletRequest.addHeader("If-None-Match", etag); long currentEpoch = currentDate.getTime(); @@ -224,8 +232,10 @@ public class ServletWebRequestHttpMethodsTests { assertThat(servletResponse.getDateHeader("Last-Modified") / 1000).isEqualTo(currentDate.getTime() / 1000); } - @Test - public void checkModifiedETagAndNotModifiedTimestamp() { + @ParameterizedHttpMethodTest + public void checkModifiedETagAndNotModifiedTimestamp(String method) { + setUpRequest(method); + String currentETag = "\"Foo\""; String oldETag = "\"Bar\""; servletRequest.addHeader("If-None-Match", oldETag); @@ -238,8 +248,10 @@ public class ServletWebRequestHttpMethodsTests { assertThat(servletResponse.getDateHeader("Last-Modified") / 1000).isEqualTo(currentDate.getTime() / 1000); } - @Test - public void checkNotModifiedETagWeakStrong() { + @ParameterizedHttpMethodTest + public void checkNotModifiedETagWeakStrong(String method) { + setUpRequest(method); + String etag = "\"Foo\""; String weakETag = String.format("W/%s", etag); servletRequest.addHeader("If-None-Match", etag); @@ -249,8 +261,10 @@ public class ServletWebRequestHttpMethodsTests { assertThat(servletResponse.getHeader("ETag")).isEqualTo(weakETag); } - @Test - public void checkNotModifiedETagStrongWeak() { + @ParameterizedHttpMethodTest + public void checkNotModifiedETagStrongWeak(String method) { + setUpRequest(method); + String etag = "\"Foo\""; servletRequest.addHeader("If-None-Match", String.format("W/%s", etag)); @@ -259,8 +273,10 @@ public class ServletWebRequestHttpMethodsTests { assertThat(servletResponse.getHeader("ETag")).isEqualTo(etag); } - @Test - public void checkNotModifiedMultipleETags() { + @ParameterizedHttpMethodTest + public void checkNotModifiedMultipleETags(String method) { + setUpRequest(method); + String etag = "\"Bar\""; String multipleETags = String.format("\"Foo\", %s", etag); servletRequest.addHeader("If-None-Match", multipleETags); @@ -270,8 +286,10 @@ public class ServletWebRequestHttpMethodsTests { assertThat(servletResponse.getHeader("ETag")).isEqualTo(etag); } - @Test - public void checkNotModifiedTimestampWithLengthPart() { + @ParameterizedHttpMethodTest + public void checkNotModifiedTimestampWithLengthPart(String method) { + setUpRequest(method); + long epochTime = ZonedDateTime.parse(CURRENT_TIME, RFC_1123_DATE_TIME).toInstant().toEpochMilli(); servletRequest.setMethod("GET"); servletRequest.addHeader("If-Modified-Since", "Wed, 09 Apr 2014 09:57:42 GMT; length=13774"); @@ -281,8 +299,10 @@ public class ServletWebRequestHttpMethodsTests { assertThat(servletResponse.getDateHeader("Last-Modified") / 1000).isEqualTo(epochTime / 1000); } - @Test - public void checkModifiedTimestampWithLengthPart() { + @ParameterizedHttpMethodTest + public void checkModifiedTimestampWithLengthPart(String method) { + setUpRequest(method); + long epochTime = ZonedDateTime.parse(CURRENT_TIME, RFC_1123_DATE_TIME).toInstant().toEpochMilli(); servletRequest.setMethod("GET"); servletRequest.addHeader("If-Modified-Since", "Wed, 08 Apr 2014 09:57:42 GMT; length=13774"); @@ -292,8 +312,10 @@ public class ServletWebRequestHttpMethodsTests { assertThat(servletResponse.getDateHeader("Last-Modified") / 1000).isEqualTo(epochTime / 1000); } - @Test - public void checkNotModifiedTimestampConditionalPut() { + @ParameterizedHttpMethodTest + public void checkNotModifiedTimestampConditionalPut(String method) { + setUpRequest(method); + long currentEpoch = currentDate.getTime(); long oneMinuteAgo = currentEpoch - (1000 * 60); servletRequest.setMethod("PUT"); @@ -304,8 +326,10 @@ public class ServletWebRequestHttpMethodsTests { assertThat(servletResponse.getHeader("Last-Modified")).isEqualTo(null); } - @Test - public void checkNotModifiedTimestampConditionalPutConflict() { + @ParameterizedHttpMethodTest + public void checkNotModifiedTimestampConditionalPutConflict(String method) { + setUpRequest(method); + long currentEpoch = currentDate.getTime(); long oneMinuteAgo = currentEpoch - (1000 * 60); servletRequest.setMethod("PUT"); @@ -316,4 +340,17 @@ public class ServletWebRequestHttpMethodsTests { assertThat(servletResponse.getHeader("Last-Modified")).isEqualTo(null); } + private void setUpRequest(String method) { + this.servletRequest.setMethod(method); + this.servletRequest.setRequestURI("https://example.org"); + } + + + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.METHOD) + @ParameterizedTest + @ValueSource(strings = { "GET", "HEAD" }) + @interface ParameterizedHttpMethodTest { + } + } diff --git a/spring-web/src/test/java/org/springframework/web/context/request/ServletWebRequestTests.java b/spring-web/src/test/java/org/springframework/web/context/request/ServletWebRequestTests.java index cbf47b625c6..707b858989c 100644 --- a/spring-web/src/test/java/org/springframework/web/context/request/ServletWebRequestTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/request/ServletWebRequestTests.java @@ -25,8 +25,8 @@ import javax.servlet.http.HttpServletRequestWrapper; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponseWrapper; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockHttpServletResponse; @@ -46,7 +46,7 @@ public class ServletWebRequestTests { private ServletWebRequest request; - @Before + @BeforeEach public void setup() { servletRequest = new MockHttpServletRequest(); servletResponse = new MockHttpServletResponse(); diff --git a/spring-web/src/test/java/org/springframework/web/context/request/SessionScopeTests.java b/spring-web/src/test/java/org/springframework/web/context/request/SessionScopeTests.java index 3991dd09f29..9d296bbe642 100644 --- a/spring-web/src/test/java/org/springframework/web/context/request/SessionScopeTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/request/SessionScopeTests.java @@ -19,9 +19,9 @@ package org.springframework.web.context.request; import java.io.Serializable; import java.util.concurrent.atomic.AtomicInteger; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanNameAware; @@ -48,14 +48,14 @@ public class SessionScopeTests { private final DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory(); - @Before + @BeforeEach public void setup() throws Exception { this.beanFactory.registerScope("session", new SessionScope()); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(this.beanFactory); reader.loadBeanDefinitions(new ClassPathResource("sessionScopeTests.xml", getClass())); } - @After + @AfterEach public void resetRequestAttributes() { RequestContextHolder.setRequestAttributes(null); } diff --git a/spring-web/src/test/java/org/springframework/web/context/request/WebApplicationContextScopeTests.java b/spring-web/src/test/java/org/springframework/web/context/request/WebApplicationContextScopeTests.java index a762d14a8e2..255889c4526 100644 --- a/spring-web/src/test/java/org/springframework/web/context/request/WebApplicationContextScopeTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/request/WebApplicationContextScopeTests.java @@ -18,7 +18,7 @@ package org.springframework.web.context.request; import javax.servlet.ServletContextEvent; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.GenericBeanDefinition; import org.springframework.mock.web.test.MockHttpServletRequest; diff --git a/spring-web/src/test/java/org/springframework/web/context/request/async/DeferredResultTests.java b/spring-web/src/test/java/org/springframework/web/context/request/async/DeferredResultTests.java index 1b7fea4aabe..e079c5beb4d 100644 --- a/spring-web/src/test/java/org/springframework/web/context/request/async/DeferredResultTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/request/async/DeferredResultTests.java @@ -18,7 +18,7 @@ package org.springframework.web.context.request.async; import java.util.function.Consumer; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.web.context.request.async.DeferredResult.DeferredResultHandler; diff --git a/spring-web/src/test/java/org/springframework/web/context/request/async/StandardServletAsyncWebRequestTests.java b/spring-web/src/test/java/org/springframework/web/context/request/async/StandardServletAsyncWebRequestTests.java index 4c34d6e3efc..fd647444241 100644 --- a/spring-web/src/test/java/org/springframework/web/context/request/async/StandardServletAsyncWebRequestTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/request/async/StandardServletAsyncWebRequestTests.java @@ -19,8 +19,8 @@ package org.springframework.web.context.request.async; import java.util.function.Consumer; import javax.servlet.AsyncEvent; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockAsyncContext; import org.springframework.mock.web.test.MockHttpServletRequest; @@ -44,7 +44,7 @@ public class StandardServletAsyncWebRequestTests { private MockHttpServletResponse response; - @Before + @BeforeEach public void setup() { this.request = new MockHttpServletRequest(); this.request.setAsyncSupported(true); diff --git a/spring-web/src/test/java/org/springframework/web/context/request/async/WebAsyncManagerErrorTests.java b/spring-web/src/test/java/org/springframework/web/context/request/async/WebAsyncManagerErrorTests.java index edb534676d4..4eb1b5ce4ac 100644 --- a/spring-web/src/test/java/org/springframework/web/context/request/async/WebAsyncManagerErrorTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/request/async/WebAsyncManagerErrorTests.java @@ -20,8 +20,8 @@ import java.util.concurrent.Callable; import java.util.function.Consumer; import javax.servlet.AsyncEvent; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.task.AsyncTaskExecutor; import org.springframework.mock.web.test.MockAsyncContext; @@ -53,7 +53,7 @@ public class WebAsyncManagerErrorTests { private MockHttpServletResponse servletResponse; - @Before + @BeforeEach public void setup() { this.servletRequest = new MockHttpServletRequest("GET", "/test"); this.servletRequest.setAsyncSupported(true); diff --git a/spring-web/src/test/java/org/springframework/web/context/request/async/WebAsyncManagerTests.java b/spring-web/src/test/java/org/springframework/web/context/request/async/WebAsyncManagerTests.java index 51bc66d29a7..778bbc0b9a2 100644 --- a/spring-web/src/test/java/org/springframework/web/context/request/async/WebAsyncManagerTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/request/async/WebAsyncManagerTests.java @@ -20,8 +20,8 @@ import java.util.concurrent.Callable; import java.util.function.Consumer; import javax.servlet.http.HttpServletRequest; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.task.AsyncTaskExecutor; import org.springframework.core.task.SimpleAsyncTaskExecutor; @@ -53,7 +53,7 @@ public class WebAsyncManagerTests { private MockHttpServletRequest servletRequest; - @Before + @BeforeEach public void setup() { this.servletRequest = new MockHttpServletRequest(); this.asyncManager = WebAsyncUtils.getAsyncManager(servletRequest); diff --git a/spring-web/src/test/java/org/springframework/web/context/request/async/WebAsyncManagerTimeoutTests.java b/spring-web/src/test/java/org/springframework/web/context/request/async/WebAsyncManagerTimeoutTests.java index 5bd37ecee32..e9008a48114 100644 --- a/spring-web/src/test/java/org/springframework/web/context/request/async/WebAsyncManagerTimeoutTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/request/async/WebAsyncManagerTimeoutTests.java @@ -20,8 +20,8 @@ import java.util.concurrent.Callable; import java.util.concurrent.Future; import javax.servlet.AsyncEvent; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.task.AsyncTaskExecutor; import org.springframework.mock.web.test.MockAsyncContext; @@ -56,7 +56,7 @@ public class WebAsyncManagerTimeoutTests { private MockHttpServletResponse servletResponse; - @Before + @BeforeEach public void setup() { this.servletRequest = new MockHttpServletRequest("GET", "/test"); this.servletRequest.setAsyncSupported(true); diff --git a/spring-web/src/test/java/org/springframework/web/context/support/AnnotationConfigWebApplicationContextTests.java b/spring-web/src/test/java/org/springframework/web/context/support/AnnotationConfigWebApplicationContextTests.java index 05040d586e8..106eb25c63a 100644 --- a/spring-web/src/test/java/org/springframework/web/context/support/AnnotationConfigWebApplicationContextTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/support/AnnotationConfigWebApplicationContextTests.java @@ -16,7 +16,7 @@ package org.springframework.web.context.support; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.support.BeanDefinitionRegistry; diff --git a/spring-web/src/test/java/org/springframework/web/context/support/ResourceTests.java b/spring-web/src/test/java/org/springframework/web/context/support/ResourceTests.java index 885a70f658a..ead4700185d 100644 --- a/spring-web/src/test/java/org/springframework/web/context/support/ResourceTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/support/ResourceTests.java @@ -18,7 +18,7 @@ package org.springframework.web.context.support; import java.io.IOException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.io.Resource; import org.springframework.mock.web.test.MockServletContext; diff --git a/spring-web/src/test/java/org/springframework/web/context/support/Spr8510Tests.java b/spring-web/src/test/java/org/springframework/web/context/support/Spr8510Tests.java index 07a57e521cf..094c042455a 100644 --- a/spring-web/src/test/java/org/springframework/web/context/support/Spr8510Tests.java +++ b/spring-web/src/test/java/org/springframework/web/context/support/Spr8510Tests.java @@ -18,7 +18,7 @@ package org.springframework.web.context.support; import javax.servlet.ServletContextEvent; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.annotation.ClassPathBeanDefinitionScanner; import org.springframework.mock.web.test.MockServletContext; diff --git a/spring-web/src/test/java/org/springframework/web/context/support/SpringBeanAutowiringSupportTests.java b/spring-web/src/test/java/org/springframework/web/context/support/SpringBeanAutowiringSupportTests.java index 52b408f9102..1ba05f1dd06 100644 --- a/spring-web/src/test/java/org/springframework/web/context/support/SpringBeanAutowiringSupportTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/support/SpringBeanAutowiringSupportTests.java @@ -16,7 +16,7 @@ package org.springframework.web.context.support; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.MutablePropertyValues; import org.springframework.beans.factory.annotation.Autowired; diff --git a/spring-web/src/test/java/org/springframework/web/context/support/StandardServletEnvironmentTests.java b/spring-web/src/test/java/org/springframework/web/context/support/StandardServletEnvironmentTests.java index 683a63cf20a..6b25e4aeb8a 100644 --- a/spring-web/src/test/java/org/springframework/web/context/support/StandardServletEnvironmentTests.java +++ b/spring-web/src/test/java/org/springframework/web/context/support/StandardServletEnvironmentTests.java @@ -16,7 +16,7 @@ package org.springframework.web.context.support; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.core.env.MutablePropertySources; diff --git a/spring-web/src/test/java/org/springframework/web/cors/CorsConfigurationTests.java b/spring-web/src/test/java/org/springframework/web/cors/CorsConfigurationTests.java index 0770732fcef..c18a456111b 100644 --- a/spring-web/src/test/java/org/springframework/web/cors/CorsConfigurationTests.java +++ b/spring-web/src/test/java/org/springframework/web/cors/CorsConfigurationTests.java @@ -20,7 +20,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpMethod; diff --git a/spring-web/src/test/java/org/springframework/web/cors/CorsUtilsTests.java b/spring-web/src/test/java/org/springframework/web/cors/CorsUtilsTests.java index 57faad68e43..defa940ca87 100644 --- a/spring-web/src/test/java/org/springframework/web/cors/CorsUtilsTests.java +++ b/spring-web/src/test/java/org/springframework/web/cors/CorsUtilsTests.java @@ -16,7 +16,7 @@ package org.springframework.web.cors; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; diff --git a/spring-web/src/test/java/org/springframework/web/cors/DefaultCorsProcessorTests.java b/spring-web/src/test/java/org/springframework/web/cors/DefaultCorsProcessorTests.java index aab829d3fd7..72970cd7b14 100644 --- a/spring-web/src/test/java/org/springframework/web/cors/DefaultCorsProcessorTests.java +++ b/spring-web/src/test/java/org/springframework/web/cors/DefaultCorsProcessorTests.java @@ -18,8 +18,8 @@ package org.springframework.web.cors; import javax.servlet.http.HttpServletResponse; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; @@ -46,7 +46,7 @@ public class DefaultCorsProcessorTests { private CorsConfiguration conf; - @Before + @BeforeEach public void setup() { this.request = new MockHttpServletRequest(); this.request.setRequestURI("/test.html"); diff --git a/spring-web/src/test/java/org/springframework/web/cors/UrlBasedCorsConfigurationSourceTests.java b/spring-web/src/test/java/org/springframework/web/cors/UrlBasedCorsConfigurationSourceTests.java index 71d25291f63..5ef4ca99a73 100644 --- a/spring-web/src/test/java/org/springframework/web/cors/UrlBasedCorsConfigurationSourceTests.java +++ b/spring-web/src/test/java/org/springframework/web/cors/UrlBasedCorsConfigurationSourceTests.java @@ -16,7 +16,7 @@ package org.springframework.web.cors; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpMethod; import org.springframework.mock.web.test.MockHttpServletRequest; diff --git a/spring-web/src/test/java/org/springframework/web/cors/reactive/CorsUtilsTests.java b/spring-web/src/test/java/org/springframework/web/cors/reactive/CorsUtilsTests.java index 30418703e1c..5b530a2ae25 100644 --- a/spring-web/src/test/java/org/springframework/web/cors/reactive/CorsUtilsTests.java +++ b/spring-web/src/test/java/org/springframework/web/cors/reactive/CorsUtilsTests.java @@ -18,7 +18,7 @@ package org.springframework.web.cors.reactive; import java.util.concurrent.atomic.AtomicReference; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; import org.springframework.http.HttpHeaders; diff --git a/spring-web/src/test/java/org/springframework/web/cors/reactive/CorsWebFilterTests.java b/spring-web/src/test/java/org/springframework/web/cors/reactive/CorsWebFilterTests.java index 0254a016a32..d66fb585535 100644 --- a/spring-web/src/test/java/org/springframework/web/cors/reactive/CorsWebFilterTests.java +++ b/spring-web/src/test/java/org/springframework/web/cors/reactive/CorsWebFilterTests.java @@ -20,8 +20,8 @@ import java.io.IOException; import java.util.Arrays; import javax.servlet.ServletException; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; import org.springframework.http.HttpHeaders; @@ -51,7 +51,7 @@ public class CorsWebFilterTests { private final CorsConfiguration config = new CorsConfiguration(); - @Before + @BeforeEach public void setup() throws Exception { config.setAllowedOrigins(Arrays.asList("https://domain1.com", "https://domain2.com")); config.setAllowedMethods(Arrays.asList("GET", "POST")); diff --git a/spring-web/src/test/java/org/springframework/web/cors/reactive/DefaultCorsProcessorTests.java b/spring-web/src/test/java/org/springframework/web/cors/reactive/DefaultCorsProcessorTests.java index 8e8bbf5f7c4..42d46222f38 100644 --- a/spring-web/src/test/java/org/springframework/web/cors/reactive/DefaultCorsProcessorTests.java +++ b/spring-web/src/test/java/org/springframework/web/cors/reactive/DefaultCorsProcessorTests.java @@ -16,8 +16,8 @@ package org.springframework.web.cors.reactive; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; @@ -48,7 +48,7 @@ public class DefaultCorsProcessorTests { private CorsConfiguration conf; - @Before + @BeforeEach public void setup() { this.conf = new CorsConfiguration(); this.processor = new DefaultCorsProcessor(); diff --git a/spring-web/src/test/java/org/springframework/web/cors/reactive/UrlBasedCorsConfigurationSourceTests.java b/spring-web/src/test/java/org/springframework/web/cors/reactive/UrlBasedCorsConfigurationSourceTests.java index 34f1de0a3a0..e05e8652d9e 100644 --- a/spring-web/src/test/java/org/springframework/web/cors/reactive/UrlBasedCorsConfigurationSourceTests.java +++ b/spring-web/src/test/java/org/springframework/web/cors/reactive/UrlBasedCorsConfigurationSourceTests.java @@ -16,7 +16,7 @@ package org.springframework.web.cors.reactive; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; import org.springframework.mock.web.test.server.MockServerWebExchange; diff --git a/spring-web/src/test/java/org/springframework/web/filter/CharacterEncodingFilterTests.java b/spring-web/src/test/java/org/springframework/web/filter/CharacterEncodingFilterTests.java index cbd989b6e96..7ee5c856848 100644 --- a/spring-web/src/test/java/org/springframework/web/filter/CharacterEncodingFilterTests.java +++ b/spring-web/src/test/java/org/springframework/web/filter/CharacterEncodingFilterTests.java @@ -20,7 +20,7 @@ import javax.servlet.FilterChain; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockFilterConfig; import org.springframework.mock.web.test.MockHttpServletResponse; diff --git a/spring-web/src/test/java/org/springframework/web/filter/CompositeFilterTests.java b/spring-web/src/test/java/org/springframework/web/filter/CompositeFilterTests.java index c2a02176d37..0e180d4e25b 100644 --- a/spring-web/src/test/java/org/springframework/web/filter/CompositeFilterTests.java +++ b/spring-web/src/test/java/org/springframework/web/filter/CompositeFilterTests.java @@ -26,7 +26,7 @@ import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockFilterConfig; import org.springframework.mock.web.test.MockHttpServletRequest; diff --git a/spring-web/src/test/java/org/springframework/web/filter/CorsFilterTests.java b/spring-web/src/test/java/org/springframework/web/filter/CorsFilterTests.java index 3b73b370a18..9bc60e8dcb7 100644 --- a/spring-web/src/test/java/org/springframework/web/filter/CorsFilterTests.java +++ b/spring-web/src/test/java/org/springframework/web/filter/CorsFilterTests.java @@ -21,8 +21,8 @@ import java.util.Arrays; import javax.servlet.FilterChain; import javax.servlet.ServletException; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; @@ -43,7 +43,7 @@ public class CorsFilterTests { private final CorsConfiguration config = new CorsConfiguration(); - @Before + @BeforeEach public void setup() throws Exception { config.setAllowedOrigins(Arrays.asList("https://domain1.com", "https://domain2.com")); config.setAllowedMethods(Arrays.asList("GET", "POST")); diff --git a/spring-web/src/test/java/org/springframework/web/filter/DelegatingFilterProxyTests.java b/spring-web/src/test/java/org/springframework/web/filter/DelegatingFilterProxyTests.java index a55a78396fe..f06c889a553 100644 --- a/spring-web/src/test/java/org/springframework/web/filter/DelegatingFilterProxyTests.java +++ b/spring-web/src/test/java/org/springframework/web/filter/DelegatingFilterProxyTests.java @@ -25,7 +25,7 @@ import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockFilterConfig; import org.springframework.mock.web.test.MockHttpServletRequest; diff --git a/spring-web/src/test/java/org/springframework/web/filter/FormContentFilterTests.java b/spring-web/src/test/java/org/springframework/web/filter/FormContentFilterTests.java index d82590472b5..d583610b252 100644 --- a/spring-web/src/test/java/org/springframework/web/filter/FormContentFilterTests.java +++ b/spring-web/src/test/java/org/springframework/web/filter/FormContentFilterTests.java @@ -21,8 +21,8 @@ import java.util.Collections; import java.util.List; import java.util.Map; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpMethod; import org.springframework.mock.web.test.MockFilterChain; @@ -47,7 +47,7 @@ public class FormContentFilterTests { private MockFilterChain filterChain; - @Before + @BeforeEach public void setup() { this.request = new MockHttpServletRequest("PUT", "/"); this.request.setContentType("application/x-www-form-urlencoded; charset=ISO-8859-1"); diff --git a/spring-web/src/test/java/org/springframework/web/filter/ForwardedHeaderFilterTests.java b/spring-web/src/test/java/org/springframework/web/filter/ForwardedHeaderFilterTests.java index b99a757b03e..0de9886792c 100644 --- a/spring-web/src/test/java/org/springframework/web/filter/ForwardedHeaderFilterTests.java +++ b/spring-web/src/test/java/org/springframework/web/filter/ForwardedHeaderFilterTests.java @@ -26,8 +26,8 @@ import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockFilterChain; import org.springframework.mock.web.test.MockHttpServletRequest; @@ -59,7 +59,7 @@ public class ForwardedHeaderFilterTests { private MockFilterChain filterChain; - @Before + @BeforeEach @SuppressWarnings("serial") public void setup() throws Exception { this.request = new MockHttpServletRequest(); diff --git a/spring-web/src/test/java/org/springframework/web/filter/HiddenHttpMethodFilterTests.java b/spring-web/src/test/java/org/springframework/web/filter/HiddenHttpMethodFilterTests.java index 1da78f21526..922e949d7cd 100644 --- a/spring-web/src/test/java/org/springframework/web/filter/HiddenHttpMethodFilterTests.java +++ b/spring-web/src/test/java/org/springframework/web/filter/HiddenHttpMethodFilterTests.java @@ -23,7 +23,7 @@ import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockHttpServletResponse; diff --git a/spring-web/src/test/java/org/springframework/web/filter/OncePerRequestFilterTests.java b/spring-web/src/test/java/org/springframework/web/filter/OncePerRequestFilterTests.java index c017cf64d17..c256c71ac61 100644 --- a/spring-web/src/test/java/org/springframework/web/filter/OncePerRequestFilterTests.java +++ b/spring-web/src/test/java/org/springframework/web/filter/OncePerRequestFilterTests.java @@ -24,8 +24,8 @@ import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockFilterChain; import org.springframework.mock.web.test.MockHttpServletRequest; @@ -49,7 +49,7 @@ public class OncePerRequestFilterTests { private MockFilterChain filterChain; - @Before + @BeforeEach @SuppressWarnings("serial") public void setup() throws Exception { this.request = new MockHttpServletRequest(); diff --git a/spring-web/src/test/java/org/springframework/web/filter/RelativeRedirectFilterTests.java b/spring-web/src/test/java/org/springframework/web/filter/RelativeRedirectFilterTests.java index a2c8590a0fa..71c94994d45 100644 --- a/spring-web/src/test/java/org/springframework/web/filter/RelativeRedirectFilterTests.java +++ b/spring-web/src/test/java/org/springframework/web/filter/RelativeRedirectFilterTests.java @@ -19,7 +19,7 @@ package org.springframework.web.filter; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponseWrapper; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.mockito.InOrder; import org.mockito.Mockito; diff --git a/spring-web/src/test/java/org/springframework/web/filter/RequestContextFilterTests.java b/spring-web/src/test/java/org/springframework/web/filter/RequestContextFilterTests.java index fd353de16c9..2f961809067 100644 --- a/spring-web/src/test/java/org/springframework/web/filter/RequestContextFilterTests.java +++ b/spring-web/src/test/java/org/springframework/web/filter/RequestContextFilterTests.java @@ -22,7 +22,7 @@ import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockFilterConfig; import org.springframework.mock.web.test.MockHttpServletRequest; diff --git a/spring-web/src/test/java/org/springframework/web/filter/RequestLoggingFilterTests.java b/spring-web/src/test/java/org/springframework/web/filter/RequestLoggingFilterTests.java index 7b8d4f1d979..ab261c863eb 100644 --- a/spring-web/src/test/java/org/springframework/web/filter/RequestLoggingFilterTests.java +++ b/spring-web/src/test/java/org/springframework/web/filter/RequestLoggingFilterTests.java @@ -25,7 +25,7 @@ import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockHttpServletResponse; diff --git a/spring-web/src/test/java/org/springframework/web/filter/ShallowEtagHeaderFilterTests.java b/spring-web/src/test/java/org/springframework/web/filter/ShallowEtagHeaderFilterTests.java index 69380413a98..f0144bd86b5 100644 --- a/spring-web/src/test/java/org/springframework/web/filter/ShallowEtagHeaderFilterTests.java +++ b/spring-web/src/test/java/org/springframework/web/filter/ShallowEtagHeaderFilterTests.java @@ -19,7 +19,7 @@ package org.springframework.web.filter; import javax.servlet.FilterChain; import javax.servlet.http.HttpServletResponse; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockHttpServletResponse; diff --git a/spring-web/src/test/java/org/springframework/web/filter/reactive/HiddenHttpMethodFilterTests.java b/spring-web/src/test/java/org/springframework/web/filter/reactive/HiddenHttpMethodFilterTests.java index 4518c23c623..61d79238a26 100644 --- a/spring-web/src/test/java/org/springframework/web/filter/reactive/HiddenHttpMethodFilterTests.java +++ b/spring-web/src/test/java/org/springframework/web/filter/reactive/HiddenHttpMethodFilterTests.java @@ -18,7 +18,7 @@ package org.springframework.web.filter.reactive; import java.time.Duration; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; diff --git a/spring-web/src/test/java/org/springframework/web/filter/reactive/ServerWebExchangeContextFilterTests.java b/spring-web/src/test/java/org/springframework/web/filter/reactive/ServerWebExchangeContextFilterTests.java index e58905eb409..fee9f9293ae 100644 --- a/spring-web/src/test/java/org/springframework/web/filter/reactive/ServerWebExchangeContextFilterTests.java +++ b/spring-web/src/test/java/org/springframework/web/filter/reactive/ServerWebExchangeContextFilterTests.java @@ -18,7 +18,7 @@ package org.springframework.web.filter.reactive; import java.time.Duration; import java.util.concurrent.atomic.AtomicReference; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; import org.springframework.http.server.reactive.HttpHandler; diff --git a/spring-web/src/test/java/org/springframework/web/jsf/DelegatingNavigationHandlerTests.java b/spring-web/src/test/java/org/springframework/web/jsf/DelegatingNavigationHandlerTests.java index 8714a74be2c..07a27a0cd62 100644 --- a/spring-web/src/test/java/org/springframework/web/jsf/DelegatingNavigationHandlerTests.java +++ b/spring-web/src/test/java/org/springframework/web/jsf/DelegatingNavigationHandlerTests.java @@ -19,7 +19,7 @@ package org.springframework.web.jsf; import javax.faces.application.NavigationHandler; import javax.faces.context.FacesContext; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.support.StaticListableBeanFactory; diff --git a/spring-web/src/test/java/org/springframework/web/jsf/DelegatingPhaseListenerTests.java b/spring-web/src/test/java/org/springframework/web/jsf/DelegatingPhaseListenerTests.java index 68809d55b76..f174615da96 100644 --- a/spring-web/src/test/java/org/springframework/web/jsf/DelegatingPhaseListenerTests.java +++ b/spring-web/src/test/java/org/springframework/web/jsf/DelegatingPhaseListenerTests.java @@ -21,7 +21,7 @@ import javax.faces.event.PhaseEvent; import javax.faces.event.PhaseId; import javax.faces.event.PhaseListener; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.ListableBeanFactory; import org.springframework.beans.factory.support.StaticListableBeanFactory; diff --git a/spring-web/src/test/java/org/springframework/web/method/ControllerAdviceBeanTests.java b/spring-web/src/test/java/org/springframework/web/method/ControllerAdviceBeanTests.java index 763f83c44b9..ef15e71402c 100644 --- a/spring-web/src/test/java/org/springframework/web/method/ControllerAdviceBeanTests.java +++ b/spring-web/src/test/java/org/springframework/web/method/ControllerAdviceBeanTests.java @@ -21,7 +21,7 @@ import java.lang.annotation.RetentionPolicy; import java.util.List; import javax.annotation.Priority; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.BeanFactory; diff --git a/spring-web/src/test/java/org/springframework/web/method/HandlerTypePredicateTests.java b/spring-web/src/test/java/org/springframework/web/method/HandlerTypePredicateTests.java index 311b2f18eaf..144bb4e36fd 100644 --- a/spring-web/src/test/java/org/springframework/web/method/HandlerTypePredicateTests.java +++ b/spring-web/src/test/java/org/springframework/web/method/HandlerTypePredicateTests.java @@ -17,7 +17,7 @@ package org.springframework.web.method; import java.util.function.Predicate; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RestController; diff --git a/spring-web/src/test/java/org/springframework/web/method/annotation/CookieValueMethodArgumentResolverTests.java b/spring-web/src/test/java/org/springframework/web/method/annotation/CookieValueMethodArgumentResolverTests.java index 125f3353e0f..9bab0cef580 100644 --- a/spring-web/src/test/java/org/springframework/web/method/annotation/CookieValueMethodArgumentResolverTests.java +++ b/spring-web/src/test/java/org/springframework/web/method/annotation/CookieValueMethodArgumentResolverTests.java @@ -19,8 +19,8 @@ package org.springframework.web.method.annotation; import java.lang.reflect.Method; import javax.servlet.http.Cookie; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.MethodParameter; import org.springframework.core.annotation.SynthesizingMethodParameter; @@ -55,7 +55,7 @@ public class CookieValueMethodArgumentResolverTests { private MockHttpServletRequest request; - @Before + @BeforeEach public void setUp() throws Exception { resolver = new TestCookieValueMethodArgumentResolver(); diff --git a/spring-web/src/test/java/org/springframework/web/method/annotation/ErrorsMethodArgumentResolverTests.java b/spring-web/src/test/java/org/springframework/web/method/annotation/ErrorsMethodArgumentResolverTests.java index 6edf54e02ec..a3444193fc0 100644 --- a/spring-web/src/test/java/org/springframework/web/method/annotation/ErrorsMethodArgumentResolverTests.java +++ b/spring-web/src/test/java/org/springframework/web/method/annotation/ErrorsMethodArgumentResolverTests.java @@ -16,8 +16,8 @@ package org.springframework.web.method.annotation; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.MethodParameter; import org.springframework.mock.web.test.MockHttpServletRequest; @@ -47,7 +47,7 @@ public class ErrorsMethodArgumentResolverTests { private NativeWebRequest webRequest; - @Before + @BeforeEach public void setup() throws Exception { paramErrors = new MethodParameter(getClass().getDeclaredMethod("handle", Errors.class), 0); bindingResult = new WebDataBinder(new Object(), "attr").getBindingResult(); diff --git a/spring-web/src/test/java/org/springframework/web/method/annotation/ExceptionHandlerMethodResolverTests.java b/spring-web/src/test/java/org/springframework/web/method/annotation/ExceptionHandlerMethodResolverTests.java index ede0b189e49..cda4fe44f8b 100644 --- a/spring-web/src/test/java/org/springframework/web/method/annotation/ExceptionHandlerMethodResolverTests.java +++ b/spring-web/src/test/java/org/springframework/web/method/annotation/ExceptionHandlerMethodResolverTests.java @@ -23,7 +23,7 @@ import java.net.SocketException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.stereotype.Controller; import org.springframework.util.ClassUtils; diff --git a/spring-web/src/test/java/org/springframework/web/method/annotation/ExpressionValueMethodArgumentResolverTests.java b/spring-web/src/test/java/org/springframework/web/method/annotation/ExpressionValueMethodArgumentResolverTests.java index b5fb9d93857..74d06bdd126 100644 --- a/spring-web/src/test/java/org/springframework/web/method/annotation/ExpressionValueMethodArgumentResolverTests.java +++ b/spring-web/src/test/java/org/springframework/web/method/annotation/ExpressionValueMethodArgumentResolverTests.java @@ -18,9 +18,9 @@ package org.springframework.web.method.annotation; import java.lang.reflect.Method; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Value; import org.springframework.core.MethodParameter; @@ -50,7 +50,7 @@ public class ExpressionValueMethodArgumentResolverTests { private NativeWebRequest webRequest; - @Before + @BeforeEach @SuppressWarnings("resource") public void setUp() throws Exception { GenericWebApplicationContext context = new GenericWebApplicationContext(); @@ -68,7 +68,7 @@ public class ExpressionValueMethodArgumentResolverTests { RequestContextHolder.setRequestAttributes(webRequest); } - @After + @AfterEach public void teardown() { RequestContextHolder.resetRequestAttributes(); } diff --git a/spring-web/src/test/java/org/springframework/web/method/annotation/InitBinderDataBinderFactoryTests.java b/spring-web/src/test/java/org/springframework/web/method/annotation/InitBinderDataBinderFactoryTests.java index a4f94e41091..c74c221ec18 100644 --- a/spring-web/src/test/java/org/springframework/web/method/annotation/InitBinderDataBinderFactoryTests.java +++ b/spring-web/src/test/java/org/springframework/web/method/annotation/InitBinderDataBinderFactoryTests.java @@ -19,7 +19,7 @@ package org.springframework.web.method.annotation; import java.lang.reflect.Method; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.LocalVariableTableParameterNameDiscoverer; import org.springframework.core.convert.ConversionService; diff --git a/spring-web/src/test/java/org/springframework/web/method/annotation/MapMethodProcessorTests.java b/spring-web/src/test/java/org/springframework/web/method/annotation/MapMethodProcessorTests.java index 53805d9647d..635dff6a3d8 100644 --- a/spring-web/src/test/java/org/springframework/web/method/annotation/MapMethodProcessorTests.java +++ b/spring-web/src/test/java/org/springframework/web/method/annotation/MapMethodProcessorTests.java @@ -18,8 +18,8 @@ package org.springframework.web.method.annotation; import java.util.Map; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.MethodParameter; import org.springframework.mock.web.test.MockHttpServletRequest; @@ -51,7 +51,7 @@ public class MapMethodProcessorTests { ResolvableMethod.on(getClass()).annotPresent(RequestMapping.class).build(); - @Before + @BeforeEach public void setUp() throws Exception { this.processor = new MapMethodProcessor(); this.mavContainer = new ModelAndViewContainer(); diff --git a/spring-web/src/test/java/org/springframework/web/method/annotation/ModelAttributeMethodProcessorTests.java b/spring-web/src/test/java/org/springframework/web/method/annotation/ModelAttributeMethodProcessorTests.java index 5a80f5a4c60..f536e8538d0 100644 --- a/spring-web/src/test/java/org/springframework/web/method/annotation/ModelAttributeMethodProcessorTests.java +++ b/spring-web/src/test/java/org/springframework/web/method/annotation/ModelAttributeMethodProcessorTests.java @@ -20,8 +20,8 @@ import java.lang.annotation.Retention; import java.lang.annotation.Target; import java.lang.reflect.Method; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.MethodParameter; import org.springframework.core.annotation.SynthesizingMethodParameter; @@ -78,7 +78,7 @@ public class ModelAttributeMethodProcessorTests { private MethodParameter returnParamNonSimpleType; - @Before + @BeforeEach public void setup() throws Exception { this.request = new ServletWebRequest(new MockHttpServletRequest()); this.container = new ModelAndViewContainer(); diff --git a/spring-web/src/test/java/org/springframework/web/method/annotation/ModelFactoryOrderingTests.java b/spring-web/src/test/java/org/springframework/web/method/annotation/ModelFactoryOrderingTests.java index 0cd5240cc6c..31a3a271551 100644 --- a/spring-web/src/test/java/org/springframework/web/method/annotation/ModelFactoryOrderingTests.java +++ b/spring-web/src/test/java/org/springframework/web/method/annotation/ModelFactoryOrderingTests.java @@ -25,8 +25,8 @@ import java.util.Set; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.MethodIntrospector; import org.springframework.core.annotation.AnnotationUtils; @@ -65,7 +65,7 @@ public class ModelFactoryOrderingTests { private SessionAttributeStore sessionAttributeStore; - @Before + @BeforeEach public void setup() { this.sessionAttributeStore = new DefaultSessionAttributeStore(); this.webRequest = new ServletWebRequest(new MockHttpServletRequest(), new MockHttpServletResponse()); diff --git a/spring-web/src/test/java/org/springframework/web/method/annotation/ModelFactoryTests.java b/spring-web/src/test/java/org/springframework/web/method/annotation/ModelFactoryTests.java index 801b0dff3d1..afcfdc1b2d6 100644 --- a/spring-web/src/test/java/org/springframework/web/method/annotation/ModelFactoryTests.java +++ b/spring-web/src/test/java/org/springframework/web/method/annotation/ModelFactoryTests.java @@ -19,8 +19,8 @@ package org.springframework.web.method.annotation; import java.lang.reflect.Method; import java.util.Collections; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.LocalVariableTableParameterNameDiscoverer; import org.springframework.mock.web.test.MockHttpServletRequest; @@ -64,7 +64,7 @@ public class ModelFactoryTests { private ModelAndViewContainer mavContainer; - @Before + @BeforeEach public void setUp() throws Exception { this.webRequest = new ServletWebRequest(new MockHttpServletRequest()); this.attributeStore = new DefaultSessionAttributeStore(); diff --git a/spring-web/src/test/java/org/springframework/web/method/annotation/ModelMethodProcessorTests.java b/spring-web/src/test/java/org/springframework/web/method/annotation/ModelMethodProcessorTests.java index d44402809e0..f3c5564c598 100644 --- a/spring-web/src/test/java/org/springframework/web/method/annotation/ModelMethodProcessorTests.java +++ b/spring-web/src/test/java/org/springframework/web/method/annotation/ModelMethodProcessorTests.java @@ -18,8 +18,8 @@ package org.springframework.web.method.annotation; import java.lang.reflect.Method; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.MethodParameter; import org.springframework.mock.web.test.MockHttpServletRequest; @@ -48,7 +48,7 @@ public class ModelMethodProcessorTests { private NativeWebRequest webRequest; - @Before + @BeforeEach public void setUp() throws Exception { processor = new ModelMethodProcessor(); mavContainer = new ModelAndViewContainer(); diff --git a/spring-web/src/test/java/org/springframework/web/method/annotation/RequestHeaderMapMethodArgumentResolverTests.java b/spring-web/src/test/java/org/springframework/web/method/annotation/RequestHeaderMapMethodArgumentResolverTests.java index 90477601242..98568ec4fc1 100644 --- a/spring-web/src/test/java/org/springframework/web/method/annotation/RequestHeaderMapMethodArgumentResolverTests.java +++ b/spring-web/src/test/java/org/springframework/web/method/annotation/RequestHeaderMapMethodArgumentResolverTests.java @@ -20,8 +20,8 @@ import java.lang.reflect.Method; import java.util.Collections; import java.util.Map; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.MethodParameter; import org.springframework.core.annotation.SynthesizingMethodParameter; @@ -59,7 +59,7 @@ public class RequestHeaderMapMethodArgumentResolverTests { private MockHttpServletRequest request; - @Before + @BeforeEach public void setup() throws Exception { resolver = new RequestHeaderMapMethodArgumentResolver(); diff --git a/spring-web/src/test/java/org/springframework/web/method/annotation/RequestHeaderMethodArgumentResolverTests.java b/spring-web/src/test/java/org/springframework/web/method/annotation/RequestHeaderMethodArgumentResolverTests.java index bbe771b404b..c8a9147e4f4 100644 --- a/spring-web/src/test/java/org/springframework/web/method/annotation/RequestHeaderMethodArgumentResolverTests.java +++ b/spring-web/src/test/java/org/springframework/web/method/annotation/RequestHeaderMethodArgumentResolverTests.java @@ -22,9 +22,9 @@ import java.time.format.DateTimeFormatter; import java.util.Date; import java.util.Map; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.MethodParameter; import org.springframework.core.annotation.SynthesizingMethodParameter; @@ -69,7 +69,7 @@ public class RequestHeaderMethodArgumentResolverTests { private NativeWebRequest webRequest; - @Before + @BeforeEach @SuppressWarnings("resource") public void setup() throws Exception { GenericWebApplicationContext context = new GenericWebApplicationContext(); @@ -94,7 +94,7 @@ public class RequestHeaderMethodArgumentResolverTests { RequestContextHolder.setRequestAttributes(webRequest); } - @After + @AfterEach public void reset() { RequestContextHolder.resetRequestAttributes(); } diff --git a/spring-web/src/test/java/org/springframework/web/method/annotation/RequestParamMapMethodArgumentResolverTests.java b/spring-web/src/test/java/org/springframework/web/method/annotation/RequestParamMapMethodArgumentResolverTests.java index 6a9dfe81ae9..7f3dcf974c6 100644 --- a/spring-web/src/test/java/org/springframework/web/method/annotation/RequestParamMapMethodArgumentResolverTests.java +++ b/spring-web/src/test/java/org/springframework/web/method/annotation/RequestParamMapMethodArgumentResolverTests.java @@ -20,7 +20,7 @@ import java.util.Collections; import java.util.Map; import javax.servlet.http.Part; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.MethodParameter; import org.springframework.mock.web.test.MockHttpServletRequest; diff --git a/spring-web/src/test/java/org/springframework/web/method/annotation/RequestParamMethodArgumentResolverTests.java b/spring-web/src/test/java/org/springframework/web/method/annotation/RequestParamMethodArgumentResolverTests.java index 81b738459fe..4473286d84b 100644 --- a/spring-web/src/test/java/org/springframework/web/method/annotation/RequestParamMethodArgumentResolverTests.java +++ b/spring-web/src/test/java/org/springframework/web/method/annotation/RequestParamMethodArgumentResolverTests.java @@ -22,7 +22,7 @@ import java.util.Map; import java.util.Optional; import javax.servlet.http.Part; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.propertyeditors.StringTrimmerEditor; import org.springframework.core.MethodParameter; diff --git a/spring-web/src/test/java/org/springframework/web/method/annotation/SessionAttributesHandlerTests.java b/spring-web/src/test/java/org/springframework/web/method/annotation/SessionAttributesHandlerTests.java index bb6506e533e..0c980da38f5 100644 --- a/spring-web/src/test/java/org/springframework/web/method/annotation/SessionAttributesHandlerTests.java +++ b/spring-web/src/test/java/org/springframework/web/method/annotation/SessionAttributesHandlerTests.java @@ -19,7 +19,7 @@ package org.springframework.web.method.annotation; import java.util.HashSet; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.tests.sample.beans.TestBean; diff --git a/spring-web/src/test/java/org/springframework/web/method/annotation/WebArgumentResolverAdapterTests.java b/spring-web/src/test/java/org/springframework/web/method/annotation/WebArgumentResolverAdapterTests.java index 7d1b27a0bdc..b6d1c22b3d8 100644 --- a/spring-web/src/test/java/org/springframework/web/method/annotation/WebArgumentResolverAdapterTests.java +++ b/spring-web/src/test/java/org/springframework/web/method/annotation/WebArgumentResolverAdapterTests.java @@ -16,9 +16,9 @@ package org.springframework.web.method.annotation; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.MethodParameter; import org.springframework.mock.web.test.MockHttpServletRequest; @@ -50,7 +50,7 @@ public class WebArgumentResolverAdapterTests { private NativeWebRequest webRequest; - @Before + @BeforeEach public void setUp() throws Exception { adaptee = mock(WebArgumentResolver.class); adapter = new TestWebArgumentResolverAdapter(adaptee); @@ -61,7 +61,7 @@ public class WebArgumentResolverAdapterTests { RequestContextHolder.setRequestAttributes(webRequest); } - @After + @AfterEach public void resetRequestContextHolder() { RequestContextHolder.resetRequestAttributes(); } diff --git a/spring-web/src/test/java/org/springframework/web/method/support/CompositeUriComponentsContributorTests.java b/spring-web/src/test/java/org/springframework/web/method/support/CompositeUriComponentsContributorTests.java index 3e8fbc9da94..a9030b3ab79 100644 --- a/spring-web/src/test/java/org/springframework/web/method/support/CompositeUriComponentsContributorTests.java +++ b/spring-web/src/test/java/org/springframework/web/method/support/CompositeUriComponentsContributorTests.java @@ -20,7 +20,7 @@ import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.MethodParameter; import org.springframework.util.ClassUtils; diff --git a/spring-web/src/test/java/org/springframework/web/method/support/HandlerMethodArgumentResolverCompositeTests.java b/spring-web/src/test/java/org/springframework/web/method/support/HandlerMethodArgumentResolverCompositeTests.java index a5137a1d859..c4d8e7bf7be 100644 --- a/spring-web/src/test/java/org/springframework/web/method/support/HandlerMethodArgumentResolverCompositeTests.java +++ b/spring-web/src/test/java/org/springframework/web/method/support/HandlerMethodArgumentResolverCompositeTests.java @@ -18,8 +18,8 @@ package org.springframework.web.method.support; import java.lang.reflect.Method; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.MethodParameter; @@ -40,7 +40,7 @@ public class HandlerMethodArgumentResolverCompositeTests { private MethodParameter paramStr; - @Before + @BeforeEach public void setup() throws Exception { this.resolverComposite = new HandlerMethodArgumentResolverComposite(); diff --git a/spring-web/src/test/java/org/springframework/web/method/support/HandlerMethodReturnValueHandlerCompositeTests.java b/spring-web/src/test/java/org/springframework/web/method/support/HandlerMethodReturnValueHandlerCompositeTests.java index 3870e1b8877..9562a658216 100644 --- a/spring-web/src/test/java/org/springframework/web/method/support/HandlerMethodReturnValueHandlerCompositeTests.java +++ b/spring-web/src/test/java/org/springframework/web/method/support/HandlerMethodReturnValueHandlerCompositeTests.java @@ -16,8 +16,8 @@ package org.springframework.web.method.support; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.MethodParameter; @@ -47,7 +47,7 @@ public class HandlerMethodReturnValueHandlerCompositeTests { private MethodParameter stringType; - @Before + @BeforeEach public void setup() throws Exception { this.integerType = new MethodParameter(getClass().getDeclaredMethod("handleInteger"), -1); this.stringType = new MethodParameter(getClass().getDeclaredMethod("handleString"), -1); diff --git a/spring-web/src/test/java/org/springframework/web/method/support/InvocableHandlerMethodTests.java b/spring-web/src/test/java/org/springframework/web/method/support/InvocableHandlerMethodTests.java index e589fa7fabf..d2f6676d508 100644 --- a/spring-web/src/test/java/org/springframework/web/method/support/InvocableHandlerMethodTests.java +++ b/spring-web/src/test/java/org/springframework/web/method/support/InvocableHandlerMethodTests.java @@ -18,8 +18,8 @@ package org.springframework.web.method.support; import java.lang.reflect.Method; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.MethodParameter; import org.springframework.mock.web.test.MockHttpServletRequest; @@ -46,7 +46,7 @@ public class InvocableHandlerMethodTests { private final HandlerMethodArgumentResolverComposite composite = new HandlerMethodArgumentResolverComposite(); - @Before + @BeforeEach public void setUp() throws Exception { this.request = new ServletWebRequest(new MockHttpServletRequest(), new MockHttpServletResponse()); } diff --git a/spring-web/src/test/java/org/springframework/web/method/support/ModelAndViewContainerTests.java b/spring-web/src/test/java/org/springframework/web/method/support/ModelAndViewContainerTests.java index ad9fe35fce5..13a2f1c5563 100644 --- a/spring-web/src/test/java/org/springframework/web/method/support/ModelAndViewContainerTests.java +++ b/spring-web/src/test/java/org/springframework/web/method/support/ModelAndViewContainerTests.java @@ -16,8 +16,8 @@ package org.springframework.web.method.support; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.ui.ModelMap; @@ -34,7 +34,7 @@ public class ModelAndViewContainerTests { private ModelAndViewContainer mavContainer; - @Before + @BeforeEach public void setup() { this.mavContainer = new ModelAndViewContainer(); } diff --git a/spring-web/src/test/java/org/springframework/web/multipart/commons/CommonsMultipartResolverTests.java b/spring-web/src/test/java/org/springframework/web/multipart/commons/CommonsMultipartResolverTests.java index 68eab8ebbaf..ec154fe55cf 100644 --- a/spring-web/src/test/java/org/springframework/web/multipart/commons/CommonsMultipartResolverTests.java +++ b/spring-web/src/test/java/org/springframework/web/multipart/commons/CommonsMultipartResolverTests.java @@ -42,7 +42,7 @@ import org.apache.commons.fileupload.FileItemFactory; import org.apache.commons.fileupload.FileItemHeaders; import org.apache.commons.fileupload.FileUpload; import org.apache.commons.fileupload.servlet.ServletFileUpload; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.MutablePropertyValues; import org.springframework.mock.web.test.MockFilterConfig; diff --git a/spring-web/src/test/java/org/springframework/web/multipart/support/ByteArrayMultipartFileEditorTests.java b/spring-web/src/test/java/org/springframework/web/multipart/support/ByteArrayMultipartFileEditorTests.java index 5c1b33f932e..cce0b992c2a 100644 --- a/spring-web/src/test/java/org/springframework/web/multipart/support/ByteArrayMultipartFileEditorTests.java +++ b/spring-web/src/test/java/org/springframework/web/multipart/support/ByteArrayMultipartFileEditorTests.java @@ -18,7 +18,7 @@ package org.springframework.web.multipart.support; import java.io.IOException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.web.multipart.MultipartFile; diff --git a/spring-web/src/test/java/org/springframework/web/multipart/support/DefaultMultipartHttpServletRequestTests.java b/spring-web/src/test/java/org/springframework/web/multipart/support/DefaultMultipartHttpServletRequestTests.java index 602447bfb22..e98f58de2a2 100644 --- a/spring-web/src/test/java/org/springframework/web/multipart/support/DefaultMultipartHttpServletRequestTests.java +++ b/spring-web/src/test/java/org/springframework/web/multipart/support/DefaultMultipartHttpServletRequestTests.java @@ -19,7 +19,7 @@ import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.util.LinkedMultiValueMap; diff --git a/spring-web/src/test/java/org/springframework/web/multipart/support/RequestPartServletServerHttpRequestTests.java b/spring-web/src/test/java/org/springframework/web/multipart/support/RequestPartServletServerHttpRequestTests.java index 5d1ff721280..762d6a2596a 100644 --- a/spring-web/src/test/java/org/springframework/web/multipart/support/RequestPartServletServerHttpRequestTests.java +++ b/spring-web/src/test/java/org/springframework/web/multipart/support/RequestPartServletServerHttpRequestTests.java @@ -21,7 +21,7 @@ import java.nio.charset.StandardCharsets; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequestWrapper; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; diff --git a/spring-web/src/test/java/org/springframework/web/multipart/support/StandardMultipartHttpServletRequestTests.java b/spring-web/src/test/java/org/springframework/web/multipart/support/StandardMultipartHttpServletRequestTests.java index e78a49c3c6b..6ce3f7d0de2 100644 --- a/spring-web/src/test/java/org/springframework/web/multipart/support/StandardMultipartHttpServletRequestTests.java +++ b/spring-web/src/test/java/org/springframework/web/multipart/support/StandardMultipartHttpServletRequestTests.java @@ -19,7 +19,7 @@ package org.springframework.web.multipart.support; import java.io.IOException; import java.nio.charset.StandardCharsets; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.MockHttpOutputMessage; import org.springframework.http.converter.FormHttpMessageConverter; diff --git a/spring-web/src/test/java/org/springframework/web/server/adapter/DefaultServerWebExchangeCheckNotModifiedTests.java b/spring-web/src/test/java/org/springframework/web/server/adapter/DefaultServerWebExchangeCheckNotModifiedTests.java index 920aaf7f5fe..e945e20d9ba 100644 --- a/spring-web/src/test/java/org/springframework/web/server/adapter/DefaultServerWebExchangeCheckNotModifiedTests.java +++ b/spring-web/src/test/java/org/springframework/web/server/adapter/DefaultServerWebExchangeCheckNotModifiedTests.java @@ -24,10 +24,8 @@ import java.util.Arrays; import java.util.Locale; import java.util.TimeZone; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.junit.runners.Parameterized.Parameter; import org.junit.runners.Parameterized.Parameters; @@ -44,7 +42,6 @@ import static org.springframework.mock.http.server.reactive.test.MockServerHttpR * * @author Rossen Stoyanchev */ -@RunWith(Parameterized.class) public class DefaultServerWebExchangeCheckNotModifiedTests { private static final String CURRENT_TIME = "Wed, 09 Apr 2014 09:57:42 GMT"; @@ -66,7 +63,7 @@ public class DefaultServerWebExchangeCheckNotModifiedTests { } - @Before + @BeforeEach public void setup() throws URISyntaxException { this.currentDate = Instant.now().truncatedTo(ChronoUnit.SECONDS); this.dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US); diff --git a/spring-web/src/test/java/org/springframework/web/server/adapter/DefaultServerWebExchangeTests.java b/spring-web/src/test/java/org/springframework/web/server/adapter/DefaultServerWebExchangeTests.java index 68ae32158e8..dd7045c2cd3 100644 --- a/spring-web/src/test/java/org/springframework/web/server/adapter/DefaultServerWebExchangeTests.java +++ b/spring-web/src/test/java/org/springframework/web/server/adapter/DefaultServerWebExchangeTests.java @@ -16,7 +16,7 @@ package org.springframework.web.server.adapter; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.codec.ServerCodecConfigurer; import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; diff --git a/spring-web/src/test/java/org/springframework/web/server/adapter/ForwardedHeaderTransformerTests.java b/spring-web/src/test/java/org/springframework/web/server/adapter/ForwardedHeaderTransformerTests.java index 94b39d52439..3f5a674fe50 100644 --- a/spring-web/src/test/java/org/springframework/web/server/adapter/ForwardedHeaderTransformerTests.java +++ b/spring-web/src/test/java/org/springframework/web/server/adapter/ForwardedHeaderTransformerTests.java @@ -18,7 +18,7 @@ package org.springframework.web.server.adapter; import java.net.URI; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; diff --git a/spring-web/src/test/java/org/springframework/web/server/adapter/WebHttpHandlerBuilderTests.java b/spring-web/src/test/java/org/springframework/web/server/adapter/WebHttpHandlerBuilderTests.java index 44af80e2dde..08e30c83b4d 100644 --- a/spring-web/src/test/java/org/springframework/web/server/adapter/WebHttpHandlerBuilderTests.java +++ b/spring-web/src/test/java/org/springframework/web/server/adapter/WebHttpHandlerBuilderTests.java @@ -19,7 +19,7 @@ package org.springframework.web.server.adapter; import java.nio.charset.StandardCharsets; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; diff --git a/spring-web/src/test/java/org/springframework/web/server/handler/ExceptionHandlingWebHandlerTests.java b/spring-web/src/test/java/org/springframework/web/server/handler/ExceptionHandlingWebHandlerTests.java index 683905dc492..8524dabaee6 100644 --- a/spring-web/src/test/java/org/springframework/web/server/handler/ExceptionHandlingWebHandlerTests.java +++ b/spring-web/src/test/java/org/springframework/web/server/handler/ExceptionHandlingWebHandlerTests.java @@ -18,7 +18,7 @@ package org.springframework.web.server.handler; import java.util.Arrays; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; diff --git a/spring-web/src/test/java/org/springframework/web/server/handler/FilteringWebHandlerTests.java b/spring-web/src/test/java/org/springframework/web/server/handler/FilteringWebHandlerTests.java index 9d8830b212a..d567ff9bd41 100644 --- a/spring-web/src/test/java/org/springframework/web/server/handler/FilteringWebHandlerTests.java +++ b/spring-web/src/test/java/org/springframework/web/server/handler/FilteringWebHandlerTests.java @@ -22,7 +22,7 @@ import java.util.Collections; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; import org.springframework.http.HttpStatus; diff --git a/spring-web/src/test/java/org/springframework/web/server/handler/ResponseStatusExceptionHandlerTests.java b/spring-web/src/test/java/org/springframework/web/server/handler/ResponseStatusExceptionHandlerTests.java index 9a3c77af681..e760e0cfd98 100644 --- a/spring-web/src/test/java/org/springframework/web/server/handler/ResponseStatusExceptionHandlerTests.java +++ b/spring-web/src/test/java/org/springframework/web/server/handler/ResponseStatusExceptionHandlerTests.java @@ -18,8 +18,8 @@ package org.springframework.web.server.handler; import java.time.Duration; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; @@ -43,7 +43,7 @@ public class ResponseStatusExceptionHandlerTests { protected ResponseStatusExceptionHandler handler; - @Before + @BeforeEach public void setup() { this.handler = createResponseStatusExceptionHandler(); } diff --git a/spring-web/src/test/java/org/springframework/web/server/i18n/AcceptHeaderLocaleContextResolverTests.java b/spring-web/src/test/java/org/springframework/web/server/i18n/AcceptHeaderLocaleContextResolverTests.java index 6cb675377dc..882e7ddb8f5 100644 --- a/spring-web/src/test/java/org/springframework/web/server/i18n/AcceptHeaderLocaleContextResolverTests.java +++ b/spring-web/src/test/java/org/springframework/web/server/i18n/AcceptHeaderLocaleContextResolverTests.java @@ -20,7 +20,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.Locale; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpHeaders; import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; diff --git a/spring-web/src/test/java/org/springframework/web/server/i18n/FixedLocaleContextResolverTests.java b/spring-web/src/test/java/org/springframework/web/server/i18n/FixedLocaleContextResolverTests.java index f79b10cf6fa..29099806718 100644 --- a/spring-web/src/test/java/org/springframework/web/server/i18n/FixedLocaleContextResolverTests.java +++ b/spring-web/src/test/java/org/springframework/web/server/i18n/FixedLocaleContextResolverTests.java @@ -20,8 +20,8 @@ import java.time.ZoneId; import java.util.Locale; import java.util.TimeZone; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.context.i18n.TimeZoneAwareLocaleContext; import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; @@ -40,7 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat; */ public class FixedLocaleContextResolverTests { - @Before + @BeforeEach public void setup() { Locale.setDefault(US); } diff --git a/spring-web/src/test/java/org/springframework/web/server/session/CookieWebSessionIdResolverTests.java b/spring-web/src/test/java/org/springframework/web/server/session/CookieWebSessionIdResolverTests.java index c5aff2459b4..5eb203761c6 100644 --- a/spring-web/src/test/java/org/springframework/web/server/session/CookieWebSessionIdResolverTests.java +++ b/spring-web/src/test/java/org/springframework/web/server/session/CookieWebSessionIdResolverTests.java @@ -15,7 +15,7 @@ */ package org.springframework.web.server.session; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.ResponseCookie; import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; diff --git a/spring-web/src/test/java/org/springframework/web/server/session/DefaultWebSessionManagerTests.java b/spring-web/src/test/java/org/springframework/web/server/session/DefaultWebSessionManagerTests.java index 343eeedbdff..7dca7c1d1e6 100644 --- a/spring-web/src/test/java/org/springframework/web/server/session/DefaultWebSessionManagerTests.java +++ b/spring-web/src/test/java/org/springframework/web/server/session/DefaultWebSessionManagerTests.java @@ -20,11 +20,11 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; import reactor.core.publisher.Mono; import org.springframework.http.codec.ServerCodecConfigurer; @@ -47,8 +47,8 @@ import static org.mockito.Mockito.verify; * @author Rossen Stoyanchev * @author Rob Winch */ -@RunWith(MockitoJUnitRunner.class) -public class DefaultWebSessionManagerTests { +@MockitoSettings(strictness = Strictness.LENIENT) +class DefaultWebSessionManagerTests { @Mock private WebSessionIdResolver sessionIdResolver; @@ -67,8 +67,8 @@ public class DefaultWebSessionManagerTests { private ServerWebExchange exchange; - @Before - public void setUp() throws Exception { + @BeforeEach + void setUp() throws Exception { given(this.createSession.save()).willReturn(Mono.empty()); given(this.createSession.getId()).willReturn("create-session-id"); given(this.updateSession.getId()).willReturn("update-session-id"); @@ -83,12 +83,11 @@ public class DefaultWebSessionManagerTests { MockServerHttpRequest request = MockServerHttpRequest.get("/path").build(); MockServerHttpResponse response = new MockServerHttpResponse(); this.exchange = new DefaultServerWebExchange(request, response, this.sessionManager, - ServerCodecConfigurer.create(), new AcceptHeaderLocaleContextResolver()); + ServerCodecConfigurer.create(), new AcceptHeaderLocaleContextResolver()); } @Test - public void getSessionSaveWhenCreatedAndNotStartedThenNotSaved() { - + void getSessionSaveWhenCreatedAndNotStartedThenNotSaved() { given(this.sessionIdResolver.resolveSessionIds(this.exchange)).willReturn(Collections.emptyList()); WebSession session = this.sessionManager.getSession(this.exchange).block(); this.exchange.getResponse().setComplete().block(); @@ -101,8 +100,7 @@ public class DefaultWebSessionManagerTests { } @Test - public void getSessionSaveWhenCreatedAndStartedThenSavesAndSetsId() { - + void getSessionSaveWhenCreatedAndStartedThenSavesAndSetsId() { given(this.sessionIdResolver.resolveSessionIds(this.exchange)).willReturn(Collections.emptyList()); WebSession session = this.sessionManager.getSession(this.exchange).block(); assertThat(session).isSameAs(this.createSession); @@ -117,8 +115,7 @@ public class DefaultWebSessionManagerTests { } @Test - public void existingSession() { - + void existingSession() { String sessionId = this.updateSession.getId(); given(this.sessionIdResolver.resolveSessionIds(this.exchange)).willReturn(Collections.singletonList(sessionId)); @@ -128,8 +125,7 @@ public class DefaultWebSessionManagerTests { } @Test - public void multipleSessionIds() { - + void multipleSessionIds() { List ids = Arrays.asList("not-this", "not-that", this.updateSession.getId()); given(this.sessionStore.retrieveSession("not-this")).willReturn(Mono.empty()); given(this.sessionStore.retrieveSession("not-that")).willReturn(Mono.empty()); @@ -139,4 +135,5 @@ public class DefaultWebSessionManagerTests { assertThat(actual).isNotNull(); assertThat(actual.getId()).isEqualTo(this.updateSession.getId()); } + } diff --git a/spring-web/src/test/java/org/springframework/web/server/session/HeaderWebSessionIdResolverTests.java b/spring-web/src/test/java/org/springframework/web/server/session/HeaderWebSessionIdResolverTests.java index dc508a014d2..5e9c7f2eab1 100644 --- a/spring-web/src/test/java/org/springframework/web/server/session/HeaderWebSessionIdResolverTests.java +++ b/spring-web/src/test/java/org/springframework/web/server/session/HeaderWebSessionIdResolverTests.java @@ -18,8 +18,8 @@ package org.springframework.web.server.session; import java.util.Arrays; import java.util.List; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; import org.springframework.mock.web.test.server.MockServerWebExchange; @@ -39,7 +39,7 @@ public class HeaderWebSessionIdResolverTests { private ServerWebExchange exchange; - @Before + @BeforeEach public void setUp() { this.idResolver = new HeaderWebSessionIdResolver(); this.exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/path")); diff --git a/spring-web/src/test/java/org/springframework/web/server/session/InMemoryWebSessionStoreTests.java b/spring-web/src/test/java/org/springframework/web/server/session/InMemoryWebSessionStoreTests.java index 540bcd899eb..d2ab0de61d9 100644 --- a/spring-web/src/test/java/org/springframework/web/server/session/InMemoryWebSessionStoreTests.java +++ b/spring-web/src/test/java/org/springframework/web/server/session/InMemoryWebSessionStoreTests.java @@ -22,7 +22,7 @@ import java.time.Instant; import java.util.Map; import java.util.stream.IntStream; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.DirectFieldAccessor; import org.springframework.web.server.WebSession; diff --git a/spring-web/src/test/java/org/springframework/web/server/session/WebSessionIntegrationTests.java b/spring-web/src/test/java/org/springframework/web/server/session/WebSessionIntegrationTests.java index 30dcf38b725..922199e7e98 100644 --- a/spring-web/src/test/java/org/springframework/web/server/session/WebSessionIntegrationTests.java +++ b/spring-web/src/test/java/org/springframework/web/server/session/WebSessionIntegrationTests.java @@ -23,7 +23,6 @@ import java.time.Duration; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; -import org.junit.Test; import reactor.core.publisher.Mono; import org.springframework.http.HttpHeaders; @@ -32,6 +31,7 @@ import org.springframework.http.RequestEntity; import org.springframework.http.ResponseEntity; import org.springframework.http.server.reactive.AbstractHttpHandlerIntegrationTests; import org.springframework.http.server.reactive.HttpHandler; +import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.web.client.RestTemplate; import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.WebHandler; @@ -41,29 +41,30 @@ import org.springframework.web.server.adapter.WebHttpHandlerBuilder; import static org.assertj.core.api.Assertions.assertThat; /** - * Integration tests for with a server-side session. + * Integration tests for {@link DefaultWebSessionManager} with a server-side session. * * @author Rossen Stoyanchev + * @author Sam Brannen */ public class WebSessionIntegrationTests extends AbstractHttpHandlerIntegrationTests { private final RestTemplate restTemplate = new RestTemplate(); - private DefaultWebSessionManager sessionManager; + private final DefaultWebSessionManager sessionManager = new DefaultWebSessionManager(); - private TestWebHandler handler; + private final TestWebHandler handler = new TestWebHandler(); @Override protected HttpHandler createHttpHandler() { - this.sessionManager = new DefaultWebSessionManager(); - this.handler = new TestWebHandler(); return WebHttpHandlerBuilder.webHandler(this.handler).sessionManager(this.sessionManager).build(); } - @Test - public void createSession() throws Exception { + @ParameterizedHttpServerTest + public void createSession(HttpServer httpServer) throws Exception { + startServer(httpServer); + RequestEntity request = RequestEntity.get(createUri()).build(); ResponseEntity response = this.restTemplate.exchange(request, Void.class); @@ -80,8 +81,10 @@ public class WebSessionIntegrationTests extends AbstractHttpHandlerIntegrationTe assertThat(this.handler.getSessionRequestCount()).isEqualTo(2); } - @Test - public void expiredSessionIsRecreated() throws Exception { + @ParameterizedHttpServerTest + public void expiredSessionIsRecreated(HttpServer httpServer) throws Exception { + startServer(httpServer); + // First request: no session yet, new session created RequestEntity request = RequestEntity.get(createUri()).build(); @@ -116,8 +119,10 @@ public class WebSessionIntegrationTests extends AbstractHttpHandlerIntegrationTe assertThat(this.handler.getSessionRequestCount()).isEqualTo(1); } - @Test - public void expiredSessionEnds() throws Exception { + @ParameterizedHttpServerTest + public void expiredSessionEnds(HttpServer httpServer) throws Exception { + startServer(httpServer); + // First request: no session yet, new session created RequestEntity request = RequestEntity.get(createUri()).build(); @@ -142,8 +147,10 @@ public class WebSessionIntegrationTests extends AbstractHttpHandlerIntegrationTe assertThat(value.contains("Max-Age=0")).as("Actual value: " + value).isTrue(); } - @Test - public void changeSessionId() throws Exception { + @ParameterizedHttpServerTest + public void changeSessionId(HttpServer httpServer) throws Exception { + startServer(httpServer); + // First request: no session yet, new session created RequestEntity request = RequestEntity.get(createUri()).build(); @@ -166,8 +173,9 @@ public class WebSessionIntegrationTests extends AbstractHttpHandlerIntegrationTe assertThat(this.handler.getSessionRequestCount()).isEqualTo(2); } - @Test - public void invalidate() throws Exception { + @ParameterizedHttpServerTest + public void invalidate(HttpServer httpServer) throws Exception { + startServer(httpServer); // First request: no session yet, new session created RequestEntity request = RequestEntity.get(createUri()).build(); diff --git a/spring-web/src/test/java/org/springframework/web/util/ContentCachingRequestWrapperTests.java b/spring-web/src/test/java/org/springframework/web/util/ContentCachingRequestWrapperTests.java index feaea348821..20f040715f3 100644 --- a/spring-web/src/test/java/org/springframework/web/util/ContentCachingRequestWrapperTests.java +++ b/spring-web/src/test/java/org/springframework/web/util/ContentCachingRequestWrapperTests.java @@ -16,7 +16,7 @@ package org.springframework.web.util; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.util.FileCopyUtils; diff --git a/spring-web/src/test/java/org/springframework/web/util/DefaultUriBuilderFactoryTests.java b/spring-web/src/test/java/org/springframework/web/util/DefaultUriBuilderFactoryTests.java index 54637926fb1..ab53012321e 100644 --- a/spring-web/src/test/java/org/springframework/web/util/DefaultUriBuilderFactoryTests.java +++ b/spring-web/src/test/java/org/springframework/web/util/DefaultUriBuilderFactoryTests.java @@ -20,7 +20,7 @@ import java.net.URI; import java.util.HashMap; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.web.util.DefaultUriBuilderFactory.EncodingMode; diff --git a/spring-web/src/test/java/org/springframework/web/util/DefaultUriTemplateHandlerTests.java b/spring-web/src/test/java/org/springframework/web/util/DefaultUriTemplateHandlerTests.java index 9d5ff94e306..edb284c9c13 100644 --- a/spring-web/src/test/java/org/springframework/web/util/DefaultUriTemplateHandlerTests.java +++ b/spring-web/src/test/java/org/springframework/web/util/DefaultUriTemplateHandlerTests.java @@ -20,7 +20,7 @@ import java.net.URI; import java.util.HashMap; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/web/util/HtmlCharacterEntityReferencesTests.java b/spring-web/src/test/java/org/springframework/web/util/HtmlCharacterEntityReferencesTests.java index 726808a2277..c92ad5379c8 100644 --- a/spring-web/src/test/java/org/springframework/web/util/HtmlCharacterEntityReferencesTests.java +++ b/spring-web/src/test/java/org/springframework/web/util/HtmlCharacterEntityReferencesTests.java @@ -24,7 +24,7 @@ import java.io.StreamTokenizer; import java.util.HashMap; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/web/util/HtmlUtilsTests.java b/spring-web/src/test/java/org/springframework/web/util/HtmlUtilsTests.java index 256f309a342..68d31898f54 100644 --- a/spring-web/src/test/java/org/springframework/web/util/HtmlUtilsTests.java +++ b/spring-web/src/test/java/org/springframework/web/util/HtmlUtilsTests.java @@ -16,7 +16,7 @@ package org.springframework.web.util; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/web/util/JavaScriptUtilsTests.java b/spring-web/src/test/java/org/springframework/web/util/JavaScriptUtilsTests.java index 43b7d853bc6..4d2e9614e6d 100644 --- a/spring-web/src/test/java/org/springframework/web/util/JavaScriptUtilsTests.java +++ b/spring-web/src/test/java/org/springframework/web/util/JavaScriptUtilsTests.java @@ -18,7 +18,7 @@ package org.springframework.web.util; import java.io.UnsupportedEncodingException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-web/src/test/java/org/springframework/web/util/ServletContextPropertyUtilsTests.java b/spring-web/src/test/java/org/springframework/web/util/ServletContextPropertyUtilsTests.java index c682b8df810..3a66ff0b228 100644 --- a/spring-web/src/test/java/org/springframework/web/util/ServletContextPropertyUtilsTests.java +++ b/spring-web/src/test/java/org/springframework/web/util/ServletContextPropertyUtilsTests.java @@ -16,7 +16,7 @@ package org.springframework.web.util; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockServletContext; diff --git a/spring-web/src/test/java/org/springframework/web/util/TagUtilsTests.java b/spring-web/src/test/java/org/springframework/web/util/TagUtilsTests.java index 0f4d4e0b857..2306cdca78c 100644 --- a/spring-web/src/test/java/org/springframework/web/util/TagUtilsTests.java +++ b/spring-web/src/test/java/org/springframework/web/util/TagUtilsTests.java @@ -20,7 +20,7 @@ import javax.servlet.jsp.PageContext; import javax.servlet.jsp.tagext.Tag; import javax.servlet.jsp.tagext.TagSupport; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-web/src/test/java/org/springframework/web/util/UriComponentsBuilderTests.java b/spring-web/src/test/java/org/springframework/web/util/UriComponentsBuilderTests.java index 761bc68cfe9..e8400799f9e 100644 --- a/spring-web/src/test/java/org/springframework/web/util/UriComponentsBuilderTests.java +++ b/spring-web/src/test/java/org/springframework/web/util/UriComponentsBuilderTests.java @@ -24,7 +24,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpRequest; diff --git a/spring-web/src/test/java/org/springframework/web/util/UriComponentsTests.java b/spring-web/src/test/java/org/springframework/web/util/UriComponentsTests.java index 6fb68437003..a0578029ba1 100644 --- a/spring-web/src/test/java/org/springframework/web/util/UriComponentsTests.java +++ b/spring-web/src/test/java/org/springframework/web/util/UriComponentsTests.java @@ -25,7 +25,7 @@ import java.net.URISyntaxException; import java.util.Arrays; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-web/src/test/java/org/springframework/web/util/UriTemplateTests.java b/spring-web/src/test/java/org/springframework/web/util/UriTemplateTests.java index 9c31f6f6ddc..d1fd6a19e96 100644 --- a/spring-web/src/test/java/org/springframework/web/util/UriTemplateTests.java +++ b/spring-web/src/test/java/org/springframework/web/util/UriTemplateTests.java @@ -23,7 +23,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-web/src/test/java/org/springframework/web/util/UriUtilsTests.java b/spring-web/src/test/java/org/springframework/web/util/UriUtilsTests.java index d3da7707a9b..019107a535c 100644 --- a/spring-web/src/test/java/org/springframework/web/util/UriUtilsTests.java +++ b/spring-web/src/test/java/org/springframework/web/util/UriUtilsTests.java @@ -19,7 +19,7 @@ package org.springframework.web.util; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-web/src/test/java/org/springframework/web/util/UrlPathHelperTests.java b/spring-web/src/test/java/org/springframework/web/util/UrlPathHelperTests.java index 0308ea0b6f9..e4809de72b2 100644 --- a/spring-web/src/test/java/org/springframework/web/util/UrlPathHelperTests.java +++ b/spring-web/src/test/java/org/springframework/web/util/UrlPathHelperTests.java @@ -18,8 +18,8 @@ package org.springframework.web.util; import java.io.UnsupportedEncodingException; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockHttpServletRequest; @@ -301,7 +301,7 @@ public class UrlPathHelperTests { } // test the root mapping for /foo/* w/o a trailing slash - //foo - @Test @Ignore + @Test @Disabled public void tomcatCasualServletRootWithMissingSlash() throws Exception { request.setContextPath("/test"); request.setPathInfo(null); @@ -349,7 +349,7 @@ public class UrlPathHelperTests { } // test the root mapping for /foo/* w/o a trailing slash - //foo - @Ignore + @Disabled @Test public void wasCasualServletRootWithMissingSlash() throws Exception { request.setContextPath("/test"); @@ -361,7 +361,7 @@ public class UrlPathHelperTests { assertThat(helper.getLookupPathForRequest(request)).isEqualTo("/"); } - @Ignore + @Disabled @Test public void wasCasualServletRootWithMissingSlashWithCompliantSetting() throws Exception { request.setAttribute(WEBSPHERE_URI_ATTRIBUTE, "/test/foo"); diff --git a/spring-web/src/test/java/org/springframework/web/util/WebUtilsTests.java b/spring-web/src/test/java/org/springframework/web/util/WebUtilsTests.java index 61f7cca0814..efea7ae046c 100644 --- a/spring-web/src/test/java/org/springframework/web/util/WebUtilsTests.java +++ b/spring-web/src/test/java/org/springframework/web/util/WebUtilsTests.java @@ -23,7 +23,7 @@ import java.util.List; import java.util.Map; import javax.servlet.http.HttpServletRequest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpHeaders; import org.springframework.http.server.ServerHttpRequest; diff --git a/spring-web/src/test/java/org/springframework/web/util/pattern/PathPatternParserTests.java b/spring-web/src/test/java/org/springframework/web/util/pattern/PathPatternParserTests.java index b141763f3ad..a233a017182 100644 --- a/spring-web/src/test/java/org/springframework/web/util/pattern/PathPatternParserTests.java +++ b/spring-web/src/test/java/org/springframework/web/util/pattern/PathPatternParserTests.java @@ -20,7 +20,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.server.PathContainer; import org.springframework.web.util.pattern.PatternParseException.PatternMessage; diff --git a/spring-web/src/test/java/org/springframework/web/util/pattern/PathPatternRouteMatcherTests.java b/spring-web/src/test/java/org/springframework/web/util/pattern/PathPatternRouteMatcherTests.java index 5bfba935f9d..b02f3f2cda6 100644 --- a/spring-web/src/test/java/org/springframework/web/util/pattern/PathPatternRouteMatcherTests.java +++ b/spring-web/src/test/java/org/springframework/web/util/pattern/PathPatternRouteMatcherTests.java @@ -18,7 +18,7 @@ package org.springframework.web.util.pattern; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.server.PathContainer; import org.springframework.util.RouteMatcher; diff --git a/spring-web/src/test/java/org/springframework/web/util/pattern/PathPatternTests.java b/spring-web/src/test/java/org/springframework/web/util/pattern/PathPatternTests.java index 8bce4a77557..ebf95ff215c 100644 --- a/spring-web/src/test/java/org/springframework/web/util/pattern/PathPatternTests.java +++ b/spring-web/src/test/java/org/springframework/web/util/pattern/PathPatternTests.java @@ -23,7 +23,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.server.PathContainer; import org.springframework.http.server.PathContainer.Element; 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 445f6252f71..ff0e948eea2 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 @@ -21,7 +21,7 @@ import io.mockk.mockk import io.mockk.verify import org.junit.Assert import org.junit.Assert.assertEquals -import org.junit.Test +import org.junit.jupiter.api.Test import org.springframework.core.ParameterizedTypeReference import org.springframework.http.* import org.springframework.util.ReflectionUtils 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 328d43d1e65..46646e4de62 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * 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. @@ -18,8 +18,9 @@ package org.springframework.web.method.annotation import org.junit.Assert.assertEquals import org.junit.Assert.assertNull -import org.junit.Before -import org.junit.Test +import org.junit.Assert.fail +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Test import org.springframework.core.MethodParameter import org.springframework.core.annotation.SynthesizingMethodParameter import org.springframework.core.convert.support.DefaultConversionService @@ -44,6 +45,7 @@ import org.springframework.web.multipart.support.MissingServletRequestPartExcept * Kotlin test fixture for [RequestParamMethodArgumentResolver]. * * @author Sebastien Deleuze + * @author Sam Brannen */ class RequestParamMethodArgumentResolverKotlinTests { @@ -63,7 +65,7 @@ class RequestParamMethodArgumentResolverKotlinTests { lateinit var nonNullableMultipartParamNotRequired: MethodParameter - @Before + @BeforeEach fun setup() { resolver = RequestParamMethodArgumentResolver(null, true) request = MockHttpServletRequest() @@ -121,9 +123,15 @@ class RequestParamMethodArgumentResolverKotlinTests { assertEquals("123", result) } - @Test(expected = MissingServletRequestParameterException::class) + @Test fun resolveNonNullableRequiredWithoutParameter() { - resolver.resolveArgument(nonNullableParamRequired, null, webRequest, binderFactory) + try { + resolver.resolveArgument(nonNullableParamRequired, null, webRequest, binderFactory) + fail("should have thrown a MissingServletRequestParameterException") + } + catch (e: MissingServletRequestParameterException) { + // expected + } } @Test @@ -133,12 +141,17 @@ class RequestParamMethodArgumentResolverKotlinTests { assertEquals("123", result) } - @Test(expected = TypeCastException::class) + @Test fun resolveNonNullableNotRequiredWithoutParameter() { - resolver.resolveArgument(nonNullableParamNotRequired, null, webRequest, binderFactory) as String + try { + resolver.resolveArgument(nonNullableParamNotRequired, null, webRequest, binderFactory) as String + fail("should have thrown a TypeCastException") + } + catch (e: TypeCastException) { + // expected + } } - @Test fun resolveNullableRequiredWithMultipartParameter() { val request = MockMultipartHttpServletRequest() @@ -190,11 +203,18 @@ class RequestParamMethodArgumentResolverKotlinTests { assertEquals(expected, result) } - @Test(expected = MissingServletRequestPartException::class) + @Test fun resolveNonNullableRequiredWithoutMultipartParameter() { request.method = HttpMethod.POST.name request.contentType = MediaType.MULTIPART_FORM_DATA_VALUE - resolver.resolveArgument(nonNullableMultipartParamRequired, null, webRequest, binderFactory) + + try { + resolver.resolveArgument(nonNullableMultipartParamRequired, null, webRequest, binderFactory) + fail("should have thrown a MissingServletRequestPartException") + } + catch (e: MissingServletRequestPartException) { + // expected + } } @Test @@ -208,11 +228,18 @@ class RequestParamMethodArgumentResolverKotlinTests { assertEquals(expected, result) } - @Test(expected = TypeCastException::class) + @Test fun resolveNonNullableNotRequiredWithoutMultipartParameter() { request.method = HttpMethod.POST.name request.contentType = MediaType.MULTIPART_FORM_DATA_VALUE - resolver.resolveArgument(nonNullableMultipartParamNotRequired, null, webRequest, binderFactory) as MultipartFile + + try { + resolver.resolveArgument(nonNullableMultipartParamNotRequired, null, webRequest, binderFactory) as MultipartFile + fail("should have thrown a TypeCastException") + } + catch (e: TypeCastException) { + // expected + } } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/DispatcherHandlerErrorTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/DispatcherHandlerErrorTests.java index db9e2690ab9..43d1401e7fe 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/DispatcherHandlerErrorTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/DispatcherHandlerErrorTests.java @@ -21,8 +21,8 @@ import java.util.Collections; import java.util.List; import java.util.concurrent.atomic.AtomicReference; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.reactivestreams.Publisher; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; @@ -67,7 +67,7 @@ public class DispatcherHandlerErrorTests { private DispatcherHandler dispatcherHandler; - @Before + @BeforeEach public void setup() { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(TestConfig.class); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/DispatcherHandlerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/DispatcherHandlerTests.java index 4a978fb9e56..30c73409ace 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/DispatcherHandlerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/DispatcherHandlerTests.java @@ -20,7 +20,7 @@ import java.nio.charset.StandardCharsets; import java.time.Duration; import java.util.function.Supplier; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; import org.springframework.context.support.StaticApplicationContext; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/FlushingIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/FlushingIntegrationTests.java index 67bf56d4526..62fe229976a 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/FlushingIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/FlushingIntegrationTests.java @@ -19,8 +19,6 @@ package org.springframework.web.reactive; import java.nio.charset.StandardCharsets; import java.time.Duration; -import org.junit.Before; -import org.junit.Test; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; @@ -30,6 +28,7 @@ import org.springframework.http.server.reactive.AbstractHttpHandlerIntegrationTe import org.springframework.http.server.reactive.HttpHandler; import org.springframework.http.server.reactive.ServerHttpRequest; import org.springframework.http.server.reactive.ServerHttpResponse; +import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.web.reactive.function.client.WebClient; import static org.assertj.core.api.Assertions.assertThat; @@ -39,22 +38,25 @@ import static org.assertj.core.api.Assertions.assertThat; * * @author Sebastien Deleuze * @author Rossen Stoyanchev + * @author Sam Brannen * @since 5.0 */ -public class FlushingIntegrationTests extends AbstractHttpHandlerIntegrationTests { +class FlushingIntegrationTests extends AbstractHttpHandlerIntegrationTests { private WebClient webClient; - @Before - public void setup() throws Exception { - super.setup(); + @Override + protected void startServer(HttpServer httpServer) throws Exception { + super.startServer(httpServer); this.webClient = WebClient.create("http://localhost:" + this.port); } - @Test - public void writeAndFlushWith() { + @ParameterizedHttpServerTest + void writeAndFlushWith(HttpServer httpServer) throws Exception { + startServer(httpServer); + Mono result = this.webClient.get() .uri("/write-and-flush") .retrieve() @@ -68,8 +70,10 @@ public class FlushingIntegrationTests extends AbstractHttpHandlerIntegrationTest .verify(Duration.ofSeconds(10L)); } - @Test // SPR-14991 - public void writeAndAutoFlushOnComplete() { + @ParameterizedHttpServerTest // SPR-14991 + void writeAndAutoFlushOnComplete(HttpServer httpServer) throws Exception { + startServer(httpServer); + Mono result = this.webClient.get() .uri("/write-and-complete") .retrieve() @@ -93,8 +97,10 @@ public class FlushingIntegrationTests extends AbstractHttpHandlerIntegrationTest } } - @Test // SPR-14992 - public void writeAndAutoFlushBeforeComplete() { + @ParameterizedHttpServerTest // SPR-14992 + void writeAndAutoFlushBeforeComplete(HttpServer httpServer) throws Exception { + startServer(httpServer); + Mono result = this.webClient.get() .uri("/write-and-never-complete") .retrieve() diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/accept/HeaderContentTypeResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/accept/HeaderContentTypeResolverTests.java index f3fe5cd851e..8f96d37b3e2 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/accept/HeaderContentTypeResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/accept/HeaderContentTypeResolverTests.java @@ -18,7 +18,7 @@ package org.springframework.web.reactive.accept; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.MediaType; import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/accept/ParameterContentTypeResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/accept/ParameterContentTypeResolverTests.java index 411b4693353..b7fcd474c7b 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/accept/ParameterContentTypeResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/accept/ParameterContentTypeResolverTests.java @@ -19,7 +19,7 @@ import java.util.Collections; import java.util.List; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.MediaType; import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/accept/RequestedContentTypeResolverBuilderTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/accept/RequestedContentTypeResolverBuilderTests.java index e67016f15e3..dd324411064 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/accept/RequestedContentTypeResolverBuilderTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/accept/RequestedContentTypeResolverBuilderTests.java @@ -18,7 +18,7 @@ package org.springframework.web.reactive.accept; import java.util.Collections; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.MediaType; import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/config/CorsRegistryTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/config/CorsRegistryTests.java index 6912238e02f..d104d217677 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/config/CorsRegistryTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/config/CorsRegistryTests.java @@ -19,7 +19,7 @@ package org.springframework.web.reactive.config; import java.util.Arrays; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.web.cors.CorsConfiguration; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/config/DelegatingWebFluxConfigurationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/config/DelegatingWebFluxConfigurationTests.java index ffc2a4a330e..0069be07401 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/config/DelegatingWebFluxConfigurationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/config/DelegatingWebFluxConfigurationTests.java @@ -19,13 +19,13 @@ package org.springframework.web.reactive.config; import java.util.Collections; import java.util.List; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; import org.springframework.context.support.StaticApplicationContext; import org.springframework.core.ReactiveAdapterRegistry; @@ -49,7 +49,7 @@ import static org.mockito.Mockito.verify; * * @author Brian Clozel */ -@RunWith(MockitoJUnitRunner.class) +@MockitoSettings(strictness = Strictness.LENIENT) public class DelegatingWebFluxConfigurationTests { @Mock @@ -67,7 +67,7 @@ public class DelegatingWebFluxConfigurationTests { private DelegatingWebFluxConfiguration delegatingConfig; - @Before + @BeforeEach public void setup() { delegatingConfig = new DelegatingWebFluxConfiguration(); delegatingConfig.setApplicationContext(new StaticApplicationContext()); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/config/ResourceHandlerRegistryTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/config/ResourceHandlerRegistryTests.java index be51c6a5eda..5c7dae213d5 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/config/ResourceHandlerRegistryTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/config/ResourceHandlerRegistryTests.java @@ -21,8 +21,8 @@ import java.time.Duration; import java.util.List; import java.util.concurrent.TimeUnit; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import reactor.test.StepVerifier; @@ -62,7 +62,7 @@ public class ResourceHandlerRegistryTests { private ResourceHandlerRegistration registration; - @Before + @BeforeEach public void setup() { this.registry = new ResourceHandlerRegistry(new GenericApplicationContext()); this.registration = this.registry.addResourceHandler("/resources/**"); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/config/ViewResolverRegistryTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/config/ViewResolverRegistryTests.java index 04b9f5d4819..93a93eb9907 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/config/ViewResolverRegistryTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/config/ViewResolverRegistryTests.java @@ -17,8 +17,8 @@ package org.springframework.web.reactive.config; import java.util.List; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.DirectFieldAccessor; import org.springframework.core.Ordered; @@ -45,7 +45,7 @@ public class ViewResolverRegistryTests { private ViewResolverRegistry registry; - @Before + @BeforeEach public void setup() { StaticWebApplicationContext context = new StaticWebApplicationContext(); context.registerSingleton("freeMarkerConfigurer", FreeMarkerConfigurer.class); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/config/WebFluxConfigurationSupportTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/config/WebFluxConfigurationSupportTests.java index 11f9dd1f52f..c64fafcb7ff 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/config/WebFluxConfigurationSupportTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/config/WebFluxConfigurationSupportTests.java @@ -25,7 +25,7 @@ import java.util.Map; import javax.xml.bind.annotation.XmlRootElement; import com.google.protobuf.Message; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/BodyExtractorsTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/BodyExtractorsTests.java index f3ef2faee6b..fa5944a9188 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/BodyExtractorsTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/BodyExtractorsTests.java @@ -29,8 +29,8 @@ import java.util.Optional; import com.fasterxml.jackson.annotation.JsonView; import io.netty.buffer.PooledByteBufAllocator; import io.netty.util.IllegalReferenceCountException; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; @@ -81,7 +81,7 @@ public class BodyExtractorsTests { private Optional serverResponse = Optional.empty(); - @Before + @BeforeEach public void createContext() { final List> messageReaders = new ArrayList<>(); messageReaders.add(new DecoderHttpMessageReader<>(new ByteBufferDecoder())); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/BodyInsertersTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/BodyInsertersTests.java index a54bfc85f45..8f31694a4f1 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/BodyInsertersTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/BodyInsertersTests.java @@ -31,8 +31,8 @@ import java.util.Optional; import com.fasterxml.jackson.annotation.JsonView; import io.reactivex.Single; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; @@ -82,7 +82,7 @@ public class BodyInsertersTests { private Map hints; - @Before + @BeforeEach public void createContext() { final List> messageWriters = new ArrayList<>(); messageWriters.add(new EncoderHttpMessageWriter<>(new ByteBufferEncoder())); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/MultipartIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/MultipartIntegrationTests.java index d49ffde395f..22c6f83079b 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/MultipartIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/MultipartIntegrationTests.java @@ -22,7 +22,6 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.Map; -import org.junit.Test; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; @@ -33,6 +32,7 @@ import org.springframework.http.client.MultipartBodyBuilder; import org.springframework.http.codec.multipart.FilePart; import org.springframework.http.codec.multipart.FormFieldPart; import org.springframework.http.codec.multipart.Part; +import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.util.FileCopyUtils; import org.springframework.util.MultiValueMap; import org.springframework.web.reactive.function.client.ClientResponse; @@ -49,15 +49,17 @@ import static org.springframework.web.reactive.function.server.RouterFunctions.r /** * @author Sebastien Deleuze */ -public class MultipartIntegrationTests extends AbstractRouterFunctionIntegrationTests { +class MultipartIntegrationTests extends AbstractRouterFunctionIntegrationTests { private final WebClient webClient = WebClient.create(); private ClassPathResource resource = new ClassPathResource("org/springframework/http/codec/multipart/foo.txt"); - @Test - public void multipartData() { + @ParameterizedHttpServerTest + void multipartData(HttpServer httpServer) throws Exception { + startServer(httpServer); + Mono result = webClient .post() .uri("http://localhost:" + this.port + "/multipartData") @@ -70,8 +72,10 @@ public class MultipartIntegrationTests extends AbstractRouterFunctionIntegration .verifyComplete(); } - @Test - public void parts() { + @ParameterizedHttpServerTest + void parts(HttpServer httpServer) throws Exception { + startServer(httpServer); + Mono result = webClient .post() .uri("http://localhost:" + this.port + "/parts") @@ -84,8 +88,10 @@ public class MultipartIntegrationTests extends AbstractRouterFunctionIntegration .verifyComplete(); } - @Test - public void transferTo() { + @ParameterizedHttpServerTest + void transferTo(HttpServer httpServer) throws Exception { + startServer(httpServer); + Mono result = webClient .post() .uri("http://localhost:" + this.port + "/transferTo") diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultClientRequestBuilderTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultClientRequestBuilderTests.java index 6148cd4a993..f01f37c8997 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultClientRequestBuilderTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultClientRequestBuilderTests.java @@ -21,7 +21,7 @@ import java.net.URISyntaxException; import java.util.ArrayList; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.reactivestreams.Publisher; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultClientResponseBuilderTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultClientResponseBuilderTests.java index ff87aed4bb0..8e6c01ef63b 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultClientResponseBuilderTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultClientResponseBuilderTests.java @@ -18,7 +18,7 @@ package org.springframework.web.reactive.function.client; import java.nio.charset.StandardCharsets; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Flux; import reactor.test.StepVerifier; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultClientResponseTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultClientResponseTests.java index 5bc0fafb3ba..ed05d7b2d74 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultClientResponseTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultClientResponseTests.java @@ -24,8 +24,8 @@ import java.util.List; import java.util.Optional; import java.util.OptionalLong; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -65,7 +65,7 @@ public class DefaultClientResponseTests { private DefaultClientResponse defaultClientResponse; - @Before + @BeforeEach public void createMocks() { mockResponse = mock(ClientHttpResponse.class); mockExchangeStrategies = mock(ExchangeStrategies.class); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultWebClientTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultWebClientTests.java index 275d51a3f09..f2eae9e4ea6 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultWebClientTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/DefaultWebClientTests.java @@ -21,13 +21,13 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; @@ -50,7 +50,7 @@ import static org.mockito.Mockito.verifyZeroInteractions; * @author Rossen Stoyanchev * @author Brian Clozel */ -@RunWith(MockitoJUnitRunner.class) +@MockitoSettings(strictness = Strictness.LENIENT) public class DefaultWebClientTests { @Mock @@ -62,7 +62,7 @@ public class DefaultWebClientTests { private WebClient.Builder builder; - @Before + @BeforeEach public void setup() { ClientResponse mockResponse = mock(ClientResponse.class); given(this.exchangeFunction.exchange(this.captor.capture())).willReturn(Mono.just(mockResponse)); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/ExchangeFilterFunctionsTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/ExchangeFilterFunctionsTests.java index 0f16e698be7..b6b6e42182c 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/ExchangeFilterFunctionsTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/ExchangeFilterFunctionsTests.java @@ -19,7 +19,7 @@ package org.springframework.web.reactive.function.client; import java.net.URI; import java.nio.charset.StandardCharsets; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/ExchangeStrategiesTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/ExchangeStrategiesTests.java index 365b6b5f11d..eb37921f7a1 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/ExchangeStrategiesTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/ExchangeStrategiesTests.java @@ -16,7 +16,7 @@ package org.springframework.web.reactive.function.client; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientIntegrationTests.java index d78d4d7bbc1..41d9819969f 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/WebClientIntegrationTests.java @@ -18,22 +18,25 @@ package org.springframework.web.reactive.function.client; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; import java.net.URI; import java.nio.file.Files; import java.time.Duration; import java.util.Arrays; import java.util.List; import java.util.function.Consumer; +import java.util.stream.Stream; import java.util.zip.CRC32; import okhttp3.mockwebserver.MockResponse; import okhttp3.mockwebserver.MockWebServer; import okhttp3.mockwebserver.RecordedRequest; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; @@ -64,44 +67,46 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Rossen Stoyanchev * @author Denys Ivano * @author Sebastien Deleuze + * @author Sam Brannen */ -@RunWith(Parameterized.class) -public class WebClientIntegrationTests { +class WebClientIntegrationTests { - private MockWebServer server; + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.METHOD) + @ParameterizedTest(name = "webClient [{0}]") + @MethodSource("arguments") + @interface ParameterizedWebClientTest { + } - private WebClient webClient; + static Stream arguments() { + return Stream.of(new JettyClientHttpConnector(), new ReactorClientHttpConnector()); + } - @Parameterized.Parameter(0) - public ClientHttpConnector connector; - @Parameterized.Parameters(name = "webClient [{0}]") - public static Object[][] arguments() { - return new Object[][] { - {new JettyClientHttpConnector()}, - {new ReactorClientHttpConnector()} - }; - } + private MockWebServer server; + + private WebClient webClient; - @Before - public void setup() { + private void startServer(ClientHttpConnector connector) { this.server = new MockWebServer(); this.webClient = WebClient .builder() - .clientConnector(this.connector) + .clientConnector(connector) .baseUrl(this.server.url("/").toString()) .build(); } - @After - public void shutdown() throws IOException { + @AfterEach + void shutdown() throws IOException { this.server.shutdown(); } - @Test - public void shouldReceiveResponseHeaders() { + @ParameterizedWebClientTest + void shouldReceiveResponseHeaders(ClientHttpConnector connector) { + startServer(connector); + prepareResponse(response -> response .setHeader("Content-Type", "text/plain") .setBody("Hello Spring!")); @@ -126,8 +131,10 @@ public class WebClientIntegrationTests { }); } - @Test - public void shouldReceivePlainText() { + @ParameterizedWebClientTest + void shouldReceivePlainText(ClientHttpConnector connector) { + startServer(connector); + prepareResponse(response -> response.setBody("Hello Spring!")); Mono result = this.webClient.get() @@ -148,8 +155,10 @@ public class WebClientIntegrationTests { }); } - @Test - public void shouldReceivePlainTextFlux() throws Exception { + @ParameterizedWebClientTest + void shouldReceivePlainTextFlux(ClientHttpConnector connector) { + startServer(connector); + prepareResponse(response -> response.setBody("Hello Spring!")); Flux result = this.webClient.get() @@ -170,8 +179,10 @@ public class WebClientIntegrationTests { }); } - @Test - public void shouldReceiveJsonAsString() { + @ParameterizedWebClientTest + void shouldReceiveJsonAsString(ClientHttpConnector connector) { + startServer(connector); + String content = "{\"bar\":\"barbar\",\"foo\":\"foofoo\"}"; prepareResponse(response -> response .setHeader("Content-Type", "application/json").setBody(content)); @@ -192,8 +203,10 @@ public class WebClientIntegrationTests { }); } - @Test // SPR-16715 - public void shouldReceiveJsonAsTypeReferenceString() { + @ParameterizedWebClientTest // SPR-16715 + void shouldReceiveJsonAsTypeReferenceString(ClientHttpConnector connector) { + startServer(connector); + String content = "{\"containerValue\":{\"fooValue\":\"bar\"}}"; prepareResponse(response -> response .setHeader("Content-Type", "application/json").setBody(content)); @@ -218,8 +231,10 @@ public class WebClientIntegrationTests { }); } - @Test - public void exchangeShouldReceiveJsonAsResponseEntityString() { + @ParameterizedWebClientTest + void exchangeShouldReceiveJsonAsResponseEntityString(ClientHttpConnector connector) { + startServer(connector); + String content = "{\"bar\":\"barbar\",\"foo\":\"foofoo\"}"; prepareResponse(response -> response .setHeader("Content-Type", "application/json").setBody(content)); @@ -245,8 +260,10 @@ public class WebClientIntegrationTests { }); } - @Test - public void retrieveShouldReceiveJsonAsResponseEntityString() { + @ParameterizedWebClientTest + void retrieveShouldReceiveJsonAsResponseEntityString(ClientHttpConnector connector) { + startServer(connector); + String content = "{\"bar\":\"barbar\",\"foo\":\"foofoo\"}"; prepareResponse(response -> response .setHeader("Content-Type", "application/json").setBody(content)); @@ -272,8 +289,10 @@ public class WebClientIntegrationTests { }); } - @Test - public void retrieveEntityWithServerError() { + @ParameterizedWebClientTest + void retrieveEntityWithServerError(ClientHttpConnector connector) { + startServer(connector); + prepareResponse(response -> response.setResponseCode(500) .setHeader("Content-Type", "text/plain").setBody("Internal Server error")); @@ -293,8 +312,10 @@ public class WebClientIntegrationTests { }); } - @Test - public void retrieveEntityWithServerErrorStatusHandler() { + @ParameterizedWebClientTest + void retrieveEntityWithServerErrorStatusHandler(ClientHttpConnector connector) { + startServer(connector); + String content = "Internal Server error"; prepareResponse(response -> response.setResponseCode(500) .setHeader("Content-Type", "text/plain").setBody(content)); @@ -320,8 +341,10 @@ public class WebClientIntegrationTests { }); } - @Test - public void exchangeShouldReceiveJsonAsResponseEntityList() { + @ParameterizedWebClientTest + void exchangeShouldReceiveJsonAsResponseEntityList(ClientHttpConnector connector) { + startServer(connector); + String content = "[{\"bar\":\"bar1\",\"foo\":\"foo1\"}, {\"bar\":\"bar2\",\"foo\":\"foo2\"}]"; prepareResponse(response -> response .setHeader("Content-Type", "application/json").setBody(content)); @@ -349,8 +372,10 @@ public class WebClientIntegrationTests { }); } - @Test - public void retrieveShouldReceiveJsonAsResponseEntityList() { + @ParameterizedWebClientTest + void retrieveShouldReceiveJsonAsResponseEntityList(ClientHttpConnector connector) { + startServer(connector); + String content = "[{\"bar\":\"bar1\",\"foo\":\"foo1\"}, {\"bar\":\"bar2\",\"foo\":\"foo2\"}]"; prepareResponse(response -> response .setHeader("Content-Type", "application/json").setBody(content)); @@ -378,8 +403,10 @@ public class WebClientIntegrationTests { }); } - @Test - public void retrieveEntityListWithServerError() { + @ParameterizedWebClientTest + void retrieveEntityListWithServerError(ClientHttpConnector connector) { + startServer(connector); + prepareResponse(response -> response.setResponseCode(500) .setHeader("Content-Type", "text/plain").setBody("Internal Server error")); @@ -399,9 +426,10 @@ public class WebClientIntegrationTests { }); } + @ParameterizedWebClientTest + void shouldReceiveJsonAsFluxString(ClientHttpConnector connector) { + startServer(connector); - @Test - public void shouldReceiveJsonAsFluxString() { String content = "{\"bar\":\"barbar\",\"foo\":\"foofoo\"}"; prepareResponse(response -> response .setHeader("Content-Type", "application/json").setBody(content)); @@ -422,8 +450,10 @@ public class WebClientIntegrationTests { }); } - @Test - public void shouldReceiveJsonAsPojo() { + @ParameterizedWebClientTest + void shouldReceiveJsonAsPojo(ClientHttpConnector connector) { + startServer(connector); + prepareResponse(response -> response .setHeader("Content-Type", "application/json") .setBody("{\"bar\":\"barbar\",\"foo\":\"foofoo\"}")); @@ -446,8 +476,10 @@ public class WebClientIntegrationTests { }); } - @Test - public void shouldReceiveJsonAsFluxPojo() { + @ParameterizedWebClientTest + void shouldReceiveJsonAsFluxPojo(ClientHttpConnector connector) { + startServer(connector); + prepareResponse(response -> response .setHeader("Content-Type", "application/json") .setBody("[{\"bar\":\"bar1\",\"foo\":\"foo1\"},{\"bar\":\"bar2\",\"foo\":\"foo2\"}]")); @@ -471,8 +503,10 @@ public class WebClientIntegrationTests { }); } - @Test - public void shouldSendPojoAsJson() { + @ParameterizedWebClientTest + void shouldSendPojoAsJson(ClientHttpConnector connector) { + startServer(connector); + prepareResponse(response -> response.setHeader("Content-Type", "application/json") .setBody("{\"bar\":\"BARBAR\",\"foo\":\"FOOFOO\"}")); @@ -499,8 +533,10 @@ public class WebClientIntegrationTests { }); } - @Test - public void shouldSendCookies() { + @ParameterizedWebClientTest + void shouldSendCookies(ClientHttpConnector connector) { + startServer(connector); + prepareResponse(response -> response .setHeader("Content-Type", "text/plain").setBody("test")); @@ -522,8 +558,10 @@ public class WebClientIntegrationTests { }); } - @Test // SPR-16246 - public void shouldSendLargeTextFile() throws IOException { + @ParameterizedWebClientTest // SPR-16246 + void shouldSendLargeTextFile(ClientHttpConnector connector) throws Exception { + startServer(connector); + prepareResponse(response -> {}); Resource resource = new ClassPathResource("largeTextFile.txt", getClass()); @@ -556,8 +594,10 @@ public class WebClientIntegrationTests { return crc.getValue(); } - @Test - public void shouldReceive404Response() { + @ParameterizedWebClientTest + void shouldReceive404Response(ClientHttpConnector connector) { + startServer(connector); + prepareResponse(response -> response.setResponseCode(404) .setHeader("Content-Type", "text/plain").setBody("Not Found")); @@ -575,8 +615,10 @@ public class WebClientIntegrationTests { }); } - @Test - public void shouldGetErrorSignalOn404() { + @ParameterizedWebClientTest + void shouldGetErrorSignalOn404(ClientHttpConnector connector) { + startServer(connector); + prepareResponse(response -> response.setResponseCode(404) .setHeader("Content-Type", "text/plain").setBody("Not Found")); @@ -596,8 +638,10 @@ public class WebClientIntegrationTests { }); } - @Test // SPR-15946 - public void shouldGetErrorSignalOnEmptyErrorResponse() { + @ParameterizedWebClientTest // SPR-15946 + void shouldGetErrorSignalOnEmptyErrorResponse(ClientHttpConnector connector) { + startServer(connector); + prepareResponse(response -> response.setResponseCode(404) .setHeader("Content-Type", "text/plain")); @@ -616,8 +660,10 @@ public class WebClientIntegrationTests { }); } - @Test - public void shouldGetInternalServerErrorSignal() { + @ParameterizedWebClientTest + void shouldGetInternalServerErrorSignal(ClientHttpConnector connector) { + startServer(connector); + String errorMessage = "Internal Server error"; prepareResponse(response -> response.setResponseCode(500) .setHeader("Content-Type", "text/plain").setBody(errorMessage)); @@ -652,8 +698,10 @@ public class WebClientIntegrationTests { }); } - @Test - public void shouldSupportUnknownStatusCode() { + @ParameterizedWebClientTest + void shouldSupportUnknownStatusCode(ClientHttpConnector connector) { + startServer(connector); + int errorStatus = 555; assertThat((Object) HttpStatus.resolve(errorStatus)).isNull(); String errorMessage = "Something went wrong"; @@ -676,8 +724,10 @@ public class WebClientIntegrationTests { }); } - @Test - public void shouldGetErrorSignalWhenRetrievingUnknownStatusCode() { + @ParameterizedWebClientTest + void shouldGetErrorSignalWhenRetrievingUnknownStatusCode(ClientHttpConnector connector) { + startServer(connector); + int errorStatus = 555; assertThat((Object) HttpStatus.resolve(errorStatus)).isNull(); String errorMessage = "Something went wrong"; @@ -708,8 +758,10 @@ public class WebClientIntegrationTests { }); } - @Test - public void shouldApplyCustomStatusHandler() { + @ParameterizedWebClientTest + void shouldApplyCustomStatusHandler(ClientHttpConnector connector) { + startServer(connector); + prepareResponse(response -> response.setResponseCode(500) .setHeader("Content-Type", "text/plain").setBody("Internal Server error")); @@ -730,8 +782,10 @@ public class WebClientIntegrationTests { }); } - @Test - public void shouldApplyCustomRawStatusHandler() { + @ParameterizedWebClientTest + void shouldApplyCustomRawStatusHandler(ClientHttpConnector connector) { + startServer(connector); + prepareResponse(response -> response.setResponseCode(500) .setHeader("Content-Type", "text/plain").setBody("Internal Server error")); @@ -752,8 +806,10 @@ public class WebClientIntegrationTests { }); } - @Test - public void shouldApplyCustomStatusHandlerParameterizedTypeReference() { + @ParameterizedWebClientTest + void shouldApplyCustomStatusHandlerParameterizedTypeReference(ClientHttpConnector connector) { + startServer(connector); + prepareResponse(response -> response.setResponseCode(500) .setHeader("Content-Type", "text/plain").setBody("Internal Server error")); @@ -774,8 +830,10 @@ public class WebClientIntegrationTests { }); } - @Test - public void emptyStatusHandlerShouldReturnBody() { + @ParameterizedWebClientTest + void emptyStatusHandlerShouldReturnBody(ClientHttpConnector connector) { + startServer(connector); + prepareResponse(response -> response.setResponseCode(500) .setHeader("Content-Type", "text/plain").setBody("Internal Server error")); @@ -796,8 +854,10 @@ public class WebClientIntegrationTests { }); } - @Test - public void emptyStatusHandlerShouldReturnBodyFlux() { + @ParameterizedWebClientTest + void emptyStatusHandlerShouldReturnBodyFlux(ClientHttpConnector connector) { + startServer(connector); + prepareResponse(response -> response.setResponseCode(500) .setHeader("Content-Type", "text/plain").setBody("Internal Server error")); @@ -818,8 +878,10 @@ public class WebClientIntegrationTests { }); } - @Test - public void shouldReceiveNotFoundEntity() { + @ParameterizedWebClientTest + void shouldReceiveNotFoundEntity(ClientHttpConnector connector) { + startServer(connector); + prepareResponse(response -> response.setResponseCode(404) .setHeader("Content-Type", "text/plain").setBody("Not Found")); @@ -840,8 +902,10 @@ public class WebClientIntegrationTests { }); } - @Test - public void shouldApplyExchangeFilter() { + @ParameterizedWebClientTest + void shouldApplyExchangeFilter(ClientHttpConnector connector) { + startServer(connector); + prepareResponse(response -> response.setHeader("Content-Type", "text/plain") .setBody("Hello Spring!")); @@ -867,8 +931,9 @@ public class WebClientIntegrationTests { expectRequest(request -> assertThat(request.getHeader("foo")).isEqualTo("bar")); } - @Test - public void shouldApplyErrorHandlingFilter() { + @ParameterizedWebClientTest + void shouldApplyErrorHandlingFilter(ClientHttpConnector connector) { + startServer(connector); ExchangeFilterFunction filter = ExchangeFilterFunction.ofResponseProcessor( clientResponse -> { @@ -910,8 +975,10 @@ public class WebClientIntegrationTests { expectRequestCount(2); } - @Test - public void shouldReceiveEmptyResponse() { + @ParameterizedWebClientTest + void shouldReceiveEmptyResponse(ClientHttpConnector connector) { + startServer(connector); + prepareResponse(response -> response.setHeader("Content-Length", "0").setBody("")); Mono> result = this.webClient.get() @@ -924,8 +991,10 @@ public class WebClientIntegrationTests { ).verifyComplete(); } - @Test // SPR-15782 - public void shouldFailWithRelativeUrls() { + @ParameterizedWebClientTest // SPR-15782 + void shouldFailWithRelativeUrls(ClientHttpConnector connector) { + startServer(connector); + String uri = "/api/v4/groups/1"; Mono responseMono = WebClient.builder().build().get().uri(uri).exchange(); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/support/ClientResponseWrapperTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/support/ClientResponseWrapperTests.java index 7190ea6c61e..5e7d13008cc 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/support/ClientResponseWrapperTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/client/support/ClientResponseWrapperTests.java @@ -18,8 +18,8 @@ package org.springframework.web.reactive.function.client.support; import java.util.List; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -47,7 +47,7 @@ public class ClientResponseWrapperTests { private ClientResponseWrapper wrapper; - @Before + @BeforeEach public void createWrapper() { this.mockResponse = mock(ClientResponse.class); this.wrapper = new ClientResponseWrapper(mockResponse); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultEntityResponseBuilderTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultEntityResponseBuilderTests.java index 8b9304f64ae..e6aafd795df 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultEntityResponseBuilderTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultEntityResponseBuilderTests.java @@ -25,7 +25,7 @@ import java.util.List; import java.util.Set; import io.reactivex.Single; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.reactivestreams.Publisher; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultRenderingResponseTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultRenderingResponseTests.java index 35715d861f2..46a57bb063d 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultRenderingResponseTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultRenderingResponseTests.java @@ -26,7 +26,7 @@ import java.util.Locale; import java.util.Map; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultServerRequestBuilderTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultServerRequestBuilderTests.java index d2452195b9a..ee85f887207 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultServerRequestBuilderTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultServerRequestBuilderTests.java @@ -18,7 +18,7 @@ package org.springframework.web.reactive.function.server; import java.nio.charset.StandardCharsets; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Flux; import reactor.test.StepVerifier; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultServerRequestTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultServerRequestTests.java index 10123cafbec..87feefb06df 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultServerRequestTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultServerRequestTests.java @@ -29,7 +29,7 @@ import java.util.Map; import java.util.Optional; import java.util.OptionalLong; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultServerResponseBuilderTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultServerResponseBuilderTests.java index e8957339a02..708012f65a9 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultServerResponseBuilderTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DefaultServerResponseBuilderTests.java @@ -25,7 +25,7 @@ import java.util.EnumSet; import java.util.List; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DispatcherHandlerIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DispatcherHandlerIntegrationTests.java index a981d8fd60f..25dd8a2b277 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DispatcherHandlerIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/DispatcherHandlerIntegrationTests.java @@ -19,7 +19,6 @@ package org.springframework.web.reactive.function.server; import java.util.List; import java.util.Map; -import org.junit.Test; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -32,6 +31,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.http.server.reactive.AbstractHttpHandlerIntegrationTests; import org.springframework.http.server.reactive.HttpHandler; +import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; @@ -53,7 +53,7 @@ import static org.springframework.web.reactive.function.server.RouterFunctions.r * * @author Arjen Poutsma */ -public class DispatcherHandlerIntegrationTests extends AbstractHttpHandlerIntegrationTests { +class DispatcherHandlerIntegrationTests extends AbstractHttpHandlerIntegrationTests { private final RestTemplate restTemplate = new RestTemplate(); @@ -73,8 +73,10 @@ public class DispatcherHandlerIntegrationTests extends AbstractHttpHandlerIntegr } - @Test - public void mono() { + @ParameterizedHttpServerTest + void mono(HttpServer httpServer) throws Exception { + startServer(httpServer); + ResponseEntity result = this.restTemplate.getForEntity("http://localhost:" + this.port + "/mono", Person.class); @@ -82,8 +84,10 @@ public class DispatcherHandlerIntegrationTests extends AbstractHttpHandlerIntegr assertThat(result.getBody().getName()).isEqualTo("John"); } - @Test - public void flux() { + @ParameterizedHttpServerTest + void flux(HttpServer httpServer) throws Exception { + startServer(httpServer); + ParameterizedTypeReference> reference = new ParameterizedTypeReference>() {}; ResponseEntity> result = this.restTemplate @@ -96,8 +100,10 @@ public class DispatcherHandlerIntegrationTests extends AbstractHttpHandlerIntegr assertThat(body.get(1).getName()).isEqualTo("Jane"); } - @Test - public void controller() { + @ParameterizedHttpServerTest + void controller(HttpServer httpServer) throws Exception { + startServer(httpServer); + ResponseEntity result = this.restTemplate.getForEntity("http://localhost:" + this.port + "/controller", Person.class); @@ -105,8 +111,10 @@ public class DispatcherHandlerIntegrationTests extends AbstractHttpHandlerIntegr assertThat(result.getBody().getName()).isEqualTo("John"); } - @Test - public void attributes() { + @ParameterizedHttpServerTest + void attributes(HttpServer httpServer) throws Exception { + startServer(httpServer); + ResponseEntity result = this.restTemplate .getForEntity("http://localhost:" + this.port + "/attributes/bar", String.class); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/HandlerStrategiesTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/HandlerStrategiesTests.java index d41a64227a2..f3dc04d0bf1 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/HandlerStrategiesTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/HandlerStrategiesTests.java @@ -16,7 +16,7 @@ package org.springframework.web.reactive.function.server; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/HeadersWrapperTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/HeadersWrapperTests.java index 619dd5f9fc7..cbfed649320 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/HeadersWrapperTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/HeadersWrapperTests.java @@ -24,8 +24,8 @@ import java.util.List; import java.util.Optional; import java.util.OptionalLong; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpRange; @@ -46,7 +46,7 @@ public class HeadersWrapperTests { private ServerRequestWrapper.HeadersWrapper wrapper; - @Before + @BeforeEach public void createWrapper() { mockHeaders = mock(ServerRequest.Headers.class); wrapper = new ServerRequestWrapper.HeadersWrapper(mockHeaders); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/InvalidHttpMethodIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/InvalidHttpMethodIntegrationTests.java index 4257e8f0405..49bf19586dd 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/InvalidHttpMethodIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/InvalidHttpMethodIntegrationTests.java @@ -16,19 +16,18 @@ package org.springframework.web.reactive.function.server; -import java.io.IOException; - import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.Response; -import org.junit.Test; + +import org.springframework.http.server.reactive.bootstrap.HttpServer; import static org.assertj.core.api.Assertions.assertThat; /** * @author Arjen Poutsma */ -public class InvalidHttpMethodIntegrationTests extends AbstractRouterFunctionIntegrationTests { +class InvalidHttpMethodIntegrationTests extends AbstractRouterFunctionIntegrationTests { @Override protected RouterFunction routerFunction() { @@ -37,8 +36,10 @@ public class InvalidHttpMethodIntegrationTests extends AbstractRouterFunctionInt .andRoute(RequestPredicates.all(), request -> ServerResponse.ok().body("BAR")); } - @Test - public void invalidHttpMethod() throws IOException { + @ParameterizedHttpServerTest + void invalidHttpMethod(HttpServer httpServer) throws Exception { + startServer(httpServer); + OkHttpClient client = new OkHttpClient(); Request request = new Request.Builder() diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/LocaleContextResolverIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/LocaleContextResolverIntegrationTests.java index 11157cdce6b..e5a229a9f7b 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/LocaleContextResolverIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/LocaleContextResolverIntegrationTests.java @@ -21,12 +21,12 @@ import java.util.List; import java.util.Locale; import java.util.Map; -import org.junit.Test; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; +import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.lang.Nullable; import org.springframework.web.reactive.function.client.ClientResponse; import org.springframework.web.reactive.function.client.WebClient; @@ -40,7 +40,7 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Sebastien Deleuze */ -public class LocaleContextResolverIntegrationTests extends AbstractRouterFunctionIntegrationTests { +class LocaleContextResolverIntegrationTests extends AbstractRouterFunctionIntegrationTests { private final WebClient webClient = WebClient.create(); @@ -50,7 +50,7 @@ public class LocaleContextResolverIntegrationTests extends AbstractRouterFunctio return RouterFunctions.route(RequestPredicates.path("/"), this::render); } - public Mono render(ServerRequest request) { + Mono render(ServerRequest request) { return RenderingResponse.create("foo").build(); } @@ -62,9 +62,10 @@ public class LocaleContextResolverIntegrationTests extends AbstractRouterFunctio .build(); } + @ParameterizedHttpServerTest + void fixedLocale(HttpServer httpServer) throws Exception { + startServer(httpServer); - @Test - public void fixedLocale() { Mono result = webClient .get() .uri("http://localhost:" + this.port + "/") diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/NestedRouteIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/NestedRouteIntegrationTests.java index a8ad88c02bf..75ab644f8fd 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/NestedRouteIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/NestedRouteIntegrationTests.java @@ -18,13 +18,13 @@ package org.springframework.web.reactive.function.server; import java.util.Map; -import org.junit.Test; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; +import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.lang.Nullable; import org.springframework.web.client.RestTemplate; import org.springframework.web.util.pattern.PathPattern; @@ -40,7 +40,7 @@ import static org.springframework.web.reactive.function.server.RouterFunctions.r /** * @author Arjen Poutsma */ -public class NestedRouteIntegrationTests extends AbstractRouterFunctionIntegrationTests { +class NestedRouteIntegrationTests extends AbstractRouterFunctionIntegrationTests { private final RestTemplate restTemplate = new RestTemplate(); @@ -60,8 +60,10 @@ public class NestedRouteIntegrationTests extends AbstractRouterFunctionIntegrati } - @Test - public void bar() { + @ParameterizedHttpServerTest + void bar(HttpServer httpServer) throws Exception { + startServer(httpServer); + ResponseEntity result = restTemplate.getForEntity("http://localhost:" + port + "/foo/bar", String.class); @@ -69,8 +71,10 @@ public class NestedRouteIntegrationTests extends AbstractRouterFunctionIntegrati assertThat(result.getBody()).isEqualTo("/foo/bar"); } - @Test - public void baz() { + @ParameterizedHttpServerTest + void baz(HttpServer httpServer) throws Exception { + startServer(httpServer); + ResponseEntity result = restTemplate.getForEntity("http://localhost:" + port + "/foo/baz", String.class); @@ -78,8 +82,10 @@ public class NestedRouteIntegrationTests extends AbstractRouterFunctionIntegrati assertThat(result.getBody()).isEqualTo("/foo/baz"); } - @Test - public void variables() { + @ParameterizedHttpServerTest + void variables(HttpServer httpServer) throws Exception { + startServer(httpServer); + ResponseEntity result = restTemplate.getForEntity("http://localhost:" + port + "/1/2/3", String.class); @@ -88,8 +94,10 @@ public class NestedRouteIntegrationTests extends AbstractRouterFunctionIntegrati } // SPR-16868 - @Test - public void parentVariables() { + @ParameterizedHttpServerTest + void parentVariables(HttpServer httpServer) throws Exception { + startServer(httpServer); + ResponseEntity result = restTemplate.getForEntity("http://localhost:" + port + "/1/bar", String.class); @@ -99,8 +107,10 @@ public class NestedRouteIntegrationTests extends AbstractRouterFunctionIntegrati } // SPR 16692 - @Test - public void removeFailedNestedPathVariables() { + @ParameterizedHttpServerTest + void removeFailedNestedPathVariables(HttpServer httpServer) throws Exception { + startServer(httpServer); + ResponseEntity result = restTemplate.getForEntity("http://localhost:" + port + "/qux/quux", String.class); @@ -110,8 +120,10 @@ public class NestedRouteIntegrationTests extends AbstractRouterFunctionIntegrati } // SPR 17210 - @Test - public void removeFailedPathVariablesAnd() { + @ParameterizedHttpServerTest + void removeFailedPathVariablesAnd(HttpServer httpServer) throws Exception { + startServer(httpServer); + ResponseEntity result = restTemplate.postForEntity("http://localhost:" + port + "/qux/quux", "", String.class); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/PathResourceLookupFunctionTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/PathResourceLookupFunctionTests.java index 0e9ed189046..0c62da5a3d7 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/PathResourceLookupFunctionTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/PathResourceLookupFunctionTests.java @@ -21,7 +21,7 @@ import java.io.IOException; import java.net.URI; import java.util.function.Function; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/PublisherHandlerFunctionIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/PublisherHandlerFunctionIntegrationTests.java index 99f6c9f7998..c20054bbeb6 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/PublisherHandlerFunctionIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/PublisherHandlerFunctionIntegrationTests.java @@ -19,7 +19,6 @@ package org.springframework.web.reactive.function.server; import java.net.URI; import java.util.List; -import org.junit.Test; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -28,6 +27,7 @@ import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.http.RequestEntity; import org.springframework.http.ResponseEntity; +import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.web.client.RestTemplate; import static org.assertj.core.api.Assertions.assertThat; @@ -40,7 +40,7 @@ import static org.springframework.web.reactive.function.server.RouterFunctions.r /** * @author Arjen Poutsma */ -public class PublisherHandlerFunctionIntegrationTests extends AbstractRouterFunctionIntegrationTests { +class PublisherHandlerFunctionIntegrationTests extends AbstractRouterFunctionIntegrationTests { private final RestTemplate restTemplate = new RestTemplate(); @@ -54,20 +54,24 @@ public class PublisherHandlerFunctionIntegrationTests extends AbstractRouterFunc } - @Test - public void mono() { + @ParameterizedHttpServerTest + void mono(HttpServer httpServer) throws Exception { + startServer(httpServer); + ResponseEntity result = - restTemplate.getForEntity("http://localhost:" + port + "/mono", Person.class); + restTemplate.getForEntity("http://localhost:" + super.port + "/mono", Person.class); assertThat(result.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(result.getBody().getName()).isEqualTo("John"); } - @Test - public void flux() { + @ParameterizedHttpServerTest + void flux(HttpServer httpServer) throws Exception { + startServer(httpServer); + ParameterizedTypeReference> reference = new ParameterizedTypeReference>() {}; ResponseEntity> result = - restTemplate.exchange("http://localhost:" + port + "/flux", HttpMethod.GET, null, reference); + restTemplate.exchange("http://localhost:" + super.port + "/flux", HttpMethod.GET, null, reference); assertThat(result.getStatusCode()).isEqualTo(HttpStatus.OK); List body = result.getBody(); @@ -76,9 +80,11 @@ public class PublisherHandlerFunctionIntegrationTests extends AbstractRouterFunc assertThat(body.get(1).getName()).isEqualTo("Jane"); } - @Test - public void postMono() { - URI uri = URI.create("http://localhost:" + port + "/mono"); + @ParameterizedHttpServerTest + void postMono(HttpServer httpServer) throws Exception { + startServer(httpServer); + + URI uri = URI.create("http://localhost:" + super.port + "/mono"); Person person = new Person("Jack"); RequestEntity requestEntity = RequestEntity.post(uri).body(person); ResponseEntity result = restTemplate.exchange(requestEntity, Person.class); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RenderingResponseIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RenderingResponseIntegrationTests.java index 77bcdc1d7c1..6cf0a7baefd 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RenderingResponseIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RenderingResponseIntegrationTests.java @@ -23,7 +23,6 @@ import java.util.List; import java.util.Locale; import java.util.Map; -import org.junit.Test; import reactor.core.publisher.Mono; import org.springframework.core.io.buffer.DataBuffer; @@ -31,6 +30,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.http.server.reactive.ServerHttpResponse; +import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.lang.Nullable; import org.springframework.web.client.RestTemplate; import org.springframework.web.reactive.result.view.View; @@ -46,7 +46,7 @@ import static org.springframework.web.reactive.function.server.RouterFunctions.r * @author Arjen Poutsma * @since 5.0 */ -public class RenderingResponseIntegrationTests extends AbstractRouterFunctionIntegrationTests { +class RenderingResponseIntegrationTests extends AbstractRouterFunctionIntegrationTests { private final RestTemplate restTemplate = new RestTemplate(); @@ -72,8 +72,10 @@ public class RenderingResponseIntegrationTests extends AbstractRouterFunctionInt } - @Test - public void normal() { + @ParameterizedHttpServerTest + void normal(HttpServer httpServer) throws Exception { + startServer(httpServer); + ResponseEntity result = restTemplate.getForEntity("http://localhost:" + port + "/normal", String.class); @@ -84,8 +86,10 @@ public class RenderingResponseIntegrationTests extends AbstractRouterFunctionInt assertThat(body.get("bar")).isEqualTo("baz"); } - @Test - public void filter() { + @ParameterizedHttpServerTest + void filter(HttpServer httpServer) throws Exception { + startServer(httpServer); + ResponseEntity result = restTemplate.getForEntity("http://localhost:" + port + "/filter", String.class); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RequestPredicateAttributesTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RequestPredicateAttributesTests.java index 1b290b4ac3a..2eaeaf3c90d 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RequestPredicateAttributesTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RequestPredicateAttributesTests.java @@ -18,8 +18,8 @@ package org.springframework.web.reactive.function.server; import java.util.Collections; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.codec.StringDecoder; import org.springframework.http.codec.DecoderHttpMessageReader; @@ -35,7 +35,7 @@ public class RequestPredicateAttributesTests { private DefaultServerRequest request; - @Before + @BeforeEach public void createRequest() { MockServerHttpRequest request = MockServerHttpRequest.get("https://example.com/path").build(); MockServerWebExchange webExchange = MockServerWebExchange.from(request); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RequestPredicateTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RequestPredicateTests.java index 8529f39d67f..0b76e92f0b5 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RequestPredicateTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RequestPredicateTests.java @@ -16,7 +16,7 @@ package org.springframework.web.reactive.function.server; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RequestPredicatesTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RequestPredicatesTests.java index 4f521e0e555..7783d1fe683 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RequestPredicatesTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RequestPredicatesTests.java @@ -20,7 +20,7 @@ import java.net.URI; import java.util.Collections; import java.util.function.Function; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpMethod; import org.springframework.http.MediaType; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/ResourceHandlerFunctionTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/ResourceHandlerFunctionTests.java index e2586186337..9b05431dbdc 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/ResourceHandlerFunctionTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/ResourceHandlerFunctionTests.java @@ -21,8 +21,8 @@ import java.nio.file.Files; import java.util.EnumSet; import java.util.List; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; @@ -52,7 +52,7 @@ public class ResourceHandlerFunctionTests { private ServerResponse.Context context; - @Before + @BeforeEach public void createContext() { HandlerStrategies strategies = HandlerStrategies.withDefaults(); context = new ServerResponse.Context() { diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RouterFunctionBuilderTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RouterFunctionBuilderTests.java index 65cb2b32f93..479e04ea372 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RouterFunctionBuilderTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RouterFunctionBuilderTests.java @@ -19,7 +19,7 @@ package org.springframework.web.reactive.function.server; import java.net.URI; import java.util.concurrent.atomic.AtomicInteger; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RouterFunctionTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RouterFunctionTests.java index 1963fc53fd4..d3d89e82630 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RouterFunctionTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RouterFunctionTests.java @@ -16,7 +16,7 @@ package org.springframework.web.reactive.function.server; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RouterFunctionsTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RouterFunctionsTests.java index 19f15cd6ea0..be24c7d642a 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RouterFunctionsTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RouterFunctionsTests.java @@ -19,7 +19,7 @@ package org.springframework.web.reactive.function.server; import java.util.Optional; import java.util.concurrent.atomic.AtomicBoolean; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/SseHandlerFunctionIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/SseHandlerFunctionIntegrationTests.java index a55ca9afa6c..92d51cd7644 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/SseHandlerFunctionIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/SseHandlerFunctionIntegrationTests.java @@ -18,8 +18,6 @@ package org.springframework.web.reactive.function.server; import java.time.Duration; -import org.junit.Before; -import org.junit.Test; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; @@ -27,6 +25,7 @@ import reactor.test.StepVerifier; import org.springframework.core.ParameterizedTypeReference; import org.springframework.http.MediaType; import org.springframework.http.codec.ServerSentEvent; +import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.web.reactive.function.client.WebClient; import static org.assertj.core.api.Assertions.assertThat; @@ -36,15 +35,16 @@ import static org.springframework.web.reactive.function.server.RouterFunctions.r /** * @author Arjen Poutsma + * @author Sam Brannen */ -public class SseHandlerFunctionIntegrationTests extends AbstractRouterFunctionIntegrationTests { +class SseHandlerFunctionIntegrationTests extends AbstractRouterFunctionIntegrationTests { private WebClient webClient; - @Before - public void setup() throws Exception { - super.setup(); + @Override + protected void startServer(HttpServer httpServer) throws Exception { + super.startServer(httpServer); this.webClient = WebClient.create("http://localhost:" + this.port); } @@ -57,8 +57,10 @@ public class SseHandlerFunctionIntegrationTests extends AbstractRouterFunctionIn } - @Test - public void sseAsString() { + @ParameterizedHttpServerTest + void sseAsString(HttpServer httpServer) throws Exception { + startServer(httpServer); + Flux result = this.webClient.get() .uri("/string") .accept(TEXT_EVENT_STREAM) @@ -72,8 +74,10 @@ public class SseHandlerFunctionIntegrationTests extends AbstractRouterFunctionIn .verify(Duration.ofSeconds(5L)); } - @Test - public void sseAsPerson() { + @ParameterizedHttpServerTest + void sseAsPerson(HttpServer httpServer) throws Exception { + startServer(httpServer); + Flux result = this.webClient.get() .uri("/person") .accept(TEXT_EVENT_STREAM) @@ -87,8 +91,10 @@ public class SseHandlerFunctionIntegrationTests extends AbstractRouterFunctionIn .verify(Duration.ofSeconds(5L)); } - @Test - public void sseAsEvent() { + @ParameterizedHttpServerTest + void sseAsEvent(HttpServer httpServer) throws Exception { + startServer(httpServer); + Flux> result = this.webClient.get() .uri("/event") .accept(TEXT_EVENT_STREAM) diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/ToStringVisitorTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/ToStringVisitorTests.java index 988f06693a2..1f92356a975 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/ToStringVisitorTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/ToStringVisitorTests.java @@ -16,7 +16,7 @@ package org.springframework.web.reactive.function.server; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; import org.springframework.http.HttpMethod; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/support/DispatcherHandlerIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/support/DispatcherHandlerIntegrationTests.java index 7f142141639..6276697abd4 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/support/DispatcherHandlerIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/support/DispatcherHandlerIntegrationTests.java @@ -16,7 +16,6 @@ package org.springframework.web.reactive.function.server.support; -import org.junit.Test; import reactor.core.publisher.Mono; import org.springframework.context.annotation.AnnotationConfigApplicationContext; @@ -26,6 +25,7 @@ import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.http.server.reactive.AbstractHttpHandlerIntegrationTests; import org.springframework.http.server.reactive.HttpHandler; +import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.web.client.RestTemplate; import org.springframework.web.reactive.DispatcherHandler; import org.springframework.web.reactive.config.EnableWebFlux; @@ -41,7 +41,7 @@ import static org.springframework.web.reactive.function.server.RouterFunctions.r /** * @author Arjen Poutsma */ -public class DispatcherHandlerIntegrationTests extends AbstractHttpHandlerIntegrationTests { +class DispatcherHandlerIntegrationTests extends AbstractHttpHandlerIntegrationTests { private final RestTemplate restTemplate = new RestTemplate(); @@ -56,8 +56,10 @@ public class DispatcherHandlerIntegrationTests extends AbstractHttpHandlerIntegr } - @Test - public void nested() { + @ParameterizedHttpServerTest + void nested(HttpServer httpServer) throws Exception { + startServer(httpServer); + ResponseEntity result = this.restTemplate .getForEntity("http://localhost:" + this.port + "/foo/bar", String.class); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/support/RouterFunctionMappingTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/support/RouterFunctionMappingTests.java index 937234b02bf..88748cc50c7 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/support/RouterFunctionMappingTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/support/RouterFunctionMappingTests.java @@ -16,7 +16,7 @@ package org.springframework.web.reactive.function.server.support; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/support/ServerRequestWrapperTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/support/ServerRequestWrapperTests.java index 1a7bef6f3b9..fe2c8d120f8 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/support/ServerRequestWrapperTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/support/ServerRequestWrapperTests.java @@ -21,7 +21,7 @@ import java.util.Collections; import java.util.Map; import java.util.Optional; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/handler/CorsUrlHandlerMappingTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/handler/CorsUrlHandlerMappingTests.java index b7553d62512..652c78dfb8a 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/handler/CorsUrlHandlerMappingTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/handler/CorsUrlHandlerMappingTests.java @@ -17,8 +17,8 @@ package org.springframework.web.reactive.handler; import java.util.Collections; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; @@ -45,7 +45,7 @@ public class CorsUrlHandlerMappingTests { private CorsAwareHandler corsController = new CorsAwareHandler(); - @Before + @BeforeEach public void setup() { this.handlerMapping = new AbstractUrlHandlerMapping() {}; this.handlerMapping.registerHandler("/welcome.html", this.welcomeController); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/handler/SimpleUrlHandlerMappingTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/handler/SimpleUrlHandlerMappingTests.java index db055651db4..73d80b7c432 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/handler/SimpleUrlHandlerMappingTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/handler/SimpleUrlHandlerMappingTests.java @@ -18,7 +18,7 @@ package org.springframework.web.reactive.handler; import java.net.URI; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/handler/WebFluxResponseStatusExceptionHandlerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/handler/WebFluxResponseStatusExceptionHandlerTests.java index 6e6705d0ef3..064a4d1eb64 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/handler/WebFluxResponseStatusExceptionHandlerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/handler/WebFluxResponseStatusExceptionHandlerTests.java @@ -18,7 +18,7 @@ package org.springframework.web.reactive.handler; import java.time.Duration; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.ResponseStatus; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/AppCacheManifestTransformerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/AppCacheManifestTransformerTests.java index 5985b753f50..3856014728b 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/AppCacheManifestTransformerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/AppCacheManifestTransformerTests.java @@ -21,8 +21,8 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; @@ -47,7 +47,7 @@ public class AppCacheManifestTransformerTests { private ResourceTransformerChain chain; - @Before + @BeforeEach public void setup() { VersionResourceResolver versionResolver = new VersionResourceResolver(); versionResolver.setStrategyMap(Collections.singletonMap("/**", new ContentVersionStrategy())); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/CachingResourceResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/CachingResourceResolverTests.java index 5fd210c3f74..80c0b953b59 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/CachingResourceResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/CachingResourceResolverTests.java @@ -21,8 +21,8 @@ import java.time.Duration; import java.util.ArrayList; import java.util.List; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.springframework.cache.Cache; @@ -51,7 +51,7 @@ public class CachingResourceResolverTests { private List locations; - @Before + @BeforeEach public void setup() { this.cache = new ConcurrentMapCache("resourceCache"); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ContentBasedVersionStrategyTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ContentBasedVersionStrategyTests.java index b66907b45cd..692be93a4b6 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ContentBasedVersionStrategyTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ContentBasedVersionStrategyTests.java @@ -18,8 +18,8 @@ package org.springframework.web.reactive.resource; import java.util.Collections; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; @@ -38,7 +38,7 @@ public class ContentBasedVersionStrategyTests { private ContentVersionStrategy strategy = new ContentVersionStrategy(); - @Before + @BeforeEach public void setup() { VersionResourceResolver versionResourceResolver = new VersionResourceResolver(); versionResourceResolver.setStrategyMap(Collections.singletonMap("/**", this.strategy)); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/CssLinkResourceTransformerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/CssLinkResourceTransformerTests.java index 0ccefb99590..ca008df9831 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/CssLinkResourceTransformerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/CssLinkResourceTransformerTests.java @@ -21,8 +21,8 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import reactor.test.StepVerifier; @@ -46,7 +46,7 @@ public class CssLinkResourceTransformerTests { private ResourceTransformerChain transformerChain; - @Before + @BeforeEach public void setup() { VersionResourceResolver versionResolver = new VersionResourceResolver(); versionResolver.setStrategyMap(Collections.singletonMap("/**", new ContentVersionStrategy())); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/EncodedResourceResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/EncodedResourceResolverTests.java index 2b249d533ee..648b6f06145 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/EncodedResourceResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/EncodedResourceResolverTests.java @@ -28,9 +28,9 @@ import java.util.Collections; import java.util.List; import java.util.zip.GZIPOutputStream; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.cache.Cache; import org.springframework.cache.concurrent.ConcurrentMapCache; @@ -59,7 +59,7 @@ public class EncodedResourceResolverTests { private List locations; - @BeforeClass + @BeforeAll public static void createGzippedResources() throws IOException { createGzippedFile("/js/foo.js"); createGzippedFile("foo.css"); @@ -79,7 +79,7 @@ public class EncodedResourceResolverTests { } - @Before + @BeforeEach public void setup() { Cache cache = new ConcurrentMapCache("resourceCache"); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/FixedVersionStrategyTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/FixedVersionStrategyTests.java index 3d91832279c..ada7a865751 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/FixedVersionStrategyTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/FixedVersionStrategyTests.java @@ -16,8 +16,8 @@ package org.springframework.web.reactive.resource; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; @@ -37,7 +37,7 @@ public class FixedVersionStrategyTests { private FixedVersionStrategy strategy; - @Before + @BeforeEach public void setup() { this.strategy = new FixedVersionStrategy(VERSION); } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/PathResourceResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/PathResourceResolverTests.java index fedbf992b4c..29cd298c6fc 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/PathResourceResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/PathResourceResolverTests.java @@ -19,7 +19,7 @@ import java.io.IOException; import java.time.Duration; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.FileUrlResource; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ResourceTransformerSupportTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ResourceTransformerSupportTests.java index bee7282f2ec..cafb3afb4a8 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ResourceTransformerSupportTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ResourceTransformerSupportTests.java @@ -21,8 +21,8 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; import org.springframework.core.io.ClassPathResource; @@ -49,7 +49,7 @@ public class ResourceTransformerSupportTests { private TestResourceTransformerSupport transformer; - @Before + @BeforeEach public void setup() { VersionResourceResolver versionResolver = new VersionResourceResolver(); versionResolver.setStrategyMap(Collections.singletonMap("/**", new ContentVersionStrategy())); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ResourceUrlProviderTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ResourceUrlProviderTests.java index b6caad2d2bc..1d8ce77d445 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ResourceUrlProviderTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ResourceUrlProviderTests.java @@ -24,8 +24,8 @@ import java.util.List; import java.util.Map; import org.assertj.core.api.Condition; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -61,7 +61,7 @@ public class ResourceUrlProviderTests { private final MockServerWebExchange exchange = MockServerWebExchange.from(get("/")); - @Before + @BeforeEach public void setup() throws Exception { this.locations.add(new ClassPathResource("test/", getClass())); this.locations.add(new ClassPathResource("testalternatepath/", getClass())); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ResourceWebHandlerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ResourceWebHandlerTests.java index d9f88365934..83821b2d025 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ResourceWebHandlerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/ResourceWebHandlerTests.java @@ -26,8 +26,8 @@ import java.util.List; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; @@ -78,7 +78,7 @@ public class ResourceWebHandlerTests { private DataBufferFactory bufferFactory = new DefaultDataBufferFactory(); - @Before + @BeforeEach public void setup() throws Exception { List locations = new ArrayList<>(2); locations.add(new ClassPathResource("test/", getClass())); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/VersionResourceResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/VersionResourceResolverTests.java index 295732c61bf..3d9e97be95d 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/VersionResourceResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/VersionResourceResolverTests.java @@ -23,8 +23,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; import org.springframework.core.io.ClassPathResource; @@ -56,7 +56,7 @@ public class VersionResourceResolverTests { private VersionStrategy versionStrategy; - @Before + @BeforeEach public void setup() { this.locations = new ArrayList<>(); this.locations.add(new ClassPathResource("test/", getClass())); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/WebJarsResourceResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/WebJarsResourceResolverTests.java index 8222c23c71e..b78bcc4ec0f 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/resource/WebJarsResourceResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/resource/WebJarsResourceResolverTests.java @@ -19,8 +19,8 @@ package org.springframework.web.reactive.resource; import java.time.Duration; import java.util.List; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; import org.springframework.core.io.ClassPathResource; @@ -57,7 +57,7 @@ public class WebJarsResourceResolverTests { private ServerWebExchange exchange; - @Before + @BeforeEach public void setup() { // for this to work, an actual WebJar must be on the test classpath this.locations = singletonList(new ClassPathResource("/META-INF/resources/webjars")); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/HandlerResultHandlerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/HandlerResultHandlerTests.java index e47ddfbf2b7..98121a60719 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/HandlerResultHandlerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/HandlerResultHandlerTests.java @@ -20,7 +20,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.ReactiveAdapterRegistry; import org.springframework.http.MediaType; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/SimpleUrlHandlerMappingIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/SimpleUrlHandlerMappingIntegrationTests.java index 539dde8da7e..f5d489f2e14 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/SimpleUrlHandlerMappingIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/SimpleUrlHandlerMappingIntegrationTests.java @@ -21,7 +21,6 @@ import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; -import org.junit.Test; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -36,6 +35,7 @@ import org.springframework.http.RequestEntity; import org.springframework.http.ResponseEntity; import org.springframework.http.server.reactive.AbstractHttpHandlerIntegrationTests; import org.springframework.http.server.reactive.HttpHandler; +import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.web.client.HttpClientErrorException; import org.springframework.web.client.RestTemplate; import org.springframework.web.reactive.DispatcherHandler; @@ -52,7 +52,7 @@ import static org.assertj.core.api.Assertions.assertThat; * * @author Rossen Stoyanchev */ -public class SimpleUrlHandlerMappingIntegrationTests extends AbstractHttpHandlerIntegrationTests { +class SimpleUrlHandlerMappingIntegrationTests extends AbstractHttpHandlerIntegrationTests { @Override protected HttpHandler createHttpHandler() { @@ -66,8 +66,10 @@ public class SimpleUrlHandlerMappingIntegrationTests extends AbstractHttpHandler } - @Test - public void testRequestToFooHandler() throws Exception { + @ParameterizedHttpServerTest + void testRequestToFooHandler(HttpServer httpServer) throws Exception { + startServer(httpServer); + URI url = new URI("http://localhost:" + this.port + "/foo"); RequestEntity request = RequestEntity.get(url).build(); ResponseEntity response = new RestTemplate().exchange(request, byte[].class); @@ -76,8 +78,10 @@ public class SimpleUrlHandlerMappingIntegrationTests extends AbstractHttpHandler assertThat(response.getBody()).isEqualTo("foo".getBytes("UTF-8")); } - @Test - public void testRequestToBarHandler() throws Exception { + @ParameterizedHttpServerTest + public void testRequestToBarHandler(HttpServer httpServer) throws Exception { + startServer(httpServer); + URI url = new URI("http://localhost:" + this.port + "/bar"); RequestEntity request = RequestEntity.get(url).build(); ResponseEntity response = new RestTemplate().exchange(request, byte[].class); @@ -86,8 +90,10 @@ public class SimpleUrlHandlerMappingIntegrationTests extends AbstractHttpHandler assertThat(response.getBody()).isEqualTo("bar".getBytes("UTF-8")); } - @Test - public void testRequestToHeaderSettingHandler() throws Exception { + @ParameterizedHttpServerTest + void testRequestToHeaderSettingHandler(HttpServer httpServer) throws Exception { + startServer(httpServer); + URI url = new URI("http://localhost:" + this.port + "/header"); RequestEntity request = RequestEntity.get(url).build(); ResponseEntity response = new RestTemplate().exchange(request, byte[].class); @@ -96,8 +102,10 @@ public class SimpleUrlHandlerMappingIntegrationTests extends AbstractHttpHandler assertThat(response.getHeaders().getFirst("foo")).isEqualTo("bar"); } - @Test - public void testHandlerNotFound() throws Exception { + @ParameterizedHttpServerTest + void testHandlerNotFound(HttpServer httpServer) throws Exception { + startServer(httpServer); + URI url = new URI("http://localhost:" + this.port + "/oops"); RequestEntity request = RequestEntity.get(url).build(); try { diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/CompositeRequestConditionTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/CompositeRequestConditionTests.java index 22da61c77e9..1a04dfbb880 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/CompositeRequestConditionTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/CompositeRequestConditionTests.java @@ -16,8 +16,8 @@ package org.springframework.web.reactive.result.condition; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; import org.springframework.mock.web.test.server.MockServerWebExchange; @@ -42,7 +42,7 @@ public class CompositeRequestConditionTests { private HeadersRequestCondition header3; - @Before + @BeforeEach public void setup() throws Exception { this.param1 = new ParamsRequestCondition("param1"); this.param2 = new ParamsRequestCondition("param2"); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/ConsumesRequestConditionTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/ConsumesRequestConditionTests.java index e0e479f42c7..12bb56842d5 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/ConsumesRequestConditionTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/ConsumesRequestConditionTests.java @@ -19,7 +19,7 @@ package org.springframework.web.reactive.result.condition; import java.util.Collection; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpHeaders; import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/HeadersRequestConditionTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/HeadersRequestConditionTests.java index 150424fe23c..ebe9da15199 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/HeadersRequestConditionTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/HeadersRequestConditionTests.java @@ -18,7 +18,7 @@ package org.springframework.web.reactive.result.condition; import java.util.Collection; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.web.server.ServerWebExchange; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/ParamsRequestConditionTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/ParamsRequestConditionTests.java index ae6100926c4..dd8d11cfb5a 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/ParamsRequestConditionTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/ParamsRequestConditionTests.java @@ -18,7 +18,7 @@ package org.springframework.web.reactive.result.condition; import java.util.Collection; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.web.server.ServerWebExchange; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/PatternsRequestConditionTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/PatternsRequestConditionTests.java index 216c54d3363..3cd5074426a 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/PatternsRequestConditionTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/PatternsRequestConditionTests.java @@ -20,7 +20,7 @@ import java.util.Arrays; import java.util.Iterator; import java.util.stream.Collectors; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.server.MockServerWebExchange; import org.springframework.web.server.ServerWebExchange; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/ProducesRequestConditionTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/ProducesRequestConditionTests.java index 81addd26037..e7c40731182 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/ProducesRequestConditionTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/ProducesRequestConditionTests.java @@ -19,7 +19,7 @@ package org.springframework.web.reactive.result.condition; import java.util.Collection; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.MediaType; import org.springframework.mock.web.test.server.MockServerWebExchange; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/RequestConditionHolderTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/RequestConditionHolderTests.java index 491d232d488..7fd98a58335 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/RequestConditionHolderTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/RequestConditionHolderTests.java @@ -16,7 +16,7 @@ package org.springframework.web.reactive.result.condition; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; import org.springframework.mock.web.test.server.MockServerWebExchange; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/RequestMappingInfoTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/RequestMappingInfoTests.java index aa412511165..60e7dcf1e71 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/RequestMappingInfoTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/RequestMappingInfoTests.java @@ -21,8 +21,8 @@ import java.util.Collections; import java.util.Comparator; import java.util.List; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; @@ -47,7 +47,7 @@ import static org.springframework.web.reactive.result.method.RequestMappingInfo. */ public class RequestMappingInfoTests { - // TODO: CORS pre-flight (see @Ignore) + // TODO: CORS pre-flight (see @Disabled) @Test @@ -274,7 +274,7 @@ public class RequestMappingInfoTests { } @Test - @Ignore + @Disabled public void preFlightRequest() throws Exception { MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.options("/foo") .header("Origin", "https://domain.com") diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/RequestMethodsRequestConditionTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/RequestMethodsRequestConditionTests.java index 1a775156077..d7b9f50ab05 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/RequestMethodsRequestConditionTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/condition/RequestMethodsRequestConditionTests.java @@ -19,8 +19,8 @@ package org.springframework.web.reactive.result.condition; import java.net.URISyntaxException; import java.util.Collections; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; @@ -44,7 +44,7 @@ import static org.springframework.web.bind.annotation.RequestMethod.PUT; */ public class RequestMethodsRequestConditionTests { - // TODO: custom method, CORS pre-flight (see @Ignored) + // TODO: custom method, CORS pre-flight (see @Disabledd) @Test public void getMatchingCondition() throws Exception { @@ -73,7 +73,7 @@ public class RequestMethodsRequestConditionTests { } @Test - @Ignore + @Disabled public void getMatchingConditionWithCustomMethod() throws Exception { ServerWebExchange exchange = getExchange("PROPFIND"); assertThat(new RequestMethodsRequestCondition().getMatchingCondition(exchange)).isNotNull(); @@ -81,7 +81,7 @@ public class RequestMethodsRequestConditionTests { } @Test - @Ignore + @Disabled public void getMatchingConditionWithCorsPreFlight() throws Exception { ServerWebExchange exchange = getExchange("OPTIONS"); exchange.getRequest().getHeaders().add("Origin", "https://example.com"); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/HandlerMethodMappingTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/HandlerMethodMappingTests.java index 45c2ab0e9db..471329379c5 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/HandlerMethodMappingTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/HandlerMethodMappingTests.java @@ -20,8 +20,8 @@ import java.lang.reflect.Method; import java.util.Comparator; import org.hamcrest.Matchers; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; @@ -55,7 +55,7 @@ public class HandlerMethodMappingTests { private Method method2; - @Before + @BeforeEach public void setup() throws Exception { this.mapping = new MyHandlerMethodMapping(); this.handler = new MyHandler(); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/InvocableHandlerMethodTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/InvocableHandlerMethodTests.java index cbef4c21c00..c870e2b26f2 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/InvocableHandlerMethodTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/InvocableHandlerMethodTests.java @@ -23,7 +23,7 @@ import java.time.Instant; import java.util.ArrayList; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/RequestMappingInfoHandlerMappingTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/RequestMappingInfoHandlerMappingTests.java index 395d3d1906b..d9d1b505479 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/RequestMappingInfoHandlerMappingTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/RequestMappingInfoHandlerMappingTests.java @@ -27,8 +27,8 @@ import java.util.Map; import java.util.Set; import java.util.function.Consumer; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; @@ -87,7 +87,7 @@ public class RequestMappingInfoHandlerMappingTests { private TestRequestMappingInfoHandlerMapping handlerMapping; - @Before + @BeforeEach public void setup() { this.handlerMapping = new TestRequestMappingInfoHandlerMapping(); this.handlerMapping.registerHandler(new TestController()); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ContextPathIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ContextPathIntegrationTests.java index ba16cfbf57b..2eb722eac83 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ContextPathIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ContextPathIntegrationTests.java @@ -17,7 +17,7 @@ package org.springframework.web.reactive.result.method.annotation; import java.io.File; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ControllerAdviceTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ControllerAdviceTests.java index 9a4da6ecfe5..cd0424fbd75 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ControllerAdviceTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ControllerAdviceTests.java @@ -20,7 +20,7 @@ import java.lang.reflect.Method; import java.time.Duration; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.FatalBeanException; import org.springframework.context.ApplicationContext; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ControllerInputIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ControllerInputIntegrationTests.java index 7cf3c12413b..af93bb19461 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ControllerInputIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ControllerInputIntegrationTests.java @@ -16,7 +16,6 @@ package org.springframework.web.reactive.result.method.annotation; -import org.junit.Test; import org.reactivestreams.Publisher; import reactor.core.publisher.Flux; @@ -24,6 +23,7 @@ import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpHeaders; +import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.MatrixVariable; import org.springframework.web.bind.annotation.RequestParam; @@ -41,7 +41,7 @@ import static org.assertj.core.api.Assertions.assertThat; * * @author Rossen Stoyanchev */ -public class ControllerInputIntegrationTests extends AbstractRequestMappingIntegrationTests { +class ControllerInputIntegrationTests extends AbstractRequestMappingIntegrationTests { @Override protected ApplicationContext initApplicationContext() { @@ -52,20 +52,26 @@ public class ControllerInputIntegrationTests extends AbstractRequestMappingInteg } - @Test - public void handleWithParam() throws Exception { + @ParameterizedHttpServerTest + void handleWithParam(HttpServer httpServer) throws Exception { + startServer(httpServer); + String expected = "Hello George!"; assertThat(performGet("/param?name=George", new HttpHeaders(), String.class).getBody()).isEqualTo(expected); } - @Test // SPR-15140 - public void handleWithEncodedParam() throws Exception { + @ParameterizedHttpServerTest // SPR-15140 + void handleWithEncodedParam(HttpServer httpServer) throws Exception { + startServer(httpServer); + String expected = "Hello + \u00e0!"; assertThat(performGet("/param?name=%20%2B+%C3%A0", new HttpHeaders(), String.class).getBody()).isEqualTo(expected); } - @Test - public void matrixVariable() throws Exception { + @ParameterizedHttpServerTest + void matrixVariable(HttpServer httpServer) throws Exception { + startServer(httpServer); + String expected = "p=11, q2=22, q4=44"; String url = "/first;p=11/second;q=22/third-fourth;q=44"; assertThat(performGet(url, new HttpHeaders(), String.class).getBody()).isEqualTo(expected); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ControllerMethodResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ControllerMethodResolverTests.java index dcce6653b83..b85e6c4248e 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ControllerMethodResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ControllerMethodResolverTests.java @@ -20,8 +20,8 @@ import java.lang.reflect.Method; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; import org.springframework.context.annotation.AnnotationConfigApplicationContext; @@ -61,7 +61,7 @@ public class ControllerMethodResolverTests { private HandlerMethod handlerMethod; - @Before + @BeforeEach public void setup() { ArgumentResolverConfigurer resolvers = new ArgumentResolverConfigurer(); resolvers.addCustomResolver(new CustomArgumentResolver()); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/CookieValueMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/CookieValueMethodArgumentResolverTests.java index e9715d81a82..a6829344bc9 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/CookieValueMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/CookieValueMethodArgumentResolverTests.java @@ -18,8 +18,8 @@ package org.springframework.web.reactive.result.method.annotation; import java.lang.reflect.Method; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; @@ -55,7 +55,7 @@ public class CookieValueMethodArgumentResolverTests { private MethodParameter cookieMonoParameter; - @Before + @BeforeEach @SuppressWarnings("resource") public void setup() throws Exception { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/CrossOriginAnnotationIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/CrossOriginAnnotationIntegrationTests.java index 2f039a2405d..07a027b6926 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/CrossOriginAnnotationIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/CrossOriginAnnotationIntegrationTests.java @@ -18,9 +18,6 @@ package org.springframework.web.reactive.result.method.annotation; import java.util.Properties; -import org.junit.Before; -import org.junit.Test; - import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.ComponentScan; @@ -32,6 +29,7 @@ import org.springframework.http.HttpMethod; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; +import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; @@ -49,20 +47,19 @@ import static org.assertj.core.api.Assertions.assertThat; * * @author Sebastien Deleuze * @author Rossen Stoyanchev + * @author Sam Brannen */ -public class CrossOriginAnnotationIntegrationTests extends AbstractRequestMappingIntegrationTests { +class CrossOriginAnnotationIntegrationTests extends AbstractRequestMappingIntegrationTests { - private HttpHeaders headers; + private final HttpHeaders headers = new HttpHeaders(); - @Before - public void setup() throws Exception { - super.setup(); - this.headers = new HttpHeaders(); + @Override + protected void startServer(HttpServer httpServer) throws Exception { + super.startServer(httpServer); this.headers.setOrigin("https://site1.com"); } - @Override protected ApplicationContext initApplicationContext() { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); @@ -82,24 +79,30 @@ public class CrossOriginAnnotationIntegrationTests extends AbstractRequestMappin } - @Test - public void actualGetRequestWithoutAnnotation() throws Exception { + @ParameterizedHttpServerTest + void actualGetRequestWithoutAnnotation(HttpServer httpServer) throws Exception { + startServer(httpServer); + ResponseEntity entity = performGet("/no", this.headers, String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getHeaders().getAccessControlAllowOrigin()).isNull(); assertThat(entity.getBody()).isEqualTo("no"); } - @Test - public void actualPostRequestWithoutAnnotation() throws Exception { + @ParameterizedHttpServerTest + void actualPostRequestWithoutAnnotation(HttpServer httpServer) throws Exception { + startServer(httpServer); + ResponseEntity entity = performPost("/no", this.headers, null, String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getHeaders().getAccessControlAllowOrigin()).isNull(); assertThat(entity.getBody()).isEqualTo("no-post"); } - @Test - public void actualRequestWithDefaultAnnotation() throws Exception { + @ParameterizedHttpServerTest + void actualRequestWithDefaultAnnotation(HttpServer httpServer) throws Exception { + startServer(httpServer); + ResponseEntity entity = performGet("/default", this.headers, String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getHeaders().getAccessControlAllowOrigin()).isEqualTo("*"); @@ -107,8 +110,10 @@ public class CrossOriginAnnotationIntegrationTests extends AbstractRequestMappin assertThat(entity.getBody()).isEqualTo("default"); } - @Test - public void preflightRequestWithDefaultAnnotation() throws Exception { + @ParameterizedHttpServerTest + void preflightRequestWithDefaultAnnotation(HttpServer httpServer) throws Exception { + startServer(httpServer); + this.headers.add(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET"); ResponseEntity entity = performOptions("/default", this.headers, Void.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); @@ -117,8 +122,10 @@ public class CrossOriginAnnotationIntegrationTests extends AbstractRequestMappin assertThat(entity.getHeaders().getAccessControlAllowCredentials()).isFalse(); } - @Test - public void actualRequestWithDefaultAnnotationAndNoOrigin() throws Exception { + @ParameterizedHttpServerTest + void actualRequestWithDefaultAnnotationAndNoOrigin(HttpServer httpServer) throws Exception { + startServer(httpServer); + HttpHeaders headers = new HttpHeaders(); ResponseEntity entity = performGet("/default", headers, String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); @@ -126,8 +133,10 @@ public class CrossOriginAnnotationIntegrationTests extends AbstractRequestMappin assertThat(entity.getBody()).isEqualTo("default"); } - @Test - public void actualRequestWithCustomizedAnnotation() throws Exception { + @ParameterizedHttpServerTest + void actualRequestWithCustomizedAnnotation(HttpServer httpServer) throws Exception { + startServer(httpServer); + ResponseEntity entity = performGet("/customized", this.headers, String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getHeaders().getAccessControlAllowOrigin()).isEqualTo("https://site1.com"); @@ -136,8 +145,10 @@ public class CrossOriginAnnotationIntegrationTests extends AbstractRequestMappin assertThat(entity.getBody()).isEqualTo("customized"); } - @Test - public void preflightRequestWithCustomizedAnnotation() throws Exception { + @ParameterizedHttpServerTest + void preflightRequestWithCustomizedAnnotation(HttpServer httpServer) throws Exception { + startServer(httpServer); + this.headers.add(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET"); this.headers.add(HttpHeaders.ACCESS_CONTROL_REQUEST_HEADERS, "header1, header2"); ResponseEntity entity = performOptions("/customized", this.headers, String.class); @@ -151,24 +162,30 @@ public class CrossOriginAnnotationIntegrationTests extends AbstractRequestMappin assertThat(entity.getHeaders().getAccessControlMaxAge()).isEqualTo(123); } - @Test - public void customOriginDefinedViaValueAttribute() throws Exception { + @ParameterizedHttpServerTest + void customOriginDefinedViaValueAttribute(HttpServer httpServer) throws Exception { + startServer(httpServer); + ResponseEntity entity = performGet("/origin-value-attribute", this.headers, String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getHeaders().getAccessControlAllowOrigin()).isEqualTo("https://site1.com"); assertThat(entity.getBody()).isEqualTo("value-attribute"); } - @Test - public void customOriginDefinedViaPlaceholder() throws Exception { + @ParameterizedHttpServerTest + void customOriginDefinedViaPlaceholder(HttpServer httpServer) throws Exception { + startServer(httpServer); + ResponseEntity entity = performGet("/origin-placeholder", this.headers, String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getHeaders().getAccessControlAllowOrigin()).isEqualTo("https://site1.com"); assertThat(entity.getBody()).isEqualTo("placeholder"); } - @Test - public void classLevel() throws Exception { + @ParameterizedHttpServerTest + void classLevel(HttpServer httpServer) throws Exception { + startServer(httpServer); + ResponseEntity entity = performGet("/foo", this.headers, String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getHeaders().getAccessControlAllowOrigin()).isEqualTo("*"); @@ -188,8 +205,10 @@ public class CrossOriginAnnotationIntegrationTests extends AbstractRequestMappin assertThat(entity.getBody()).isEqualTo("baz"); } - @Test - public void ambiguousHeaderPreflightRequest() throws Exception { + @ParameterizedHttpServerTest + void ambiguousHeaderPreflightRequest(HttpServer httpServer) throws Exception { + startServer(httpServer); + this.headers.add(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET"); this.headers.add(HttpHeaders.ACCESS_CONTROL_REQUEST_HEADERS, "header1"); ResponseEntity entity = performOptions("/ambiguous-header", this.headers, String.class); @@ -201,8 +220,10 @@ public class CrossOriginAnnotationIntegrationTests extends AbstractRequestMappin assertThat(entity.getHeaders().getAccessControlAllowCredentials()).isTrue(); } - @Test - public void ambiguousProducesPreflightRequest() throws Exception { + @ParameterizedHttpServerTest + void ambiguousProducesPreflightRequest(HttpServer httpServer) throws Exception { + startServer(httpServer); + this.headers.add(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET"); ResponseEntity entity = performOptions("/ambiguous-produces", this.headers, String.class); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ErrorsMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ErrorsMethodArgumentResolverTests.java index 6b98a95dd22..f576115dde4 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ErrorsMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ErrorsMethodArgumentResolverTests.java @@ -18,7 +18,7 @@ package org.springframework.web.reactive.result.method.annotation; import java.time.Duration; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; import reactor.core.publisher.MonoProcessor; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ExpressionValueMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ExpressionValueMethodArgumentResolverTests.java index 2fe03f8b4f4..43d5ac18f18 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ExpressionValueMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ExpressionValueMethodArgumentResolverTests.java @@ -18,8 +18,8 @@ package org.springframework.web.reactive.result.method.annotation; import java.lang.reflect.Method; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; import org.springframework.beans.factory.annotation.Value; @@ -50,7 +50,7 @@ public class ExpressionValueMethodArgumentResolverTests { private MethodParameter paramAlsoNotSupported; - @Before + @BeforeEach @SuppressWarnings("resource") public void setup() throws Exception { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/GlobalCorsConfigIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/GlobalCorsConfigIntegrationTests.java index 658c22301b2..49dd73e5a06 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/GlobalCorsConfigIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/GlobalCorsConfigIntegrationTests.java @@ -16,9 +16,6 @@ package org.springframework.web.reactive.result.method.annotation; -import org.junit.Before; -import org.junit.Test; - import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.ComponentScan; @@ -29,6 +26,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; +import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.client.HttpClientErrorException; @@ -46,26 +44,22 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; * * @author Sebastien Deleuze * @author Rossen Stoyanchev + * @author Sam Brannen */ -public class GlobalCorsConfigIntegrationTests extends AbstractRequestMappingIntegrationTests { +class GlobalCorsConfigIntegrationTests extends AbstractRequestMappingIntegrationTests { - private HttpHeaders headers; + private final HttpHeaders headers = new HttpHeaders(); - @Before - public void setup() throws Exception { - super.setup(); - this.headers = new HttpHeaders(); + @Override + protected void startServer(HttpServer httpServer) throws Exception { + super.startServer(httpServer); this.headers.setOrigin("http://localhost:9000"); } - @Override protected ApplicationContext initApplicationContext() { - AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); - context.register(WebConfig.class); - context.refresh(); - return context; + return new AnnotationConfigApplicationContext(WebConfig.class); } @Override @@ -75,39 +69,49 @@ public class GlobalCorsConfigIntegrationTests extends AbstractRequestMappingInte } - @Test - public void actualRequestWithCorsEnabled() throws Exception { + @ParameterizedHttpServerTest + void actualRequestWithCorsEnabled(HttpServer httpServer) throws Exception { + startServer(httpServer); + ResponseEntity entity = performGet("/cors", this.headers, String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getHeaders().getAccessControlAllowOrigin()).isEqualTo("*"); assertThat(entity.getBody()).isEqualTo("cors"); } - @Test - public void actualRequestWithCorsRejected() throws Exception { + @ParameterizedHttpServerTest + void actualRequestWithCorsRejected(HttpServer httpServer) throws Exception { + startServer(httpServer); + assertThatExceptionOfType(HttpClientErrorException.class).isThrownBy(() -> performGet("/cors-restricted", this.headers, String.class)) .satisfies(ex -> assertThat(ex.getStatusCode()).isEqualTo(HttpStatus.FORBIDDEN)); } - @Test - public void actualRequestWithoutCorsEnabled() throws Exception { + @ParameterizedHttpServerTest + void actualRequestWithoutCorsEnabled(HttpServer httpServer) throws Exception { + startServer(httpServer); + ResponseEntity entity = performGet("/welcome", this.headers, String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getHeaders().getAccessControlAllowOrigin()).isNull(); assertThat(entity.getBody()).isEqualTo("welcome"); } - @Test - public void actualRequestWithAmbiguousMapping() throws Exception { + @ParameterizedHttpServerTest + void actualRequestWithAmbiguousMapping(HttpServer httpServer) throws Exception { + startServer(httpServer); + this.headers.add(HttpHeaders.ACCEPT, MediaType.TEXT_HTML_VALUE); ResponseEntity entity = performGet("/ambiguous", this.headers, String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getHeaders().getAccessControlAllowOrigin()).isEqualTo("*"); } - @Test - public void preFlightRequestWithCorsEnabled() throws Exception { + @ParameterizedHttpServerTest + void preFlightRequestWithCorsEnabled(HttpServer httpServer) throws Exception { + startServer(httpServer); + this.headers.add(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET"); ResponseEntity entity = performOptions("/cors", this.headers, String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); @@ -116,24 +120,30 @@ public class GlobalCorsConfigIntegrationTests extends AbstractRequestMappingInte .containsExactly(HttpMethod.GET, HttpMethod.HEAD, HttpMethod.POST); } - @Test - public void preFlightRequestWithCorsRejected() throws Exception { + @ParameterizedHttpServerTest + void preFlightRequestWithCorsRejected(HttpServer httpServer) throws Exception { + startServer(httpServer); + this.headers.add(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET"); assertThatExceptionOfType(HttpClientErrorException.class).isThrownBy(() -> performOptions("/cors-restricted", this.headers, String.class)) .satisfies(ex -> assertThat(ex.getStatusCode()).isEqualTo(HttpStatus.FORBIDDEN)); } - @Test - public void preFlightRequestWithoutCorsEnabled() throws Exception { + @ParameterizedHttpServerTest + void preFlightRequestWithoutCorsEnabled(HttpServer httpServer) throws Exception { + startServer(httpServer); + this.headers.add(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET"); assertThatExceptionOfType(HttpClientErrorException.class).isThrownBy(() -> performOptions("/welcome", this.headers, String.class)) .satisfies(ex -> assertThat(ex.getStatusCode()).isEqualTo(HttpStatus.FORBIDDEN)); } - @Test - public void preFlightRequestWithCorsRestricted() throws Exception { + @ParameterizedHttpServerTest + void preFlightRequestWithCorsRestricted(HttpServer httpServer) throws Exception { + startServer(httpServer); + this.headers.set(HttpHeaders.ORIGIN, "https://foo"); this.headers.add(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET"); ResponseEntity entity = performOptions("/cors-restricted", this.headers, String.class); @@ -143,8 +153,10 @@ public class GlobalCorsConfigIntegrationTests extends AbstractRequestMappingInte .containsExactly(HttpMethod.GET, HttpMethod.POST); } - @Test - public void preFlightRequestWithAmbiguousMapping() throws Exception { + @ParameterizedHttpServerTest + void preFlightRequestWithAmbiguousMapping(HttpServer httpServer) throws Exception { + startServer(httpServer); + this.headers.add(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET"); ResponseEntity entity = performOptions("/ambiguous", this.headers, String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/HttpEntityMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/HttpEntityMethodArgumentResolverTests.java index 1bc9d5db350..d163b54ccfd 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/HttpEntityMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/HttpEntityMethodArgumentResolverTests.java @@ -24,7 +24,7 @@ import java.util.concurrent.CompletableFuture; import io.reactivex.BackpressureStrategy; import io.reactivex.Flowable; import io.reactivex.Maybe; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/InitBinderBindingContextTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/InitBinderBindingContextTests.java index dd4e91ff4e2..8d1bbd33d9f 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/InitBinderBindingContextTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/InitBinderBindingContextTests.java @@ -21,7 +21,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.LocalVariableTableParameterNameDiscoverer; import org.springframework.core.ReactiveAdapterRegistry; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/JacksonHintsIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/JacksonHintsIntegrationTests.java index 314f9fcec9d..f6fb973ff67 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/JacksonHintsIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/JacksonHintsIntegrationTests.java @@ -20,7 +20,6 @@ import java.util.Arrays; import java.util.List; import com.fasterxml.jackson.annotation.JsonView; -import org.junit.Test; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -31,6 +30,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpEntity; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; +import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -42,7 +42,7 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Sebastien Deleuze */ -public class JacksonHintsIntegrationTests extends AbstractRequestMappingIntegrationTests { +class JacksonHintsIntegrationTests extends AbstractRequestMappingIntegrationTests { @Override protected ApplicationContext initApplicationContext() { @@ -53,54 +53,70 @@ public class JacksonHintsIntegrationTests extends AbstractRequestMappingIntegrat } - @Test - public void jsonViewResponse() throws Exception { + @ParameterizedHttpServerTest + void jsonViewResponse(HttpServer httpServer) throws Exception { + startServer(httpServer); + String expected = "{\"withView1\":\"with\"}"; assertThat(performGet("/response/raw", MediaType.APPLICATION_JSON, String.class).getBody()).isEqualTo(expected); } - @Test - public void jsonViewWithMonoResponse() throws Exception { + @ParameterizedHttpServerTest + void jsonViewWithMonoResponse(HttpServer httpServer) throws Exception { + startServer(httpServer); + String expected = "{\"withView1\":\"with\"}"; assertThat(performGet("/response/mono", MediaType.APPLICATION_JSON, String.class).getBody()).isEqualTo(expected); } - @Test // SPR-16098 - public void jsonViewWithMonoResponseEntity() throws Exception { + @ParameterizedHttpServerTest // SPR-16098 + void jsonViewWithMonoResponseEntity(HttpServer httpServer) throws Exception { + startServer(httpServer); + String expected = "{\"withView1\":\"with\"}"; assertThat(performGet("/response/entity", MediaType.APPLICATION_JSON, String.class).getBody()).isEqualTo(expected); } - @Test - public void jsonViewWithFluxResponse() throws Exception { + @ParameterizedHttpServerTest + void jsonViewWithFluxResponse(HttpServer httpServer) throws Exception { + startServer(httpServer); + String expected = "[{\"withView1\":\"with\"},{\"withView1\":\"with\"}]"; assertThat(performGet("/response/flux", MediaType.APPLICATION_JSON, String.class).getBody()).isEqualTo(expected); } - @Test - public void jsonViewWithRequest() throws Exception { + @ParameterizedHttpServerTest + void jsonViewWithRequest(HttpServer httpServer) throws Exception { + startServer(httpServer); + String expected = "{\"withView1\":\"with\",\"withView2\":null,\"withoutView\":null}"; assertThat(performPost("/request/raw", MediaType.APPLICATION_JSON, new JacksonViewBean("with", "with", "without"), MediaType.APPLICATION_JSON, String.class).getBody()).isEqualTo(expected); } - @Test - public void jsonViewWithMonoRequest() throws Exception { + @ParameterizedHttpServerTest + void jsonViewWithMonoRequest(HttpServer httpServer) throws Exception { + startServer(httpServer); + String expected = "{\"withView1\":\"with\",\"withView2\":null,\"withoutView\":null}"; assertThat(performPost("/request/mono", MediaType.APPLICATION_JSON, new JacksonViewBean("with", "with", "without"), MediaType.APPLICATION_JSON, String.class).getBody()).isEqualTo(expected); } - @Test // SPR-16098 - public void jsonViewWithEntityMonoRequest() throws Exception { + @ParameterizedHttpServerTest // SPR-16098 + void jsonViewWithEntityMonoRequest(HttpServer httpServer) throws Exception { + startServer(httpServer); + String expected = "{\"withView1\":\"with\",\"withView2\":null,\"withoutView\":null}"; assertThat(performPost("/request/entity/mono", MediaType.APPLICATION_JSON, new JacksonViewBean("with", "with", "without"), MediaType.APPLICATION_JSON, String.class).getBody()).isEqualTo(expected); } - @Test // SPR-16098 - public void jsonViewWithEntityFluxRequest() throws Exception { + @ParameterizedHttpServerTest // SPR-16098 + void jsonViewWithEntityFluxRequest(HttpServer httpServer) throws Exception { + startServer(httpServer); + String expected = "[" + "{\"withView1\":\"with\",\"withView2\":null,\"withoutView\":null}," + "{\"withView1\":\"with\",\"withView2\":null,\"withoutView\":null}]"; @@ -110,8 +126,10 @@ public class JacksonHintsIntegrationTests extends AbstractRequestMappingIntegrat MediaType.APPLICATION_JSON, String.class).getBody()).isEqualTo(expected); } - @Test - public void jsonViewWithFluxRequest() throws Exception { + @ParameterizedHttpServerTest + void jsonViewWithFluxRequest(HttpServer httpServer) throws Exception { + startServer(httpServer); + String expected = "[" + "{\"withView1\":\"with\",\"withView2\":null,\"withoutView\":null}," + "{\"withView1\":\"with\",\"withView2\":null,\"withoutView\":null}]"; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/JacksonStreamingIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/JacksonStreamingIntegrationTests.java index 40829966966..b6efc7ebec9 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/JacksonStreamingIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/JacksonStreamingIntegrationTests.java @@ -18,8 +18,6 @@ package org.springframework.web.reactive.result.method.annotation; import java.time.Duration; -import org.junit.Before; -import org.junit.Test; import reactor.core.publisher.Flux; import reactor.test.StepVerifier; @@ -29,6 +27,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.http.MediaType; import org.springframework.http.server.reactive.AbstractHttpHandlerIntegrationTests; import org.springframework.http.server.reactive.HttpHandler; +import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.reactive.DispatcherHandler; @@ -41,22 +40,15 @@ import static org.springframework.http.MediaType.APPLICATION_STREAM_JSON_VALUE; /** * @author Sebastien Deleuze + * @author Sam Brannen */ -public class JacksonStreamingIntegrationTests extends AbstractHttpHandlerIntegrationTests { +class JacksonStreamingIntegrationTests extends AbstractHttpHandlerIntegrationTests { private AnnotationConfigApplicationContext wac; private WebClient webClient; - @Override - @Before - public void setup() throws Exception { - super.setup(); - this.webClient = WebClient.create("http://localhost:" + this.port); - } - - @Override protected HttpHandler createHttpHandler() { this.wac = new AnnotationConfigApplicationContext(); @@ -66,8 +58,17 @@ public class JacksonStreamingIntegrationTests extends AbstractHttpHandlerIntegra return WebHttpHandlerBuilder.webHandler(new DispatcherHandler(this.wac)).build(); } - @Test - public void jsonStreaming() { + @Override + protected void startServer(HttpServer httpServer) throws Exception { + super.startServer(httpServer); + this.webClient = WebClient.create("http://localhost:" + this.port); + } + + + @ParameterizedHttpServerTest + void jsonStreaming(HttpServer httpServer) throws Exception { + startServer(httpServer); + Flux result = this.webClient.get() .uri("/stream") .accept(APPLICATION_STREAM_JSON) @@ -81,8 +82,10 @@ public class JacksonStreamingIntegrationTests extends AbstractHttpHandlerIntegra .verify(); } - @Test - public void smileStreaming() { + @ParameterizedHttpServerTest + void smileStreaming(HttpServer httpServer) throws Exception { + startServer(httpServer); + Flux result = this.webClient.get() .uri("/stream") .accept(new MediaType("application", "stream+x-jackson-smile")) @@ -96,6 +99,7 @@ public class JacksonStreamingIntegrationTests extends AbstractHttpHandlerIntegra .verify(); } + @RestController @SuppressWarnings("unused") static class JacksonStreamingController { diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MatrixVariablesMapMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MatrixVariablesMapMethodArgumentResolverTests.java index 9886efad896..681dafa7370 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MatrixVariablesMapMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MatrixVariablesMapMethodArgumentResolverTests.java @@ -21,8 +21,8 @@ import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.MethodParameter; import org.springframework.core.ReactiveAdapterRegistry; @@ -53,7 +53,7 @@ public class MatrixVariablesMapMethodArgumentResolverTests { private final ResolvableMethod testMethod = ResolvableMethod.on(this.getClass()).named("handle").build(); - @Before + @BeforeEach public void setUp() throws Exception { this.exchange.getAttributes().put(HandlerMapping.MATRIX_VARIABLES_ATTRIBUTE, new LinkedHashMap<>()); } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MatrixVariablesMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MatrixVariablesMethodArgumentResolverTests.java index 3c118f0589e..c51b6201492 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MatrixVariablesMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MatrixVariablesMethodArgumentResolverTests.java @@ -21,8 +21,8 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.MethodParameter; import org.springframework.core.ReactiveAdapterRegistry; @@ -56,7 +56,7 @@ public class MatrixVariablesMethodArgumentResolverTests { private ResolvableMethod testMethod = ResolvableMethod.on(this.getClass()).named("handle").build(); - @Before + @BeforeEach public void setUp() throws Exception { this.exchange.getAttributes().put(HandlerMapping.MATRIX_VARIABLES_ATTRIBUTE, new LinkedHashMap<>()); } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MessageReaderArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MessageReaderArgumentResolverTests.java index 405a566d60a..c9e540da7bb 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MessageReaderArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MessageReaderArgumentResolverTests.java @@ -30,8 +30,8 @@ import javax.xml.bind.annotation.XmlRootElement; import io.reactivex.Flowable; import io.reactivex.Maybe; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; @@ -77,7 +77,7 @@ public class MessageReaderArgumentResolverTests { private ResolvableMethod testMethod = ResolvableMethod.on(getClass()).named("handle").build(); - @Before + @BeforeEach public void setup() throws Exception { ConfigurableWebBindingInitializer initializer = new ConfigurableWebBindingInitializer(); initializer.setValidator(new TestBeanValidator()); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MessageWriterResultHandlerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MessageWriterResultHandlerTests.java index e9264284327..b695cc9ae6c 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MessageWriterResultHandlerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MessageWriterResultHandlerTests.java @@ -29,7 +29,7 @@ import java.util.List; import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeName; import io.reactivex.Flowable; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ModelAttributeMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ModelAttributeMethodArgumentResolverTests.java index 323cdb97c22..3b0beaef44d 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ModelAttributeMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ModelAttributeMethodArgumentResolverTests.java @@ -21,8 +21,8 @@ import java.time.Duration; import java.util.Map; import java.util.function.Function; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; import rx.RxReactiveStreams; @@ -58,7 +58,7 @@ public class ModelAttributeMethodArgumentResolverTests { private ResolvableMethod testMethod = ResolvableMethod.on(getClass()).named("handle").build(); - @Before + @BeforeEach public void setup() throws Exception { LocalValidatorFactoryBean validator = new LocalValidatorFactoryBean(); validator.afterPropertiesSet(); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ModelInitializerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ModelInitializerTests.java index 65caa3d6722..a8a5ef0d0fa 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ModelInitializerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ModelInitializerTests.java @@ -23,8 +23,8 @@ import java.util.List; import java.util.Map; import java.util.stream.Collectors; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; import rx.Single; @@ -69,7 +69,7 @@ public class ModelInitializerTests { private final ServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/path")); - @Before + @BeforeEach public void setup() { ReactiveAdapterRegistry adapterRegistry = ReactiveAdapterRegistry.getSharedInstance(); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ModelMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ModelMethodArgumentResolverTests.java index a1c8e6ceac4..3611213f0c0 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ModelMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ModelMethodArgumentResolverTests.java @@ -19,7 +19,7 @@ package org.springframework.web.reactive.result.method.annotation; import java.time.Duration; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.MethodParameter; import org.springframework.core.ReactiveAdapterRegistry; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MultipartIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MultipartIntegrationTests.java index 0926c28af8f..dc5d9f58e18 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MultipartIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/MultipartIntegrationTests.java @@ -25,8 +25,6 @@ import java.util.stream.Collectors; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; -import org.junit.Before; -import org.junit.Test; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; @@ -45,6 +43,7 @@ import org.springframework.http.codec.multipart.MultipartHttpMessageReader; import org.springframework.http.codec.multipart.Part; import org.springframework.http.server.reactive.AbstractHttpHandlerIntegrationTests; import org.springframework.http.server.reactive.HttpHandler; +import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.util.MultiValueMap; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.PostMapping; @@ -59,19 +58,11 @@ import org.springframework.web.server.adapter.WebHttpHandlerBuilder; import static org.assertj.core.api.Assertions.assertThat; -public class MultipartIntegrationTests extends AbstractHttpHandlerIntegrationTests { +class MultipartIntegrationTests extends AbstractHttpHandlerIntegrationTests { private WebClient webClient; - @Override - @Before - public void setup() throws Exception { - super.setup(); - this.webClient = WebClient.create("http://localhost:" + this.port); - } - - @Override protected HttpHandler createHttpHandler() { AnnotationConfigApplicationContext wac = new AnnotationConfigApplicationContext(); @@ -80,8 +71,17 @@ public class MultipartIntegrationTests extends AbstractHttpHandlerIntegrationTes return WebHttpHandlerBuilder.webHandler(new DispatcherHandler(wac)).build(); } - @Test - public void requestPart() { + @Override + protected void startServer(HttpServer httpServer) throws Exception { + super.startServer(httpServer); + this.webClient = WebClient.create("http://localhost:" + this.port); + } + + + @ParameterizedHttpServerTest + void requestPart(HttpServer httpServer) throws Exception { + startServer(httpServer); + Mono result = webClient .post() .uri("/requestPart") @@ -94,8 +94,10 @@ public class MultipartIntegrationTests extends AbstractHttpHandlerIntegrationTes .verifyComplete(); } - @Test - public void requestBodyMap() { + @ParameterizedHttpServerTest + void requestBodyMap(HttpServer httpServer) throws Exception { + startServer(httpServer); + Mono result = webClient .post() .uri("/requestBodyMap") @@ -108,8 +110,10 @@ public class MultipartIntegrationTests extends AbstractHttpHandlerIntegrationTes .verifyComplete(); } - @Test - public void requestBodyFlux() { + @ParameterizedHttpServerTest + void requestBodyFlux(HttpServer httpServer) throws Exception { + startServer(httpServer); + Mono result = webClient .post() .uri("/requestBodyFlux") @@ -122,8 +126,10 @@ public class MultipartIntegrationTests extends AbstractHttpHandlerIntegrationTes .verifyComplete(); } - @Test - public void filePartsFlux() { + @ParameterizedHttpServerTest + void filePartsFlux(HttpServer httpServer) throws Exception { + startServer(httpServer); + Mono result = webClient .post() .uri("/filePartFlux") @@ -136,8 +142,10 @@ public class MultipartIntegrationTests extends AbstractHttpHandlerIntegrationTes .verifyComplete(); } - @Test - public void filePartsMono() { + @ParameterizedHttpServerTest + void filePartsMono(HttpServer httpServer) throws Exception { + startServer(httpServer); + Mono result = webClient .post() .uri("/filePartMono") @@ -150,8 +158,10 @@ public class MultipartIntegrationTests extends AbstractHttpHandlerIntegrationTes .verifyComplete(); } - @Test - public void transferTo() { + @ParameterizedHttpServerTest + void transferTo(HttpServer httpServer) throws Exception { + startServer(httpServer); + Flux result = webClient .post() .uri("/transferTo") @@ -166,20 +176,10 @@ public class MultipartIntegrationTests extends AbstractHttpHandlerIntegrationTes } - private static void verifyContents(Path tempFile, Resource resource) { - try { - byte[] tempBytes = Files.readAllBytes(tempFile); - byte[] resourceBytes = Files.readAllBytes(resource.getFile().toPath()); - assertThat(tempBytes).isEqualTo(resourceBytes); - } - catch (IOException ex) { - throw new AssertionError(ex); - } - } - + @ParameterizedHttpServerTest + void modelAttribute(HttpServer httpServer) throws Exception { + startServer(httpServer); - @Test - public void modelAttribute() { Mono result = webClient .post() .uri("/modelAttribute") @@ -201,6 +201,17 @@ public class MultipartIntegrationTests extends AbstractHttpHandlerIntegrationTes return builder.build(); } + private static void verifyContents(Path tempFile, Resource resource) { + try { + byte[] tempBytes = Files.readAllBytes(tempFile); + byte[] resourceBytes = Files.readAllBytes(resource.getFile().toPath()); + assertThat(tempBytes).isEqualTo(resourceBytes); + } + catch (IOException ex) { + throw new AssertionError(ex); + } + } + @Configuration @EnableWebFlux diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/PathVariableMapMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/PathVariableMapMethodArgumentResolverTests.java index b91265f7023..051e10bcb03 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/PathVariableMapMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/PathVariableMapMethodArgumentResolverTests.java @@ -21,8 +21,8 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; import org.springframework.core.MethodParameter; @@ -54,7 +54,7 @@ public class PathVariableMapMethodArgumentResolverTests { private MethodParameter paramMonoMap; - @Before + @BeforeEach public void setup() throws Exception { this.resolver = new PathVariableMapMethodArgumentResolver(ReactiveAdapterRegistry.getSharedInstance()); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/PathVariableMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/PathVariableMethodArgumentResolverTests.java index 4c8b9d5c2e0..2be22e77e1b 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/PathVariableMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/PathVariableMethodArgumentResolverTests.java @@ -21,8 +21,8 @@ import java.util.HashMap; import java.util.Map; import java.util.Optional; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; @@ -61,7 +61,7 @@ public class PathVariableMethodArgumentResolverTests { private MethodParameter paramMono; - @Before + @BeforeEach public void setup() throws Exception { this.resolver = new PathVariableMethodArgumentResolver(null, ReactiveAdapterRegistry.getSharedInstance()); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/PrincipalMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/PrincipalMethodArgumentResolverTests.java index 8eec4db8855..4ad26e732e3 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/PrincipalMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/PrincipalMethodArgumentResolverTests.java @@ -19,7 +19,7 @@ package org.springframework.web.reactive.result.method.annotation; import java.security.Principal; import io.reactivex.Single; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; import org.springframework.core.MethodParameter; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ProtobufIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ProtobufIntegrationTests.java index a01da5da1ee..2b58d9ff0e4 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ProtobufIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ProtobufIntegrationTests.java @@ -18,8 +18,6 @@ package org.springframework.web.reactive.result.method.annotation; import java.time.Duration; -import org.junit.Before; -import org.junit.Test; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; @@ -28,6 +26,7 @@ import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; +import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.reactive.config.EnableWebFlux; @@ -41,33 +40,32 @@ import static org.assertj.core.api.Assertions.assertThat; * Integration tests for Protobuf support. * * @author Sebastien Deleuze + * @author Sam Brannen */ -public class ProtobufIntegrationTests extends AbstractRequestMappingIntegrationTests { +class ProtobufIntegrationTests extends AbstractRequestMappingIntegrationTests { - public static final Msg TEST_MSG = + static final Msg TEST_MSG = Msg.newBuilder().setFoo("Foo").setBlah(SecondMsg.newBuilder().setBlah(123).build()).build(); private WebClient webClient; @Override - @Before - public void setup() throws Exception { - super.setup(); + protected void startServer(HttpServer httpServer) throws Exception { + super.startServer(httpServer); this.webClient = WebClient.create("http://localhost:" + this.port); } @Override protected ApplicationContext initApplicationContext() { - AnnotationConfigApplicationContext wac = new AnnotationConfigApplicationContext(); - wac.register(TestConfiguration .class); - wac.refresh(); - return wac; + return new AnnotationConfigApplicationContext(TestConfiguration.class); } - @Test - public void value() { + @ParameterizedHttpServerTest + void value(HttpServer httpServer) throws Exception { + startServer(httpServer); + Mono result = this.webClient.get() .uri("/message") .exchange() @@ -83,8 +81,10 @@ public class ProtobufIntegrationTests extends AbstractRequestMappingIntegrationT .verifyComplete(); } - @Test - public void values() { + @ParameterizedHttpServerTest + void values(HttpServer httpServer) throws Exception { + startServer(httpServer); + Flux result = this.webClient.get() .uri("/messages") .exchange() @@ -102,8 +102,10 @@ public class ProtobufIntegrationTests extends AbstractRequestMappingIntegrationT .verifyComplete(); } - @Test - public void streaming() { + @ParameterizedHttpServerTest + void streaming(HttpServer httpServer) throws Exception { + startServer(httpServer); + Flux result = this.webClient.get() .uri("/message-stream") .exchange() @@ -121,8 +123,10 @@ public class ProtobufIntegrationTests extends AbstractRequestMappingIntegrationT .verify(); } - @Test - public void empty() { + @ParameterizedHttpServerTest + void empty(HttpServer httpServer) throws Exception { + startServer(httpServer); + Mono result = this.webClient.get() .uri("/empty") .retrieve() @@ -132,8 +136,10 @@ public class ProtobufIntegrationTests extends AbstractRequestMappingIntegrationT .verifyComplete(); } - @Test - public void defaultInstance() { + @ParameterizedHttpServerTest + void defaultInstance(HttpServer httpServer) throws Exception { + startServer(httpServer); + Mono result = this.webClient.get() .uri("/default-instance") .retrieve() diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestAttributeMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestAttributeMethodArgumentResolverTests.java index 4b77047c528..c4ba3f373e1 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestAttributeMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestAttributeMethodArgumentResolverTests.java @@ -20,8 +20,8 @@ import java.time.Duration; import java.util.Optional; import io.reactivex.Single; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; @@ -55,7 +55,7 @@ public class RequestAttributeMethodArgumentResolverTests { .named("handleWithRequestAttribute").build(); - @Before + @BeforeEach @SuppressWarnings("resource") public void setup() throws Exception { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestBodyMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestBodyMethodArgumentResolverTests.java index 3ac90a11d58..3442f208db6 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestBodyMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestBodyMethodArgumentResolverTests.java @@ -23,8 +23,8 @@ import java.util.Map; import java.util.concurrent.CompletableFuture; import io.reactivex.Maybe; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; @@ -63,7 +63,7 @@ public class RequestBodyMethodArgumentResolverTests { private ResolvableMethod testMethod = ResolvableMethod.on(getClass()).named("handle").build(); - @Before + @BeforeEach public void setup() { List> readers = new ArrayList<>(); readers.add(new DecoderHttpMessageReader<>(StringDecoder.allMimeTypes())); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestHeaderMapMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestHeaderMapMethodArgumentResolverTests.java index ed6fdf915ec..a333fad4876 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestHeaderMapMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestHeaderMapMethodArgumentResolverTests.java @@ -20,8 +20,8 @@ import java.lang.reflect.Method; import java.util.Collections; import java.util.Map; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; import org.springframework.core.MethodParameter; @@ -54,7 +54,7 @@ public class RequestHeaderMapMethodArgumentResolverTests { private MethodParameter paramAlsoUnsupported; - @Before + @BeforeEach public void setup() throws Exception { resolver = new RequestHeaderMapMethodArgumentResolver(ReactiveAdapterRegistry.getSharedInstance()); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestHeaderMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestHeaderMethodArgumentResolverTests.java index 0e5791fb6e2..57350e0e829 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestHeaderMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestHeaderMethodArgumentResolverTests.java @@ -22,8 +22,8 @@ import java.time.format.DateTimeFormatter; import java.util.Date; import java.util.Map; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; @@ -66,7 +66,7 @@ public class RequestHeaderMethodArgumentResolverTests { private MethodParameter paramMono; - @Before + @BeforeEach @SuppressWarnings("resource") public void setup() throws Exception { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingDataBindingIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingDataBindingIntegrationTests.java index 3bf91f0f357..250441f5eb3 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingDataBindingIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingDataBindingIntegrationTests.java @@ -20,7 +20,6 @@ import java.text.SimpleDateFormat; import java.util.Date; import java.util.Optional; -import org.junit.Test; import reactor.core.publisher.Mono; import org.springframework.beans.propertyeditors.CustomDateEditor; @@ -30,6 +29,7 @@ import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; +import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import org.springframework.validation.Errors; @@ -50,7 +50,7 @@ import static org.assertj.core.api.Assertions.assertThat; * * @author Rossen Stoyanchev */ -public class RequestMappingDataBindingIntegrationTests extends AbstractRequestMappingIntegrationTests { +class RequestMappingDataBindingIntegrationTests extends AbstractRequestMappingIntegrationTests { @Override protected ApplicationContext initApplicationContext() { @@ -61,14 +61,17 @@ public class RequestMappingDataBindingIntegrationTests extends AbstractRequestMa } - @Test - public void handleDateParam() throws Exception { + @ParameterizedHttpServerTest + void handleDateParam(HttpServer httpServer) throws Exception { + startServer(httpServer); + assertThat(performPost("/date-param?date=2016-10-31&date-pattern=YYYY-mm-dd", new HttpHeaders(), null, String.class).getBody()).isEqualTo("Processed date!"); } - @Test - public void handleForm() throws Exception { + @ParameterizedHttpServerTest + void handleForm(HttpServer httpServer) throws Exception { + startServer(httpServer); MultiValueMap formData = new LinkedMultiValueMap<>(); formData.add("name", "George"); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingExceptionHandlingIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingExceptionHandlingIntegrationTests.java index 414d1c5a0c2..25bff1a87d3 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingExceptionHandlingIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingExceptionHandlingIntegrationTests.java @@ -20,7 +20,6 @@ import java.io.IOException; import java.util.Collections; import java.util.Map; -import org.junit.Test; import org.reactivestreams.Publisher; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -31,6 +30,7 @@ import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpHeaders; import org.springframework.http.ResponseEntity; +import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @@ -46,7 +46,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType; * @author Rossen Stoyanchev * @author Juergen Hoeller */ -public class RequestMappingExceptionHandlingIntegrationTests extends AbstractRequestMappingIntegrationTests { +class RequestMappingExceptionHandlingIntegrationTests extends AbstractRequestMappingIntegrationTests { @Override protected ApplicationContext initApplicationContext() { @@ -57,35 +57,47 @@ public class RequestMappingExceptionHandlingIntegrationTests extends AbstractReq } - @Test - public void thrownException() throws Exception { + @ParameterizedHttpServerTest + void thrownException(HttpServer httpServer) throws Exception { + startServer(httpServer); + doTest("/thrown-exception", "Recovered from error: State"); } - @Test - public void thrownExceptionWithCause() throws Exception { + @ParameterizedHttpServerTest + void thrownExceptionWithCause(HttpServer httpServer) throws Exception { + startServer(httpServer); + doTest("/thrown-exception-with-cause", "Recovered from error: State"); } - @Test - public void thrownExceptionWithCauseToHandle() throws Exception { + @ParameterizedHttpServerTest + void thrownExceptionWithCauseToHandle(HttpServer httpServer) throws Exception { + startServer(httpServer); + doTest("/thrown-exception-with-cause-to-handle", "Recovered from error: IO"); } - @Test - public void errorBeforeFirstItem() throws Exception { + @ParameterizedHttpServerTest + void errorBeforeFirstItem(HttpServer httpServer) throws Exception { + startServer(httpServer); + doTest("/mono-error", "Recovered from error: Argument"); } - @Test // SPR-16051 - public void exceptionAfterSeveralItems() { + @ParameterizedHttpServerTest // SPR-16051 + void exceptionAfterSeveralItems(HttpServer httpServer) throws Exception { + startServer(httpServer); + assertThatExceptionOfType(Throwable.class).isThrownBy(() -> performGet("/SPR-16051", new HttpHeaders(), String.class).getBody()) .withMessageStartingWith("Error while extracting response"); } - @Test // SPR-16318 - public void exceptionFromMethodWithProducesCondition() throws Exception { + @ParameterizedHttpServerTest // SPR-16318 + void exceptionFromMethodWithProducesCondition(HttpServer httpServer) throws Exception { + startServer(httpServer); + HttpHeaders headers = new HttpHeaders(); headers.add("Accept", "text/plain, application/problem+json"); assertThatExceptionOfType(HttpStatusCodeException.class).isThrownBy(() -> diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingHandlerMappingTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingHandlerMappingTests.java index ebd1d2f1d48..293ce04780e 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingHandlerMappingTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingHandlerMappingTests.java @@ -25,8 +25,8 @@ import java.security.Principal; import java.util.Collections; import java.util.Set; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.annotation.AliasFor; import org.springframework.http.MediaType; @@ -64,7 +64,7 @@ public class RequestMappingHandlerMappingTests { private final RequestMappingHandlerMapping handlerMapping = new RequestMappingHandlerMapping(); - @Before + @BeforeEach public void setup() { this.handlerMapping.setApplicationContext(wac); } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingIntegrationTests.java index 8963198ae75..75819401dde 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingIntegrationTests.java @@ -19,7 +19,6 @@ package org.springframework.web.reactive.result.method.annotation; import java.net.URI; import java.time.Duration; -import org.junit.Test; import org.reactivestreams.Publisher; import org.springframework.context.ApplicationContext; @@ -30,6 +29,7 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.RequestEntity; import org.springframework.http.ResponseEntity; import org.springframework.http.server.reactive.ServerHttpRequest; +import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @@ -49,7 +49,7 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Stephane Maldini * @since 5.0 */ -public class RequestMappingIntegrationTests extends AbstractRequestMappingIntegrationTests { +class RequestMappingIntegrationTests extends AbstractRequestMappingIntegrationTests { @Override protected ApplicationContext initApplicationContext() { @@ -60,8 +60,10 @@ public class RequestMappingIntegrationTests extends AbstractRequestMappingIntegr } - @Test - public void httpHead() { + @ParameterizedHttpServerTest + void httpHead(HttpServer httpServer) throws Exception { + startServer(httpServer); + String url = "http://localhost:" + this.port + "/text"; HttpHeaders headers = getRestTemplate().headForHeaders(url); String contentType = headers.getFirst("Content-Type"); @@ -70,8 +72,9 @@ public class RequestMappingIntegrationTests extends AbstractRequestMappingIntegr assertThat(headers.getContentLength()).isEqualTo(3); } - @Test - public void forwardedHeaders() { + @ParameterizedHttpServerTest + void forwardedHeaders(HttpServer httpServer) throws Exception { + startServer(httpServer); // One integration test to verify triggering of Forwarded header support. // More fine-grained tests in ForwardedHeaderTransformerTests. @@ -84,8 +87,10 @@ public class RequestMappingIntegrationTests extends AbstractRequestMappingIntegr assertThat(entity.getBody()).isEqualTo("https://84.198.58.199/uri"); } - @Test - public void stream() throws Exception { + @ParameterizedHttpServerTest + void stream(HttpServer httpServer) throws Exception { + startServer(httpServer); + String[] expected = {"0", "1", "2", "3", "4"}; assertThat(performGet("/stream", new HttpHeaders(), String[].class).getBody()).isEqualTo(expected); } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingMessageConversionIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingMessageConversionIntegrationTests.java index 820ca2d95ed..8f724a4b65e 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingMessageConversionIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingMessageConversionIntegrationTests.java @@ -27,7 +27,6 @@ import javax.xml.bind.annotation.XmlRootElement; import io.reactivex.Flowable; import io.reactivex.Maybe; -import org.junit.Test; import org.reactivestreams.Publisher; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -52,6 +51,7 @@ import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.http.codec.json.Jackson2JsonEncoder; import org.springframework.http.server.reactive.ZeroCopyIntegrationTests; +import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -86,71 +86,92 @@ public class RequestMappingMessageConversionIntegrationTests extends AbstractReq return wac; } - @Test - public void byteBufferResponseBodyWithPublisher() throws Exception { + + @ParameterizedHttpServerTest + public void byteBufferResponseBodyWithPublisher(HttpServer httpServer) throws Exception { + startServer(httpServer); + Person expected = new Person("Robert"); assertThat(performGet("/raw-response/publisher", JSON, Person.class).getBody()).isEqualTo(expected); } - @Test - public void byteBufferResponseBodyWithFlux() throws Exception { + @ParameterizedHttpServerTest + public void byteBufferResponseBodyWithFlux(HttpServer httpServer) throws Exception { + startServer(httpServer); + String expected = "Hello!"; assertThat(performGet("/raw-response/flux", new HttpHeaders(), String.class).getBody()).isEqualTo(expected); } - @Test - public void byteBufferResponseBodyWithMono() throws Exception { + @ParameterizedHttpServerTest + public void byteBufferResponseBodyWithMono(HttpServer httpServer) throws Exception { + startServer(httpServer); + String expected = "Hello!"; ResponseEntity responseEntity = performGet("/raw-response/mono", new HttpHeaders(), String.class); assertThat(responseEntity.getHeaders().getContentLength()).isEqualTo(6); assertThat(responseEntity.getBody()).isEqualTo(expected); } - @Test - public void byteBufferResponseBodyWithObservable() throws Exception { + @ParameterizedHttpServerTest + public void byteBufferResponseBodyWithObservable(HttpServer httpServer) throws Exception { + startServer(httpServer); + String expected = "Hello!"; assertThat(performGet("/raw-response/observable", new HttpHeaders(), String.class).getBody()).isEqualTo(expected); } - @Test - public void byteBufferResponseBodyWithRxJava2Observable() throws Exception { + @ParameterizedHttpServerTest + public void byteBufferResponseBodyWithRxJava2Observable(HttpServer httpServer) throws Exception { + startServer(httpServer); + String expected = "Hello!"; assertThat(performGet("/raw-response/rxjava2-observable", new HttpHeaders(), String.class).getBody()).isEqualTo(expected); } - @Test - public void byteBufferResponseBodyWithFlowable() throws Exception { + @ParameterizedHttpServerTest + public void byteBufferResponseBodyWithFlowable(HttpServer httpServer) throws Exception { + startServer(httpServer); + String expected = "Hello!"; assertThat(performGet("/raw-response/flowable", new HttpHeaders(), String.class).getBody()).isEqualTo(expected); } - @Test - public void personResponseBody() throws Exception { + @ParameterizedHttpServerTest + public void personResponseBody(HttpServer httpServer) throws Exception { + startServer(httpServer); + Person expected = new Person("Robert"); ResponseEntity responseEntity = performGet("/person-response/person", JSON, Person.class); assertThat(responseEntity.getHeaders().getContentLength()).isEqualTo(17); assertThat(responseEntity.getBody()).isEqualTo(expected); } - @Test - public void personResponseBodyWithCompletableFuture() throws Exception { + @ParameterizedHttpServerTest + public void personResponseBodyWithCompletableFuture(HttpServer httpServer) throws Exception { + startServer(httpServer); + Person expected = new Person("Robert"); ResponseEntity responseEntity = performGet("/person-response/completable-future", JSON, Person.class); assertThat(responseEntity.getHeaders().getContentLength()).isEqualTo(17); assertThat(responseEntity.getBody()).isEqualTo(expected); } - @Test - public void personResponseBodyWithMono() throws Exception { + @ParameterizedHttpServerTest + public void personResponseBodyWithMono(HttpServer httpServer) throws Exception { + startServer(httpServer); + Person expected = new Person("Robert"); ResponseEntity responseEntity = performGet("/person-response/mono", JSON, Person.class); assertThat(responseEntity.getHeaders().getContentLength()).isEqualTo(17); assertThat(responseEntity.getBody()).isEqualTo(expected); } - @Test // SPR-17506 - public void personResponseBodyWithEmptyMono() throws Exception { + @ParameterizedHttpServerTest // SPR-17506 + public void personResponseBodyWithEmptyMono(HttpServer httpServer) throws Exception { + startServer(httpServer); + ResponseEntity responseEntity = performGet("/person-response/mono-empty", JSON, Person.class); assertThat(responseEntity.getHeaders().getContentLength()).isEqualTo(0); assertThat(responseEntity.getBody()).isNull(); @@ -162,32 +183,40 @@ public class RequestMappingMessageConversionIntegrationTests extends AbstractReq assertThat(responseEntity.getBody()).isNull(); } - @Test - public void personResponseBodyWithMonoDeclaredAsObject() throws Exception { + @ParameterizedHttpServerTest + public void personResponseBodyWithMonoDeclaredAsObject(HttpServer httpServer) throws Exception { + startServer(httpServer); + Person expected = new Person("Robert"); ResponseEntity entity = performGet("/person-response/mono-declared-as-object", JSON, Person.class); assertThat(entity.getHeaders().getContentLength()).isEqualTo(17); assertThat(entity.getBody()).isEqualTo(expected); } - @Test - public void personResponseBodyWithSingle() throws Exception { + @ParameterizedHttpServerTest + public void personResponseBodyWithSingle(HttpServer httpServer) throws Exception { + startServer(httpServer); + Person expected = new Person("Robert"); ResponseEntity entity = performGet("/person-response/single", JSON, Person.class); assertThat(entity.getHeaders().getContentLength()).isEqualTo(17); assertThat(entity.getBody()).isEqualTo(expected); } - @Test - public void personResponseBodyWithMonoResponseEntity() throws Exception { + @ParameterizedHttpServerTest + public void personResponseBodyWithMonoResponseEntity(HttpServer httpServer) throws Exception { + startServer(httpServer); + Person expected = new Person("Robert"); ResponseEntity entity = performGet("/person-response/mono-response-entity", JSON, Person.class); assertThat(entity.getHeaders().getContentLength()).isEqualTo(17); assertThat(entity.getBody()).isEqualTo(expected); } - @Test // SPR-16172 - public void personResponseBodyWithMonoResponseEntityXml() throws Exception { + @ParameterizedHttpServerTest // SPR-16172 + public void personResponseBodyWithMonoResponseEntityXml(HttpServer httpServer) throws Exception { + startServer(httpServer); + String url = "/person-response/mono-response-entity-xml"; ResponseEntity entity = performGet(url, new HttpHeaders(), String.class); @@ -198,36 +227,46 @@ public class RequestMappingMessageConversionIntegrationTests extends AbstractReq "Robert")); } - @Test - public void personResponseBodyWithList() throws Exception { + @ParameterizedHttpServerTest + public void personResponseBodyWithList(HttpServer httpServer) throws Exception { + startServer(httpServer); + List expected = asList(new Person("Robert"), new Person("Marie")); ResponseEntity> entity = performGet("/person-response/list", JSON, PERSON_LIST); assertThat(entity.getHeaders().getContentLength()).isEqualTo(36); assertThat(entity.getBody()).isEqualTo(expected); } - @Test - public void personResponseBodyWithPublisher() throws Exception { + @ParameterizedHttpServerTest + public void personResponseBodyWithPublisher(HttpServer httpServer) throws Exception { + startServer(httpServer); + List expected = asList(new Person("Robert"), new Person("Marie")); ResponseEntity> entity = performGet("/person-response/publisher", JSON, PERSON_LIST); assertThat(entity.getHeaders().getContentLength()).isEqualTo(-1); assertThat(entity.getBody()).isEqualTo(expected); } - @Test - public void personResponseBodyWithFlux() throws Exception { + @ParameterizedHttpServerTest + public void personResponseBodyWithFlux(HttpServer httpServer) throws Exception { + startServer(httpServer); + List expected = asList(new Person("Robert"), new Person("Marie")); assertThat(performGet("/person-response/flux", JSON, PERSON_LIST).getBody()).isEqualTo(expected); } - @Test - public void personResponseBodyWithObservable() throws Exception { + @ParameterizedHttpServerTest + public void personResponseBodyWithObservable(HttpServer httpServer) throws Exception { + startServer(httpServer); + List expected = asList(new Person("Robert"), new Person("Marie")); assertThat(performGet("/person-response/observable", JSON, PERSON_LIST).getBody()).isEqualTo(expected); } - @Test - public void resource() throws Exception { + @ParameterizedHttpServerTest + public void resource(HttpServer httpServer) throws Exception { + startServer(httpServer); + ResponseEntity response = performGet("/resource", new HttpHeaders(), byte[].class); assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK); @@ -237,85 +276,111 @@ public class RequestMappingMessageConversionIntegrationTests extends AbstractReq assertThat(response.getHeaders().getContentType()).isEqualTo(new MediaType("image", "png")); } - @Test - public void personTransform() throws Exception { + @ParameterizedHttpServerTest + public void personTransform(HttpServer httpServer) throws Exception { + startServer(httpServer); + assertThat(performPost("/person-transform/person", JSON, new Person("Robert"), JSON, Person.class).getBody()).isEqualTo(new Person("ROBERT")); } - @Test - public void personTransformWithCompletableFuture() throws Exception { + @ParameterizedHttpServerTest + public void personTransformWithCompletableFuture(HttpServer httpServer) throws Exception { + startServer(httpServer); + assertThat(performPost("/person-transform/completable-future", JSON, new Person("Robert"), JSON, Person.class).getBody()).isEqualTo(new Person("ROBERT")); } - @Test - public void personTransformWithMono() throws Exception { + @ParameterizedHttpServerTest + public void personTransformWithMono(HttpServer httpServer) throws Exception { + startServer(httpServer); + assertThat(performPost("/person-transform/mono", JSON, new Person("Robert"), JSON, Person.class).getBody()).isEqualTo(new Person("ROBERT")); } - @Test // SPR-16759 - public void personTransformWithMonoAndXml() throws Exception { + @ParameterizedHttpServerTest // SPR-16759 + public void personTransformWithMonoAndXml(HttpServer httpServer) throws Exception { + startServer(httpServer); + assertThat(performPost("/person-transform/mono", MediaType.APPLICATION_XML, new Person("Robert"), MediaType.APPLICATION_XML, Person.class).getBody()).isEqualTo(new Person("ROBERT")); } - @Test - public void personTransformWithSingle() throws Exception { + @ParameterizedHttpServerTest + public void personTransformWithSingle(HttpServer httpServer) throws Exception { + startServer(httpServer); + assertThat(performPost("/person-transform/single", JSON, new Person("Robert"), JSON, Person.class).getBody()).isEqualTo(new Person("ROBERT")); } - @Test - public void personTransformWithRxJava2Single() throws Exception { + @ParameterizedHttpServerTest + public void personTransformWithRxJava2Single(HttpServer httpServer) throws Exception { + startServer(httpServer); + assertThat(performPost("/person-transform/rxjava2-single", JSON, new Person("Robert"), JSON, Person.class).getBody()).isEqualTo(new Person("ROBERT")); } - @Test - public void personTransformWithRxJava2Maybe() throws Exception { + @ParameterizedHttpServerTest + public void personTransformWithRxJava2Maybe(HttpServer httpServer) throws Exception { + startServer(httpServer); + assertThat(performPost("/person-transform/rxjava2-maybe", JSON, new Person("Robert"), JSON, Person.class).getBody()).isEqualTo(new Person("ROBERT")); } - @Test - public void personTransformWithPublisher() throws Exception { + @ParameterizedHttpServerTest + public void personTransformWithPublisher(HttpServer httpServer) throws Exception { + startServer(httpServer); + List req = asList(new Person("Robert"), new Person("Marie")); List res = asList(new Person("ROBERT"), new Person("MARIE")); assertThat(performPost("/person-transform/publisher", JSON, req, JSON, PERSON_LIST).getBody()).isEqualTo(res); } - @Test - public void personTransformWithFlux() throws Exception { + @ParameterizedHttpServerTest + public void personTransformWithFlux(HttpServer httpServer) throws Exception { + startServer(httpServer); + List req = asList(new Person("Robert"), new Person("Marie")); List res = asList(new Person("ROBERT"), new Person("MARIE")); assertThat(performPost("/person-transform/flux", JSON, req, JSON, PERSON_LIST).getBody()).isEqualTo(res); } - @Test - public void personTransformWithObservable() throws Exception { + @ParameterizedHttpServerTest + public void personTransformWithObservable(HttpServer httpServer) throws Exception { + startServer(httpServer); + List req = asList(new Person("Robert"), new Person("Marie")); List res = asList(new Person("ROBERT"), new Person("MARIE")); assertThat(performPost("/person-transform/observable", JSON, req, JSON, PERSON_LIST).getBody()).isEqualTo(res); } - @Test - public void personTransformWithRxJava2Observable() throws Exception { + @ParameterizedHttpServerTest + public void personTransformWithRxJava2Observable(HttpServer httpServer) throws Exception { + startServer(httpServer); + List req = asList(new Person("Robert"), new Person("Marie")); List res = asList(new Person("ROBERT"), new Person("MARIE")); assertThat(performPost("/person-transform/rxjava2-observable", JSON, req, JSON, PERSON_LIST).getBody()).isEqualTo(res); } - @Test - public void personTransformWithFlowable() throws Exception { + @ParameterizedHttpServerTest + public void personTransformWithFlowable(HttpServer httpServer) throws Exception { + startServer(httpServer); + List req = asList(new Person("Robert"), new Person("Marie")); List res = asList(new Person("ROBERT"), new Person("MARIE")); assertThat(performPost("/person-transform/flowable", JSON, req, JSON, PERSON_LIST).getBody()).isEqualTo(res); } - @Test - public void personCreateWithPublisherJson() throws Exception { + @ParameterizedHttpServerTest + public void personCreateWithPublisherJson(HttpServer httpServer) throws Exception { + startServer(httpServer); + ResponseEntity entity = performPost("/person-create/publisher", JSON, asList(new Person("Robert"), new Person("Marie")), null, Void.class); @@ -323,8 +388,10 @@ public class RequestMappingMessageConversionIntegrationTests extends AbstractReq assertThat(getApplicationContext().getBean(PersonCreateController.class).persons.size()).isEqualTo(2); } - @Test - public void personCreateWithPublisherXml() throws Exception { + @ParameterizedHttpServerTest + public void personCreateWithPublisherXml(HttpServer httpServer) throws Exception { + startServer(httpServer); + People people = new People(new Person("Robert"), new Person("Marie")); ResponseEntity response = performPost("/person-create/publisher", APPLICATION_XML, people, null, Void.class); @@ -332,8 +399,10 @@ public class RequestMappingMessageConversionIntegrationTests extends AbstractReq assertThat(getApplicationContext().getBean(PersonCreateController.class).persons.size()).isEqualTo(2); } - @Test - public void personCreateWithMono() throws Exception { + @ParameterizedHttpServerTest + public void personCreateWithMono(HttpServer httpServer) throws Exception { + startServer(httpServer); + ResponseEntity entity = performPost( "/person-create/mono", JSON, new Person("Robert"), null, Void.class); @@ -341,8 +410,10 @@ public class RequestMappingMessageConversionIntegrationTests extends AbstractReq assertThat(getApplicationContext().getBean(PersonCreateController.class).persons.size()).isEqualTo(1); } - @Test - public void personCreateWithSingle() throws Exception { + @ParameterizedHttpServerTest + public void personCreateWithSingle(HttpServer httpServer) throws Exception { + startServer(httpServer); + ResponseEntity entity = performPost( "/person-create/single", JSON, new Person("Robert"), null, Void.class); @@ -350,8 +421,10 @@ public class RequestMappingMessageConversionIntegrationTests extends AbstractReq assertThat(getApplicationContext().getBean(PersonCreateController.class).persons.size()).isEqualTo(1); } - @Test - public void personCreateWithRxJava2Single() throws Exception { + @ParameterizedHttpServerTest + public void personCreateWithRxJava2Single(HttpServer httpServer) throws Exception { + startServer(httpServer); + ResponseEntity entity = performPost( "/person-create/rxjava2-single", JSON, new Person("Robert"), null, Void.class); @@ -359,8 +432,10 @@ public class RequestMappingMessageConversionIntegrationTests extends AbstractReq assertThat(getApplicationContext().getBean(PersonCreateController.class).persons.size()).isEqualTo(1); } - @Test - public void personCreateWithFluxJson() throws Exception { + @ParameterizedHttpServerTest + public void personCreateWithFluxJson(HttpServer httpServer) throws Exception { + startServer(httpServer); + ResponseEntity entity = performPost("/person-create/flux", JSON, asList(new Person("Robert"), new Person("Marie")), null, Void.class); @@ -368,8 +443,10 @@ public class RequestMappingMessageConversionIntegrationTests extends AbstractReq assertThat(getApplicationContext().getBean(PersonCreateController.class).persons.size()).isEqualTo(2); } - @Test - public void personCreateWithFluxXml() throws Exception { + @ParameterizedHttpServerTest + public void personCreateWithFluxXml(HttpServer httpServer) throws Exception { + startServer(httpServer); + People people = new People(new Person("Robert"), new Person("Marie")); ResponseEntity response = performPost("/person-create/flux", APPLICATION_XML, people, null, Void.class); @@ -377,8 +454,10 @@ public class RequestMappingMessageConversionIntegrationTests extends AbstractReq assertThat(getApplicationContext().getBean(PersonCreateController.class).persons.size()).isEqualTo(2); } - @Test - public void personCreateWithObservableJson() throws Exception { + @ParameterizedHttpServerTest + public void personCreateWithObservableJson(HttpServer httpServer) throws Exception { + startServer(httpServer); + ResponseEntity entity = performPost("/person-create/observable", JSON, asList(new Person("Robert"), new Person("Marie")), null, Void.class); @@ -386,8 +465,10 @@ public class RequestMappingMessageConversionIntegrationTests extends AbstractReq assertThat(getApplicationContext().getBean(PersonCreateController.class).persons.size()).isEqualTo(2); } - @Test - public void personCreateWithRxJava2ObservableJson() throws Exception { + @ParameterizedHttpServerTest + public void personCreateWithRxJava2ObservableJson(HttpServer httpServer) throws Exception { + startServer(httpServer); + ResponseEntity entity = performPost("/person-create/rxjava2-observable", JSON, asList(new Person("Robert"), new Person("Marie")), null, Void.class); @@ -395,8 +476,10 @@ public class RequestMappingMessageConversionIntegrationTests extends AbstractReq assertThat(getApplicationContext().getBean(PersonCreateController.class).persons.size()).isEqualTo(2); } - @Test - public void personCreateWithObservableXml() throws Exception { + @ParameterizedHttpServerTest + public void personCreateWithObservableXml(HttpServer httpServer) throws Exception { + startServer(httpServer); + People people = new People(new Person("Robert"), new Person("Marie")); ResponseEntity response = performPost("/person-create/observable", APPLICATION_XML, people, null, Void.class); @@ -404,8 +487,10 @@ public class RequestMappingMessageConversionIntegrationTests extends AbstractReq assertThat(getApplicationContext().getBean(PersonCreateController.class).persons.size()).isEqualTo(2); } - @Test - public void personCreateWithRxJava2ObservableXml() throws Exception { + @ParameterizedHttpServerTest + public void personCreateWithRxJava2ObservableXml(HttpServer httpServer) throws Exception { + startServer(httpServer); + People people = new People(new Person("Robert"), new Person("Marie")); String url = "/person-create/rxjava2-observable"; ResponseEntity response = performPost(url, APPLICATION_XML, people, null, Void.class); @@ -414,8 +499,10 @@ public class RequestMappingMessageConversionIntegrationTests extends AbstractReq assertThat(getApplicationContext().getBean(PersonCreateController.class).persons.size()).isEqualTo(2); } - @Test - public void personCreateWithFlowableJson() throws Exception { + @ParameterizedHttpServerTest + public void personCreateWithFlowableJson(HttpServer httpServer) throws Exception { + startServer(httpServer); + ResponseEntity entity = performPost("/person-create/flowable", JSON, asList(new Person("Robert"), new Person("Marie")), null, Void.class); @@ -423,8 +510,10 @@ public class RequestMappingMessageConversionIntegrationTests extends AbstractReq assertThat(getApplicationContext().getBean(PersonCreateController.class).persons.size()).isEqualTo(2); } - @Test - public void personCreateWithFlowableXml() throws Exception { + @ParameterizedHttpServerTest + public void personCreateWithFlowableXml(HttpServer httpServer) throws Exception { + startServer(httpServer); + People people = new People(new Person("Robert"), new Person("Marie")); ResponseEntity response = performPost("/person-create/flowable", APPLICATION_XML, people, null, Void.class); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingViewResolutionIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingViewResolutionIntegrationTests.java index 277b13a057a..7714923dc21 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingViewResolutionIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingViewResolutionIntegrationTests.java @@ -21,8 +21,6 @@ import java.net.HttpURLConnection; import java.net.URI; import java.util.Optional; -import org.junit.Test; - import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; @@ -33,6 +31,7 @@ import org.springframework.http.MediaType; import org.springframework.http.RequestEntity; import org.springframework.http.ResponseEntity; import org.springframework.http.client.SimpleClientHttpRequestFactory; +import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; @@ -50,7 +49,7 @@ import static org.assertj.core.api.Assertions.assertThat; * * @author Rossen Stoyanchev */ -public class RequestMappingViewResolutionIntegrationTests extends AbstractRequestMappingIntegrationTests { +class RequestMappingViewResolutionIntegrationTests extends AbstractRequestMappingIntegrationTests { @Override protected ApplicationContext initApplicationContext() { @@ -61,14 +60,18 @@ public class RequestMappingViewResolutionIntegrationTests extends AbstractReques } - @Test - public void html() throws Exception { + @ParameterizedHttpServerTest + void html(HttpServer httpServer) throws Exception { + startServer(httpServer); + String expected = "Hello: Jason!"; assertThat(performGet("/html?name=Jason", MediaType.TEXT_HTML, String.class).getBody()).isEqualTo(expected); } - @Test - public void etagCheckWithNotModifiedResponse() throws Exception { + @ParameterizedHttpServerTest + void etagCheckWithNotModifiedResponse(HttpServer httpServer) throws Exception { + startServer(httpServer); + URI uri = new URI("http://localhost:" + this.port + "/html"); RequestEntity request = RequestEntity.get(uri).ifNoneMatch("\"deadb33f8badf00d\"").build(); ResponseEntity response = getRestTemplate().exchange(request, String.class); @@ -77,8 +80,10 @@ public class RequestMappingViewResolutionIntegrationTests extends AbstractReques assertThat(response.getBody()).isNull(); } - @Test // SPR-15291 - public void redirect() throws Exception { + @ParameterizedHttpServerTest // SPR-15291 + void redirect(HttpServer httpServer) throws Exception { + startServer(httpServer); + SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory() { @Override protected void prepareConnection(HttpURLConnection conn, String method) throws IOException { diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestParamMapMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestParamMapMethodArgumentResolverTests.java index cd405014021..dbb2e44071d 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestParamMapMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestParamMapMethodArgumentResolverTests.java @@ -21,7 +21,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; import org.springframework.core.MethodParameter; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestParamMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestParamMethodArgumentResolverTests.java index dd184c83297..33cd535338c 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestParamMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestParamMethodArgumentResolverTests.java @@ -20,8 +20,8 @@ import java.time.Duration; import java.util.Map; import java.util.Optional; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; @@ -56,7 +56,7 @@ public class RequestParamMethodArgumentResolverTests { private ResolvableMethod testMethod = ResolvableMethod.on(getClass()).named("handle").build(); - @Before + @BeforeEach public void setup() throws Exception { ReactiveAdapterRegistry adapterRegistry = ReactiveAdapterRegistry.getSharedInstance(); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestPartMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestPartMethodArgumentResolverTests.java index 35eac4b1fa9..26019f40b9f 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestPartMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestPartMethodArgumentResolverTests.java @@ -23,8 +23,8 @@ import java.util.List; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; @@ -71,7 +71,7 @@ public class RequestPartMethodArgumentResolverTests { private MultipartHttpMessageWriter writer; - @Before + @BeforeEach public void setup() throws Exception { List> readers = ServerCodecConfigurer.create().getReaders(); ReactiveAdapterRegistry registry = ReactiveAdapterRegistry.getSharedInstance(); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseBodyResultHandlerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseBodyResultHandlerTests.java index 6f64c1389dd..ecc77837de7 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseBodyResultHandlerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseBodyResultHandlerTests.java @@ -20,8 +20,8 @@ import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; import rx.Completable; import rx.Single; @@ -60,7 +60,7 @@ public class ResponseBodyResultHandlerTests { private ResponseBodyResultHandler resultHandler; - @Before + @BeforeEach public void setup() throws Exception { List> writerList = new ArrayList<>(5); writerList.add(new EncoderHttpMessageWriter<>(new ByteBufferEncoder())); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseEntityResultHandlerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseEntityResultHandlerTests.java index 5d18a61e705..7a302b6ab4d 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseEntityResultHandlerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ResponseEntityResultHandlerTests.java @@ -28,8 +28,8 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.concurrent.CompletableFuture; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; @@ -81,7 +81,7 @@ public class ResponseEntityResultHandlerTests { private ResponseEntityResultHandler resultHandler; - @Before + @BeforeEach public void setup() throws Exception { this.resultHandler = createHandler(); } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ServerWebExchangeMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ServerWebExchangeMethodArgumentResolverTests.java index 0e1334c2ea0..83dc3d2ffba 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ServerWebExchangeMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ServerWebExchangeMethodArgumentResolverTests.java @@ -20,7 +20,7 @@ import java.time.ZoneId; import java.util.Locale; import java.util.TimeZone; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; import org.springframework.core.MethodParameter; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SessionAttributeMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SessionAttributeMethodArgumentResolverTests.java index cb22574817c..26215d43832 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SessionAttributeMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SessionAttributeMethodArgumentResolverTests.java @@ -19,8 +19,8 @@ package org.springframework.web.reactive.result.method.annotation; import java.lang.reflect.Method; import java.util.Optional; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; @@ -59,7 +59,7 @@ public class SessionAttributeMethodArgumentResolverTests { private Method handleMethod; - @Before + @BeforeEach @SuppressWarnings("resource") public void setup() { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SessionAttributesHandlerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SessionAttributesHandlerTests.java index 688245a31b9..3bfdb2bafbe 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SessionAttributesHandlerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SessionAttributesHandlerTests.java @@ -19,7 +19,7 @@ package org.springframework.web.reactive.result.method.annotation; import java.util.HashSet; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.server.MockWebSession; import org.springframework.tests.sample.beans.TestBean; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SseIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SseIntegrationTests.java index e14cd35508f..517c995dfd3 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SseIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SseIntegrationTests.java @@ -17,12 +17,15 @@ package org.springframework.web.reactive.result.method.annotation; import java.io.File; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; import java.time.Duration; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runners.Parameterized; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import reactor.core.publisher.Flux; import reactor.core.publisher.MonoProcessor; import reactor.test.StepVerifier; @@ -37,6 +40,7 @@ import org.springframework.http.client.reactive.ReactorClientHttpConnector; import org.springframework.http.codec.ServerSentEvent; import org.springframework.http.server.reactive.AbstractHttpHandlerIntegrationTests; import org.springframework.http.server.reactive.HttpHandler; +import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.http.server.reactive.bootstrap.JettyHttpServer; import org.springframework.http.server.reactive.bootstrap.ReactorHttpServer; import org.springframework.http.server.reactive.bootstrap.TomcatHttpServer; @@ -50,59 +54,63 @@ import org.springframework.web.reactive.function.client.WebClient; import org.springframework.web.server.adapter.WebHttpHandlerBuilder; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assume.assumeTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import static org.springframework.http.MediaType.TEXT_EVENT_STREAM; /** * @author Sebastien Deleuze + * @author Sam Brannen */ -public class SseIntegrationTests extends AbstractHttpHandlerIntegrationTests { +class SseIntegrationTests extends AbstractHttpHandlerIntegrationTests { - private AnnotationConfigApplicationContext wac; - - private WebClient webClient; - - @Parameterized.Parameter(1) - public ClientHttpConnector connector; + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.METHOD) + @ParameterizedTest(name = "server [{0}] webClient [{1}]") + @MethodSource("arguments") + protected @interface ParameterizedSseTest { + } - @Parameterized.Parameters(name = "server [{0}] webClient [{1}]") - public static Object[][] arguments() { + static Object[][] arguments() { File base = new File(System.getProperty("java.io.tmpdir")); return new Object[][] { - {new JettyHttpServer(), new ReactorClientHttpConnector()}, - {new JettyHttpServer(), new JettyClientHttpConnector()}, - {new ReactorHttpServer(), new ReactorClientHttpConnector()}, - {new ReactorHttpServer(), new JettyClientHttpConnector()}, - {new TomcatHttpServer(base.getAbsolutePath()), new ReactorClientHttpConnector()}, - {new TomcatHttpServer(base.getAbsolutePath()), new JettyClientHttpConnector()}, - {new UndertowHttpServer(), new ReactorClientHttpConnector()}, - {new UndertowHttpServer(), new JettyClientHttpConnector()} + {new JettyHttpServer(), new ReactorClientHttpConnector()}, + {new JettyHttpServer(), new JettyClientHttpConnector()}, + {new ReactorHttpServer(), new ReactorClientHttpConnector()}, + {new ReactorHttpServer(), new JettyClientHttpConnector()}, + {new TomcatHttpServer(base.getAbsolutePath()), new ReactorClientHttpConnector()}, + {new TomcatHttpServer(base.getAbsolutePath()), new JettyClientHttpConnector()}, + {new UndertowHttpServer(), new ReactorClientHttpConnector()}, + {new UndertowHttpServer(), new JettyClientHttpConnector()} }; } - @Override - @Before - public void setup() throws Exception { - super.setup(); + private AnnotationConfigApplicationContext wac; + + private WebClient webClient; + + + private void startServer(HttpServer httpServer, ClientHttpConnector connector) throws Exception { + super.startServer(httpServer); + this.webClient = WebClient .builder() - .clientConnector(this.connector) + .clientConnector(connector) .baseUrl("http://localhost:" + this.port + "/sse") .build(); } @Override protected HttpHandler createHttpHandler() { - this.wac = new AnnotationConfigApplicationContext(); - this.wac.register(TestConfiguration.class); - this.wac.refresh(); + this.wac = new AnnotationConfigApplicationContext(TestConfiguration.class); return WebHttpHandlerBuilder.webHandler(new DispatcherHandler(this.wac)).build(); } - @Test - public void sseAsString() { + @ParameterizedSseTest + void sseAsString(HttpServer httpServer, ClientHttpConnector connector) throws Exception { + startServer(httpServer, connector); + Flux result = this.webClient.get() .uri("/string") .accept(TEXT_EVENT_STREAM) @@ -116,8 +124,10 @@ public class SseIntegrationTests extends AbstractHttpHandlerIntegrationTests { .verify(Duration.ofSeconds(5L)); } - @Test - public void sseAsPerson() { + @ParameterizedSseTest + void sseAsPerson(HttpServer httpServer, ClientHttpConnector connector) throws Exception { + startServer(httpServer, connector); + Flux result = this.webClient.get() .uri("/person") .accept(TEXT_EVENT_STREAM) @@ -131,10 +141,11 @@ public class SseIntegrationTests extends AbstractHttpHandlerIntegrationTests { .verify(Duration.ofSeconds(5L)); } - @Test - public void sseAsEvent() { + @ParameterizedSseTest + void sseAsEvent(HttpServer httpServer, ClientHttpConnector connector) throws Exception { + startServer(httpServer, connector); - assumeTrue(server instanceof JettyHttpServer); + assumeTrue(super.server instanceof JettyHttpServer); Flux> result = this.webClient.get() .uri("/event") @@ -145,8 +156,10 @@ public class SseIntegrationTests extends AbstractHttpHandlerIntegrationTests { verifyPersonEvents(result); } - @Test - public void sseAsEventWithoutAcceptHeader() { + @ParameterizedSseTest + void sseAsEventWithoutAcceptHeader(HttpServer httpServer, ClientHttpConnector connector) throws Exception { + startServer(httpServer, connector); + Flux> result = this.webClient.get() .uri("/event") .accept(TEXT_EVENT_STREAM) @@ -176,11 +189,12 @@ public class SseIntegrationTests extends AbstractHttpHandlerIntegrationTests { .verify(Duration.ofSeconds(5L)); } - @Test // SPR-16494 - @Ignore // https://github.com/reactor/reactor-netty/issues/283 - public void serverDetectsClientDisconnect() { + @ParameterizedSseTest // SPR-16494 + @Disabled // https://github.com/reactor/reactor-netty/issues/283 + void serverDetectsClientDisconnect(HttpServer httpServer, ClientHttpConnector connector) throws Exception { + startServer(httpServer, connector); - assumeTrue(this.server instanceof ReactorHttpServer); + assumeTrue(super.server instanceof ReactorHttpServer); Flux result = this.webClient.get() .uri("/infinite") diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/WebSessionMethodArgumentResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/WebSessionMethodArgumentResolverTests.java index 8bc13e0ec22..60543892666 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/WebSessionMethodArgumentResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/WebSessionMethodArgumentResolverTests.java @@ -16,7 +16,7 @@ package org.springframework.web.reactive.result.method.annotation; import io.reactivex.Single; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; import org.springframework.core.MethodParameter; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/AbstractViewTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/AbstractViewTests.java index f5ad6df3e31..a2b413bd30a 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/AbstractViewTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/AbstractViewTests.java @@ -23,7 +23,7 @@ import java.util.Map; import io.reactivex.Observable; import io.reactivex.Single; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/DefaultRenderingBuilderTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/DefaultRenderingBuilderTests.java index e50581b09af..62b195bef46 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/DefaultRenderingBuilderTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/DefaultRenderingBuilderTests.java @@ -20,7 +20,7 @@ import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpHeaders; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/HttpMessageWriterViewTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/HttpMessageWriterViewTests.java index 7684e6415af..87803b6a703 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/HttpMessageWriterViewTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/HttpMessageWriterViewTests.java @@ -24,7 +24,7 @@ import java.util.HashSet; import java.util.LinkedHashMap; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.test.StepVerifier; import org.springframework.core.codec.CharSequenceEncoder; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/LocaleContextResolverIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/LocaleContextResolverIntegrationTests.java index efd9ec6983f..f2d07209822 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/LocaleContextResolverIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/LocaleContextResolverIntegrationTests.java @@ -21,7 +21,6 @@ import java.util.List; import java.util.Locale; import java.util.Map; -import org.junit.Test; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; @@ -31,6 +30,7 @@ import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; +import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.lang.Nullable; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; @@ -48,7 +48,7 @@ import static org.assertj.core.api.Assertions.assertThat; /** * @author Sebastien Deleuze */ -public class LocaleContextResolverIntegrationTests extends AbstractRequestMappingIntegrationTests { +class LocaleContextResolverIntegrationTests extends AbstractRequestMappingIntegrationTests { private final WebClient webClient = WebClient.create(); @@ -61,8 +61,11 @@ public class LocaleContextResolverIntegrationTests extends AbstractRequestMappin return context; } - @Test - public void fixedLocale() { + + @ParameterizedHttpServerTest + void fixedLocale(HttpServer httpServer) throws Exception { + startServer(httpServer); + Mono result = webClient .get() .uri("http://localhost:" + this.port + "/") diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/RedirectViewTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/RedirectViewTests.java index 13a5d1034f2..35e57892ca8 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/RedirectViewTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/RedirectViewTests.java @@ -21,8 +21,8 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; @@ -44,7 +44,7 @@ public class RedirectViewTests { private MockServerWebExchange exchange; - @Before + @BeforeEach public void setup() { this.exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/context/path").contextPath("/context")); } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/RequestContextTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/RequestContextTests.java index 1831e22b55e..3ed184f6bc9 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/RequestContextTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/RequestContextTests.java @@ -19,8 +19,8 @@ package org.springframework.web.reactive.result.view; import java.util.HashMap; import java.util.Map; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.context.support.GenericApplicationContext; import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest; @@ -42,7 +42,7 @@ public class RequestContextTests { private Map model = new HashMap<>(); - @Before + @BeforeEach public void init() { this.applicationContext = new GenericApplicationContext(); this.applicationContext.refresh(); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/UrlBasedViewResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/UrlBasedViewResolverTests.java index 63e4f6c154b..41d0628471b 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/UrlBasedViewResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/UrlBasedViewResolverTests.java @@ -20,8 +20,8 @@ import java.time.Duration; import java.util.Locale; import java.util.Map; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; @@ -44,7 +44,7 @@ public class UrlBasedViewResolverTests { private final UrlBasedViewResolver resolver = new UrlBasedViewResolver(); - @Before + @BeforeEach public void setup() { StaticApplicationContext context = new StaticApplicationContext(); context.refresh(); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/ViewResolutionResultHandlerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/ViewResolutionResultHandlerTests.java index bc60e853914..8e5cd2ef011 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/ViewResolutionResultHandlerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/ViewResolutionResultHandlerTests.java @@ -26,7 +26,7 @@ import java.util.Locale; import java.util.Map; import java.util.TreeMap; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/freemarker/FreeMarkerConfigurerTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/freemarker/FreeMarkerConfigurerTests.java index 72d277db14c..a0041345b23 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/freemarker/FreeMarkerConfigurerTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/freemarker/FreeMarkerConfigurerTests.java @@ -23,7 +23,7 @@ import freemarker.cache.ClassTemplateLoader; import freemarker.cache.MultiTemplateLoader; import freemarker.template.Configuration; import freemarker.template.Template; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.io.ByteArrayResource; import org.springframework.core.io.FileSystemResource; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/freemarker/FreeMarkerMacroTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/freemarker/FreeMarkerMacroTests.java index 0f02c4eb006..02caeb09668 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/freemarker/FreeMarkerMacroTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/freemarker/FreeMarkerMacroTests.java @@ -25,8 +25,8 @@ import java.util.List; import java.util.Map; import freemarker.template.Configuration; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; import org.springframework.context.support.GenericApplicationContext; @@ -66,7 +66,7 @@ public class FreeMarkerMacroTests { private Configuration freeMarkerConfig; - @Before + @BeforeEach public void setUp() throws Exception { this.applicationContext.refresh(); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/freemarker/FreeMarkerViewTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/freemarker/FreeMarkerViewTests.java index e542714f125..6feddbd5695 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/freemarker/FreeMarkerViewTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/freemarker/FreeMarkerViewTests.java @@ -22,8 +22,8 @@ import java.time.Duration; import java.util.Locale; import freemarker.template.Configuration; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import reactor.test.StepVerifier; import org.springframework.context.ApplicationContextException; @@ -62,7 +62,7 @@ public class FreeMarkerViewTests { private Configuration freeMarkerConfig; - @Before + @BeforeEach public void setup() throws Exception { this.context.refresh(); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/JRubyScriptTemplateTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/JRubyScriptTemplateTests.java index 5e8042f621c..6fa014884f8 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/JRubyScriptTemplateTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/JRubyScriptTemplateTests.java @@ -19,8 +19,8 @@ package org.springframework.web.reactive.result.view.script; import java.util.HashMap; import java.util.Map; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; @@ -37,7 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat; * * @author Sebastien Deleuze */ -@Ignore("JRuby not compatible with JDK 9 yet") +@Disabled("JRuby not compatible with JDK 9 yet") public class JRubyScriptTemplateTests { @Test diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/JythonScriptTemplateTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/JythonScriptTemplateTests.java index bb7c261fe0b..6a29ef0643a 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/JythonScriptTemplateTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/JythonScriptTemplateTests.java @@ -19,7 +19,7 @@ package org.springframework.web.reactive.result.view.script; import java.util.HashMap; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/KotlinScriptTemplateTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/KotlinScriptTemplateTests.java index 252bb6e202b..3ceab25891f 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/KotlinScriptTemplateTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/KotlinScriptTemplateTests.java @@ -20,7 +20,7 @@ import java.util.HashMap; import java.util.Locale; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/NashornScriptTemplateTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/NashornScriptTemplateTests.java index 719fe4bfb48..b57138fea0c 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/NashornScriptTemplateTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/NashornScriptTemplateTests.java @@ -19,7 +19,7 @@ package org.springframework.web.reactive.result.view.script; import java.util.HashMap; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/ScriptTemplateViewResolverTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/ScriptTemplateViewResolverTests.java index 029e1f5bf8a..9f6baef9465 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/ScriptTemplateViewResolverTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/ScriptTemplateViewResolverTests.java @@ -16,7 +16,7 @@ package org.springframework.web.reactive.result.view.script; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.DirectFieldAccessor; diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/ScriptTemplateViewTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/ScriptTemplateViewTests.java index aa1b39773a4..d3a483cc2ca 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/ScriptTemplateViewTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/view/script/ScriptTemplateViewTests.java @@ -26,8 +26,8 @@ import java.util.concurrent.Future; import javax.script.Invocable; import javax.script.ScriptEngine; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.DirectFieldAccessor; import org.springframework.context.ApplicationContextException; @@ -53,7 +53,7 @@ public class ScriptTemplateViewTests { private StaticApplicationContext context; - @Before + @BeforeEach public void setup() { this.configurer = new ScriptTemplateConfigurer(); this.context = new StaticApplicationContext(); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/socket/AbstractWebSocketIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/socket/AbstractWebSocketIntegrationTests.java index 82a66607f73..86b1d2ac513 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/socket/AbstractWebSocketIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/socket/AbstractWebSocketIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * 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. @@ -18,23 +18,25 @@ package org.springframework.web.reactive.socket; import java.io.File; import java.io.IOException; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; import java.net.URI; import java.net.URISyntaxException; import java.util.LinkedHashMap; import java.util.Map; import org.apache.tomcat.websocket.server.WsContextListener; -import org.junit.After; -import org.junit.Before; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.xnio.OptionMap; import org.xnio.Xnio; import reactor.core.publisher.Flux; import reactor.util.function.Tuple3; +import org.springframework.context.ApplicationContext; import org.springframework.context.Lifecycle; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; @@ -67,28 +69,21 @@ import org.springframework.web.server.adapter.WebHttpHandlerBuilder; * handler mappings to {@code WebSocketHandler}'s. * * @author Rossen Stoyanchev + * @author Sam Brannen */ -@RunWith(Parameterized.class) @SuppressWarnings({"unused", "WeakerAccess"}) public abstract class AbstractWebSocketIntegrationTests { private static final File TMP_DIR = new File(System.getProperty("java.io.tmpdir")); + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.METHOD) + @ParameterizedTest(name = "client[{0}] - server [{1}]") + @MethodSource("arguments") + @interface ParameterizedWebSocketTest { + } - protected int port; - - @Parameter(0) - public WebSocketClient client; - - @Parameter(1) - public HttpServer server; - - @Parameter(2) - public Class serverConfigClass; - - - @Parameters(name = "client[{0}] - server [{1}]") - public static Object[][] arguments() throws IOException { + static Object[][] arguments() throws IOException { WebSocketClient[] clients = new WebSocketClient[] { new TomcatWebSocketClient(), @@ -112,8 +107,20 @@ public abstract class AbstractWebSocketIntegrationTests { } - @Before - public void setup() throws Exception { + protected WebSocketClient client; + + protected HttpServer server; + + protected Class serverConfigClass; + + protected int port; + + + protected void startServer(WebSocketClient client, HttpServer server, Class serverConfigClass) throws Exception { + this.client = client; + this.server = server; + this.serverConfigClass = serverConfigClass; + this.server.setHandler(createHttpHandler()); this.server.afterPropertiesSet(); this.server.start(); @@ -126,8 +133,8 @@ public abstract class AbstractWebSocketIntegrationTests { } } - @After - public void stop() { + @AfterEach + void stopServer() { if (this.client instanceof Lifecycle) { ((Lifecycle) this.client).stop(); } @@ -136,10 +143,8 @@ public abstract class AbstractWebSocketIntegrationTests { private HttpHandler createHttpHandler() { - AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); - context.register(DispatcherConfig.class, this.serverConfigClass); - context.register(getWebConfigClass()); - context.refresh(); + ApplicationContext context = new AnnotationConfigApplicationContext( + DispatcherConfig.class, this.serverConfigClass, getWebConfigClass()); return WebHttpHandlerBuilder.applicationContext(context).build(); } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/socket/WebSocketIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/socket/WebSocketIntegrationTests.java index a77567542ff..a8cabe0bf39 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/socket/WebSocketIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/socket/WebSocketIntegrationTests.java @@ -25,7 +25,6 @@ import java.util.concurrent.atomic.AtomicReference; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.junit.Test; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.core.publisher.MonoProcessor; @@ -34,8 +33,10 @@ import reactor.core.publisher.ReplayProcessor; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpHeaders; +import org.springframework.http.server.reactive.bootstrap.HttpServer; import org.springframework.web.reactive.HandlerMapping; import org.springframework.web.reactive.handler.SimpleUrlHandlerMapping; +import org.springframework.web.reactive.socket.client.WebSocketClient; import static org.assertj.core.api.Assertions.assertThat; @@ -43,8 +44,9 @@ import static org.assertj.core.api.Assertions.assertThat; * Integration tests with server-side {@link WebSocketHandler}s. * * @author Rossen Stoyanchev + * @author Sam Brannen */ -public class WebSocketIntegrationTests extends AbstractWebSocketIntegrationTests { +class WebSocketIntegrationTests extends AbstractWebSocketIntegrationTests { private static final Log logger = LogFactory.getLog(WebSocketIntegrationTests.class); @@ -57,8 +59,10 @@ public class WebSocketIntegrationTests extends AbstractWebSocketIntegrationTests } - @Test - public void echo() throws Exception { + @ParameterizedWebSocketTest + void echo(WebSocketClient client, HttpServer server, Class serverConfigClass) throws Exception { + startServer(client, server, serverConfigClass); + int count = 100; Flux input = Flux.range(1, count).map(index -> "msg-" + index); ReplayProcessor output = ReplayProcessor.create(count); @@ -73,8 +77,10 @@ public class WebSocketIntegrationTests extends AbstractWebSocketIntegrationTests assertThat(output.collectList().block(TIMEOUT)).isEqualTo(input.collectList().block(TIMEOUT)); } - @Test - public void subProtocol() throws Exception { + @ParameterizedWebSocketTest + void subProtocol(WebSocketClient client, HttpServer server, Class serverConfigClass) throws Exception { + startServer(client, server, serverConfigClass); + String protocol = "echo-v1"; AtomicReference infoRef = new AtomicReference<>(); MonoProcessor output = MonoProcessor.create(); @@ -103,8 +109,10 @@ public class WebSocketIntegrationTests extends AbstractWebSocketIntegrationTests assertThat(output.block(TIMEOUT)).as("Wrong protocol detected on the server side").isEqualTo(protocol); } - @Test - public void customHeader() throws Exception { + @ParameterizedWebSocketTest + void customHeader(WebSocketClient client, HttpServer server, Class serverConfigClass) throws Exception { + startServer(client, server, serverConfigClass); + HttpHeaders headers = new HttpHeaders(); headers.add("my-header", "my-value"); MonoProcessor output = MonoProcessor.create(); @@ -119,8 +127,10 @@ public class WebSocketIntegrationTests extends AbstractWebSocketIntegrationTests assertThat(output.block(TIMEOUT)).isEqualTo("my-header:my-value"); } - @Test - public void sessionClosing() throws Exception { + @ParameterizedWebSocketTest + void sessionClosing(WebSocketClient client, HttpServer server, Class serverConfigClass) throws Exception { + startServer(client, server, serverConfigClass); + this.client.execute(getUrl("/close"), session -> { logger.debug("Starting.."); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/socket/server/support/HandshakeWebSocketServiceTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/socket/server/support/HandshakeWebSocketServiceTests.java index 75873929f77..28b143dc8f8 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/socket/server/support/HandshakeWebSocketServiceTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/socket/server/support/HandshakeWebSocketServiceTests.java @@ -20,7 +20,7 @@ import java.util.Arrays; import java.util.Map; import java.util.function.Supplier; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Mono; import org.springframework.lang.Nullable; 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 e07d8d22bb2..573598bea20 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 @@ -23,7 +23,7 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.runBlocking import org.junit.Assert.assertEquals import org.junit.Assert.assertNull -import org.junit.Test +import org.junit.jupiter.api.Test import org.springframework.core.ParameterizedTypeReference import org.springframework.http.HttpStatus import org.springframework.http.ResponseEntity 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 f0ee54fdeff..1f2232a33bd 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 @@ -23,7 +23,7 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.runBlocking import org.junit.Assert.assertEquals -import org.junit.Test +import org.junit.jupiter.api.Test import org.reactivestreams.Publisher import org.springframework.core.ParameterizedTypeReference import reactor.core.publisher.Mono 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 56719a1e0b5..0b081a88470 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,8 @@ package org.springframework.web.reactive.function.server -import org.junit.Test +import org.junit.Assert.fail +import org.junit.jupiter.api.Test import org.springframework.core.io.ClassPathResource import org.springframework.http.HttpHeaders.* import org.springframework.http.HttpMethod.* @@ -119,9 +120,15 @@ class CoRouterFunctionDslTests { .verifyComplete() } - @Test(expected = IllegalStateException::class) + @Test fun emptyRouter() { - router { } + try { + router { } + fail("should have thrown an IllegalStateException") + } + catch (e: IllegalStateException) { + // expected + } } diff --git a/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/server/RenderingResponseExtensionsTests.kt b/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/server/RenderingResponseExtensionsTests.kt index bf4dfaf15b2..08815bf50ba 100644 --- a/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/server/RenderingResponseExtensionsTests.kt +++ b/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/server/RenderingResponseExtensionsTests.kt @@ -20,7 +20,7 @@ import io.mockk.every import io.mockk.mockk import io.mockk.verify import kotlinx.coroutines.runBlocking -import org.junit.Test +import org.junit.jupiter.api.Test import reactor.core.publisher.Mono class RenderingResponseExtensionsTests { 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 b8592ef6e8c..9376a0f24f5 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,8 @@ package org.springframework.web.reactive.function.server -import org.junit.Test +import org.junit.Assert.fail +import org.junit.jupiter.api.Test import org.springframework.core.io.ClassPathResource import org.springframework.http.HttpHeaders.* import org.springframework.http.HttpMethod.* @@ -120,9 +121,15 @@ class RouterFunctionDslTests { .verifyComplete() } - @Test(expected = IllegalStateException::class) + @Test fun emptyRouter() { - router { } + try { + router { } + fail("should have thrown an IllegalStateException") + } + catch (e: IllegalStateException) { + // expected + } } 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 9e8408557c1..cf898dbd088 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 @@ -23,7 +23,7 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.runBlocking import org.junit.Assert.assertEquals import org.junit.Assert.assertNull -import org.junit.Test +import org.junit.jupiter.api.Test import org.springframework.core.ParameterizedTypeReference import org.springframework.http.codec.multipart.Part import org.springframework.util.MultiValueMap 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 c0486dcdbb9..5306a5dd61c 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 @@ -24,7 +24,7 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.runBlocking import org.junit.Assert.assertEquals -import org.junit.Test +import org.junit.jupiter.api.Test import org.reactivestreams.Publisher import org.springframework.core.ParameterizedTypeReference import org.springframework.http.MediaType.* 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 05443d6dbf8..9933a3de2a0 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 @@ -22,7 +22,7 @@ import kotlinx.coroutines.delay import org.hamcrest.CoreMatchers.`is` import org.hamcrest.MatcherAssert.assertThat import org.junit.Assert.assertEquals -import org.junit.Test +import org.junit.jupiter.api.Test import org.springframework.http.HttpStatus import org.springframework.http.server.reactive.ServerHttpResponse import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest.get 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 72d3cd20577..483616b3cf8 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 @@ -24,13 +24,14 @@ import kotlinx.coroutines.delay import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flow import org.junit.Assert.assertEquals -import org.junit.Test +import org.junit.Assert.fail import org.springframework.context.ApplicationContext import org.springframework.context.annotation.AnnotationConfigApplicationContext import org.springframework.context.annotation.ComponentScan import org.springframework.context.annotation.Configuration import org.springframework.http.HttpHeaders import org.springframework.http.HttpStatus +import org.springframework.http.server.reactive.bootstrap.HttpServer import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.RestController import org.springframework.web.client.HttpServerErrorException @@ -46,42 +47,65 @@ class CoroutinesIntegrationTests : AbstractRequestMappingIntegrationTests() { return context } - @Test - fun `Suspending handler method`() { + + @ParameterizedHttpServerTest + fun `Suspending handler method`(httpServer: HttpServer) { + startServer(httpServer) + val entity = performGet("/suspend", HttpHeaders.EMPTY, String::class.java) assertEquals(HttpStatus.OK, entity.statusCode) assertEquals("foo", entity.body) } - @Test - fun `Handler method returning Deferred`() { + @ParameterizedHttpServerTest + fun `Handler method returning Deferred`(httpServer: HttpServer) { + startServer(httpServer) + val entity = performGet("/deferred", HttpHeaders.EMPTY, String::class.java) assertEquals(HttpStatus.OK, entity.statusCode) assertEquals("foo", entity.body) } - @Test - fun `Handler method returning Flow`() { + @ParameterizedHttpServerTest + fun `Handler method returning Flow`(httpServer: HttpServer) { + startServer(httpServer) + val entity = performGet("/flow", HttpHeaders.EMPTY, String::class.java) assertEquals(HttpStatus.OK, entity.statusCode) assertEquals("foobar", entity.body) } - @Test - fun `Suspending handler method returning Flow`() { + @ParameterizedHttpServerTest + fun `Suspending handler method returning Flow`(httpServer: HttpServer) { + startServer(httpServer) + val entity = performGet("/suspending-flow", HttpHeaders.EMPTY, String::class.java) assertEquals(HttpStatus.OK, entity.statusCode) assertEquals("foobar", entity.body) } - @Test(expected = HttpServerErrorException.InternalServerError::class) - fun `Suspending handler method throwing exception`() { - performGet("/error", HttpHeaders.EMPTY, String::class.java) + @ParameterizedHttpServerTest + fun `Suspending handler method throwing exception`(httpServer: HttpServer) { + startServer(httpServer) + + try { + performGet("/error", HttpHeaders.EMPTY, String::class.java) + fail("should have thrown an HttpServerErrorException.InternalServerError") + } catch (e: HttpServerErrorException.InternalServerError) { + // expected + } } - @Test(expected = HttpServerErrorException.InternalServerError::class) - fun `Handler method returning Flow throwing exception`() { - performGet("/flow-error", HttpHeaders.EMPTY, String::class.java) + @ParameterizedHttpServerTest + fun `Handler method returning Flow throwing exception`(httpServer: HttpServer) { + startServer(httpServer) + + try { + performGet("/flow-error", HttpHeaders.EMPTY, String::class.java) + fail("should have thrown an HttpServerErrorException.InternalServerError") + } catch (e: HttpServerErrorException.InternalServerError) { + // expected + } } @Configuration diff --git a/spring-webflux/src/test/kotlin/org/springframework/web/reactive/result/method/annotation/RequestParamMethodArgumentResolverKotlinTests.kt b/spring-webflux/src/test/kotlin/org/springframework/web/reactive/result/method/annotation/RequestParamMethodArgumentResolverKotlinTests.kt index 3272e8c330e..086372c6375 100644 --- a/spring-webflux/src/test/kotlin/org/springframework/web/reactive/result/method/annotation/RequestParamMethodArgumentResolverKotlinTests.kt +++ b/spring-webflux/src/test/kotlin/org/springframework/web/reactive/result/method/annotation/RequestParamMethodArgumentResolverKotlinTests.kt @@ -16,8 +16,8 @@ package org.springframework.web.reactive.result.method.annotation -import org.junit.Before -import org.junit.Test +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Test import org.springframework.core.MethodParameter import org.springframework.core.ReactiveAdapterRegistry import org.springframework.core.annotation.SynthesizingMethodParameter @@ -47,7 +47,7 @@ class RequestParamMethodArgumentResolverKotlinTests { lateinit var nonNullableParamNotRequired: MethodParameter - @Before + @BeforeEach fun setup() { this.resolver = RequestParamMethodArgumentResolver(null, ReactiveAdapterRegistry.getSharedInstance(), true) val initializer = ConfigurableWebBindingInitializer() diff --git a/spring-webmvc/src/test/java/org/springframework/web/context/ContextLoaderTests.java b/spring-webmvc/src/test/java/org/springframework/web/context/ContextLoaderTests.java index 7f94bd7af08..a72ff30a24f 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/context/ContextLoaderTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/context/ContextLoaderTests.java @@ -22,7 +22,7 @@ import javax.servlet.ServletContext; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanCreationException; diff --git a/spring-webmvc/src/test/java/org/springframework/web/context/ServletContextAwareProcessorTests.java b/spring-webmvc/src/test/java/org/springframework/web/context/ServletContextAwareProcessorTests.java index 0e32d59bf51..b12fa97fb0a 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/context/ServletContextAwareProcessorTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/context/ServletContextAwareProcessorTests.java @@ -19,7 +19,7 @@ package org.springframework.web.context; import javax.servlet.ServletConfig; import javax.servlet.ServletContext; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockServletConfig; import org.springframework.mock.web.test.MockServletContext; diff --git a/spring-webmvc/src/test/java/org/springframework/web/context/XmlWebApplicationContextTests.java b/spring-webmvc/src/test/java/org/springframework/web/context/XmlWebApplicationContextTests.java index 66c11fe85db..6542f9f383b 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/context/XmlWebApplicationContextTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/context/XmlWebApplicationContextTests.java @@ -19,7 +19,7 @@ package org.springframework.web.context; import java.util.Locale; import javax.servlet.ServletException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.BeansException; import org.springframework.beans.factory.DisposableBean; diff --git a/spring-webmvc/src/test/java/org/springframework/web/context/support/HttpRequestHandlerTests.java b/spring-webmvc/src/test/java/org/springframework/web/context/support/HttpRequestHandlerTests.java index a1e248f69ab..dec48d57fe6 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/context/support/HttpRequestHandlerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/context/support/HttpRequestHandlerTests.java @@ -22,7 +22,7 @@ import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockHttpServletResponse; diff --git a/spring-webmvc/src/test/java/org/springframework/web/context/support/ServletContextSupportTests.java b/spring-webmvc/src/test/java/org/springframework/web/context/support/ServletContextSupportTests.java index e700b989fd8..5f4c3346200 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/context/support/ServletContextSupportTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/context/support/ServletContextSupportTests.java @@ -23,7 +23,7 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.MutablePropertyValues; import org.springframework.beans.factory.BeanCreationException; diff --git a/spring-webmvc/src/test/java/org/springframework/web/context/support/WebApplicationObjectSupportTests.java b/spring-webmvc/src/test/java/org/springframework/web/context/support/WebApplicationObjectSupportTests.java index 95b641537bc..b68db1c1440 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/context/support/WebApplicationObjectSupportTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/context/support/WebApplicationObjectSupportTests.java @@ -18,7 +18,7 @@ package org.springframework.web.context.support; import java.io.File; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.context.support.StaticApplicationContext; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/DispatcherServletTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/DispatcherServletTests.java index 48ff7a6c4bb..22095cfe9b0 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/DispatcherServletTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/DispatcherServletTests.java @@ -26,8 +26,8 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequestWrapper; import javax.servlet.http.HttpServletResponse; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.MutablePropertyValues; import org.springframework.beans.PropertyValue; @@ -83,7 +83,7 @@ public class DispatcherServletTests { private DispatcherServlet complexDispatcherServlet; - @Before + @BeforeEach public void setUp() throws ServletException { MockServletConfig complexConfig = new MockServletConfig(getServletContext(), "complex"); complexConfig.addInitParameter("publishContext", "false"); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/FlashMapTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/FlashMapTests.java index 45f7f39a06d..12d2ffde19b 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/FlashMapTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/FlashMapTests.java @@ -16,7 +16,7 @@ package org.springframework.web.servlet; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/HandlerExecutionChainTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/HandlerExecutionChainTests.java index f4bccf72abb..b2b1b200bef 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/HandlerExecutionChainTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/HandlerExecutionChainTests.java @@ -16,8 +16,8 @@ package org.springframework.web.servlet; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockHttpServletResponse; @@ -51,7 +51,7 @@ public class HandlerExecutionChainTests { private AsyncHandlerInterceptor interceptor3; - @Before + @BeforeEach public void setup() { this.request = new MockHttpServletRequest(); this.response= new MockHttpServletResponse() ; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParserTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParserTests.java index db37495d35e..932d0f24ac2 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParserTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/AnnotationDrivenBeanDefinitionParserTests.java @@ -18,7 +18,7 @@ package org.springframework.web.servlet.config; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.DirectFieldAccessor; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/MvcNamespaceTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/MvcNamespaceTests.java index 116c9566775..2f9f4004a25 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/MvcNamespaceTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/MvcNamespaceTests.java @@ -40,8 +40,8 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.xml.XmlMapper; import org.apache.tiles.definition.UnresolvingLocaleDefinitionsFactory; import org.joda.time.LocalDate; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.DirectFieldAccessor; import org.springframework.beans.TypeMismatchException; @@ -167,7 +167,7 @@ public class MvcNamespaceTests { private HandlerMethod handlerMethod; - @Before + @BeforeEach public void setup() throws Exception { TestMockServletContext servletContext = new TestMockServletContext(); appContext = new XmlWebApplicationContext(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/ContentNegotiationConfigurerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/ContentNegotiationConfigurerTests.java index 402b873d262..bef2c4ddb95 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/ContentNegotiationConfigurerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/ContentNegotiationConfigurerTests.java @@ -19,8 +19,8 @@ package org.springframework.web.servlet.config.annotation; import java.util.Arrays; import java.util.Collections; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.http.MediaType; import org.springframework.mock.web.test.MockHttpServletRequest; @@ -45,7 +45,7 @@ public class ContentNegotiationConfigurerTests { private MockHttpServletRequest servletRequest; - @Before + @BeforeEach public void setup() { this.servletRequest = new MockHttpServletRequest(); this.webRequest = new ServletWebRequest(this.servletRequest); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/CorsRegistryTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/CorsRegistryTests.java index 67f8691125c..b67ef72fafe 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/CorsRegistryTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/CorsRegistryTests.java @@ -19,8 +19,8 @@ package org.springframework.web.servlet.config.annotation; import java.util.Arrays; import java.util.Map; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.web.cors.CorsConfiguration; @@ -35,7 +35,7 @@ public class CorsRegistryTests { private CorsRegistry registry; - @Before + @BeforeEach public void setUp() { this.registry = new CorsRegistry(); } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/DefaultServletHandlerConfigurerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/DefaultServletHandlerConfigurerTests.java index be1191ddfc4..61a966132c3 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/DefaultServletHandlerConfigurerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/DefaultServletHandlerConfigurerTests.java @@ -18,8 +18,8 @@ package org.springframework.web.servlet.config.annotation; import javax.servlet.RequestDispatcher; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockHttpServletResponse; @@ -44,7 +44,7 @@ public class DefaultServletHandlerConfigurerTests { private MockHttpServletResponse response; - @Before + @BeforeEach public void setup() { response = new MockHttpServletResponse(); servletContext = new DispatchingMockServletContext(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/DelegatingWebMvcConfigurationTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/DelegatingWebMvcConfigurationTests.java index 87c4f0b54ad..ecb89f9fc3d 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/DelegatingWebMvcConfigurationTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/DelegatingWebMvcConfigurationTests.java @@ -20,12 +20,12 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.format.support.FormattingConversionService; import org.springframework.http.converter.HttpMessageConverter; @@ -55,7 +55,7 @@ import static org.mockito.Mockito.verify; * * @author Rossen Stoyanchev */ -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class DelegatingWebMvcConfigurationTests { @Mock diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/InterceptorRegistryTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/InterceptorRegistryTests.java index c7e6c19c5b4..562b03237c0 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/InterceptorRegistryTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/InterceptorRegistryTests.java @@ -21,8 +21,8 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.springframework.core.Ordered; @@ -67,7 +67,7 @@ public class InterceptorRegistryTests { private final MockHttpServletResponse response = new MockHttpServletResponse(); - @Before + @BeforeEach public void setUp() { this.registry = new InterceptorRegistry(); this.webInterceptor1 = new TestWebRequestInterceptor(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/ResourceHandlerRegistryTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/ResourceHandlerRegistryTests.java index 6d86b961a3c..ccce1f2454a 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/ResourceHandlerRegistryTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/ResourceHandlerRegistryTests.java @@ -21,8 +21,8 @@ import java.nio.charset.StandardCharsets; import java.util.List; import java.util.Map; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.springframework.cache.concurrent.ConcurrentMapCache; @@ -64,7 +64,7 @@ public class ResourceHandlerRegistryTests { private MockHttpServletResponse response; - @Before + @BeforeEach public void setUp() { GenericWebApplicationContext appContext = new GenericWebApplicationContext(); appContext.refresh(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/ViewControllerRegistryTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/ViewControllerRegistryTests.java index e33ce9f16de..cf08eb54203 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/ViewControllerRegistryTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/ViewControllerRegistryTests.java @@ -19,8 +19,8 @@ package org.springframework.web.servlet.config.annotation; import java.util.Collections; import java.util.Map; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.context.support.StaticApplicationContext; import org.springframework.http.HttpStatus; @@ -46,7 +46,7 @@ public class ViewControllerRegistryTests { private MockHttpServletResponse response; - @Before + @BeforeEach public void setup() { this.registry = new ViewControllerRegistry(new StaticApplicationContext()); this.request = new MockHttpServletRequest("GET", "/"); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/ViewResolutionIntegrationTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/ViewResolutionIntegrationTests.java index c2565447152..f9f219dda3c 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/ViewResolutionIntegrationTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/ViewResolutionIntegrationTests.java @@ -19,7 +19,7 @@ package org.springframework.web.servlet.config.annotation; import java.io.IOException; import javax.servlet.ServletException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/ViewResolverRegistryTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/ViewResolverRegistryTests.java index d8c97bf3ddc..e3373b82923 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/ViewResolverRegistryTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/ViewResolverRegistryTests.java @@ -18,8 +18,8 @@ package org.springframework.web.servlet.config.annotation; import java.util.Arrays; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.DirectFieldAccessor; import org.springframework.core.Ordered; @@ -53,7 +53,7 @@ public class ViewResolverRegistryTests { private ViewResolverRegistry registry; - @Before + @BeforeEach public void setup() { StaticWebApplicationContext context = new StaticWebApplicationContext(); context.registerSingleton("freeMarkerConfigurer", FreeMarkerConfigurer.class); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupportExtensionTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupportExtensionTests.java index d4f9185c68d..c533c3aaa94 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupportExtensionTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupportExtensionTests.java @@ -23,8 +23,8 @@ import java.util.List; import java.util.Map; import com.fasterxml.jackson.databind.ObjectMapper; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.DirectFieldAccessor; import org.springframework.core.Ordered; @@ -113,7 +113,7 @@ public class WebMvcConfigurationSupportExtensionTests { private StaticWebApplicationContext context; - @Before + @BeforeEach public void setUp() { this.context = new StaticWebApplicationContext(); this.context.setServletContext(new MockServletContext(new FileSystemResourceLoader())); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupportTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupportTests.java index aa1cf5334b3..abcc75f5d2a 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupportTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupportTests.java @@ -24,7 +24,7 @@ import javax.servlet.http.HttpServletRequest; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.xml.XmlMapper; import org.joda.time.DateTime; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.DirectFieldAccessor; import org.springframework.context.ApplicationContext; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/function/DefaultEntityResponseBuilderTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/function/DefaultEntityResponseBuilderTests.java index 0f8a4bbad02..266cb12a94f 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/function/DefaultEntityResponseBuilderTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/function/DefaultEntityResponseBuilderTests.java @@ -27,7 +27,7 @@ import java.util.Set; import javax.servlet.ServletException; import javax.servlet.http.Cookie; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.ParameterizedTypeReference; import org.springframework.http.CacheControl; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/function/DefaultRenderingResponseTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/function/DefaultRenderingResponseTests.java index b152bcad13e..353b6125497 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/function/DefaultRenderingResponseTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/function/DefaultRenderingResponseTests.java @@ -24,7 +24,7 @@ import java.util.List; import java.util.Map; import javax.servlet.http.Cookie; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/function/DefaultServerRequestBuilderTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/function/DefaultServerRequestBuilderTests.java index 7fca21e4cdd..d3eeeb87652 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/function/DefaultServerRequestBuilderTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/function/DefaultServerRequestBuilderTests.java @@ -22,7 +22,7 @@ import java.util.List; import javax.servlet.ServletException; import javax.servlet.http.Cookie; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpMethod; import org.springframework.http.converter.HttpMessageConverter; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/function/DefaultServerRequestTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/function/DefaultServerRequestTests.java index 46bd12fdf76..55d830c92ac 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/function/DefaultServerRequestTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/function/DefaultServerRequestTests.java @@ -27,7 +27,7 @@ import java.util.Optional; import java.util.OptionalLong; import javax.servlet.http.Cookie; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.ParameterizedTypeReference; import org.springframework.http.HttpHeaders; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/function/DefaultServerResponseBuilderTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/function/DefaultServerResponseBuilderTests.java index 38576446798..05457f8dc24 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/function/DefaultServerResponseBuilderTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/function/DefaultServerResponseBuilderTests.java @@ -28,7 +28,7 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionStage; import javax.servlet.http.Cookie; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.reactivestreams.Publisher; import reactor.core.publisher.Mono; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/function/PathResourceLookupFunctionTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/function/PathResourceLookupFunctionTests.java index f3c7a169a15..b8f98903ede 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/function/PathResourceLookupFunctionTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/function/PathResourceLookupFunctionTests.java @@ -21,7 +21,7 @@ import java.util.Collections; import java.util.Optional; import java.util.function.Function; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/function/RequestPredicateTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/function/RequestPredicateTests.java index 73bea78c246..0d8013cb453 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/function/RequestPredicateTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/function/RequestPredicateTests.java @@ -18,8 +18,8 @@ package org.springframework.web.servlet.function; import java.util.Collections; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockHttpServletRequest; @@ -32,7 +32,7 @@ public class RequestPredicateTests { private ServerRequest request; - @Before + @BeforeEach public void createRequest() { this.request = new DefaultServerRequest(new MockHttpServletRequest(), Collections.emptyList()); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/function/RequestPredicatesTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/function/RequestPredicatesTests.java index 382acfadf1b..d8e13a54845 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/function/RequestPredicatesTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/function/RequestPredicatesTests.java @@ -19,7 +19,7 @@ package org.springframework.web.servlet.function; import java.util.Collections; import java.util.function.Function; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpMethod; import org.springframework.http.MediaType; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/function/ResourceHandlerFunctionTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/function/ResourceHandlerFunctionTests.java index 5516e53d43e..c5e4c044a91 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/function/ResourceHandlerFunctionTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/function/ResourceHandlerFunctionTests.java @@ -23,8 +23,8 @@ import java.util.EnumSet; import java.util.List; import javax.servlet.ServletException; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; @@ -52,7 +52,7 @@ public class ResourceHandlerFunctionTests { private ResourceHttpMessageConverter messageConverter; - @Before + @BeforeEach public void createContext() { this.messageConverter = new ResourceHttpMessageConverter(); this.context = new ServerResponse.Context() { diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/function/RouterFunctionBuilderTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/function/RouterFunctionBuilderTests.java index 5c8df3bed1a..015097d5c37 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/function/RouterFunctionBuilderTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/function/RouterFunctionBuilderTests.java @@ -19,7 +19,7 @@ package org.springframework.web.servlet.function; import java.util.Optional; import java.util.concurrent.atomic.AtomicInteger; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/function/RouterFunctionTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/function/RouterFunctionTests.java index 5976678416a..e8e204bdc38 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/function/RouterFunctionTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/function/RouterFunctionTests.java @@ -18,7 +18,7 @@ package org.springframework.web.servlet.function; import java.util.Optional; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockHttpServletRequest; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/function/RouterFunctionsTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/function/RouterFunctionsTests.java index 1a46f3c6c6e..b909d2dd2ca 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/function/RouterFunctionsTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/function/RouterFunctionsTests.java @@ -19,7 +19,7 @@ package org.springframework.web.servlet.function; import java.util.Collections; import java.util.Optional; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockHttpServletRequest; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/function/ToStringVisitorTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/function/ToStringVisitorTests.java index 1aa19cf4b46..045415ec9c1 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/function/ToStringVisitorTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/function/ToStringVisitorTests.java @@ -16,7 +16,7 @@ package org.springframework.web.servlet.function; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpMethod; import org.springframework.http.MediaType; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/BeanNameUrlHandlerMappingTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/BeanNameUrlHandlerMappingTests.java index 7fc56258ee6..96e9d73e35e 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/BeanNameUrlHandlerMappingTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/BeanNameUrlHandlerMappingTests.java @@ -18,8 +18,8 @@ package org.springframework.web.servlet.handler; import javax.servlet.ServletException; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.context.support.StaticApplicationContext; import org.springframework.mock.web.test.MockHttpServletRequest; @@ -43,7 +43,7 @@ public class BeanNameUrlHandlerMappingTests { private ConfigurableWebApplicationContext wac; - @Before + @BeforeEach public void setUp() throws Exception { MockServletContext sc = new MockServletContext(""); wac = new XmlWebApplicationContext(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/CorsAbstractHandlerMappingTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/CorsAbstractHandlerMappingTests.java index b41a9e2e345..e7ac8f63850 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/CorsAbstractHandlerMappingTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/CorsAbstractHandlerMappingTests.java @@ -22,8 +22,8 @@ import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.DirectFieldAccessor; import org.springframework.http.HttpHeaders; @@ -54,7 +54,7 @@ public class CorsAbstractHandlerMappingTests { private AbstractHandlerMapping handlerMapping; - @Before + @BeforeEach public void setup() { StaticWebApplicationContext context = new StaticWebApplicationContext(); this.handlerMapping = new TestHandlerMapping(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/HandlerMappingIntrospectorTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/HandlerMappingIntrospectorTests.java index 5ab6723c56d..b27f2693a75 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/HandlerMappingIntrospectorTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/HandlerMappingIntrospectorTests.java @@ -21,7 +21,7 @@ import java.util.Collections; import java.util.List; import javax.servlet.http.HttpServletRequest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.MutablePropertyValues; import org.springframework.context.annotation.Bean; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/HandlerMappingTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/HandlerMappingTests.java index cf90460764d..1043e3ee910 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/HandlerMappingTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/HandlerMappingTests.java @@ -21,7 +21,7 @@ import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpStatus; import org.springframework.mock.web.test.MockHttpServletRequest; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/HandlerMethodMappingTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/HandlerMethodMappingTests.java index 3d6e2c86430..b026011c78a 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/HandlerMethodMappingTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/HandlerMethodMappingTests.java @@ -23,8 +23,8 @@ import java.util.List; import java.util.Set; import javax.servlet.http.HttpServletRequest; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.context.support.StaticApplicationContext; import org.springframework.mock.web.test.MockHttpServletRequest; @@ -60,7 +60,7 @@ public class HandlerMethodMappingTests { private Method method2; - @Before + @BeforeEach public void setUp() throws Exception { this.mapping = new MyHandlerMethodMapping(); this.handler = new MyHandler(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/MappedInterceptorTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/MappedInterceptorTests.java index d0e3b0f3535..63e986ad960 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/MappedInterceptorTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/MappedInterceptorTests.java @@ -20,8 +20,8 @@ import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.util.AntPathMatcher; import org.springframework.util.PathMatcher; @@ -45,7 +45,7 @@ public class MappedInterceptorTests { private final AntPathMatcher pathMatcher = new AntPathMatcher(); - @Before + @BeforeEach public void setup() { this.interceptor = new LocaleChangeInterceptor(); } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/PathMatchingUrlHandlerMappingTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/PathMatchingUrlHandlerMappingTests.java index 1587a1b5375..97f00b60db3 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/PathMatchingUrlHandlerMappingTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/PathMatchingUrlHandlerMappingTests.java @@ -16,8 +16,8 @@ package org.springframework.web.servlet.handler; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockServletContext; @@ -41,7 +41,7 @@ public class PathMatchingUrlHandlerMappingTests { private ConfigurableWebApplicationContext wac; - @Before + @BeforeEach public void setUp() throws Exception { MockServletContext sc = new MockServletContext(""); wac = new XmlWebApplicationContext(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/SimpleMappingExceptionResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/SimpleMappingExceptionResolverTests.java index 689cbcd8cdf..8c2ccf2847c 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/SimpleMappingExceptionResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/SimpleMappingExceptionResolverTests.java @@ -20,8 +20,8 @@ import java.util.Collections; import java.util.Properties; import javax.servlet.http.HttpServletResponse; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockHttpServletResponse; @@ -44,7 +44,7 @@ public class SimpleMappingExceptionResolverTests { private Object handler2; private Exception genericException; - @Before + @BeforeEach public void setUp() throws Exception { exceptionResolver = new SimpleMappingExceptionResolver(); handler1 = new String(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/SimpleUrlHandlerMappingTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/SimpleUrlHandlerMappingTests.java index 73976804d3e..5d4bcbb7943 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/SimpleUrlHandlerMappingTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/handler/SimpleUrlHandlerMappingTests.java @@ -18,7 +18,7 @@ package org.springframework.web.servlet.handler; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.FatalBeanException; import org.springframework.beans.factory.NoSuchBeanDefinitionException; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/i18n/AcceptHeaderLocaleResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/i18n/AcceptHeaderLocaleResolverTests.java index 50597a8324d..c15f83a5c48 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/i18n/AcceptHeaderLocaleResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/i18n/AcceptHeaderLocaleResolverTests.java @@ -21,7 +21,7 @@ import java.util.Collections; import java.util.Locale; import javax.servlet.http.HttpServletRequest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockHttpServletRequest; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/i18n/CookieLocaleResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/i18n/CookieLocaleResolverTests.java index 05c24283ded..6e3c84856b0 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/i18n/CookieLocaleResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/i18n/CookieLocaleResolverTests.java @@ -21,7 +21,7 @@ import java.util.TimeZone; import javax.servlet.ServletException; import javax.servlet.http.Cookie; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.i18n.LocaleContext; import org.springframework.context.i18n.SimpleLocaleContext; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/i18n/LocaleResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/i18n/LocaleResolverTests.java index 76b5b3e5d71..4d901588f3f 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/i18n/LocaleResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/i18n/LocaleResolverTests.java @@ -19,7 +19,7 @@ package org.springframework.web.servlet.i18n; import java.util.Locale; import java.util.TimeZone; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.i18n.LocaleContext; import org.springframework.context.i18n.SimpleLocaleContext; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/i18n/SessionLocaleResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/i18n/SessionLocaleResolverTests.java index 5ba4f812b0d..40c37337a74 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/i18n/SessionLocaleResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/i18n/SessionLocaleResolverTests.java @@ -19,7 +19,7 @@ package org.springframework.web.servlet.i18n; import java.util.Locale; import javax.servlet.http.HttpSession; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockHttpServletResponse; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/ControllerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/ControllerTests.java index 3bbe45e16bc..954c6568f27 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/ControllerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/ControllerTests.java @@ -26,7 +26,7 @@ import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockHttpServletResponse; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/ParameterizableViewControllerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/ParameterizableViewControllerTests.java index ed9a984fed7..5bf5843d2e4 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/ParameterizableViewControllerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/ParameterizableViewControllerTests.java @@ -16,8 +16,8 @@ package org.springframework.web.servlet.mvc; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpMethod; import org.springframework.mock.web.test.MockHttpServletRequest; @@ -40,7 +40,7 @@ public class ParameterizableViewControllerTests { private MockHttpServletRequest request; - @Before + @BeforeEach public void setup() { this.controller = new ParameterizableViewController(); this.request = new MockHttpServletRequest("GET", "/"); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/UrlFilenameViewControllerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/UrlFilenameViewControllerTests.java index 4fa13467517..130544be7a5 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/UrlFilenameViewControllerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/UrlFilenameViewControllerTests.java @@ -16,7 +16,7 @@ package org.springframework.web.servlet.mvc; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockHttpServletResponse; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/WebContentInterceptorTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/WebContentInterceptorTests.java index 4e2c8881fca..3ae71619ffe 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/WebContentInterceptorTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/WebContentInterceptorTests.java @@ -18,7 +18,7 @@ package org.springframework.web.servlet.mvc; import java.util.Properties; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockHttpServletResponse; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/annotation/CglibProxyControllerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/annotation/CglibProxyControllerTests.java index 3ed572eece1..4c94c239dda 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/annotation/CglibProxyControllerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/annotation/CglibProxyControllerTests.java @@ -20,7 +20,7 @@ import java.io.IOException; import java.io.Writer; import javax.servlet.ServletException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.Pointcut; import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/annotation/JdkProxyControllerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/annotation/JdkProxyControllerTests.java index 3e07e3d5837..d455ff52976 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/annotation/JdkProxyControllerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/annotation/JdkProxyControllerTests.java @@ -20,7 +20,7 @@ import java.io.IOException; import java.io.Writer; import javax.servlet.ServletException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator; import org.springframework.aop.interceptor.SimpleTraceInterceptor; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/annotation/ResponseStatusExceptionResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/annotation/ResponseStatusExceptionResolverTests.java index a43edafde3b..833aaf1c86a 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/annotation/ResponseStatusExceptionResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/annotation/ResponseStatusExceptionResolverTests.java @@ -20,8 +20,8 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.Locale; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.TypeMismatchException; import org.springframework.context.i18n.LocaleContextHolder; @@ -53,7 +53,7 @@ public class ResponseStatusExceptionResolverTests { private final MockHttpServletResponse response = new MockHttpServletResponse(); - @Before + @BeforeEach public void setup() { exceptionResolver.setWarnLogCategory(exceptionResolver.getClass().getName()); } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/condition/CompositeRequestConditionTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/condition/CompositeRequestConditionTests.java index 75ba5843fd8..cc56d859f46 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/condition/CompositeRequestConditionTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/condition/CompositeRequestConditionTests.java @@ -18,8 +18,8 @@ package org.springframework.web.servlet.mvc.condition; import javax.servlet.http.HttpServletRequest; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.web.bind.annotation.RequestMethod; @@ -42,7 +42,7 @@ public class CompositeRequestConditionTests { private HeadersRequestCondition header2; private HeadersRequestCondition header3; - @Before + @BeforeEach public void setup() { this.param1 = new ParamsRequestCondition("param1"); this.param2 = new ParamsRequestCondition("param2"); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/condition/ConsumesRequestConditionTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/condition/ConsumesRequestConditionTests.java index cc95b380d58..a373dd9070e 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/condition/ConsumesRequestConditionTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/condition/ConsumesRequestConditionTests.java @@ -19,7 +19,7 @@ package org.springframework.web.servlet.mvc.condition; import java.util.Collection; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpHeaders; import org.springframework.mock.web.test.MockHttpServletRequest; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/condition/HeadersRequestConditionTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/condition/HeadersRequestConditionTests.java index a95e95adc52..b318d2e5a2a 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/condition/HeadersRequestConditionTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/condition/HeadersRequestConditionTests.java @@ -18,7 +18,7 @@ package org.springframework.web.servlet.mvc.condition; import java.util.Collection; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.web.servlet.mvc.condition.HeadersRequestCondition.HeaderExpression; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/condition/ParamsRequestConditionTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/condition/ParamsRequestConditionTests.java index 9a3aa980aaf..1a03901ef99 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/condition/ParamsRequestConditionTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/condition/ParamsRequestConditionTests.java @@ -18,7 +18,7 @@ package org.springframework.web.servlet.mvc.condition; import java.util.Collection; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.web.servlet.mvc.condition.ParamsRequestCondition.ParamExpression; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/condition/PatternsRequestConditionTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/condition/PatternsRequestConditionTests.java index b8b0937b08b..465117a2db4 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/condition/PatternsRequestConditionTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/condition/PatternsRequestConditionTests.java @@ -20,7 +20,7 @@ import java.util.Arrays; import java.util.List; import javax.servlet.http.HttpServletRequest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockHttpServletRequest; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/condition/ProducesRequestConditionTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/condition/ProducesRequestConditionTests.java index 2d9e12e78d0..316e9398eaa 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/condition/ProducesRequestConditionTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/condition/ProducesRequestConditionTests.java @@ -21,7 +21,7 @@ import java.util.Collection; import java.util.Collections; import javax.servlet.http.HttpServletRequest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.MediaType; import org.springframework.mock.web.test.MockHttpServletRequest; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/condition/RequestConditionHolderTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/condition/RequestConditionHolderTests.java index 2604a216c86..32ab11c4508 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/condition/RequestConditionHolderTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/condition/RequestConditionHolderTests.java @@ -18,7 +18,7 @@ package org.springframework.web.servlet.mvc.condition; import javax.servlet.http.HttpServletRequest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.web.bind.annotation.RequestMethod; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/condition/RequestMethodsRequestConditionTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/condition/RequestMethodsRequestConditionTests.java index 1e431e7a6cf..e6132b02c4c 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/condition/RequestMethodsRequestConditionTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/condition/RequestMethodsRequestConditionTests.java @@ -20,7 +20,7 @@ import java.util.Collections; import javax.servlet.DispatcherType; import javax.servlet.http.HttpServletRequest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpHeaders; import org.springframework.mock.web.test.MockHttpServletRequest; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/RequestMappingInfoHandlerMappingTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/RequestMappingInfoHandlerMappingTests.java index ef0c30feefd..969f4b05ab1 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/RequestMappingInfoHandlerMappingTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/RequestMappingInfoHandlerMappingTests.java @@ -24,8 +24,8 @@ import java.util.Map; import java.util.Set; import javax.servlet.http.HttpServletRequest; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.annotation.AnnotationUtils; import org.springframework.http.HttpHeaders; @@ -80,7 +80,7 @@ public class RequestMappingInfoHandlerMappingTests { private HandlerMethod emptyMethod; - @Before + @BeforeEach public void setup() throws Exception { TestController testController = new TestController(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/RequestMappingInfoHandlerMethodMappingNamingStrategyTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/RequestMappingInfoHandlerMethodMappingNamingStrategyTests.java index 8d361bd5edf..ad488765a89 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/RequestMappingInfoHandlerMethodMappingNamingStrategyTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/RequestMappingInfoHandlerMethodMappingNamingStrategyTests.java @@ -18,7 +18,7 @@ package org.springframework.web.servlet.mvc.method; import java.lang.reflect.Method; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.util.ClassUtils; import org.springframework.web.bind.annotation.RequestMapping; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/RequestMappingInfoTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/RequestMappingInfoTests.java index 1777ebc2b2b..7d445fa853d 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/RequestMappingInfoTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/RequestMappingInfoTests.java @@ -21,7 +21,7 @@ import java.util.Comparator; import java.util.List; import javax.servlet.http.HttpServletRequest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpHeaders; import org.springframework.mock.web.test.MockHttpServletRequest; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/AbstractRequestAttributesArgumentResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/AbstractRequestAttributesArgumentResolverTests.java index 355bc27cb2b..263b16e90be 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/AbstractRequestAttributesArgumentResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/AbstractRequestAttributesArgumentResolverTests.java @@ -21,8 +21,8 @@ import java.util.Optional; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.DefaultParameterNameDiscoverer; import org.springframework.core.MethodParameter; @@ -61,7 +61,7 @@ public abstract class AbstractRequestAttributesArgumentResolverTests { private Method handleMethod; - @Before + @BeforeEach public void setup() throws Exception { HttpServletRequest request = new MockHttpServletRequest(); HttpServletResponse response = new MockHttpServletResponse(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/AbstractServletHandlerMethodTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/AbstractServletHandlerMethodTests.java index 296bed50127..6aff2b740ba 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/AbstractServletHandlerMethodTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/AbstractServletHandlerMethodTests.java @@ -18,7 +18,7 @@ package org.springframework.web.servlet.mvc.method.annotation; import javax.servlet.ServletException; -import org.junit.After; +import org.junit.jupiter.api.AfterEach; import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.context.ApplicationContextInitializer; @@ -52,7 +52,7 @@ public abstract class AbstractServletHandlerMethodTests { return servlet; } - @After + @AfterEach public void tearDown() { this.servlet = null; } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/CrossOriginTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/CrossOriginTests.java index 6553dab4ea9..1f39cb196da 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/CrossOriginTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/CrossOriginTests.java @@ -24,8 +24,8 @@ import java.lang.reflect.Method; import java.util.Arrays; import java.util.Properties; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.DirectFieldAccessor; import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; @@ -70,7 +70,7 @@ public class CrossOriginTests { private final MockHttpServletRequest request = new MockHttpServletRequest(); - @Before + @BeforeEach @SuppressWarnings("resource") public void setup() { StaticWebApplicationContext wac = new StaticWebApplicationContext(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/DeferredResultReturnValueHandlerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/DeferredResultReturnValueHandlerTests.java index 3284ab52eec..5b41ce55067 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/DeferredResultReturnValueHandlerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/DeferredResultReturnValueHandlerTests.java @@ -18,8 +18,8 @@ package org.springframework.web.servlet.mvc.method.annotation; import java.util.concurrent.CompletableFuture; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.MethodParameter; import org.springframework.mock.web.test.MockHttpServletRequest; @@ -51,7 +51,7 @@ public class DeferredResultReturnValueHandlerTests { private NativeWebRequest webRequest; - @Before + @BeforeEach public void setup() throws Exception { this.handler = new DeferredResultMethodReturnValueHandler(); this.request = new MockHttpServletRequest(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ExceptionHandlerExceptionResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ExceptionHandlerExceptionResolverTests.java index 62f9abcb1f4..aa44454363c 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ExceptionHandlerExceptionResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ExceptionHandlerExceptionResolverTests.java @@ -21,9 +21,9 @@ import java.io.UnsupportedEncodingException; import java.io.Writer; import java.util.Collections; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.aop.framework.ProxyFactory; import org.springframework.beans.FatalBeanException; @@ -75,7 +75,7 @@ public class ExceptionHandlerExceptionResolverTests { private MockHttpServletResponse response; - @BeforeClass + @BeforeAll public static void setupOnce() { ExceptionHandlerExceptionResolver resolver = new ExceptionHandlerExceptionResolver(); resolver.afterPropertiesSet(); @@ -83,7 +83,7 @@ public class ExceptionHandlerExceptionResolverTests { HANDLER_COUNT = resolver.getReturnValueHandlers().getHandlers().size(); } - @Before + @BeforeEach public void setup() throws Exception { this.resolver = new ExceptionHandlerExceptionResolver(); this.resolver.setWarnLogCategory(this.resolver.getClass().getName()); @@ -377,8 +377,10 @@ public class ExceptionHandlerExceptionResolverTests { @Controller static class ResponseBodyController extends WebApplicationObjectSupport implements ResponseBodyInterface { + @Override public void handle() {} + @Override @ExceptionHandler @ResponseBody public String handleException(IllegalArgumentException ex) { diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ExtendedServletRequestDataBinderTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ExtendedServletRequestDataBinderTests.java index b3de3698a45..f8b6a364a6d 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ExtendedServletRequestDataBinderTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ExtendedServletRequestDataBinderTests.java @@ -19,8 +19,8 @@ package org.springframework.web.servlet.mvc.method.annotation; import java.util.HashMap; import java.util.Map; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.tests.sample.beans.TestBean; @@ -39,7 +39,7 @@ public class ExtendedServletRequestDataBinderTests { private MockHttpServletRequest request; - @Before + @BeforeEach public void setup() { this.request = new MockHttpServletRequest(); } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/HandlerMethodAnnotationDetectionTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/HandlerMethodAnnotationDetectionTests.java index c3da6d7b118..bb8557035b1 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/HandlerMethodAnnotationDetectionTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/HandlerMethodAnnotationDetectionTests.java @@ -20,10 +20,8 @@ import java.lang.reflect.Method; import java.text.SimpleDateFormat; import java.util.Date; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator; import org.springframework.aop.interceptor.SimpleTraceInterceptor; @@ -60,11 +58,9 @@ import static org.assertj.core.api.Assertions.assertThat; * @author Rossen Stoyanchev * @author Sam Brannen */ -@RunWith(Parameterized.class) -public class HandlerMethodAnnotationDetectionTests { +class HandlerMethodAnnotationDetectionTests { - @Parameters(name = "controller [{0}], auto-proxy [{1}]") - public static Object[][] handlerTypes() { + static Object[][] handlerTypes() { return new Object[][] { { SimpleController.class, true }, // CGLIB proxy { SimpleController.class, false }, @@ -92,14 +88,14 @@ public class HandlerMethodAnnotationDetectionTests { }; } - private RequestMappingHandlerMapping handlerMapping = new RequestMappingHandlerMapping(); + private RequestMappingHandlerMapping handlerMapping; - private RequestMappingHandlerAdapter handlerAdapter = new RequestMappingHandlerAdapter(); + private RequestMappingHandlerAdapter handlerAdapter; - private ExceptionHandlerExceptionResolver exceptionResolver = new ExceptionHandlerExceptionResolver(); + private ExceptionHandlerExceptionResolver exceptionResolver; - public HandlerMethodAnnotationDetectionTests(Class controllerType, boolean useAutoProxy) { + private void setUp(Class controllerType, boolean useAutoProxy) { GenericWebApplicationContext context = new GenericWebApplicationContext(); context.registerBeanDefinition("controller", new RootBeanDefinition(controllerType)); context.registerBeanDefinition("handlerMapping", new RootBeanDefinition(RequestMappingHandlerMapping.class)); @@ -120,8 +116,11 @@ public class HandlerMethodAnnotationDetectionTests { } - @Test - public void testRequestMappingMethod() throws Exception { + @ParameterizedTest(name = "controller [{0}], auto-proxy [{1}]") + @MethodSource("handlerTypes") + void testRequestMappingMethod(Class controllerType, boolean useAutoProxy) throws Exception { + setUp(controllerType, useAutoProxy); + String datePattern = "MM:dd:yyyy"; SimpleDateFormat dateFormat = new SimpleDateFormat(datePattern); String dateA = "11:01:2011"; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/HttpEntityMethodProcessorMockTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/HttpEntityMethodProcessorMockTests.java index e8d040b1d98..86b23b62411 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/HttpEntityMethodProcessorMockTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/HttpEntityMethodProcessorMockTests.java @@ -29,8 +29,8 @@ import java.util.Arrays; import java.util.Collections; import java.util.Date; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; import org.springframework.core.MethodParameter; @@ -129,7 +129,7 @@ public class HttpEntityMethodProcessorMockTests { private ServletWebRequest webRequest; - @Before + @BeforeEach @SuppressWarnings("unchecked") public void setup() throws Exception { diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/HttpEntityMethodProcessorTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/HttpEntityMethodProcessorTests.java index d60d7f974cb..103a63564a4 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/HttpEntityMethodProcessorTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/HttpEntityMethodProcessorTests.java @@ -23,8 +23,8 @@ import java.util.List; import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeName; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.MethodParameter; import org.springframework.http.HttpEntity; @@ -75,7 +75,7 @@ public class HttpEntityMethodProcessorTests { private MockHttpServletResponse servletResponse; - @Before + @BeforeEach public void setup() throws Exception { Method method = getClass().getDeclaredMethod("handle", HttpEntity.class, HttpEntity.class); paramList = new MethodParameter(method, 0); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MatrixVariablesMapMethodArgumentResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MatrixVariablesMapMethodArgumentResolverTests.java index c36848dad9c..9e2db4554a3 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MatrixVariablesMapMethodArgumentResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MatrixVariablesMapMethodArgumentResolverTests.java @@ -21,8 +21,8 @@ import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.MethodParameter; import org.springframework.mock.web.test.MockHttpServletRequest; @@ -56,7 +56,7 @@ public class MatrixVariablesMapMethodArgumentResolverTests { private final ResolvableMethod testMethod = ResolvableMethod.on(this.getClass()).named("handle").build(); - @Before + @BeforeEach public void setup() throws Exception { this.resolver = new MatrixVariableMapMethodArgumentResolver(); this.mavContainer = new ModelAndViewContainer(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MatrixVariablesMethodArgumentResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MatrixVariablesMethodArgumentResolverTests.java index a460c9051fd..239e4ac773c 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MatrixVariablesMethodArgumentResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MatrixVariablesMethodArgumentResolverTests.java @@ -21,8 +21,8 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.MethodParameter; import org.springframework.mock.web.test.MockHttpServletRequest; @@ -57,7 +57,7 @@ public class MatrixVariablesMethodArgumentResolverTests { private ResolvableMethod testMethod = ResolvableMethod.on(this.getClass()).named("handle").build(); - @Before + @BeforeEach public void setup() throws Exception { this.resolver = new MatrixVariableMethodArgumentResolver(); this.mavContainer = new ModelAndViewContainer(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ModelAndViewMethodReturnValueHandlerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ModelAndViewMethodReturnValueHandlerTests.java index aacb618577c..edb1fa74773 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ModelAndViewMethodReturnValueHandlerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ModelAndViewMethodReturnValueHandlerTests.java @@ -18,8 +18,8 @@ package org.springframework.web.servlet.mvc.method.annotation; import java.lang.reflect.Method; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.MethodParameter; import org.springframework.mock.web.test.MockHttpServletRequest; @@ -48,7 +48,7 @@ public class ModelAndViewMethodReturnValueHandlerTests { private MethodParameter returnParamModelAndView; - @Before + @BeforeEach public void setup() throws Exception { this.handler = new ModelAndViewMethodReturnValueHandler(); this.mavContainer = new ModelAndViewContainer(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ModelAndViewResolverMethodReturnValueHandlerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ModelAndViewResolverMethodReturnValueHandlerTests.java index b45f8913869..5961552fe4f 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ModelAndViewResolverMethodReturnValueHandlerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ModelAndViewResolverMethodReturnValueHandlerTests.java @@ -20,8 +20,8 @@ import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.MethodParameter; import org.springframework.mock.web.test.MockHttpServletRequest; @@ -52,7 +52,7 @@ public class ModelAndViewResolverMethodReturnValueHandlerTests { private ServletWebRequest request; - @Before + @BeforeEach public void setup() { mavResolvers = new ArrayList<>(); handler = new ModelAndViewResolverMethodReturnValueHandler(mavResolvers); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilderTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilderTests.java index a42254be3ab..3ca221a166d 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilderTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilderTests.java @@ -28,9 +28,9 @@ import javax.servlet.http.HttpServletRequest; import org.joda.time.DateTime; import org.joda.time.format.ISODateTimeFormat; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.context.annotation.Bean; import org.springframework.format.annotation.DateTimeFormat; @@ -83,12 +83,12 @@ public class MvcUriComponentsBuilderTests { private final MockHttpServletRequest request = new MockHttpServletRequest(); - @Before + @BeforeEach public void setup() { RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(this.request)); } - @After + @AfterEach public void reset() { RequestContextHolder.resetRequestAttributes(); } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/PathVariableMapMethodArgumentResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/PathVariableMapMethodArgumentResolverTests.java index 9034505e883..0430b54394d 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/PathVariableMapMethodArgumentResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/PathVariableMapMethodArgumentResolverTests.java @@ -21,8 +21,8 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.MethodParameter; import org.springframework.mock.web.test.MockHttpServletRequest; @@ -54,7 +54,7 @@ public class PathVariableMapMethodArgumentResolverTests { private MethodParameter paramMapNoAnnot; - @Before + @BeforeEach public void setup() throws Exception { resolver = new PathVariableMapMethodArgumentResolver(); mavContainer = new ModelAndViewContainer(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/PathVariableMethodArgumentResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/PathVariableMethodArgumentResolverTests.java index 0836b040b5a..0c46eab2b0f 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/PathVariableMethodArgumentResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/PathVariableMethodArgumentResolverTests.java @@ -21,8 +21,8 @@ import java.util.HashMap; import java.util.Map; import java.util.Optional; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.MethodParameter; import org.springframework.core.annotation.SynthesizingMethodParameter; @@ -65,7 +65,7 @@ public class PathVariableMethodArgumentResolverTests { private MethodParameter paramOptional; - @Before + @BeforeEach public void setup() throws Exception { resolver = new PathVariableMethodArgumentResolver(); mavContainer = new ModelAndViewContainer(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ReactiveTypeHandlerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ReactiveTypeHandlerTests.java index 9257213b6f7..55d62b0bbe0 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ReactiveTypeHandlerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ReactiveTypeHandlerTests.java @@ -26,8 +26,8 @@ import java.util.concurrent.atomic.AtomicReference; import java.util.function.Consumer; import java.util.stream.Collectors; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import reactor.core.publisher.EmitterProcessor; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -73,7 +73,7 @@ public class ReactiveTypeHandlerTests { private NativeWebRequest webRequest; - @Before + @BeforeEach public void setup() throws Exception { ContentNegotiationManagerFactoryBean factoryBean = new ContentNegotiationManagerFactoryBean(); factoryBean.afterPropertiesSet(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapterIntegrationTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapterIntegrationTests.java index f9bf698d2d6..fe205699730 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapterIntegrationTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapterIntegrationTests.java @@ -34,9 +34,9 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.propertyeditors.CustomDateEditor; @@ -106,7 +106,7 @@ public class RequestMappingHandlerAdapterIntegrationTests { private MockHttpServletResponse response; - @Before + @BeforeEach public void setup() throws Exception { ConfigurableWebBindingInitializer bindingInitializer = new ConfigurableWebBindingInitializer(); bindingInitializer.setValidator(new StubValidator()); @@ -133,7 +133,7 @@ public class RequestMappingHandlerAdapterIntegrationTests { RequestContextHolder.setRequestAttributes(new ServletWebRequest(request)); } - @After + @AfterEach public void teardown() { RequestContextHolder.resetRequestAttributes(); } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapterTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapterTests.java index d4e0cc65481..8ec5bd501e4 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapterTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapterTests.java @@ -25,9 +25,9 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.MethodParameter; import org.springframework.http.HttpInputMessage; @@ -86,7 +86,7 @@ public class RequestMappingHandlerAdapterTests { private StaticWebApplicationContext webAppContext; - @BeforeClass + @BeforeAll public static void setupOnce() { RequestMappingHandlerAdapter adapter = new RequestMappingHandlerAdapter(); adapter.setApplicationContext(new StaticWebApplicationContext()); @@ -97,7 +97,7 @@ public class RequestMappingHandlerAdapterTests { HANDLER_COUNT = adapter.getReturnValueHandlers().size(); } - @Before + @BeforeEach public void setup() throws Exception { this.webAppContext = new StaticWebApplicationContext(); this.handlerAdapter = new RequestMappingHandlerAdapter(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMappingTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMappingTests.java index 771a9fa73e1..9968cfe4a69 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMappingTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMappingTests.java @@ -28,7 +28,7 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.annotation.AliasFor; import org.springframework.http.MediaType; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestPartIntegrationTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestPartIntegrationTests.java index 8605a14ccd3..63fe2860aaa 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestPartIntegrationTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestPartIntegrationTests.java @@ -30,10 +30,10 @@ import org.eclipse.jetty.server.NetworkConnector; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletHolder; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -85,7 +85,7 @@ public class RequestPartIntegrationTests { private static String baseUrl; - @BeforeClass + @BeforeAll public static void startServer() throws Exception { // Let server pick its own random, available port. server = new Server(0); @@ -114,14 +114,14 @@ public class RequestPartIntegrationTests { baseUrl = "http://localhost:" + connector.getLocalPort(); } - @AfterClass + @AfterAll public static void stopServer() throws Exception { if (server != null) { server.stop(); } } - @Before + @BeforeEach public void setup() { ByteArrayHttpMessageConverter emptyBodyConverter = new ByteArrayHttpMessageConverter(); emptyBodyConverter.setSupportedMediaTypes(Collections.singletonList(MediaType.APPLICATION_JSON)); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestPartMethodArgumentResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestPartMethodArgumentResolverTests.java index c53f49bd7c6..cea079061ff 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestPartMethodArgumentResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestPartMethodArgumentResolverTests.java @@ -26,8 +26,8 @@ import javax.servlet.http.Part; import javax.validation.Valid; import javax.validation.constraints.NotNull; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.LocalVariableTableParameterNameDiscoverer; import org.springframework.core.MethodParameter; @@ -103,7 +103,7 @@ public class RequestPartMethodArgumentResolverTests { private MethodParameter optionalRequestPart; - @Before + @BeforeEach @SuppressWarnings("unchecked") public void setup() throws Exception { messageConverter = mock(HttpMessageConverter.class); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestResponseBodyAdviceChainTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestResponseBodyAdviceChainTests.java index 89b5627dbf5..93a2bb0ad09 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestResponseBodyAdviceChainTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestResponseBodyAdviceChainTests.java @@ -21,8 +21,8 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.springframework.core.MethodParameter; @@ -68,7 +68,7 @@ public class RequestResponseBodyAdviceChainTests { private ServerHttpResponse response; - @Before + @BeforeEach public void setup() { this.body = "body"; this.contentType = MediaType.TEXT_PLAIN; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestResponseBodyMethodProcessorMockTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestResponseBodyMethodProcessorMockTests.java index e30c7e56eb4..d5671a48d12 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestResponseBodyMethodProcessorMockTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestResponseBodyMethodProcessorMockTests.java @@ -25,8 +25,8 @@ import java.util.Optional; import javax.validation.Valid; import javax.validation.constraints.NotNull; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.MethodParameter; import org.springframework.core.io.ByteArrayResource; @@ -107,7 +107,7 @@ public class RequestResponseBodyMethodProcessorMockTests { private MethodParameter returnTypeResource; - @Before + @BeforeEach @SuppressWarnings("unchecked") public void setup() throws Exception { stringMessageConverter = mock(HttpMessageConverter.class); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestResponseBodyMethodProcessorTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestResponseBodyMethodProcessorTests.java index e9f4c064379..1578c957ac9 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestResponseBodyMethodProcessorTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestResponseBodyMethodProcessorTests.java @@ -29,8 +29,8 @@ import java.util.List; import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonView; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.aop.framework.ProxyFactory; import org.springframework.aop.target.SingletonTargetSource; @@ -102,7 +102,7 @@ public class RequestResponseBodyMethodProcessorTests { private MethodParameter returnTypeString; - @Before + @BeforeEach public void setup() throws Exception { container = new ModelAndViewContainer(); servletRequest = new MockHttpServletRequest(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ResponseBodyEmitterReturnValueHandlerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ResponseBodyEmitterReturnValueHandlerTests.java index 20d0b884906..de78f399801 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ResponseBodyEmitterReturnValueHandlerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ResponseBodyEmitterReturnValueHandlerTests.java @@ -22,8 +22,8 @@ import java.util.List; import java.util.concurrent.atomic.AtomicReference; import java.util.function.Consumer; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import reactor.core.publisher.EmitterProcessor; import reactor.core.publisher.Flux; @@ -69,7 +69,7 @@ public class ResponseBodyEmitterReturnValueHandlerTests { private final ModelAndViewContainer mavContainer = new ModelAndViewContainer(); - @Before + @BeforeEach public void setup() throws Exception { List> converters = Arrays.asList( diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ResponseBodyEmitterTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ResponseBodyEmitterTests.java index aeb661660af..902287db0fc 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ResponseBodyEmitterTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ResponseBodyEmitterTests.java @@ -18,11 +18,11 @@ package org.springframework.web.servlet.mvc.method.annotation; import java.io.IOException; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentCaptor; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.http.MediaType; @@ -42,7 +42,7 @@ import static org.mockito.Mockito.verifyNoMoreInteractions; * @author Rossen Stoyanchev * @author Tomasz Nurkiewicz */ -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class ResponseBodyEmitterTests { @Mock diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ResponseEntityExceptionHandlerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ResponseEntityExceptionHandlerTests.java index f04d1a0ad9b..b97ffc8b33a 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ResponseEntityExceptionHandlerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ResponseEntityExceptionHandlerTests.java @@ -22,7 +22,7 @@ import java.util.EnumSet; import java.util.List; import javax.servlet.ServletException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.ConversionNotSupportedException; import org.springframework.beans.TypeMismatchException; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodTests.java index 0c40c709c82..7162d231ca6 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletAnnotationControllerHandlerMethodTests.java @@ -58,7 +58,7 @@ import javax.validation.Valid; import javax.validation.constraints.NotNull; import javax.xml.bind.annotation.XmlRootElement; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator; import org.springframework.aop.interceptor.SimpleTraceInterceptor; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletCookieValueMethodArgumentResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletCookieValueMethodArgumentResolverTests.java index 8ec9e8ab0e2..2a35a1e0d42 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletCookieValueMethodArgumentResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletCookieValueMethodArgumentResolverTests.java @@ -19,8 +19,8 @@ package org.springframework.web.servlet.mvc.method.annotation; import java.lang.reflect.Method; import javax.servlet.http.Cookie; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.MethodParameter; import org.springframework.core.annotation.SynthesizingMethodParameter; @@ -49,7 +49,7 @@ public class ServletCookieValueMethodArgumentResolverTests { private MethodParameter cookieStringParameter; - @Before + @BeforeEach public void setup() throws Exception { resolver = new ServletCookieValueMethodArgumentResolver(null); request = new MockHttpServletRequest(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletInvocableHandlerMethodTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletInvocableHandlerMethodTests.java index 9d566248966..618e7e27ae5 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletInvocableHandlerMethodTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletInvocableHandlerMethodTests.java @@ -24,7 +24,7 @@ import java.util.Collections; import java.util.List; import javax.servlet.http.HttpServletResponse; -import org.junit.Test; +import org.junit.jupiter.api.Test; import reactor.core.publisher.Flux; import org.springframework.core.MethodParameter; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletModelAttributeMethodProcessorTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletModelAttributeMethodProcessorTests.java index b093f0ab5ae..57389379190 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletModelAttributeMethodProcessorTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletModelAttributeMethodProcessorTests.java @@ -21,8 +21,8 @@ import java.util.HashMap; import java.util.Map; import java.util.Optional; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.MethodParameter; import org.springframework.core.convert.support.DefaultConversionService; @@ -61,7 +61,7 @@ public class ServletModelAttributeMethodProcessorTests { private MethodParameter testBeanWithOptionalModelAttr; - @Before + @BeforeEach public void setup() throws Exception { processor = new ServletModelAttributeMethodProcessor(false); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletRequestMethodArgumentResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletRequestMethodArgumentResolverTests.java index 457b1bc98b6..15e1c2dc300 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletRequestMethodArgumentResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletRequestMethodArgumentResolverTests.java @@ -27,8 +27,8 @@ import javax.servlet.ServletRequest; import javax.servlet.http.HttpSession; import javax.servlet.http.PushBuilder; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.springframework.core.MethodParameter; @@ -64,7 +64,7 @@ public class ServletRequestMethodArgumentResolverTests { private Method method; - @Before + @BeforeEach public void setup() throws Exception { resolver = new ServletRequestMethodArgumentResolver(); mavContainer = new ModelAndViewContainer(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletResponseMethodArgumentResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletResponseMethodArgumentResolverTests.java index 573d1c538ff..c1e5ca85e5b 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletResponseMethodArgumentResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletResponseMethodArgumentResolverTests.java @@ -21,8 +21,8 @@ import java.io.Writer; import java.lang.reflect.Method; import javax.servlet.ServletResponse; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.MethodParameter; import org.springframework.mock.web.test.MockHttpServletRequest; @@ -50,7 +50,7 @@ public class ServletResponseMethodArgumentResolverTests { private Method method; - @Before + @BeforeEach public void setup() throws Exception { resolver = new ServletResponseMethodArgumentResolver(); mavContainer = new ModelAndViewContainer(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/SseEmitterTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/SseEmitterTests.java index 77fe8e77049..03509ab70b7 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/SseEmitterTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/SseEmitterTests.java @@ -20,8 +20,8 @@ import java.util.ArrayList; import java.util.List; import java.util.function.Consumer; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.http.MediaType; @@ -40,7 +40,7 @@ public class SseEmitterTests { private TestHandler handler; - @Before + @BeforeEach public void setup() throws IOException { this.handler = new TestHandler(); this.emitter = new SseEmitter(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/StreamingResponseBodyReturnValueHandlerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/StreamingResponseBodyReturnValueHandlerTests.java index 547b014cfc9..f29c7dfbe17 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/StreamingResponseBodyReturnValueHandlerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/StreamingResponseBodyReturnValueHandlerTests.java @@ -23,8 +23,8 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.MethodParameter; import org.springframework.http.ResponseEntity; @@ -59,7 +59,7 @@ public class StreamingResponseBodyReturnValueHandlerTests { private MockHttpServletResponse response; - @Before + @BeforeEach public void setup() throws Exception { this.handler = new StreamingResponseBodyReturnValueHandler(); this.mavContainer = new ModelAndViewContainer(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/UriComponentsBuilderMethodArgumentResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/UriComponentsBuilderMethodArgumentResolverTests.java index 5d652a71311..1403ce19ed2 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/UriComponentsBuilderMethodArgumentResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/UriComponentsBuilderMethodArgumentResolverTests.java @@ -18,8 +18,8 @@ package org.springframework.web.servlet.mvc.method.annotation; import java.lang.reflect.Method; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.MethodParameter; import org.springframework.mock.web.test.MockHttpServletRequest; @@ -48,7 +48,7 @@ public class UriComponentsBuilderMethodArgumentResolverTests { private MethodParameter intParam; - @Before + @BeforeEach public void setup() throws Exception { this.resolver = new UriComponentsBuilderMethodArgumentResolver(); this.servletRequest = new MockHttpServletRequest(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/UriTemplateServletAnnotationControllerHandlerMethodTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/UriTemplateServletAnnotationControllerHandlerMethodTests.java index 6c6f586f9e4..dfd1ee273fb 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/UriTemplateServletAnnotationControllerHandlerMethodTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/UriTemplateServletAnnotationControllerHandlerMethodTests.java @@ -29,7 +29,7 @@ import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.beans.propertyeditors.CustomDateEditor; @@ -673,13 +673,13 @@ public class UriTemplateServletAnnotationControllerHandlerMethodTests extends Ab } } -// @Ignore("ControllerClassNameHandlerMapping") +// @Disabled("ControllerClassNameHandlerMapping") // public void controllerClassName() throws Exception { -// @Ignore("useDefaultSuffixPattern property not supported") +// @Disabled("useDefaultSuffixPattern property not supported") // public void doubles() throws Exception { -// @Ignore("useDefaultSuffixPattern property not supported") +// @Disabled("useDefaultSuffixPattern property not supported") // public void noDefaultSuffixPattern() throws Exception { } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ViewMethodReturnValueHandlerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ViewMethodReturnValueHandlerTests.java index 0c909154a1b..128428c3b02 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ViewMethodReturnValueHandlerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ViewMethodReturnValueHandlerTests.java @@ -18,8 +18,8 @@ package org.springframework.web.servlet.mvc.method.annotation; import java.lang.reflect.Method; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.MethodParameter; import org.springframework.mock.web.test.MockHttpServletRequest; @@ -47,7 +47,7 @@ public class ViewMethodReturnValueHandlerTests { private ServletWebRequest webRequest; - @Before + @BeforeEach public void setup() { this.handler = new ViewMethodReturnValueHandler(); this.mavContainer = new ModelAndViewContainer(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ViewNameMethodReturnValueHandlerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ViewNameMethodReturnValueHandlerTests.java index ac1d5923418..985ae8a7073 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ViewNameMethodReturnValueHandlerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ViewNameMethodReturnValueHandlerTests.java @@ -16,8 +16,8 @@ package org.springframework.web.servlet.mvc.method.annotation; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.MethodParameter; import org.springframework.mock.web.test.MockHttpServletRequest; @@ -44,7 +44,7 @@ public class ViewNameMethodReturnValueHandlerTests { private MethodParameter param; - @Before + @BeforeEach public void setup() throws NoSuchMethodException { this.handler = new ViewNameMethodReturnValueHandler(); this.mavContainer = new ModelAndViewContainer(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/support/DefaultHandlerExceptionResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/support/DefaultHandlerExceptionResolverTests.java index eb9448e31b8..ff903342fce 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/support/DefaultHandlerExceptionResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/support/DefaultHandlerExceptionResolverTests.java @@ -19,8 +19,8 @@ package org.springframework.web.servlet.mvc.support; import java.lang.reflect.Method; import java.util.Collections; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.ConversionNotSupportedException; import org.springframework.beans.TypeMismatchException; @@ -59,7 +59,7 @@ public class DefaultHandlerExceptionResolverTests { private final MockHttpServletResponse response = new MockHttpServletResponse(); - @Before + @BeforeEach public void setup() { exceptionResolver.setWarnLogCategory(exceptionResolver.getClass().getName()); } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/support/ParameterizableViewControllerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/support/ParameterizableViewControllerTests.java index d0a11298602..58766c2f055 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/support/ParameterizableViewControllerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/support/ParameterizableViewControllerTests.java @@ -16,7 +16,7 @@ package org.springframework.web.servlet.mvc.support; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpStatus; import org.springframework.mock.web.test.MockHttpServletRequest; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/support/RedirectAttributesModelMapTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/support/RedirectAttributesModelMapTests.java index dbde2fb141a..a76a5c88ffd 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/support/RedirectAttributesModelMapTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/support/RedirectAttributesModelMapTests.java @@ -20,8 +20,8 @@ import java.util.Arrays; import java.util.HashMap; import java.util.Map; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.convert.converter.Converter; import org.springframework.format.support.DefaultFormattingConversionService; @@ -44,7 +44,7 @@ public class RedirectAttributesModelMapTests { private FormattingConversionService conversionService; - @Before + @BeforeEach public void setup() { this.conversionService = new DefaultFormattingConversionService(); DataBinder dataBinder = new DataBinder(null); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/AppCacheManifestTransformerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/AppCacheManifestTransformerTests.java index 92b2e8ed0dd..71048fddd97 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/AppCacheManifestTransformerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/AppCacheManifestTransformerTests.java @@ -21,8 +21,8 @@ import java.util.Collections; import java.util.List; import javax.servlet.http.HttpServletRequest; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; @@ -46,7 +46,7 @@ public class AppCacheManifestTransformerTests { private HttpServletRequest request; - @Before + @BeforeEach public void setup() { VersionResourceResolver versionResolver = new VersionResourceResolver(); versionResolver.setStrategyMap(Collections.singletonMap("/**", new ContentVersionStrategy())); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/CachingResourceResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/CachingResourceResolverTests.java index 73524182a47..ba0d71087f6 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/CachingResourceResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/CachingResourceResolverTests.java @@ -20,8 +20,8 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.springframework.cache.Cache; @@ -47,7 +47,7 @@ public class CachingResourceResolverTests { private List locations; - @Before + @BeforeEach public void setup() { this.cache = new ConcurrentMapCache("resourceCache"); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/ContentBasedVersionStrategyTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/ContentBasedVersionStrategyTests.java index b90a7cc5d30..a8cf32d6be6 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/ContentBasedVersionStrategyTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/ContentBasedVersionStrategyTests.java @@ -19,8 +19,8 @@ package org.springframework.web.servlet.resource; import java.io.IOException; import java.util.Collections; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; @@ -40,7 +40,7 @@ public class ContentBasedVersionStrategyTests { private ContentVersionStrategy versionStrategy = new ContentVersionStrategy(); - @Before + @BeforeEach public void setup() { VersionResourceResolver versionResourceResolver = new VersionResourceResolver(); versionResourceResolver.setStrategyMap(Collections.singletonMap("/**", this.versionStrategy)); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/CssLinkResourceTransformerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/CssLinkResourceTransformerTests.java index 30f1e1080c6..d49ddd229ee 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/CssLinkResourceTransformerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/CssLinkResourceTransformerTests.java @@ -21,8 +21,8 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.springframework.core.io.ClassPathResource; @@ -48,7 +48,7 @@ public class CssLinkResourceTransformerTests { private MockHttpServletRequest request; - @Before + @BeforeEach public void setUp() { VersionResourceResolver versionResolver = new VersionResourceResolver(); versionResolver.setStrategyMap(Collections.singletonMap("/**", new ContentVersionStrategy())); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/EncodedResourceResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/EncodedResourceResolverTests.java index 6cf7a33770e..8e258e13aa6 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/EncodedResourceResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/EncodedResourceResolverTests.java @@ -27,9 +27,9 @@ import java.util.Collections; import java.util.List; import java.util.zip.GZIPOutputStream; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.cache.Cache; import org.springframework.cache.concurrent.ConcurrentMapCache; @@ -57,7 +57,7 @@ public class EncodedResourceResolverTests { private Cache cache; - @BeforeClass + @BeforeAll public static void createGzippedResources() throws IOException { createGzippedFile("/js/foo.js"); createGzippedFile("foo.css"); @@ -77,7 +77,7 @@ public class EncodedResourceResolverTests { } - @Before + @BeforeEach public void setup() { this.cache = new ConcurrentMapCache("resourceCache"); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/FixedVersionStrategyTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/FixedVersionStrategyTests.java index 62f9da972e3..273a0a9abb4 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/FixedVersionStrategyTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/FixedVersionStrategyTests.java @@ -16,8 +16,8 @@ package org.springframework.web.servlet.resource; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; @@ -38,7 +38,7 @@ public class FixedVersionStrategyTests { private FixedVersionStrategy strategy; - @Before + @BeforeEach public void setup() { this.strategy = new FixedVersionStrategy(VERSION); } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/PathResourceResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/PathResourceResolverTests.java index 58aa5080266..653ab9e7836 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/PathResourceResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/PathResourceResolverTests.java @@ -21,7 +21,7 @@ import java.nio.charset.StandardCharsets; import java.util.Collections; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandlerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandlerTests.java index c9358ad35d7..70a7af291ca 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandlerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/ResourceHttpRequestHandlerTests.java @@ -23,8 +23,8 @@ import java.util.Collections; import java.util.List; import javax.servlet.http.HttpServletResponse; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; @@ -66,7 +66,7 @@ public class ResourceHttpRequestHandlerTests { private MockHttpServletResponse response; - @Before + @BeforeEach public void setup() throws Exception { List paths = new ArrayList<>(2); paths.add(new ClassPathResource("test/", getClass())); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/ResourceTransformerSupportTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/ResourceTransformerSupportTests.java index 78a2f01a6b8..794b3b754e6 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/ResourceTransformerSupportTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/ResourceTransformerSupportTests.java @@ -20,8 +20,8 @@ import java.util.Collections; import java.util.List; import javax.servlet.http.HttpServletRequest; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; @@ -44,7 +44,7 @@ public class ResourceTransformerSupportTests { private final MockHttpServletRequest request = new MockHttpServletRequest("GET", "/"); - @Before + @BeforeEach public void setUp() { VersionResourceResolver versionResolver = new VersionResourceResolver(); versionResolver.setStrategyMap(Collections.singletonMap("/**", new ContentVersionStrategy())); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/ResourceUrlEncodingFilterTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/ResourceUrlEncodingFilterTests.java index 37d74bb1f98..1da6808385d 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/ResourceUrlEncodingFilterTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/ResourceUrlEncodingFilterTests.java @@ -22,8 +22,8 @@ import java.util.List; import javax.servlet.ServletException; import javax.servlet.http.HttpServletResponse; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.io.ClassPathResource; import org.springframework.mock.web.test.MockHttpServletRequest; @@ -43,7 +43,7 @@ public class ResourceUrlEncodingFilterTests { private ResourceUrlProvider urlProvider; - @Before + @BeforeEach public void createFilter() { VersionResourceResolver versionResolver = new VersionResourceResolver(); versionResolver.setStrategyMap(Collections.singletonMap("/**", new ContentVersionStrategy())); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/ResourceUrlProviderJavaConfigTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/ResourceUrlProviderJavaConfigTests.java index e5f0c6a0fd7..963c0c1017e 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/ResourceUrlProviderJavaConfigTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/ResourceUrlProviderJavaConfigTests.java @@ -20,8 +20,8 @@ import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.context.annotation.Configuration; import org.springframework.mock.web.test.MockFilterChain; @@ -52,7 +52,7 @@ public class ResourceUrlProviderJavaConfigTests { private MockHttpServletResponse response; - @Before + @BeforeEach @SuppressWarnings("resource") public void setup() throws Exception { AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/ResourceUrlProviderTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/ResourceUrlProviderTests.java index 9ada1eca34a..668f9e5aa87 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/ResourceUrlProviderTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/ResourceUrlProviderTests.java @@ -22,8 +22,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -56,7 +56,7 @@ public class ResourceUrlProviderTests { private final ResourceUrlProvider urlProvider = new ResourceUrlProvider(); - @Before + @BeforeEach public void setUp() throws Exception { this.locations.add(new ClassPathResource("test/", getClass())); this.locations.add(new ClassPathResource("testalternatepath/", getClass())); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/VersionResourceResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/VersionResourceResolverTests.java index 069513d2b91..a5daad18386 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/VersionResourceResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/VersionResourceResolverTests.java @@ -21,8 +21,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; @@ -52,7 +52,7 @@ public class VersionResourceResolverTests { private VersionStrategy versionStrategy; - @Before + @BeforeEach public void setup() { this.locations = new ArrayList<>(); this.locations.add(new ClassPathResource("test/", getClass())); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/WebJarsResourceResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/WebJarsResourceResolverTests.java index d5dbef01fa1..13108d43794 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/WebJarsResourceResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/resource/WebJarsResourceResolverTests.java @@ -20,8 +20,8 @@ import java.util.Collections; import java.util.List; import javax.servlet.http.HttpServletRequest; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; @@ -51,7 +51,7 @@ public class WebJarsResourceResolverTests { private HttpServletRequest request = new MockHttpServletRequest(); - @Before + @BeforeEach public void setup() { // for this to work, an actual WebJar must be on the test classpath this.locations = Collections.singletonList(new ClassPathResource("/META-INF/resources/webjars")); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/support/AnnotationConfigDispatcherServletInitializerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/support/AnnotationConfigDispatcherServletInitializerTests.java index 3faf96d80ec..ca0331ce65c 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/support/AnnotationConfigDispatcherServletInitializerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/support/AnnotationConfigDispatcherServletInitializerTests.java @@ -30,8 +30,8 @@ import javax.servlet.ServletContextListener; import javax.servlet.ServletException; import javax.servlet.ServletRegistration; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -71,7 +71,7 @@ public class AnnotationConfigDispatcherServletInitializerTests { private Map filterRegistrations; - @Before + @BeforeEach public void setUp() throws Exception { servletContext = new MyMockServletContext(); initializer = new MyAnnotationConfigDispatcherServletInitializer(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/support/DispatcherServletInitializerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/support/DispatcherServletInitializerTests.java index 624e0f33248..d31475b5374 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/support/DispatcherServletInitializerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/support/DispatcherServletInitializerTests.java @@ -23,7 +23,7 @@ import javax.servlet.Servlet; import javax.servlet.ServletException; import javax.servlet.ServletRegistration; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockServletContext; import org.springframework.web.context.WebApplicationContext; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/support/FlashMapManagerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/support/FlashMapManagerTests.java index 0f6df9305b1..7bc077a0a18 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/support/FlashMapManagerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/support/FlashMapManagerTests.java @@ -26,7 +26,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.assertj.core.api.ObjectAssert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockHttpServletResponse; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/support/RequestContextTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/support/RequestContextTests.java index 2ac50002233..5ad6f60e288 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/support/RequestContextTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/support/RequestContextTests.java @@ -19,8 +19,8 @@ package org.springframework.web.servlet.support; import java.util.HashMap; import java.util.Map; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockHttpServletResponse; @@ -45,7 +45,7 @@ public class RequestContextTests { private Map model = new HashMap<>(); - @Before + @BeforeEach public void init() { GenericWebApplicationContext applicationContext = new GenericWebApplicationContext(); applicationContext.refresh(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/support/ServletUriComponentsBuilderTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/support/ServletUriComponentsBuilderTests.java index dd8f1dceaba..91dbe47578e 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/support/ServletUriComponentsBuilderTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/support/ServletUriComponentsBuilderTests.java @@ -18,8 +18,8 @@ package org.springframework.web.servlet.support; import javax.servlet.http.HttpServletRequest; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockFilterChain; import org.springframework.mock.web.test.MockHttpServletRequest; @@ -42,7 +42,7 @@ public class ServletUriComponentsBuilderTests { private MockHttpServletRequest request; - @Before + @BeforeEach public void setup() { this.request = new MockHttpServletRequest(); this.request.setScheme("http"); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/support/WebContentGeneratorTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/support/WebContentGeneratorTests.java index f57e5fb22de..705dab002bb 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/support/WebContentGeneratorTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/support/WebContentGeneratorTests.java @@ -17,7 +17,7 @@ package org.springframework.web.servlet.support; import java.util.Arrays; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockHttpServletResponse; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/ArgumentTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/ArgumentTagTests.java index 77449941520..5ff3a49183f 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/ArgumentTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/ArgumentTagTests.java @@ -21,8 +21,8 @@ import javax.servlet.jsp.PageContext; import javax.servlet.jsp.tagext.Tag; import javax.servlet.jsp.tagext.TagSupport; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockBodyContent; import org.springframework.mock.web.test.MockHttpServletResponse; @@ -40,7 +40,7 @@ public class ArgumentTagTests extends AbstractTagTests { private MockArgumentSupportTag parent; - @Before + @BeforeEach public void setUp() throws Exception { PageContext context = createPageContext(); parent = new MockArgumentSupportTag(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/BindTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/BindTagTests.java index 65f6cde3f40..f41289965dc 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/BindTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/BindTagTests.java @@ -26,7 +26,7 @@ import javax.servlet.jsp.JspException; import javax.servlet.jsp.PageContext; import javax.servlet.jsp.tagext.Tag; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.propertyeditors.CustomDateEditor; import org.springframework.tests.sample.beans.IndexedTestBean; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/EvalTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/EvalTagTests.java index 1cacd3b662d..ce19c5d25e7 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/EvalTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/EvalTagTests.java @@ -22,8 +22,8 @@ import java.util.Locale; import java.util.Map; import javax.servlet.jsp.tagext.Tag; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.context.support.GenericApplicationContext; import org.springframework.core.env.MapPropertySource; @@ -47,7 +47,7 @@ public class EvalTagTests extends AbstractTagTests { private MockPageContext context; - @Before + @BeforeEach public void setup() throws Exception { context = createPageContext(); FormattingConversionServiceFactoryBean factory = new FormattingConversionServiceFactoryBean(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/HtmlEscapeTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/HtmlEscapeTagTests.java index bb4c712191a..d73ae66553b 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/HtmlEscapeTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/HtmlEscapeTagTests.java @@ -21,7 +21,7 @@ import javax.servlet.jsp.PageContext; import javax.servlet.jsp.tagext.BodyTag; import javax.servlet.jsp.tagext.Tag; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockServletContext; import org.springframework.web.util.WebUtils; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/MessageTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/MessageTagTests.java index 380f3643adc..4356830f5c8 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/MessageTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/MessageTagTests.java @@ -24,7 +24,7 @@ import javax.servlet.jsp.JspException; import javax.servlet.jsp.PageContext; import javax.servlet.jsp.tagext.Tag; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.MessageSourceResolvable; import org.springframework.context.support.DefaultMessageSourceResolvable; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/ParamTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/ParamTagTests.java index 40a4a7a3e1d..5e99c29e8e6 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/ParamTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/ParamTagTests.java @@ -21,8 +21,8 @@ import javax.servlet.jsp.PageContext; import javax.servlet.jsp.tagext.Tag; import javax.servlet.jsp.tagext.TagSupport; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockBodyContent; import org.springframework.mock.web.test.MockHttpServletResponse; @@ -42,7 +42,7 @@ public class ParamTagTests extends AbstractTagTests { private MockParamSupportTag parent = new MockParamSupportTag(); - @Before + @BeforeEach public void setUp() throws Exception { PageContext context = createPageContext(); tag.setPageContext(context); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/ParamTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/ParamTests.java index 16ac3a2bf7e..acf362255af 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/ParamTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/ParamTests.java @@ -16,7 +16,7 @@ package org.springframework.web.servlet.tags; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/ThemeTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/ThemeTagTests.java index 64c22f5419b..e4ecc232f5a 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/ThemeTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/ThemeTagTests.java @@ -24,7 +24,7 @@ import javax.servlet.jsp.JspException; import javax.servlet.jsp.PageContext; import javax.servlet.jsp.tagext.Tag; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.MessageSourceResolvable; import org.springframework.context.support.DefaultMessageSourceResolvable; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/UrlTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/UrlTagTests.java index 3f182613e96..931c9f90c2d 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/UrlTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/UrlTagTests.java @@ -24,8 +24,8 @@ import javax.servlet.jsp.JspException; import javax.servlet.jsp.PageContext; import javax.servlet.jsp.tagext.Tag; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockPageContext; @@ -42,7 +42,7 @@ public class UrlTagTests extends AbstractTagTests { private MockPageContext context; - @Before + @BeforeEach public void setup() throws Exception { context = createPageContext(); tag = new UrlTag(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/AbstractHtmlElementTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/AbstractHtmlElementTagTests.java index 01d22accc39..fb226ee8152 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/AbstractHtmlElementTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/AbstractHtmlElementTagTests.java @@ -23,7 +23,7 @@ import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.jsp.JspException; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockPageContext; @@ -55,7 +55,7 @@ public abstract class AbstractHtmlElementTagTests extends AbstractTagTests { private MockPageContext pageContext; - @Before + @BeforeEach public final void setUp() throws Exception { // set up a writer for the tag content to be written to this.writer = new StringWriter(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/ButtonTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/ButtonTagTests.java index 3f10732ca91..3bcc466adbc 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/ButtonTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/ButtonTagTests.java @@ -19,7 +19,7 @@ package org.springframework.web.servlet.tags.form; import java.io.Writer; import javax.servlet.jsp.tagext.Tag; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.tests.sample.beans.TestBean; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/CheckboxTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/CheckboxTagTests.java index 65b14959deb..983bc36a01a 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/CheckboxTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/CheckboxTagTests.java @@ -30,7 +30,7 @@ import javax.servlet.jsp.tagext.Tag; import org.dom4j.Document; import org.dom4j.Element; import org.dom4j.io.SAXReader; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.propertyeditors.StringTrimmerEditor; import org.springframework.tests.sample.beans.Colour; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/CheckboxesTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/CheckboxesTagTests.java index 2e195922ab6..e58f1c7f90d 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/CheckboxesTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/CheckboxesTagTests.java @@ -34,7 +34,7 @@ import javax.servlet.jsp.tagext.Tag; import org.dom4j.Document; import org.dom4j.Element; import org.dom4j.io.SAXReader; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.propertyeditors.StringTrimmerEditor; import org.springframework.format.Formatter; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/ErrorsTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/ErrorsTagTests.java index 2c3c9917300..394fd2d8a14 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/ErrorsTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/ErrorsTagTests.java @@ -25,7 +25,7 @@ import javax.servlet.jsp.PageContext; import javax.servlet.jsp.tagext.BodyTag; import javax.servlet.jsp.tagext.Tag; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockBodyContent; import org.springframework.mock.web.test.MockPageContext; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/FormTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/FormTagTests.java index a8fdf3a6e99..254050643c8 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/FormTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/FormTagTests.java @@ -20,7 +20,7 @@ import java.util.Collections; import javax.servlet.jsp.PageContext; import javax.servlet.jsp.tagext.Tag; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.web.servlet.support.RequestDataValueProcessor; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/HiddenInputTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/HiddenInputTagTests.java index 14ee52d2814..a304e8c1987 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/HiddenInputTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/HiddenInputTagTests.java @@ -19,7 +19,7 @@ package org.springframework.web.servlet.tags.form; import javax.servlet.jsp.JspException; import javax.servlet.jsp.tagext.Tag; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.tests.sample.beans.TestBean; import org.springframework.validation.BeanPropertyBindingResult; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/InputTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/InputTagTests.java index 4ed19eb6eb4..e88cff8ac98 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/InputTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/InputTagTests.java @@ -20,7 +20,7 @@ import java.io.Writer; import javax.servlet.jsp.JspException; import javax.servlet.jsp.tagext.Tag; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.tests.sample.beans.TestBean; import org.springframework.validation.BeanPropertyBindingResult; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/LabelTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/LabelTagTests.java index 9a63a848888..019f732201f 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/LabelTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/LabelTagTests.java @@ -19,7 +19,7 @@ package org.springframework.web.servlet.tags.form; import javax.servlet.jsp.JspException; import javax.servlet.jsp.tagext.Tag; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockPageContext; import org.springframework.tests.sample.beans.TestBean; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/OptionTagEnumTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/OptionTagEnumTests.java index b0468ccdcf1..ddbb46a0493 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/OptionTagEnumTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/OptionTagEnumTests.java @@ -19,7 +19,7 @@ package org.springframework.web.servlet.tags.form; import javax.servlet.jsp.tagext.BodyTag; import javax.servlet.jsp.tagext.Tag; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.tests.sample.beans.CustomEnum; import org.springframework.tests.sample.beans.GenericBean; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/OptionTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/OptionTagTests.java index ca99d8326bf..06ba2d3b9a8 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/OptionTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/OptionTagTests.java @@ -24,7 +24,7 @@ import java.util.List; import javax.servlet.jsp.tagext.BodyTag; import javax.servlet.jsp.tagext.Tag; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.propertyeditors.StringArrayPropertyEditor; import org.springframework.mock.web.test.MockBodyContent; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/OptionsTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/OptionsTagTests.java index 784118b8271..65e58f2341e 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/OptionsTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/OptionsTagTests.java @@ -31,7 +31,7 @@ import org.dom4j.Document; import org.dom4j.Element; import org.dom4j.Node; import org.dom4j.io.SAXReader; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockPageContext; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/PasswordInputTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/PasswordInputTagTests.java index 33f73f07340..1ca5c569528 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/PasswordInputTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/PasswordInputTagTests.java @@ -20,7 +20,7 @@ import java.io.Writer; import javax.servlet.jsp.JspException; import javax.servlet.jsp.tagext.Tag; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/RadioButtonTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/RadioButtonTagTests.java index 96cd5fb971d..254c46e6750 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/RadioButtonTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/RadioButtonTagTests.java @@ -25,7 +25,7 @@ import javax.servlet.jsp.tagext.Tag; import org.dom4j.Document; import org.dom4j.Element; import org.dom4j.io.SAXReader; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.tests.sample.beans.Pet; import org.springframework.tests.sample.beans.TestBean; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/RadioButtonsTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/RadioButtonsTagTests.java index c4f494522ad..609b827d227 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/RadioButtonsTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/RadioButtonsTagTests.java @@ -33,7 +33,7 @@ import org.dom4j.Document; import org.dom4j.Element; import org.dom4j.Node; import org.dom4j.io.SAXReader; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.propertyeditors.StringTrimmerEditor; import org.springframework.tests.sample.beans.Colour; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/SelectTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/SelectTagTests.java index a88a92beeb9..ae9c1740fa2 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/SelectTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/SelectTagTests.java @@ -37,7 +37,7 @@ import org.dom4j.Document; import org.dom4j.DocumentException; import org.dom4j.Element; import org.dom4j.io.SAXReader; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.propertyeditors.CustomCollectionEditor; import org.springframework.format.Formatter; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/TagIdGeneratorTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/TagIdGeneratorTests.java index 495decdddff..bfe3db6da96 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/TagIdGeneratorTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/TagIdGeneratorTests.java @@ -19,7 +19,7 @@ package org.springframework.web.servlet.tags.form; import java.util.stream.IntStream; import javax.servlet.jsp.PageContext; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockPageContext; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/TagWriterTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/TagWriterTests.java index 1cbff8bfc11..76cce554e7f 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/TagWriterTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/TagWriterTests.java @@ -18,7 +18,7 @@ package org.springframework.web.servlet.tags.form; import java.io.StringWriter; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/TextareaTagTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/TextareaTagTests.java index 301c3168bdb..0defa4d37ba 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/TextareaTagTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/TextareaTagTests.java @@ -18,7 +18,7 @@ package org.springframework.web.servlet.tags.form; import javax.servlet.jsp.tagext.Tag; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.tests.sample.beans.TestBean; import org.springframework.validation.BeanPropertyBindingResult; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/theme/ThemeResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/theme/ThemeResolverTests.java index f2e506b63ac..f0ca0fd0eda 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/theme/ThemeResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/theme/ThemeResolverTests.java @@ -16,7 +16,7 @@ package org.springframework.web.servlet.theme; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockHttpServletResponse; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/BaseViewTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/BaseViewTests.java index ce4ff2f490c..ab38900ea77 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/BaseViewTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/BaseViewTests.java @@ -24,7 +24,7 @@ import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.ApplicationContextException; import org.springframework.mock.web.test.MockHttpServletRequest; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/ContentNegotiatingViewResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/ContentNegotiatingViewResolverTests.java index 5cf8f92a404..7f3c38becbb 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/ContentNegotiatingViewResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/ContentNegotiatingViewResolverTests.java @@ -24,9 +24,9 @@ import java.util.Locale; import java.util.Map; import java.util.Set; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.http.MediaType; import org.springframework.mock.web.test.MockHttpServletRequest; @@ -58,7 +58,7 @@ public class ContentNegotiatingViewResolverTests { private MockHttpServletRequest request; - @Before + @BeforeEach public void createViewResolver() { StaticWebApplicationContext wac = new StaticWebApplicationContext(); wac.setServletContext(new MockServletContext()); @@ -69,7 +69,7 @@ public class ContentNegotiatingViewResolverTests { RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(request)); } - @After + @AfterEach public void resetRequestContextHolder() { RequestContextHolder.resetRequestAttributes(); } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/DefaultRequestToViewNameTranslatorTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/DefaultRequestToViewNameTranslatorTests.java index b8e875fdbdf..2f22fd358b1 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/DefaultRequestToViewNameTranslatorTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/DefaultRequestToViewNameTranslatorTests.java @@ -16,8 +16,8 @@ package org.springframework.web.servlet.view; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockHttpServletRequest; @@ -37,7 +37,7 @@ public class DefaultRequestToViewNameTranslatorTests { private MockHttpServletRequest request; - @Before + @BeforeEach public void setUp() { this.translator = new DefaultRequestToViewNameTranslator(); this.request = new MockHttpServletRequest(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/InternalResourceViewTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/InternalResourceViewTests.java index cc27936a6f8..c1ba5db0df1 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/InternalResourceViewTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/InternalResourceViewTests.java @@ -21,7 +21,7 @@ import java.util.HashMap; import java.util.Map; import javax.servlet.http.HttpServletRequest; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockHttpServletResponse; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/RedirectViewTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/RedirectViewTests.java index 3b49915dae8..07c50fede29 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/RedirectViewTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/RedirectViewTests.java @@ -23,8 +23,8 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpStatus; import org.springframework.mock.web.test.MockHttpServletRequest; @@ -66,7 +66,7 @@ public class RedirectViewTests { private MockHttpServletResponse response; - @Before + @BeforeEach public void setUp() throws Exception { this.request = new MockHttpServletRequest(); this.request.setContextPath("/context"); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/RedirectViewUriTemplateTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/RedirectViewUriTemplateTests.java index 5f1ba50c7bf..7234bbb1cb6 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/RedirectViewUriTemplateTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/RedirectViewUriTemplateTests.java @@ -19,8 +19,8 @@ package org.springframework.web.servlet.view; import java.util.HashMap; import java.util.Map; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockHttpServletResponse; @@ -39,7 +39,7 @@ public class RedirectViewUriTemplateTests { private MockHttpServletResponse response; - @Before + @BeforeEach public void setUp() { this.request = new MockHttpServletRequest(); this.response = new MockHttpServletResponse(); 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 491ea8bb2ef..c05b7cfa37a 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 @@ -22,8 +22,8 @@ import java.util.MissingResourceException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.BeanIsAbstractException; import org.springframework.core.io.Resource; @@ -51,7 +51,7 @@ public class ResourceBundleViewResolverTests { private final StaticWebApplicationContext wac = new StaticWebApplicationContext(); - @Before + @BeforeEach public void setUp() throws Exception { rb.setBasename(PROPS_FILE); rb.setCache(getCache()); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/ViewResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/ViewResolverTests.java index 7a353f5f2ec..a003a4eb512 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/ViewResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/ViewResolverTests.java @@ -29,8 +29,8 @@ import javax.servlet.http.HttpServletResponse; import javax.servlet.jsp.jstl.core.Config; import javax.servlet.jsp.jstl.fmt.LocalizationContext; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.MutablePropertyValues; import org.springframework.beans.PropertyValue; @@ -71,7 +71,7 @@ public class ViewResolverTests { private final MockHttpServletRequest request = new MockHttpServletRequest(this.sc); private final HttpServletResponse response = new MockHttpServletResponse(); - @Before + @BeforeEach public void setUp() { this.wac.setServletContext(this.sc); } diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/document/XlsViewTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/document/XlsViewTests.java index f869729a5c4..80ab84644d9 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/document/XlsViewTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/document/XlsViewTests.java @@ -28,7 +28,7 @@ import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockHttpServletResponse; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/feed/AtomFeedViewTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/feed/AtomFeedViewTests.java index 02154de55dc..34320411488 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/feed/AtomFeedViewTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/feed/AtomFeedViewTests.java @@ -26,7 +26,7 @@ import javax.servlet.http.HttpServletResponse; import com.rometools.rome.feed.atom.Content; import com.rometools.rome.feed.atom.Entry; import com.rometools.rome.feed.atom.Feed; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockHttpServletResponse; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/feed/RssFeedViewTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/feed/RssFeedViewTests.java index 23c9dcb1ccf..f55d807cbfa 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/feed/RssFeedViewTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/feed/RssFeedViewTests.java @@ -26,7 +26,7 @@ import javax.servlet.http.HttpServletResponse; import com.rometools.rome.feed.rss.Channel; import com.rometools.rome.feed.rss.Description; import com.rometools.rome.feed.rss.Item; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockHttpServletResponse; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/freemarker/FreeMarkerConfigurerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/freemarker/FreeMarkerConfigurerTests.java index 8f37cf7f068..55d328e21fa 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/freemarker/FreeMarkerConfigurerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/freemarker/FreeMarkerConfigurerTests.java @@ -23,7 +23,7 @@ import freemarker.cache.ClassTemplateLoader; import freemarker.cache.MultiTemplateLoader; import freemarker.template.Configuration; import freemarker.template.Template; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.io.ByteArrayResource; import org.springframework.core.io.FileSystemResource; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/freemarker/FreeMarkerMacroTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/freemarker/FreeMarkerMacroTests.java index 6a1aa61b42e..c6c46997dfc 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/freemarker/FreeMarkerMacroTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/freemarker/FreeMarkerMacroTests.java @@ -28,8 +28,8 @@ import freemarker.template.Configuration; import freemarker.template.SimpleHash; import freemarker.template.Template; import freemarker.template.TemplateException; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.FileSystemResource; @@ -69,7 +69,7 @@ public class FreeMarkerMacroTests { private FreeMarkerConfigurer fc; - @Before + @BeforeEach public void setUp() throws Exception { ServletContext sc = new MockServletContext(); wac = new StaticWebApplicationContext(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/freemarker/FreeMarkerViewTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/freemarker/FreeMarkerViewTests.java index 8a9fb7cc883..4b784dc25bd 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/freemarker/FreeMarkerViewTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/freemarker/FreeMarkerViewTests.java @@ -29,7 +29,7 @@ import freemarker.ext.servlet.AllHttpScopesHashModel; import freemarker.template.Configuration; import freemarker.template.Template; import freemarker.template.TemplateException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.ApplicationContextException; import org.springframework.mock.web.test.MockHttpServletRequest; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/groovy/GroovyMarkupConfigurerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/groovy/GroovyMarkupConfigurerTests.java index 9a31c97fec3..cc265e8e02a 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/groovy/GroovyMarkupConfigurerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/groovy/GroovyMarkupConfigurerTests.java @@ -23,8 +23,8 @@ import java.util.Locale; import groovy.text.TemplateEngine; import groovy.text.markup.MarkupTemplateEngine; import groovy.text.markup.TemplateConfiguration; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.context.support.StaticApplicationContext; @@ -49,7 +49,7 @@ public class GroovyMarkupConfigurerTests { private GroovyMarkupConfigurer configurer; - @Before + @BeforeEach public void setup() throws Exception { this.applicationContext = new StaticApplicationContext(); this.configurer = new GroovyMarkupConfigurer(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/groovy/GroovyMarkupViewResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/groovy/GroovyMarkupViewResolverTests.java index 56065d8a3c4..82be60df207 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/groovy/GroovyMarkupViewResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/groovy/GroovyMarkupViewResolverTests.java @@ -18,7 +18,7 @@ package org.springframework.web.servlet.view.groovy; import java.util.Locale; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.DirectFieldAccessor; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/groovy/GroovyMarkupViewTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/groovy/GroovyMarkupViewTests.java index 596892d6b39..865c1ff1244 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/groovy/GroovyMarkupViewTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/groovy/GroovyMarkupViewTests.java @@ -26,8 +26,8 @@ import groovy.text.Template; import groovy.text.TemplateEngine; import groovy.text.markup.MarkupTemplateEngine; import groovy.text.markup.TemplateConfiguration; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.DirectFieldAccessor; import org.springframework.context.ApplicationContextException; @@ -57,7 +57,7 @@ public class GroovyMarkupViewTests { private ServletContext servletContext; - @Before + @BeforeEach public void setup() { this.webAppContext = mock(WebApplicationContext.class); this.servletContext = new MockServletContext(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/json/MappingJackson2JsonViewTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/json/MappingJackson2JsonViewTests.java index 819ba1ca354..900d7328d7a 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/json/MappingJackson2JsonViewTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/json/MappingJackson2JsonViewTests.java @@ -38,8 +38,8 @@ import com.fasterxml.jackson.databind.ser.FilterProvider; import com.fasterxml.jackson.databind.ser.SerializerFactory; import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter; import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mozilla.javascript.Context; import org.mozilla.javascript.ContextFactory; import org.mozilla.javascript.ScriptableObject; @@ -74,7 +74,7 @@ public class MappingJackson2JsonViewTests { private ScriptableObject jsScope; - @Before + @BeforeEach public void setUp() { request = new MockHttpServletRequest(); response = new MockHttpServletResponse(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/script/JRubyScriptTemplateTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/script/JRubyScriptTemplateTests.java index f0d6f2477bd..3dc47b992d3 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/script/JRubyScriptTemplateTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/script/JRubyScriptTemplateTests.java @@ -20,9 +20,9 @@ import java.util.HashMap; import java.util.Map; import javax.servlet.ServletContext; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; @@ -40,7 +40,7 @@ import static org.mockito.Mockito.mock; * * @author Sebastien Deleuze */ -@Ignore("JRuby not compatible with JDK 9 yet") +@Disabled("JRuby not compatible with JDK 9 yet") public class JRubyScriptTemplateTests { private WebApplicationContext webAppContext; @@ -48,7 +48,7 @@ public class JRubyScriptTemplateTests { private ServletContext servletContext; - @Before + @BeforeEach public void setup() { this.webAppContext = mock(WebApplicationContext.class); this.servletContext = new MockServletContext(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/script/JythonScriptTemplateTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/script/JythonScriptTemplateTests.java index a1b8a853820..68d7168d188 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/script/JythonScriptTemplateTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/script/JythonScriptTemplateTests.java @@ -20,8 +20,8 @@ import java.util.HashMap; import java.util.Map; import javax.servlet.ServletContext; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; @@ -46,7 +46,7 @@ public class JythonScriptTemplateTests { private ServletContext servletContext; - @Before + @BeforeEach public void setup() { this.webAppContext = mock(WebApplicationContext.class); this.servletContext = new MockServletContext(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/script/KotlinScriptTemplateTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/script/KotlinScriptTemplateTests.java index b155eb11ba3..b05a500c007 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/script/KotlinScriptTemplateTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/script/KotlinScriptTemplateTests.java @@ -21,8 +21,8 @@ import java.util.Locale; import java.util.Map; import javax.servlet.ServletContext; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; @@ -48,7 +48,7 @@ public class KotlinScriptTemplateTests { private ServletContext servletContext; - @Before + @BeforeEach public void setup() { this.webAppContext = mock(WebApplicationContext.class); this.servletContext = new MockServletContext(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/script/NashornScriptTemplateTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/script/NashornScriptTemplateTests.java index 5bcc7d957f4..099b238ff5b 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/script/NashornScriptTemplateTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/script/NashornScriptTemplateTests.java @@ -20,8 +20,8 @@ import java.util.HashMap; import java.util.Map; import javax.servlet.ServletContext; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; @@ -46,7 +46,7 @@ public class NashornScriptTemplateTests { private ServletContext servletContext; - @Before + @BeforeEach public void setup() { this.webAppContext = mock(WebApplicationContext.class); this.servletContext = new MockServletContext(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/script/ScriptTemplateViewResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/script/ScriptTemplateViewResolverTests.java index c5735179dbb..d41044b436b 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/script/ScriptTemplateViewResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/script/ScriptTemplateViewResolverTests.java @@ -16,7 +16,7 @@ package org.springframework.web.servlet.view.script; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.DirectFieldAccessor; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/script/ScriptTemplateViewTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/script/ScriptTemplateViewTests.java index 03079a76646..a47cc83f2c3 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/script/ScriptTemplateViewTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/script/ScriptTemplateViewTests.java @@ -28,8 +28,8 @@ import java.util.concurrent.Future; import javax.script.Invocable; import javax.script.ScriptEngine; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.DirectFieldAccessor; import org.springframework.context.ApplicationContextException; @@ -63,7 +63,7 @@ public class ScriptTemplateViewTests { private StaticWebApplicationContext wac; - @Before + @BeforeEach public void setup() { this.configurer = new ScriptTemplateConfigurer(); this.wac = new StaticWebApplicationContext(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/tiles3/TilesConfigurerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/tiles3/TilesConfigurerTests.java index 3fd03bfdee9..5b40447ae9c 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/tiles3/TilesConfigurerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/tiles3/TilesConfigurerTests.java @@ -22,7 +22,7 @@ import org.apache.tiles.request.ApplicationContext; import org.apache.tiles.request.Request; import org.apache.tiles.request.servlet.ServletRequest; import org.apache.tiles.request.servlet.ServletUtil; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.annotation.Configuration; import org.springframework.mock.web.test.MockHttpServletRequest; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/tiles3/TilesViewResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/tiles3/TilesViewResolverTests.java index 656b633ecaa..00231937554 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/tiles3/TilesViewResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/tiles3/TilesViewResolverTests.java @@ -19,8 +19,8 @@ import java.util.Locale; import org.apache.tiles.request.Request; import org.apache.tiles.request.render.Renderer; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockServletContext; import org.springframework.web.context.support.StaticWebApplicationContext; @@ -44,7 +44,7 @@ public class TilesViewResolverTests { private Renderer renderer; - @Before + @BeforeEach public void setUp() { StaticWebApplicationContext wac = new StaticWebApplicationContext(); wac.setServletContext(new MockServletContext()); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/tiles3/TilesViewTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/tiles3/TilesViewTests.java index c52f814062c..b1473863252 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/tiles3/TilesViewTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/tiles3/TilesViewTests.java @@ -21,8 +21,8 @@ import java.util.Map; import org.apache.tiles.request.AbstractRequest; import org.apache.tiles.request.Request; import org.apache.tiles.request.render.Renderer; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockHttpServletResponse; @@ -55,7 +55,7 @@ public class TilesViewTests { private MockHttpServletResponse response; - @Before + @BeforeEach public void setUp() throws Exception { MockServletContext servletContext = new MockServletContext(); StaticWebApplicationContext wac = new StaticWebApplicationContext(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/xml/MappingJackson2XmlViewTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/xml/MappingJackson2XmlViewTests.java index c1eee53c144..038f27f5225 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/xml/MappingJackson2XmlViewTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/xml/MappingJackson2XmlViewTests.java @@ -33,8 +33,8 @@ import com.fasterxml.jackson.databind.cfg.SerializerFactoryConfig; import com.fasterxml.jackson.databind.ser.BeanSerializerFactory; import com.fasterxml.jackson.databind.ser.SerializerFactory; import com.fasterxml.jackson.dataformat.xml.XmlMapper; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mozilla.javascript.Context; import org.mozilla.javascript.ContextFactory; import org.mozilla.javascript.ScriptableObject; @@ -65,7 +65,7 @@ public class MappingJackson2XmlViewTests { private ScriptableObject jsScope; - @Before + @BeforeEach public void setUp() { request = new MockHttpServletRequest(); response = new MockHttpServletResponse(); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/xml/MarshallingViewTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/xml/MarshallingViewTests.java index c2ac0e279f1..64b9112c823 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/xml/MarshallingViewTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/xml/MarshallingViewTests.java @@ -23,8 +23,8 @@ import javax.xml.bind.JAXBElement; import javax.xml.namespace.QName; import javax.xml.transform.stream.StreamResult; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockHttpServletRequest; import org.springframework.mock.web.test.MockHttpServletResponse; @@ -51,7 +51,7 @@ public class MarshallingViewTests { private MarshallingView view; - @Before + @BeforeEach public void createView() throws Exception { marshallerMock = mock(Marshaller.class); view = new MarshallingView(marshallerMock); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/xslt/XsltViewResolverTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/xslt/XsltViewResolverTests.java index 0271e101719..8cf03178869 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/xslt/XsltViewResolverTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/xslt/XsltViewResolverTests.java @@ -18,7 +18,7 @@ package org.springframework.web.servlet.view.xslt; import java.util.Locale; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.support.StaticApplicationContext; import org.springframework.util.ClassUtils; diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/xslt/XsltViewTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/xslt/XsltViewTests.java index 6c6809240a7..0b29ce2c3a9 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/view/xslt/XsltViewTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/view/xslt/XsltViewTests.java @@ -31,7 +31,7 @@ import javax.xml.transform.stream.StreamSource; import org.dom4j.Document; import org.dom4j.Element; import org.dom4j.io.SAXReader; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.xml.sax.SAXException; import org.springframework.context.support.StaticApplicationContext; diff --git a/spring-webmvc/src/test/java/org/springframework/web/util/NestedServletExceptionTests.java b/spring-webmvc/src/test/java/org/springframework/web/util/NestedServletExceptionTests.java index 5fa470d1292..d9360342cf5 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/util/NestedServletExceptionTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/util/NestedServletExceptionTests.java @@ -16,7 +16,7 @@ package org.springframework.web.util; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.NestedExceptionUtils; 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 a927b67a7c1..fe2cafefd84 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 @@ -18,7 +18,8 @@ package org.springframework.web.servlet.function import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue -import org.junit.Test +import org.junit.Assert.fail +import org.junit.jupiter.api.Test import org.springframework.core.io.ClassPathResource import org.springframework.http.HttpHeaders.* import org.springframework.http.HttpMethod.* @@ -109,9 +110,15 @@ class RouterFunctionDslTests { assertTrue(sampleRouter().route(request).get().handle(request) is RenderingResponse) } - @Test(expected = IllegalStateException::class) + @Test fun emptyRouter() { - router { } + try { + router { } + fail("should have thrown an IllegalStateException") + } + catch (e: IllegalStateException) { + // expected + } } 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 9548908aced..fca71de99fd 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 @@ -21,7 +21,7 @@ import io.mockk.mockk import io.mockk.verify import org.junit.Assert.assertEquals import org.junit.Assert.assertNull -import org.junit.Test +import org.junit.jupiter.api.Test import org.springframework.core.ParameterizedTypeReference import org.springframework.http.MediaType import java.net.InetSocketAddress 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 fe4bae04507..d352d98a0d8 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 @@ -20,7 +20,7 @@ import io.mockk.every import io.mockk.mockk import io.mockk.verify import org.junit.Assert -import org.junit.Test +import org.junit.jupiter.api.Test import org.springframework.core.ParameterizedTypeReference import java.util.* 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 ce8c81fd957..fc6b0957212 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 @@ -17,7 +17,7 @@ package org.springframework.web.servlet.mvc.method.annotation import org.junit.Assert.* -import org.junit.Test +import org.junit.jupiter.api.Test import org.springframework.mock.web.test.MockHttpServletRequest import org.springframework.mock.web.test.MockHttpServletResponse import org.springframework.web.bind.annotation.RequestMapping diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/AbstractHttpRequestTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/AbstractHttpRequestTests.java index 5ffff020ad3..75cf1affffd 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/AbstractHttpRequestTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/AbstractHttpRequestTests.java @@ -16,7 +16,7 @@ package org.springframework.web.socket; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.springframework.http.server.ServerHttpAsyncRequestControl; import org.springframework.http.server.ServerHttpRequest; @@ -44,7 +44,7 @@ public abstract class AbstractHttpRequestTests { protected ServerHttpAsyncRequestControl asyncControl; - @Before + @BeforeEach public void setup() { resetRequestAndResponse(); } diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/AbstractWebSocketIntegrationTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/AbstractWebSocketIntegrationTests.java index 41c6fea7064..f5c9f08a810 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/AbstractWebSocketIntegrationTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/AbstractWebSocketIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * 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. @@ -16,16 +16,19 @@ package org.springframework.web.socket; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; import java.util.HashMap; import java.util.Map; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.rules.TestName; -import org.junit.runners.Parameterized.Parameter; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.TestInfo; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.springframework.context.Lifecycle; import org.springframework.context.annotation.Bean; @@ -56,23 +59,28 @@ public abstract class AbstractWebSocketIntegrationTests { } - @Rule - public final TestName testName = new TestName(); - - @Parameter(0) - public WebSocketTestServer server; + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.METHOD) + @ParameterizedTest(name = "server [{0}], client [{1}]") + @MethodSource("arguments") + protected @interface ParameterizedWebSocketTest { + } - @Parameter(1) - public WebSocketClient webSocketClient; protected final Log logger = LogFactory.getLog(getClass()); + protected WebSocketTestServer server; + + protected WebSocketClient webSocketClient; + protected AnnotationConfigWebApplicationContext wac; - @Before - public void setup() throws Exception { - logger.debug("Setting up '" + this.testName.getMethodName() + "', client=" + + protected void setup(WebSocketTestServer server, WebSocketClient webSocketClient, TestInfo testInfo) throws Exception { + this.server = server; + this.webSocketClient = webSocketClient; + + logger.debug("Setting up '" + testInfo.getTestMethod().get().getName() + "', client=" + this.webSocketClient.getClass().getSimpleName() + ", server=" + this.server.getClass().getSimpleName()); @@ -94,8 +102,8 @@ public abstract class AbstractWebSocketIntegrationTests { protected abstract Class[] getAnnotatedConfigClasses(); - @After - public void teardown() throws Exception { + @AfterEach + void teardown() throws Exception { try { if (this.webSocketClient instanceof Lifecycle) { ((Lifecycle) this.webSocketClient).stop(); @@ -147,6 +155,7 @@ public abstract class AbstractWebSocketIntegrationTests { @Configuration static class JettyUpgradeStrategyConfig extends AbstractRequestUpgradeStrategyConfig { + @Override @Bean public RequestUpgradeStrategy requestUpgradeStrategy() { return new JettyRequestUpgradeStrategy(); @@ -157,6 +166,7 @@ public abstract class AbstractWebSocketIntegrationTests { @Configuration static class TomcatUpgradeStrategyConfig extends AbstractRequestUpgradeStrategyConfig { + @Override @Bean public RequestUpgradeStrategy requestUpgradeStrategy() { return new TomcatRequestUpgradeStrategy(); @@ -167,6 +177,7 @@ public abstract class AbstractWebSocketIntegrationTests { @Configuration static class UndertowUpgradeStrategyConfig extends AbstractRequestUpgradeStrategyConfig { + @Override @Bean public RequestUpgradeStrategy requestUpgradeStrategy() { return new UndertowRequestUpgradeStrategy(); diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/TextMessageTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/TextMessageTests.java index 97bd2652b6f..c2009464d26 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/TextMessageTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/TextMessageTests.java @@ -16,7 +16,7 @@ package org.springframework.web.socket; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/WebSocketExtensionTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/WebSocketExtensionTests.java index ca5d435b1f2..3f0c1f63f25 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/WebSocketExtensionTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/WebSocketExtensionTests.java @@ -18,7 +18,7 @@ package org.springframework.web.socket; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/WebSocketHandshakeTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/WebSocketHandshakeTests.java index 7fa3ca88feb..d94d27e546a 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/WebSocketHandshakeTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/WebSocketHandshakeTests.java @@ -23,14 +23,12 @@ import java.util.List; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.api.TestInfo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.web.socket.client.WebSocketClient; import org.springframework.web.socket.client.jetty.JettyWebSocketClient; import org.springframework.web.socket.client.standard.StandardWebSocketClient; import org.springframework.web.socket.config.annotation.EnableWebSocket; @@ -47,12 +45,11 @@ import static org.assertj.core.api.Assertions.assertThat; * * @author Rossen Stoyanchev * @author Juergen Hoeller + * @author Sam Brannen */ -@RunWith(Parameterized.class) -public class WebSocketHandshakeTests extends AbstractWebSocketIntegrationTests { +class WebSocketHandshakeTests extends AbstractWebSocketIntegrationTests { - @Parameters(name = "server [{0}], client [{1}]") - public static Iterable arguments() { + static Iterable arguments() { return Arrays.asList(new Object[][] { {new JettyWebSocketTestServer(), new JettyWebSocketClient()}, {new TomcatWebSocketTestServer(), new StandardWebSocketClient()}, @@ -66,8 +63,11 @@ public class WebSocketHandshakeTests extends AbstractWebSocketIntegrationTests { return new Class[] {TestConfig.class}; } - @Test - public void subProtocolNegotiation() throws Exception { + + @ParameterizedWebSocketTest + void subProtocolNegotiation(WebSocketTestServer server, WebSocketClient webSocketClient, TestInfo testInfo) throws Exception { + super.setup(server, webSocketClient, testInfo); + WebSocketHttpHeaders headers = new WebSocketHttpHeaders(); headers.setSecWebSocketProtocol("foo"); URI url = new URI(getWsBaseUrl() + "/ws"); @@ -76,8 +76,10 @@ public class WebSocketHandshakeTests extends AbstractWebSocketIntegrationTests { session.close(); } - @Test // SPR-12727 - public void unsolicitedPongWithEmptyPayload() throws Exception { + @ParameterizedWebSocketTest // SPR-12727 + void unsolicitedPongWithEmptyPayload(WebSocketTestServer server, WebSocketClient webSocketClient, TestInfo testInfo) throws Exception { + super.setup(server, webSocketClient, testInfo); + String url = getWsBaseUrl() + "/ws"; WebSocketSession session = this.webSocketClient.doHandshake(new AbstractWebSocketHandler() {}, url).get(); diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/adapter/jetty/JettyWebSocketHandlerAdapterTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/adapter/jetty/JettyWebSocketHandlerAdapterTests.java index 8f8d2737da5..84baa9552dd 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/adapter/jetty/JettyWebSocketHandlerAdapterTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/adapter/jetty/JettyWebSocketHandlerAdapterTests.java @@ -19,8 +19,8 @@ package org.springframework.web.socket.adapter.jetty; import org.eclipse.jetty.websocket.api.Session; import org.eclipse.jetty.websocket.api.UpgradeRequest; import org.eclipse.jetty.websocket.api.UpgradeResponse; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.springframework.web.socket.CloseStatus; @@ -46,7 +46,7 @@ public class JettyWebSocketHandlerAdapterTests { private Session session; - @Before + @BeforeEach public void setup() { this.session = mock(Session.class); given(this.session.getUpgradeRequest()).willReturn(Mockito.mock(UpgradeRequest.class)); diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/adapter/jetty/JettyWebSocketSessionTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/adapter/jetty/JettyWebSocketSessionTests.java index c67a0e8d68e..ab4c6e927a4 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/adapter/jetty/JettyWebSocketSessionTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/adapter/jetty/JettyWebSocketSessionTests.java @@ -22,7 +22,7 @@ import java.util.Map; import org.eclipse.jetty.websocket.api.Session; import org.eclipse.jetty.websocket.api.UpgradeRequest; import org.eclipse.jetty.websocket.api.UpgradeResponse; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.springframework.web.socket.handler.TestPrincipal; diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/adapter/standard/ConvertingEncoderDecoderSupportTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/adapter/standard/ConvertingEncoderDecoderSupportTests.java index c44ed07b83c..d71e11e31dc 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/adapter/standard/ConvertingEncoderDecoderSupportTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/adapter/standard/ConvertingEncoderDecoderSupportTests.java @@ -22,9 +22,9 @@ import javax.websocket.Decoder; import javax.websocket.EncodeException; import javax.websocket.Encoder; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; @@ -62,12 +62,12 @@ public class ConvertingEncoderDecoderSupportTests { private MyType myType = new MyType("test"); - @Before + @BeforeEach public void setup() { setup(Config.class); } - @After + @AfterEach public void teardown() { ContextLoaderTestUtils.setCurrentWebApplicationContext(null); } diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/adapter/standard/StandardWebSocketHandlerAdapterTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/adapter/standard/StandardWebSocketHandlerAdapterTests.java index e4a384239ba..872424d3a5e 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/adapter/standard/StandardWebSocketHandlerAdapterTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/adapter/standard/StandardWebSocketHandlerAdapterTests.java @@ -22,8 +22,8 @@ import javax.websocket.CloseReason.CloseCodes; import javax.websocket.MessageHandler; import javax.websocket.Session; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.web.socket.CloseStatus; import org.springframework.web.socket.WebSocketHandler; @@ -51,7 +51,7 @@ public class StandardWebSocketHandlerAdapterTests { private Session session; - @Before + @BeforeEach public void setup() { this.session = mock(Session.class); this.webSocketHandler = mock(WebSocketHandler.class); diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/adapter/standard/StandardWebSocketSessionTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/adapter/standard/StandardWebSocketSessionTests.java index 1e0b6a04a22..c6fcabfd34b 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/adapter/standard/StandardWebSocketSessionTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/adapter/standard/StandardWebSocketSessionTests.java @@ -20,7 +20,7 @@ import java.util.HashMap; import java.util.Map; import javax.websocket.Session; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.springframework.http.HttpHeaders; diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/client/WebSocketConnectionManagerTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/client/WebSocketConnectionManagerTests.java index c99957d2c9b..7d172ec4ce0 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/client/WebSocketConnectionManagerTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/client/WebSocketConnectionManagerTests.java @@ -20,7 +20,7 @@ import java.net.URI; import java.util.Arrays; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.Lifecycle; import org.springframework.http.HttpHeaders; diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/client/jetty/JettyWebSocketClientTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/client/jetty/JettyWebSocketClientTests.java index 5ab480ac814..212b92ae891 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/client/jetty/JettyWebSocketClientTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/client/jetty/JettyWebSocketClientTests.java @@ -25,9 +25,9 @@ import org.eclipse.jetty.websocket.servlet.ServletUpgradeRequest; import org.eclipse.jetty.websocket.servlet.ServletUpgradeResponse; import org.eclipse.jetty.websocket.servlet.WebSocketCreator; import org.eclipse.jetty.websocket.servlet.WebSocketServletFactory; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.core.task.SimpleAsyncTaskExecutor; import org.springframework.util.CollectionUtils; @@ -55,7 +55,7 @@ public class JettyWebSocketClientTests { private WebSocketSession wsSession; - @Before + @BeforeEach public void setup() throws Exception { this.server = new TestJettyWebSocketServer(new TextWebSocketHandler()); @@ -67,7 +67,7 @@ public class JettyWebSocketClientTests { this.wsUrl = "ws://localhost:" + this.server.getPort() + "/test"; } - @After + @AfterEach public void teardown() throws Exception { this.wsSession.close(); this.client.stop(); diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/client/standard/StandardWebSocketClientTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/client/standard/StandardWebSocketClientTests.java index 968b1f28515..db06fa38553 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/client/standard/StandardWebSocketClientTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/client/standard/StandardWebSocketClientTests.java @@ -25,8 +25,8 @@ import javax.websocket.ClientEndpointConfig; import javax.websocket.Endpoint; import javax.websocket.WebSocketContainer; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; import org.springframework.core.task.SimpleAsyncTaskExecutor; @@ -57,7 +57,7 @@ public class StandardWebSocketClientTests { private WebSocketHttpHeaders headers; - @Before + @BeforeEach public void setup() { this.headers = new WebSocketHttpHeaders(); this.wsHandler = new AbstractWebSocketHandler() { diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/config/HandlersBeanDefinitionParserTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/config/HandlersBeanDefinitionParserTests.java index a15c1032ab4..27024631adc 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/config/HandlersBeanDefinitionParserTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/config/HandlersBeanDefinitionParserTests.java @@ -23,7 +23,7 @@ import java.util.List; import java.util.Map; import java.util.concurrent.ScheduledFuture; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import org.springframework.core.io.ClassPathResource; diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParserTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParserTests.java index 2959f5ff47b..43e1ad59bdf 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParserTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/config/MessageBrokerBeanDefinitionParserTests.java @@ -24,7 +24,7 @@ import java.util.List; import java.util.Map; import java.util.concurrent.ScheduledThreadPoolExecutor; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.DirectFieldAccessor; import org.springframework.beans.factory.NoSuchBeanDefinitionException; diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/config/annotation/WebMvcStompEndpointRegistryTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/config/annotation/WebMvcStompEndpointRegistryTests.java index 310c19cd07b..30cb2609eed 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/config/annotation/WebMvcStompEndpointRegistryTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/config/annotation/WebMvcStompEndpointRegistryTests.java @@ -18,8 +18,8 @@ package org.springframework.web.socket.config.annotation; import java.util.Map; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.messaging.SubscribableChannel; import org.springframework.scheduling.TaskScheduler; @@ -46,7 +46,7 @@ public class WebMvcStompEndpointRegistryTests { private SubProtocolWebSocketHandler webSocketHandler; - @Before + @BeforeEach public void setup() { SubscribableChannel inChannel = mock(SubscribableChannel.class); SubscribableChannel outChannel = mock(SubscribableChannel.class); diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/config/annotation/WebMvcStompWebSocketEndpointRegistrationTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/config/annotation/WebMvcStompWebSocketEndpointRegistrationTests.java index 924ec2eec01..9a5fe7945f0 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/config/annotation/WebMvcStompWebSocketEndpointRegistrationTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/config/annotation/WebMvcStompWebSocketEndpointRegistrationTests.java @@ -20,8 +20,8 @@ import java.util.Arrays; import java.util.List; import java.util.Map; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.messaging.MessageChannel; import org.springframework.messaging.SubscribableChannel; @@ -55,7 +55,7 @@ public class WebMvcStompWebSocketEndpointRegistrationTests { private TaskScheduler scheduler; - @Before + @BeforeEach public void setup() { this.handler = new SubProtocolWebSocketHandler(mock(MessageChannel.class), mock(SubscribableChannel.class)); this.scheduler = mock(TaskScheduler.class); diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/config/annotation/WebSocketConfigurationTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/config/annotation/WebSocketConfigurationTests.java index d03e396830c..92800c007c4 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/config/annotation/WebSocketConfigurationTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/config/annotation/WebSocketConfigurationTests.java @@ -20,10 +20,7 @@ import java.util.Arrays; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.api.TestInfo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; @@ -33,6 +30,8 @@ import org.springframework.web.socket.JettyWebSocketTestServer; import org.springframework.web.socket.TomcatWebSocketTestServer; import org.springframework.web.socket.UndertowTestServer; import org.springframework.web.socket.WebSocketSession; +import org.springframework.web.socket.WebSocketTestServer; +import org.springframework.web.socket.client.WebSocketClient; import org.springframework.web.socket.client.jetty.JettyWebSocketClient; import org.springframework.web.socket.client.standard.StandardWebSocketClient; import org.springframework.web.socket.handler.AbstractWebSocketHandler; @@ -45,12 +44,11 @@ import static org.assertj.core.api.Assertions.assertThat; * Integration tests for WebSocket Java server-side configuration. * * @author Rossen Stoyanchev + * @author Sam Brannen */ -@RunWith(Parameterized.class) -public class WebSocketConfigurationTests extends AbstractWebSocketIntegrationTests { +class WebSocketConfigurationTests extends AbstractWebSocketIntegrationTests { - @Parameters(name = "server [{0}], client [{1}]") - public static Iterable arguments() { + static Iterable arguments() { return Arrays.asList(new Object[][] { {new JettyWebSocketTestServer(), new JettyWebSocketClient()}, {new TomcatWebSocketTestServer(), new StandardWebSocketClient()}, @@ -64,8 +62,11 @@ public class WebSocketConfigurationTests extends AbstractWebSocketIntegrationTes return new Class[] {TestConfig.class}; } - @Test - public void registerWebSocketHandler() throws Exception { + + @ParameterizedWebSocketTest + void registerWebSocketHandler(WebSocketTestServer server, WebSocketClient webSocketClient, TestInfo testInfo) throws Exception { + super.setup(server, webSocketClient, testInfo); + WebSocketSession session = this.webSocketClient.doHandshake( new AbstractWebSocketHandler() {}, getWsBaseUrl() + "/ws").get(); @@ -75,8 +76,10 @@ public class WebSocketConfigurationTests extends AbstractWebSocketIntegrationTes session.close(); } - @Test - public void registerWebSocketHandlerWithSockJS() throws Exception { + @ParameterizedWebSocketTest + void registerWebSocketHandlerWithSockJS(WebSocketTestServer server, WebSocketClient webSocketClient, TestInfo testInfo) throws Exception { + super.setup(server, webSocketClient, testInfo); + WebSocketSession session = this.webSocketClient.doHandshake( new AbstractWebSocketHandler() {}, getWsBaseUrl() + "/sockjs/websocket").get(); diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/config/annotation/WebSocketHandlerRegistrationTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/config/annotation/WebSocketHandlerRegistrationTests.java index b44b64fbf0e..398c7afe134 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/config/annotation/WebSocketHandlerRegistrationTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/config/annotation/WebSocketHandlerRegistrationTests.java @@ -19,7 +19,7 @@ package org.springframework.web.socket.config.annotation; import java.util.ArrayList; import java.util.List; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.scheduling.TaskScheduler; import org.springframework.web.socket.WebSocketHandler; diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/config/annotation/WebSocketMessageBrokerConfigurationSupportTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/config/annotation/WebSocketMessageBrokerConfigurationSupportTests.java index b5f1b4aa605..19e81bc360e 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/config/annotation/WebSocketMessageBrokerConfigurationSupportTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/config/annotation/WebSocketMessageBrokerConfigurationSupportTests.java @@ -22,7 +22,7 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.ScheduledThreadPoolExecutor; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/handler/BeanCreatingHandlerProviderTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/handler/BeanCreatingHandlerProviderTests.java index e21dcf117f1..e33077c63c8 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/handler/BeanCreatingHandlerProviderTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/handler/BeanCreatingHandlerProviderTests.java @@ -16,7 +16,7 @@ package org.springframework.web.socket.handler; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.BeanInstantiationException; import org.springframework.beans.factory.annotation.Autowired; diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/handler/ConcurrentWebSocketSessionDecoratorTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/handler/ConcurrentWebSocketSessionDecoratorTests.java index f3f76afb1ba..0f06aba3a47 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/handler/ConcurrentWebSocketSessionDecoratorTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/handler/ConcurrentWebSocketSessionDecoratorTests.java @@ -22,7 +22,7 @@ import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.web.socket.CloseStatus; import org.springframework.web.socket.TextMessage; diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/handler/ExceptionWebSocketHandlerDecoratorTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/handler/ExceptionWebSocketHandlerDecoratorTests.java index b61978331bb..0001722a136 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/handler/ExceptionWebSocketHandlerDecoratorTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/handler/ExceptionWebSocketHandlerDecoratorTests.java @@ -16,8 +16,8 @@ package org.springframework.web.socket.handler; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.web.socket.CloseStatus; import org.springframework.web.socket.TextMessage; @@ -41,7 +41,7 @@ public class ExceptionWebSocketHandlerDecoratorTests { private WebSocketHandler delegate; - @Before + @BeforeEach public void setup() { this.delegate = mock(WebSocketHandler.class); diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/handler/PerConnectionWebSocketHandlerTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/handler/PerConnectionWebSocketHandlerTests.java index 088a1632f95..72c4357fa1b 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/handler/PerConnectionWebSocketHandlerTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/handler/PerConnectionWebSocketHandlerTests.java @@ -16,7 +16,7 @@ package org.springframework.web.socket.handler; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.DisposableBean; import org.springframework.context.annotation.AnnotationConfigApplicationContext; diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/handler/WebSocketHandlerDecoratorTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/handler/WebSocketHandlerDecoratorTests.java index 5e1b1157ffa..5f19bc11d5f 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/handler/WebSocketHandlerDecoratorTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/handler/WebSocketHandlerDecoratorTests.java @@ -16,7 +16,7 @@ package org.springframework.web.socket.handler; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/handler/WebSocketHttpHeadersTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/handler/WebSocketHttpHeadersTests.java index 98d0067cf71..4b85eff219d 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/handler/WebSocketHttpHeadersTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/handler/WebSocketHttpHeadersTests.java @@ -19,8 +19,8 @@ package org.springframework.web.socket.handler; import java.util.ArrayList; import java.util.List; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.web.socket.WebSocketExtension; import org.springframework.web.socket.WebSocketHttpHeaders; @@ -37,7 +37,7 @@ public class WebSocketHttpHeadersTests { private WebSocketHttpHeaders headers; - @Before + @BeforeEach public void setUp() { headers = new WebSocketHttpHeaders(); } diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/messaging/DefaultSimpUserRegistryTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/messaging/DefaultSimpUserRegistryTests.java index 93781faad48..30f31fd2ae0 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/messaging/DefaultSimpUserRegistryTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/messaging/DefaultSimpUserRegistryTests.java @@ -22,7 +22,7 @@ import java.util.HashSet; import java.util.Iterator; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.messaging.Message; import org.springframework.messaging.simp.SimpMessageHeaderAccessor; diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/messaging/StompSubProtocolErrorHandlerTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/messaging/StompSubProtocolErrorHandlerTests.java index f9015df5774..b204b03b5d8 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/messaging/StompSubProtocolErrorHandlerTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/messaging/StompSubProtocolErrorHandlerTests.java @@ -15,8 +15,8 @@ */ package org.springframework.web.socket.messaging; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.messaging.Message; import org.springframework.messaging.MessageHeaders; @@ -36,7 +36,7 @@ public class StompSubProtocolErrorHandlerTests { private StompSubProtocolErrorHandler handler; - @Before + @BeforeEach public void setUp() throws Exception { this.handler = new StompSubProtocolErrorHandler(); } diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/messaging/StompSubProtocolHandlerTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/messaging/StompSubProtocolHandlerTests.java index e87fb194d18..964cc8b8511 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/messaging/StompSubProtocolHandlerTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/messaging/StompSubProtocolHandlerTests.java @@ -25,8 +25,8 @@ import java.util.HashSet; import java.util.List; import java.util.concurrent.atomic.AtomicReference; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; import org.mockito.Mockito; @@ -87,7 +87,7 @@ public class StompSubProtocolHandlerTests { private ArgumentCaptor messageCaptor; - @Before + @BeforeEach public void setup() { this.protocolHandler = new StompSubProtocolHandler(); this.channel = Mockito.mock(MessageChannel.class); diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/messaging/StompWebSocketIntegrationTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/messaging/StompWebSocketIntegrationTests.java index 87bc32e6d3f..1d02244db27 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/messaging/StompWebSocketIntegrationTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/messaging/StompWebSocketIntegrationTests.java @@ -23,10 +23,7 @@ import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.api.TestInfo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; @@ -49,6 +46,8 @@ import org.springframework.web.socket.TextMessage; import org.springframework.web.socket.TomcatWebSocketTestServer; import org.springframework.web.socket.UndertowTestServer; import org.springframework.web.socket.WebSocketSession; +import org.springframework.web.socket.WebSocketTestServer; +import org.springframework.web.socket.client.WebSocketClient; import org.springframework.web.socket.client.jetty.JettyWebSocketClient; import org.springframework.web.socket.client.standard.StandardWebSocketClient; import org.springframework.web.socket.config.annotation.DelegatingWebSocketMessageBrokerConfiguration; @@ -64,15 +63,13 @@ import static org.springframework.web.socket.messaging.StompTextMessageBuilder.c * Integration tests with annotated message-handling methods. * * @author Rossen Stoyanchev + * @author Sam Brannen */ -@RunWith(Parameterized.class) -public class StompWebSocketIntegrationTests extends AbstractWebSocketIntegrationTests { +class StompWebSocketIntegrationTests extends AbstractWebSocketIntegrationTests { private static final long TIMEOUT = 10; - - @Parameters(name = "server [{0}], client [{1}]") - public static Object[][] arguments() { + static Object[][] arguments() { return new Object[][] { {new JettyWebSocketTestServer(), new JettyWebSocketClient()}, {new TomcatWebSocketTestServer(), new StandardWebSocketClient()}, @@ -87,8 +84,10 @@ public class StompWebSocketIntegrationTests extends AbstractWebSocketIntegration } - @Test - public void sendMessageToController() throws Exception { + @ParameterizedWebSocketTest + void sendMessageToController(WebSocketTestServer server, WebSocketClient webSocketClient, TestInfo testInfo) throws Exception { + super.setup(server, webSocketClient, testInfo); + TextMessage message = create(StompCommand.SEND).headers("destination:/app/simple").build(); WebSocketSession session = doHandshake(new TestClientWebSocketHandler(0, message), "/ws").get(); @@ -101,8 +100,10 @@ public class StompWebSocketIntegrationTests extends AbstractWebSocketIntegration } } - @Test - public void sendMessageToControllerAndReceiveReplyViaTopic() throws Exception { + @ParameterizedWebSocketTest + void sendMessageToControllerAndReceiveReplyViaTopic(WebSocketTestServer server, WebSocketClient webSocketClient, TestInfo testInfo) throws Exception { + super.setup(server, webSocketClient, testInfo); + TextMessage m0 = create(StompCommand.CONNECT).headers("accept-version:1.1").build(); TextMessage m1 = create(StompCommand.SUBSCRIBE) .headers("id:subs1", "destination:/topic/increment").build(); @@ -120,8 +121,10 @@ public class StompWebSocketIntegrationTests extends AbstractWebSocketIntegration } } - @Test // SPR-10930 - public void sendMessageToBrokerAndReceiveReplyViaTopic() throws Exception { + @ParameterizedWebSocketTest // SPR-10930 + void sendMessageToBrokerAndReceiveReplyViaTopic(WebSocketTestServer server, WebSocketClient webSocketClient, TestInfo testInfo) throws Exception { + super.setup(server, webSocketClient, testInfo); + TextMessage m0 = create(StompCommand.CONNECT).headers("accept-version:1.1").build(); TextMessage m1 = create(StompCommand.SUBSCRIBE).headers("id:subs1", "destination:/topic/foo").build(); TextMessage m2 = create(StompCommand.SEND).headers("destination:/topic/foo").body("5").build(); @@ -140,8 +143,10 @@ public class StompWebSocketIntegrationTests extends AbstractWebSocketIntegration } } - @Test // SPR-11648 - public void sendSubscribeToControllerAndReceiveReply() throws Exception { + @ParameterizedWebSocketTest // SPR-11648 + void sendSubscribeToControllerAndReceiveReply(WebSocketTestServer server, WebSocketClient webSocketClient, TestInfo testInfo) throws Exception { + super.setup(server, webSocketClient, testInfo); + TextMessage m0 = create(StompCommand.CONNECT).headers("accept-version:1.1").build(); String destHeader = "destination:/app/number"; TextMessage m1 = create(StompCommand.SUBSCRIBE).headers("id:subs1", destHeader).build(); @@ -160,8 +165,10 @@ public class StompWebSocketIntegrationTests extends AbstractWebSocketIntegration } } - @Test - public void handleExceptionAndSendToUser() throws Exception { + @ParameterizedWebSocketTest + void handleExceptionAndSendToUser(WebSocketTestServer server, WebSocketClient webSocketClient, TestInfo testInfo) throws Exception { + super.setup(server, webSocketClient, testInfo); + String destHeader = "destination:/user/queue/error"; TextMessage m0 = create(StompCommand.CONNECT).headers("accept-version:1.1").build(); TextMessage m1 = create(StompCommand.SUBSCRIBE).headers("id:subs1", destHeader).build(); @@ -182,8 +189,10 @@ public class StompWebSocketIntegrationTests extends AbstractWebSocketIntegration } } - @Test - public void webSocketScope() throws Exception { + @ParameterizedWebSocketTest + void webSocketScope(WebSocketTestServer server, WebSocketClient webSocketClient, TestInfo testInfo) throws Exception { + super.setup(server, webSocketClient, testInfo); + TextMessage m0 = create(StompCommand.CONNECT).headers("accept-version:1.1").build(); TextMessage m1 = create(StompCommand.SUBSCRIBE) .headers("id:subs1", "destination:/topic/scopedBeanValue").build(); diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/messaging/SubProtocolWebSocketHandlerTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/messaging/SubProtocolWebSocketHandlerTests.java index 7ef4a98b742..7144c485e5f 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/messaging/SubProtocolWebSocketHandlerTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/messaging/SubProtocolWebSocketHandlerTests.java @@ -19,11 +19,11 @@ package org.springframework.web.socket.messaging; import java.util.Arrays; import java.util.Map; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; import org.springframework.beans.DirectFieldAccessor; import org.springframework.messaging.MessageChannel; @@ -47,7 +47,7 @@ import static org.mockito.Mockito.verify; * @author Rossen Stoyanchev * @author Andy Wilkinson */ -@RunWith(MockitoJUnitRunner.class) +@MockitoSettings(strictness = Strictness.LENIENT) public class SubProtocolWebSocketHandlerTests { @Mock SubProtocolHandler stompHandler; @@ -66,7 +66,7 @@ public class SubProtocolWebSocketHandlerTests { private TestWebSocketSession session; - @Before + @BeforeEach public void setup() { this.webSocketHandler = new SubProtocolWebSocketHandler(this.inClientChannel, this.outClientChannel); given(stompHandler.getSupportedProtocols()).willReturn(Arrays.asList("v10.stomp", "v11.stomp", "v12.stomp")); diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/messaging/WebSocketAnnotationMethodMessageHandlerTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/messaging/WebSocketAnnotationMethodMessageHandlerTests.java index 49deddd7d86..84eaf351469 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/messaging/WebSocketAnnotationMethodMessageHandlerTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/messaging/WebSocketAnnotationMethodMessageHandlerTests.java @@ -18,8 +18,8 @@ package org.springframework.web.socket.messaging; import java.util.concurrent.ConcurrentHashMap; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.springframework.context.support.StaticApplicationContext; @@ -48,7 +48,7 @@ public class WebSocketAnnotationMethodMessageHandlerTests { private StaticApplicationContext applicationContext; - @Before + @BeforeEach public void setUp() throws Exception { this.applicationContext = new StaticApplicationContext(); this.applicationContext.registerSingleton("controller", TestController.class); diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/messaging/WebSocketStompClientIntegrationTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/messaging/WebSocketStompClientIntegrationTests.java index 0b895e3fd2f..28d72b22a46 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/messaging/WebSocketStompClientIntegrationTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/messaging/WebSocketStompClientIntegrationTests.java @@ -22,11 +22,10 @@ import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TestName; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; import org.springframework.context.annotation.Configuration; import org.springframework.lang.Nullable; @@ -52,14 +51,14 @@ import static org.assertj.core.api.Assertions.assertThat; /** * Integration tests for {@link WebSocketStompClient}. + * * @author Rossen Stoyanchev + * @author Sam Brannen */ -public class WebSocketStompClientIntegrationTests { +class WebSocketStompClientIntegrationTests { private static final Log logger = LogFactory.getLog(WebSocketStompClientIntegrationTests.class); - @Rule - public final TestName testName = new TestName(); private WebSocketStompClient stompClient; @@ -68,10 +67,9 @@ public class WebSocketStompClientIntegrationTests { private AnnotationConfigWebApplicationContext wac; - @Before - public void setUp() throws Exception { - - logger.debug("Setting up before '" + this.testName.getMethodName() + "'"); + @BeforeEach + void setUp(TestInfo testInfo) throws Exception { + logger.debug("Setting up before '" + testInfo.getTestMethod().get().getName() + "'"); this.wac = new AnnotationConfigWebApplicationContext(); this.wac.register(TestConfig.class); @@ -87,8 +85,8 @@ public class WebSocketStompClientIntegrationTests { this.stompClient.setMessageConverter(new StringMessageConverter()); } - @After - public void tearDown() throws Exception { + @AfterEach + void tearDown() throws Exception { try { this.server.undeployConfig(); } @@ -111,7 +109,7 @@ public class WebSocketStompClientIntegrationTests { @Test - public void publishSubscribe() throws Exception { + void publishSubscribe() throws Exception { String url = "ws://127.0.0.1:" + this.server.getPort() + "/stomp"; diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/messaging/WebSocketStompClientTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/messaging/WebSocketStompClientTests.java index 0d3e70ed1cc..f65ef7ed0c0 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/messaging/WebSocketStompClientTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/messaging/WebSocketStompClientTests.java @@ -20,12 +20,12 @@ import java.net.URI; import java.nio.charset.StandardCharsets; import java.util.concurrent.ScheduledFuture; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; import org.springframework.messaging.Message; import org.springframework.messaging.simp.stomp.ConnectionHandlingStompSession; @@ -64,7 +64,7 @@ import static org.mockito.Mockito.verifyNoMoreInteractions; * * @author Rossen Stoyanchev */ -@RunWith(MockitoJUnitRunner.class) +@MockitoSettings(strictness = Strictness.LENIENT) public class WebSocketStompClientTests { @Mock @@ -83,7 +83,7 @@ public class WebSocketStompClientTests { private SettableListenableFuture handshakeFuture; - @Before + @BeforeEach public void setUp() throws Exception { WebSocketClient webSocketClient = mock(WebSocketClient.class); this.stompClient = new TestWebSocketStompClient(webSocketClient); diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/server/DefaultHandshakeHandlerTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/server/DefaultHandshakeHandlerTests.java index c0c44765eaa..c8a4868bdc6 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/server/DefaultHandshakeHandlerTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/server/DefaultHandshakeHandlerTests.java @@ -21,7 +21,7 @@ import java.util.Collections; import java.util.List; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpHeaders; import org.springframework.web.socket.AbstractHttpRequestTests; diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/server/standard/ServerEndpointExporterTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/server/standard/ServerEndpointExporterTests.java index 5e7037fa726..c5e6ab97910 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/server/standard/ServerEndpointExporterTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/server/standard/ServerEndpointExporterTests.java @@ -23,8 +23,8 @@ import javax.websocket.Session; import javax.websocket.server.ServerContainer; import javax.websocket.server.ServerEndpoint; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -51,7 +51,7 @@ public class ServerEndpointExporterTests { private ServerEndpointExporter exporter; - @Before + @BeforeEach public void setup() { this.serverContainer = mock(ServerContainer.class); diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/server/standard/ServerEndpointRegistrationTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/server/standard/ServerEndpointRegistrationTests.java index ec13e13f60c..04f3740e5fc 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/server/standard/ServerEndpointRegistrationTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/server/standard/ServerEndpointRegistrationTests.java @@ -20,7 +20,7 @@ import javax.websocket.Endpoint; import javax.websocket.EndpointConfig; import javax.websocket.Session; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ConfigurableApplicationContext; diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/server/standard/SpringConfiguratorTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/server/standard/SpringConfiguratorTests.java index 6410da0f0d0..609535aae97 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/server/standard/SpringConfiguratorTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/server/standard/SpringConfiguratorTests.java @@ -18,9 +18,9 @@ package org.springframework.web.socket.server.standard; import javax.websocket.server.ServerEndpoint; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; @@ -44,7 +44,7 @@ public class SpringConfiguratorTests { private SpringConfigurator configurator; - @Before + @BeforeEach public void setup() { this.servletContext = new MockServletContext(); @@ -57,7 +57,7 @@ public class SpringConfiguratorTests { this.configurator = new SpringConfigurator(); } - @After + @AfterEach public void destroy() { this.contextLoader.closeWebApplicationContext(this.servletContext); } diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/server/support/HandshakeInterceptorChainTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/server/support/HandshakeInterceptorChainTests.java index cc973395e83..ab6f479622c 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/server/support/HandshakeInterceptorChainTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/server/support/HandshakeInterceptorChainTests.java @@ -21,8 +21,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.web.socket.AbstractHttpRequestTests; import org.springframework.web.socket.WebSocketHandler; @@ -53,7 +53,7 @@ public class HandshakeInterceptorChainTests extends AbstractHttpRequestTests { private Map attributes; - @Before + @BeforeEach public void setup() { super.setup(); diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/server/support/HttpSessionHandshakeInterceptorTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/server/support/HttpSessionHandshakeInterceptorTests.java index b77652a58a4..947d7ae964a 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/server/support/HttpSessionHandshakeInterceptorTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/server/support/HttpSessionHandshakeInterceptorTests.java @@ -21,7 +21,7 @@ import java.util.HashMap; import java.util.Map; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.mock.web.test.MockHttpSession; import org.springframework.web.socket.AbstractHttpRequestTests; diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/server/support/OriginHandshakeInterceptorTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/server/support/OriginHandshakeInterceptorTests.java index e53e666a313..e724ce85948 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/server/support/OriginHandshakeInterceptorTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/server/support/OriginHandshakeInterceptorTests.java @@ -24,7 +24,7 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentSkipListSet; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/server/support/WebSocketHttpRequestHandlerTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/server/support/WebSocketHttpRequestHandlerTests.java index e5d86ff7b60..54ec4216384 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/server/support/WebSocketHttpRequestHandlerTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/server/support/WebSocketHttpRequestHandlerTests.java @@ -21,7 +21,7 @@ import java.util.Collections; import java.util.Map; import javax.servlet.ServletException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.http.server.ServerHttpRequest; import org.springframework.http.server.ServerHttpResponse; diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/AbstractSockJsIntegrationTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/AbstractSockJsIntegrationTests.java index c412f6ce2a9..cf6674d640d 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/AbstractSockJsIntegrationTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/AbstractSockJsIntegrationTests.java @@ -39,12 +39,12 @@ import javax.servlet.http.HttpServletResponse; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TestName; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInfo; +import org.junit.jupiter.api.Timeout; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; @@ -81,9 +81,6 @@ import static org.assertj.core.api.Assertions.fail; */ public abstract class AbstractSockJsIntegrationTests { - @Rule - public final TestName testName = new TestName(); - protected Log logger = LogFactory.getLog(getClass()); @@ -98,15 +95,16 @@ public abstract class AbstractSockJsIntegrationTests { private String baseUrl; - @BeforeClass + @BeforeAll public static void performanceTestGroupAssumption() throws Exception { Assume.group(TestGroup.PERFORMANCE); } - @Before - public void setup() throws Exception { - logger.debug("Setting up '" + this.testName.getMethodName() + "'"); + @BeforeEach + public void setup(TestInfo testInfo) throws Exception { + logger.debug("Setting up '" + testInfo.getTestMethod().get().getName() + "'"); + this.testFilter = new TestFilter(); this.wac = new AnnotationConfigWebApplicationContext(); @@ -123,7 +121,7 @@ public abstract class AbstractSockJsIntegrationTests { this.baseUrl = "http://localhost:" + this.server.getPort(); } - @After + @AfterEach public void teardown() throws Exception { try { this.sockJsClient.stop(); @@ -249,7 +247,8 @@ public abstract class AbstractSockJsIntegrationTests { handler.awaitMessage(message, 5000); } - @Test(timeout = 5000) + @Test + @Timeout(5) public void fallbackAfterConnectTimeout() throws Exception { TestClientHandler clientHandler = new TestClientHandler(); this.testFilter.sleepDelayMap.put("/xhr_streaming", 10000L); diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/ClientSockJsSessionTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/ClientSockJsSessionTests.java index 090694f41f0..e5095a6aa12 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/ClientSockJsSessionTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/ClientSockJsSessionTests.java @@ -21,8 +21,8 @@ import java.net.InetSocketAddress; import java.net.URI; import java.util.List; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.util.concurrent.SettableListenableFuture; import org.springframework.web.socket.CloseStatus; @@ -59,7 +59,7 @@ public class ClientSockJsSessionTests { private SettableListenableFuture connectFuture; - @Before + @BeforeEach public void setup() throws Exception { SockJsUrlInfo urlInfo = new SockJsUrlInfo(new URI("https://example.com")); Transport transport = mock(Transport.class); diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/DefaultTransportRequestTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/DefaultTransportRequestTests.java index 9c185ca35da..b0ce1336538 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/DefaultTransportRequestTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/DefaultTransportRequestTests.java @@ -21,8 +21,8 @@ import java.net.URI; import java.util.Date; import java.util.concurrent.ExecutionException; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; import org.springframework.http.HttpHeaders; @@ -60,7 +60,7 @@ public class DefaultTransportRequestTests { @SuppressWarnings("unchecked") - @Before + @BeforeEach public void setup() throws Exception { this.connectCallback = mock(ListenableFutureCallback.class); this.connectFuture = new SettableListenableFuture<>(); diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/RestTemplateXhrTransportTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/RestTemplateXhrTransportTests.java index d307106a4e3..dee39ee3dbc 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/RestTemplateXhrTransportTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/RestTemplateXhrTransportTests.java @@ -26,7 +26,7 @@ import java.util.Queue; import java.util.concurrent.CountDownLatch; import java.util.concurrent.LinkedBlockingDeque; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.core.task.SyncTaskExecutor; import org.springframework.http.HttpHeaders; diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/SockJsClientTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/SockJsClientTests.java index ac32ce1e995..0211d3bb900 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/SockJsClientTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/SockJsClientTests.java @@ -21,8 +21,8 @@ import java.net.URISyntaxException; import java.util.ArrayList; import java.util.List; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; import org.springframework.http.HttpHeaders; @@ -65,7 +65,7 @@ public class SockJsClientTests { private ListenableFutureCallback connectCallback; - @Before + @BeforeEach @SuppressWarnings("unchecked") public void setup() { this.infoReceiver = mock(InfoReceiver.class); diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/SockJsUrlInfoTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/SockJsUrlInfoTests.java index 71320a2f64c..1297b00af0f 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/SockJsUrlInfoTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/SockJsUrlInfoTests.java @@ -18,7 +18,7 @@ package org.springframework.web.socket.sockjs.client; import java.net.URI; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.web.socket.sockjs.transport.TransportType; diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/XhrTransportTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/XhrTransportTests.java index aafd37b4af8..d45ba3363ae 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/XhrTransportTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/XhrTransportTests.java @@ -18,7 +18,7 @@ package org.springframework.web.socket.sockjs.client; import java.net.URI; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; import org.springframework.http.HttpHeaders; diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/frame/SockJsFrameTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/frame/SockJsFrameTests.java index d8feacf58e1..3f4e22621fd 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/frame/SockJsFrameTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/frame/SockJsFrameTests.java @@ -16,7 +16,7 @@ package org.springframework.web.socket.sockjs.frame; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/support/SockJsServiceTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/support/SockJsServiceTests.java index 975c42de85d..267824c78df 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/support/SockJsServiceTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/support/SockJsServiceTests.java @@ -22,8 +22,8 @@ import java.util.Collections; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; @@ -57,7 +57,7 @@ public class SockJsServiceTests extends AbstractHttpRequestTests { @Override - @Before + @BeforeEach public void setup() { super.setup(); this.service = new TestSockJsService(new ThreadPoolTaskScheduler()); diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/transport/TransportTypeTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/transport/TransportTypeTests.java index 0d884d66abb..a3f651ff67b 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/transport/TransportTypeTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/transport/TransportTypeTests.java @@ -16,7 +16,7 @@ package org.springframework.web.socket.sockjs.transport; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/transport/handler/DefaultSockJsServiceTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/transport/handler/DefaultSockJsServiceTests.java index bc3f24012f9..baa480592e1 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/transport/handler/DefaultSockJsServiceTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/transport/handler/DefaultSockJsServiceTests.java @@ -21,11 +21,11 @@ import java.util.Collections; import java.util.List; import java.util.Map; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoSettings; +import org.mockito.quality.Strictness; import org.springframework.http.HttpHeaders; import org.springframework.scheduling.TaskScheduler; @@ -58,7 +58,7 @@ import static org.mockito.Mockito.verifyNoMoreInteractions; * @author Sebastien Deleuze * @author Ben Kiefer */ -@RunWith(MockitoJUnitRunner.class) +@MockitoSettings(strictness = Strictness.LENIENT) public class DefaultSockJsServiceTests extends AbstractHttpRequestTests { private static final String sockJsPrefix = "/mysockjs"; @@ -89,7 +89,7 @@ public class DefaultSockJsServiceTests extends AbstractHttpRequestTests { @Override - @Before + @BeforeEach public void setup() { super.setup(); diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/transport/handler/HttpReceivingTransportHandlerTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/transport/handler/HttpReceivingTransportHandlerTests.java index 5671a292998..996391d16ee 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/transport/handler/HttpReceivingTransportHandlerTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/transport/handler/HttpReceivingTransportHandlerTests.java @@ -16,7 +16,7 @@ package org.springframework.web.socket.sockjs.transport.handler; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.web.socket.AbstractHttpRequestTests; import org.springframework.web.socket.TextMessage; diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/transport/handler/HttpSendingTransportHandlerTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/transport/handler/HttpSendingTransportHandlerTests.java index 35d8434c1f2..48cb9bd4392 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/transport/handler/HttpSendingTransportHandlerTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/transport/handler/HttpSendingTransportHandlerTests.java @@ -18,8 +18,8 @@ package org.springframework.web.socket.sockjs.transport.handler; import java.util.Date; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.springframework.scheduling.TaskScheduler; import org.springframework.web.socket.AbstractHttpRequestTests; @@ -50,7 +50,7 @@ public class HttpSendingTransportHandlerTests extends AbstractHttpRequestTests @Override - @Before + @BeforeEach public void setup() { super.setup(); diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/transport/handler/SockJsWebSocketHandlerTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/transport/handler/SockJsWebSocketHandlerTests.java index ef71105b4f2..3da4b9b4a75 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/transport/handler/SockJsWebSocketHandlerTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/transport/handler/SockJsWebSocketHandlerTests.java @@ -18,7 +18,7 @@ package org.springframework.web.socket.sockjs.transport.handler; import java.util.Collections; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.springframework.messaging.SubscribableChannel; import org.springframework.scheduling.TaskScheduler; diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/transport/session/AbstractSockJsSessionTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/transport/session/AbstractSockJsSessionTests.java index 64827146d6d..8473cf73d15 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/transport/session/AbstractSockJsSessionTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/transport/session/AbstractSockJsSessionTests.java @@ -16,7 +16,7 @@ package org.springframework.web.socket.sockjs.transport.session; -import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; import org.springframework.scheduling.TaskScheduler; import org.springframework.web.socket.WebSocketHandler; @@ -40,7 +40,7 @@ public abstract class AbstractSockJsSessionTests