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 388bd486a6f..736ecf5c9ff 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 @@ -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. @@ -58,8 +58,8 @@ import org.springframework.tests.sample.beans.ITestBean; import org.springframework.tests.sample.beans.TestBean; import org.springframework.util.ObjectUtils; -import static org.hamcrest.Matchers.*; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.*; import static org.junit.Assert.*; /** 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 969bb6caef8..0256632aa25 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 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,13 +18,11 @@ package org.springframework.aop.framework; import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInvocation; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.springframework.aop.AopInvocationException; -import static org.junit.Assert.*; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; /** * Test for SPR-4675. A null value returned from around advice is very hard to debug if @@ -34,9 +32,6 @@ import static org.junit.Assert.*; */ public class NullPrimitiveTests { - @Rule - public ExpectedException thrown = ExpectedException.none(); - static interface Foo { int getValue(); } @@ -62,9 +57,9 @@ public class NullPrimitiveTests { Foo foo = (Foo) factory.getProxy(); - thrown.expect(AopInvocationException.class); - thrown.expectMessage("Foo.getValue()"); - assertEquals(0, foo.getValue()); + assertThatExceptionOfType(AopInvocationException.class).isThrownBy(() -> + foo.getValue()) + .withMessageContaining("Foo.getValue()"); } public static class Bar { @@ -87,9 +82,9 @@ public class NullPrimitiveTests { Bar bar = (Bar) factory.getProxy(); - thrown.expect(AopInvocationException.class); - thrown.expectMessage("Bar.getValue()"); - assertEquals(0, bar.getValue()); + assertThatExceptionOfType(AopInvocationException.class).isThrownBy(() -> + bar.getValue()) + .withMessageContaining("Bar.getValue()"); } } 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 681ea93c257..d7d00c5ed9c 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 @@ -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. @@ -21,6 +21,7 @@ import org.apache.commons.logging.Log; import org.junit.Test; import static org.junit.Assert.*; +import static org.mockito.ArgumentMatchers.*; import static org.mockito.BDDMockito.*; /** 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 7ecd3732d39..a01cc3debbe 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 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. @@ -21,6 +21,7 @@ import org.apache.commons.logging.Log; import org.junit.Test; import static org.junit.Assert.*; +import static org.mockito.ArgumentMatchers.*; import static org.mockito.BDDMockito.*; /** 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 913c4bbaac5..1be9032819d 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 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. @@ -21,6 +21,7 @@ import org.apache.commons.logging.Log; import org.junit.Test; import static org.junit.Assert.*; +import static org.mockito.ArgumentMatchers.*; import static org.mockito.BDDMockito.*; /** 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 62636479105..2d8cdcfe559 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 @@ -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. @@ -21,6 +21,7 @@ import org.apache.commons.logging.Log; import org.junit.Test; import static org.junit.Assert.*; +import static org.mockito.ArgumentMatchers.*; import static org.mockito.BDDMockito.*; /** 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 8b3576165b1..3326d8337f3 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 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. @@ -20,7 +20,7 @@ import org.junit.Test; import org.springframework.beans.factory.config.ConfigurableBeanFactory; -import static org.mockito.BDDMockito.*; +import static org.mockito.Mockito.*; /** * Unit tests for the {@link DefaultScopedObject} class. 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 db74e254e85..d5e912446b6 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 @@ -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. @@ -34,8 +34,8 @@ import org.springframework.tests.sample.beans.SerializablePerson; import org.springframework.tests.sample.beans.TestBean; import org.springframework.util.SerializationTestUtils; -import static org.hamcrest.Matchers.*; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.*; import static org.junit.Assert.*; import static org.mockito.BDDMockito.*; diff --git a/spring-aop/src/test/java/org/springframework/tests/aop/advice/MyThrowsHandler.java b/spring-aop/src/test/java/org/springframework/tests/aop/advice/MyThrowsHandler.java index 4e5f8ecc3fe..5eec90e6163 100644 --- a/spring-aop/src/test/java/org/springframework/tests/aop/advice/MyThrowsHandler.java +++ b/spring-aop/src/test/java/org/springframework/tests/aop/advice/MyThrowsHandler.java @@ -1,6 +1,19 @@ -/** +/* + * Copyright 2002-2019 the original author or authors. * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ + package org.springframework.tests.aop.advice; import java.io.IOException; diff --git a/spring-aop/src/test/java/org/springframework/tests/aop/advice/TimestampIntroductionAdvisor.java b/spring-aop/src/test/java/org/springframework/tests/aop/advice/TimestampIntroductionAdvisor.java index 0d9ba5d9875..8e2d4b8cc23 100644 --- a/spring-aop/src/test/java/org/springframework/tests/aop/advice/TimestampIntroductionAdvisor.java +++ b/spring-aop/src/test/java/org/springframework/tests/aop/advice/TimestampIntroductionAdvisor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 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. @@ -21,15 +21,11 @@ import org.springframework.aop.support.DelegatingIntroductionInterceptor; import org.springframework.tests.aop.interceptor.TimestampIntroductionInterceptor; /** - * * @author Rod Johnson */ @SuppressWarnings("serial") public class TimestampIntroductionAdvisor extends DefaultIntroductionAdvisor { - /** - * @param dii - */ public TimestampIntroductionAdvisor() { super(new DelegatingIntroductionInterceptor(new TimestampIntroductionInterceptor())); } diff --git a/spring-aspects/src/test/java/org/springframework/scheduling/aspectj/TestableAsyncUncaughtExceptionHandler.java b/spring-aspects/src/test/java/org/springframework/scheduling/aspectj/TestableAsyncUncaughtExceptionHandler.java index cf4e517a842..89b9d24890e 100644 --- a/spring-aspects/src/test/java/org/springframework/scheduling/aspectj/TestableAsyncUncaughtExceptionHandler.java +++ b/spring-aspects/src/test/java/org/springframework/scheduling/aspectj/TestableAsyncUncaughtExceptionHandler.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. @@ -69,12 +69,12 @@ class TestableAsyncUncaughtExceptionHandler try { this.latch.await(timeout, TimeUnit.MILLISECONDS); } - catch (Exception e) { + catch (Exception ex) { Thread.currentThread().interrupt(); } } - private static class UncaughtExceptionDescriptor { + private static final class UncaughtExceptionDescriptor { private final Throwable ex; private final Method method; 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 015c50757cb..c77243fd495 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 @@ -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. @@ -181,11 +181,11 @@ public class TransactionAspectTests { try { toc.performTransactionalOperation(); } - catch (Throwable t) { + catch (Throwable ex) { if (expected == null) { fail("Expected " + expected); } - assertSame(expected, t); + assertSame(expected, ex); } finally { assertEquals(0, txManager.begun); 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 7bc653b98bf..8625fb01b30 100644 --- a/spring-beans/src/test/java/org/springframework/beans/AbstractPropertyAccessorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/AbstractPropertyAccessorTests.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. @@ -36,9 +36,7 @@ import java.util.TreeMap; import java.util.TreeSet; import org.apache.commons.logging.LogFactory; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.springframework.beans.factory.annotation.Autowire; import org.springframework.beans.propertyeditors.CustomNumberEditor; @@ -60,11 +58,13 @@ import org.springframework.tests.sample.beans.TestBean; import org.springframework.util.StopWatch; import org.springframework.util.StringUtils; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.notNullValue; import static org.hamcrest.CoreMatchers.nullValue; -import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.equalTo; import static org.junit.Assert.*; /** @@ -80,9 +80,6 @@ import static org.junit.Assert.*; */ public abstract class AbstractPropertyAccessorTests { - @Rule - public final ExpectedException thrown = ExpectedException.none(); - protected abstract AbstractPropertyAccessor createAccessor(Object target); @@ -126,8 +123,8 @@ public abstract class AbstractPropertyAccessorTests { public void isReadablePropertyNull() { AbstractPropertyAccessor accessor = createAccessor(new NoRead()); - thrown.expect(IllegalArgumentException.class); - accessor.isReadableProperty(null); + assertThatIllegalArgumentException().isThrownBy(() -> + accessor.isReadableProperty(null)); } @Test @@ -141,8 +138,8 @@ public abstract class AbstractPropertyAccessorTests { public void isWritablePropertyNull() { AbstractPropertyAccessor accessor = createAccessor(new NoRead()); - thrown.expect(IllegalArgumentException.class); - accessor.isWritableProperty(null); + assertThatIllegalArgumentException().isThrownBy(() -> + accessor.isWritableProperty(null)); } @Test @@ -290,8 +287,8 @@ public abstract class AbstractPropertyAccessorTests { Person target = createPerson("John", "London", "UK"); AbstractPropertyAccessor accessor = createAccessor(target); - thrown.expect(NotReadablePropertyException.class); - accessor.getPropertyValue("address.bar"); + assertThatExceptionOfType(NotReadablePropertyException.class).isThrownBy(() -> + accessor.getPropertyValue("address.bar")); } @Test @@ -1564,8 +1561,8 @@ public abstract class AbstractPropertyAccessorTests { Person target = createPerson("John", "Paris", "FR"); AbstractPropertyAccessor accessor = createAccessor(target); - thrown.expect(NotWritablePropertyException.class); - accessor.setPropertyValue("address.bar", "value"); + assertThatExceptionOfType(NotWritablePropertyException.class).isThrownBy(() -> + accessor.setPropertyValue("address.bar", "value")); } @Test 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 6df93c380ac..a84db352217 100644 --- a/spring-beans/src/test/java/org/springframework/beans/BeanWrapperAutoGrowingTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/BeanWrapperAutoGrowingTests.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. @@ -22,8 +22,8 @@ import java.util.Map; import org.junit.Before; import org.junit.Test; -import static org.hamcrest.Matchers.*; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.*; import static org.junit.Assert.*; /** 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 59a9f876d07..ad1cfa8f60e 100644 --- a/spring-beans/src/test/java/org/springframework/beans/ExtendedBeanInfoFactoryTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/ExtendedBeanInfoFactoryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 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. @@ -21,7 +21,7 @@ import java.beans.IntrospectionException; import org.junit.Test; import static org.hamcrest.CoreMatchers.*; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.MatcherAssert.*; /** * Unit tests for {@link ExtendedBeanInfoTests}. 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 cc0e856b204..80384bb9c18 100644 --- a/spring-beans/src/test/java/org/springframework/beans/PropertyMatchesTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/PropertyMatchesTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 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.beans; import org.junit.Test; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.MatcherAssert.*; import static org.hamcrest.Matchers.*; /** 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 1a8ae1748c2..8576e1bbec6 100644 --- a/spring-beans/src/test/java/org/springframework/beans/SimplePropertyDescriptorTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/SimplePropertyDescriptorTests.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. @@ -24,7 +24,7 @@ import java.lang.reflect.Method; import org.junit.Test; import static org.hamcrest.CoreMatchers.*; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.MatcherAssert.*; /** * @author Chris Beams 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 6b7aa023fe3..b9bfec52b02 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 @@ -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. @@ -44,9 +44,7 @@ import javax.security.auth.Subject; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.Ignore; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.mockito.ArgumentMatchers; import org.springframework.beans.BeansException; @@ -102,9 +100,11 @@ import org.springframework.util.SerializationTestUtils; import org.springframework.util.StopWatch; import org.springframework.util.StringValueResolver; -import static org.hamcrest.Matchers.*; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.*; import static org.junit.Assert.*; +import static org.mockito.ArgumentMatchers.*; import static org.mockito.BDDMockito.*; /** @@ -123,9 +123,6 @@ public class DefaultListableBeanFactoryTests { private static final Log factoryLog = LogFactory.getLog(DefaultListableBeanFactory.class); - @Rule - public ExpectedException thrown = ExpectedException.none(); - @Test public void testUnreferencedSingletonWasInstantiated() { @@ -1483,9 +1480,9 @@ public class DefaultListableBeanFactoryTests { bd2.setPrimary(true); lbf.registerBeanDefinition("bd1", bd1); lbf.registerBeanDefinition("bd2", bd2); - thrown.expect(NoUniqueBeanDefinitionException.class); - thrown.expectMessage(containsString("more than one 'primary'")); - lbf.getBean(TestBean.class); + assertThatExceptionOfType(NoUniqueBeanDefinitionException.class).isThrownBy(() -> + lbf.getBean(TestBean.class)) + .withMessageContaining("more than one 'primary'"); } @Test @@ -1528,10 +1525,10 @@ public class DefaultListableBeanFactoryTests { RootBeanDefinition bd2 = new RootBeanDefinition(HighPriorityTestBean.class); lbf.registerBeanDefinition("bd1", bd1); lbf.registerBeanDefinition("bd2", bd2); - thrown.expect(NoUniqueBeanDefinitionException.class); - thrown.expectMessage(containsString("Multiple beans found with the same priority")); - thrown.expectMessage(containsString("5")); // conflicting priority - lbf.getBean(TestBean.class); + assertThatExceptionOfType(NoUniqueBeanDefinitionException.class).isThrownBy(() -> + lbf.getBean(TestBean.class)) + .withMessageContaining("Multiple beans found with the same priority") + .withMessageContaining("5"); // conflicting priority } @Test @@ -1778,9 +1775,9 @@ public class DefaultListableBeanFactoryTests { lbf.registerBeanDefinition("bd1", bd1); lbf.registerBeanDefinition("bd2", bd2); - thrown.expect(NoUniqueBeanDefinitionException.class); - thrown.expectMessage(containsString("more than one 'primary'")); - lbf.getBean(ConstructorDependency.class, 42); + assertThatExceptionOfType(NoUniqueBeanDefinitionException.class).isThrownBy(() -> + lbf.getBean(ConstructorDependency.class, 42)) + .withMessageContaining("more than one 'primary'"); } @Test 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 ec4123fb522..1c8c8ab15c3 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,15 +21,15 @@ import java.lang.reflect.Executable; import java.lang.reflect.Method; import java.lang.reflect.Parameter; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.springframework.beans.factory.config.AutowireCapableBeanFactory; import org.springframework.beans.factory.config.DependencyDescriptor; import org.springframework.util.ClassUtils; +import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.junit.Assert.*; +import static org.mockito.ArgumentMatchers.*; import static org.mockito.Mockito.*; /** @@ -41,15 +41,11 @@ import static org.mockito.Mockito.*; */ public class ParameterResolutionTests { - @Rule - public final ExpectedException exception = ExpectedException.none(); - - @Test public void isAutowirablePreconditions() { - exception.expect(IllegalArgumentException.class); - exception.expectMessage("Parameter must not be null"); - ParameterResolutionDelegate.isAutowirable(null, 0); + assertThatIllegalArgumentException().isThrownBy(() -> + ParameterResolutionDelegate.isAutowirable(null, 0)) + .withMessageContaining("Parameter must not be null"); } @Test @@ -97,23 +93,23 @@ public class ParameterResolutionTests { @Test public void resolveDependencyPreconditionsForParameter() { - exception.expect(IllegalArgumentException.class); - exception.expectMessage("Parameter must not be null"); - ParameterResolutionDelegate.resolveDependency(null, 0, null, mock(AutowireCapableBeanFactory.class)); + assertThatIllegalArgumentException().isThrownBy(() -> + ParameterResolutionDelegate.resolveDependency(null, 0, null, mock(AutowireCapableBeanFactory.class))) + .withMessageContaining("Parameter must not be null"); } @Test public void resolveDependencyPreconditionsForContainingClass() throws Exception { - exception.expect(IllegalArgumentException.class); - exception.expectMessage("Containing class must not be null"); - ParameterResolutionDelegate.resolveDependency(getParameter(), 0, null, null); + assertThatIllegalArgumentException().isThrownBy(() -> + ParameterResolutionDelegate.resolveDependency(getParameter(), 0, null, null)) + .withMessageContaining("Containing class must not be null"); } @Test public void resolveDependencyPreconditionsForBeanFactory() throws Exception { - exception.expect(IllegalArgumentException.class); - exception.expectMessage("AutowireCapableBeanFactory must not be null"); - ParameterResolutionDelegate.resolveDependency(getParameter(), 0, getClass(), null); + assertThatIllegalArgumentException().isThrownBy(() -> + ParameterResolutionDelegate.resolveDependency(getParameter(), 0, getClass(), null)) + .withMessageContaining("AutowireCapableBeanFactory must not be null"); } private Parameter getParameter() throws NoSuchMethodException { 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 aa9b77cf569..1818a513ffc 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 @@ -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. @@ -24,7 +24,7 @@ import org.junit.Test; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import static org.junit.Assert.*; -import static org.mockito.BDDMockito.*; +import static org.mockito.Mockito.*; /** * Unit tests for {@link CustomScopeConfigurer}. 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 0f2f5bf8387..858124725f6 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 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. @@ -28,7 +28,7 @@ import org.springframework.core.NestedCheckedException; import org.springframework.core.NestedRuntimeException; import static org.junit.Assert.*; -import static org.mockito.BDDMockito.*; +import static org.mockito.Mockito.*; import static org.springframework.beans.factory.support.BeanDefinitionBuilder.*; /** 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 92c266c0e69..0ad72aff809 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 @@ -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. @@ -19,14 +19,13 @@ package org.springframework.beans.factory.config; import java.util.LinkedHashMap; import java.util.Map; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.yaml.snakeyaml.parser.ParserException; import org.yaml.snakeyaml.scanner.ScannerException; import org.springframework.core.io.ByteArrayResource; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.junit.Assert.*; /** @@ -39,9 +38,6 @@ public class YamlProcessorTests { private final YamlProcessor processor = new YamlProcessor() {}; - @Rule - public ExpectedException exception = ExpectedException.none(); - @Test public void arrayConvertedToIndexedBeanReference() { @@ -68,17 +64,17 @@ public class YamlProcessorTests { @Test public void testBadDocumentStart() { this.processor.setResources(new ByteArrayResource("foo # a document\nbar: baz".getBytes())); - this.exception.expect(ParserException.class); - this.exception.expectMessage("line 2, column 1"); - this.processor.process((properties, map) -> {}); + assertThatExceptionOfType(ParserException.class).isThrownBy(() -> + this.processor.process((properties, map) -> {})) + .withMessageContaining("line 2, column 1"); } @Test public void testBadResource() { this.processor.setResources(new ByteArrayResource("foo: bar\ncd\nspam:\n foo: baz".getBytes())); - this.exception.expect(ScannerException.class); - this.exception.expectMessage("line 3, column 1"); - this.processor.process((properties, map) -> {}); + assertThatExceptionOfType(ScannerException.class).isThrownBy(() -> + this.processor.process((properties, map) -> {})) + .withMessageContaining("line 3, column 1"); } @Test 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 92c1c1317a2..30564763e35 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 @@ -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. @@ -19,19 +19,20 @@ package org.springframework.beans.factory.config; import java.util.Map; import java.util.Properties; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.constructor.DuplicateKeyException; import org.yaml.snakeyaml.scanner.ScannerException; +import org.springframework.beans.factory.config.YamlProcessor.DocumentMatcher; +import org.springframework.beans.factory.config.YamlProcessor.MatchStatus; +import org.springframework.beans.factory.config.YamlProcessor.ResolutionMethod; import org.springframework.core.io.ByteArrayResource; import org.springframework.core.io.ClassPathResource; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.hamcrest.MatcherAssert.*; import static org.hamcrest.Matchers.*; -import static org.springframework.beans.factory.config.YamlProcessor.*; /** * Tests for {@link YamlPropertiesFactoryBean}. @@ -41,9 +42,6 @@ import static org.springframework.beans.factory.config.YamlProcessor.*; */ public class YamlPropertiesFactoryBeanTests { - @Rule - public ExpectedException exception = ExpectedException.none(); - @Test public void testLoadResource() { @@ -59,9 +57,9 @@ public class YamlPropertiesFactoryBeanTests { YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean(); factory.setResources(new ByteArrayResource( "foo: bar\ncd\nspam:\n foo: baz".getBytes())); - this.exception.expect(ScannerException.class); - this.exception.expectMessage("line 3, column 1"); - factory.getObject(); + assertThatExceptionOfType(ScannerException.class).isThrownBy( + factory::getObject) + .withMessageContaining("line 3, column 1"); } @Test 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 3fcd780b6ad..1297b543918 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 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. @@ -21,7 +21,8 @@ import org.junit.Test; import org.springframework.core.io.DescriptiveResource; -import static org.mockito.BDDMockito.*; +import static org.mockito.ArgumentMatchers.*; +import static org.mockito.Mockito.*; /** * @author Rick Evans 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 f81e8604c42..e4d20f68b8d 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 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. @@ -27,7 +27,7 @@ import org.springframework.beans.factory.config.InstantiationAwareBeanPostProces import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter; import static org.hamcrest.CoreMatchers.*; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.MatcherAssert.*; /** * Unit tests for SPR-8954, in which a custom {@link InstantiationAwareBeanPostProcessor} 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 8e199d52268..51a0cb84321 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 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. @@ -232,7 +232,6 @@ public abstract class AbstractBeanFactoryTests { /** * Check that we can get the factory bean itself. * This is only possible if we're dealing with a factory - * @throws Exception */ @Test public void getFactoryItself() throws Exception { @@ -241,7 +240,6 @@ public abstract class AbstractBeanFactoryTests { /** * Check that afterPropertiesSet gets called on factory - * @throws Exception */ @Test public void factoryIsInitialized() throws Exception { 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 57b3c97936d..a4e06f962be 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 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. @@ -29,7 +29,7 @@ import static org.junit.Assert.*; /** * With Spring 3.1, bean id attributes (and all other id attributes across the * core schemas) are no longer typed as xsd:id, but as xsd:string. This allows - * for using the same bean id within nested elements. + * for using the same bean id within nested <beans> elements. * * Duplicate ids *within the same level of nesting* will still be treated as an * error through the ProblemReporter, as this could never be an intended/valid 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 dceb26f8a68..ad94277cc16 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 @@ -25,7 +25,7 @@ import org.springframework.tests.sample.beans.TestBean; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.not; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.MatcherAssert.*; import static org.hamcrest.Matchers.hasItems; /** 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 870e2c78d3b..ea8879ecef4 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 @@ -1,3 +1,19 @@ +/* + * Copyright 2002-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.beans.factory.xml; import org.junit.Test; @@ -9,7 +25,7 @@ import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import static org.hamcrest.CoreMatchers.*; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.MatcherAssert.*; /** * Tests for new nested beans element support in Spring XML 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 65756c1609e..e7578220f17 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 @@ -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. @@ -28,7 +28,7 @@ import org.springframework.core.env.StandardEnvironment; import org.springframework.core.io.ClassPathResource; import static org.hamcrest.CoreMatchers.*; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.MatcherAssert.*; /** * Tests various combinations of profile declarations against various profile 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 4e3d41c9037..0b25653d0da 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 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,14 +17,13 @@ package org.springframework.beans.factory.xml; import org.junit.Test; +import org.xml.sax.SAXParseException; import org.springframework.beans.BeansException; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.core.io.ClassPathResource; import org.springframework.tests.sample.beans.TestBean; -import org.xml.sax.SAXParseException; - import static org.junit.Assert.*; /** diff --git a/spring-beans/src/test/java/org/springframework/tests/sample/beans/IOther.java b/spring-beans/src/test/java/org/springframework/tests/sample/beans/IOther.java index a981dfb3b52..f674ff7bb71 100644 --- a/spring-beans/src/test/java/org/springframework/tests/sample/beans/IOther.java +++ b/spring-beans/src/test/java/org/springframework/tests/sample/beans/IOther.java @@ -1,6 +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. 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 078f14b6242..35a3124677c 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 @@ -36,6 +36,7 @@ import org.springframework.context.index.sample.AbstractController; import org.springframework.context.index.sample.MetaControllerIndexed; import org.springframework.context.index.sample.SampleComponent; import org.springframework.context.index.sample.SampleController; +import org.springframework.context.index.sample.SampleEmbedded; import org.springframework.context.index.sample.SampleMetaController; import org.springframework.context.index.sample.SampleMetaIndexedController; import org.springframework.context.index.sample.SampleNonStaticEmbedded; @@ -47,7 +48,6 @@ import org.springframework.context.index.sample.cdi.SampleNamed; import org.springframework.context.index.sample.cdi.SampleTransactional; import org.springframework.context.index.sample.jpa.SampleConverter; import org.springframework.context.index.sample.jpa.SampleEmbeddable; -import org.springframework.context.index.sample.SampleEmbedded; import org.springframework.context.index.sample.jpa.SampleEntity; import org.springframework.context.index.sample.jpa.SampleMappedSuperClass; import org.springframework.context.index.sample.type.Repo; @@ -60,7 +60,7 @@ import org.springframework.context.index.test.TestCompiler; import org.springframework.stereotype.Component; import org.springframework.util.ClassUtils; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.MatcherAssert.*; import static org.hamcrest.Matchers.*; import static org.springframework.context.index.processor.Metadata.*; 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 b12eef11bb3..a27f70fb265 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 @@ -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. @@ -24,7 +24,7 @@ import java.util.HashSet; import org.junit.Test; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.MatcherAssert.*; import static org.hamcrest.Matchers.*; import static org.springframework.context.index.processor.Metadata.*; diff --git a/spring-context-indexer/src/test/java/org/springframework/context/index/sample/jpa/package-info.java b/spring-context-indexer/src/test/java/org/springframework/context/index/sample/jpa/package-info.java index 2332a1b66bd..17732bbdd54 100644 --- a/spring-context-indexer/src/test/java/org/springframework/context/index/sample/jpa/package-info.java +++ b/spring-context-indexer/src/test/java/org/springframework/context/index/sample/jpa/package-info.java @@ -1,19 +1,3 @@ -/* - * Copyright 2002-2018 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - /** * Test candidate for {@code package-info}. * 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 5b6b0c9c83e..1cf93dc5934 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 @@ -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. @@ -19,13 +19,12 @@ 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.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.springframework.cache.Cache; import org.springframework.cache.CacheManager; +import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.junit.Assert.*; import static org.mockito.Mockito.*; @@ -36,9 +35,6 @@ import static org.mockito.Mockito.*; */ public class CaffeineCacheManagerTests { - @Rule - public final ExpectedException thrown = ExpectedException.none(); - @Test public void testDynamicMode() { CacheManager cm = new CaffeineCacheManager(); @@ -187,9 +183,9 @@ public class CaffeineCacheManagerTests { assertNotNull(value); assertEquals("pong", value.get()); - thrown.expect(IllegalArgumentException.class); - thrown.expectMessage("I only know ping"); - assertNull(cache1.get("foo")); + assertThatIllegalArgumentException().isThrownBy(() -> + assertNull(cache1.get("foo"))) + .withMessageContaining("I only know ping"); } @SuppressWarnings("unchecked") 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 b264e86afc5..b00c9d7e0bc 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 @@ -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. @@ -20,7 +20,6 @@ import java.util.ArrayList; import java.util.List; import org.junit.Rule; -import org.junit.rules.ExpectedException; import org.junit.rules.TestName; import org.springframework.cache.Cache; @@ -38,9 +37,6 @@ import org.springframework.cache.support.SimpleCacheManager; */ public abstract class AbstractJCacheTests { - @Rule - public final ExpectedException thrown = ExpectedException.none(); - @Rule public final TestName name = new TestName(); 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 6c230b03368..b6b9edb1c27 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 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,9 +18,7 @@ package org.springframework.cache.jcache.config; import java.util.Arrays; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.springframework.cache.Cache; import org.springframework.cache.CacheManager; @@ -46,6 +44,7 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import static org.assertj.core.api.Assertions.assertThatIllegalStateException; import static org.junit.Assert.*; /** @@ -53,9 +52,6 @@ import static org.junit.Assert.*; */ public class JCacheJavaConfigTests extends AbstractJCacheAnnotationTests { - @Rule - public final ExpectedException thrown = ExpectedException.none(); - @Override protected ApplicationContext getApplicationContext() { return new AnnotationConfigApplicationContext(EnableCachingConfig.class); @@ -116,8 +112,8 @@ public class JCacheJavaConfigTests extends AbstractJCacheAnnotationTests { service.cache("id"); // This call requires the cache manager to be set - thrown.expect(IllegalStateException.class); - service.cacheWithException("test", false); + assertThatIllegalStateException().isThrownBy(() -> + service.cacheWithException("test", false)); } finally { context.close(); 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 d1e767cf5a8..26b611651f7 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 @@ -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. @@ -37,6 +37,7 @@ import org.springframework.cache.jcache.support.TestableCacheResolverFactory; import org.springframework.util.Assert; import org.springframework.util.ReflectionUtils; +import static org.assertj.core.api.Assertions.assertThatIllegalStateException; import static org.junit.Assert.*; import static org.mockito.BDDMockito.*; @@ -99,8 +100,8 @@ public class AnnotationCacheOperationSourceTests extends AbstractJCacheTests { @Test public void multiAnnotations() { - thrown.expect(IllegalStateException.class); - getCacheOperation(InvalidCases.class, name.getMethodName()); + assertThatIllegalStateException().isThrownBy(() -> + getCacheOperation(InvalidCases.class, name.getMethodName())); } @Test 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 fb4006d9835..e0cee833429 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 @@ -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. @@ -23,6 +23,8 @@ import javax.cache.annotation.CachePut; import org.junit.Test; +import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; +import static org.assertj.core.api.Assertions.assertThatIllegalStateException; import static org.junit.Assert.*; /** @@ -56,8 +58,8 @@ public class CachePutOperationTests extends AbstractCacheOperationTests methodDetails = create(CachePut.class, SampleObject.class, "noCacheValue", Long.class); - thrown.expect(IllegalArgumentException.class); - createDefaultOperation(methodDetails); + assertThatIllegalArgumentException().isThrownBy(() -> + createDefaultOperation(methodDetails)); } @Test @@ -65,16 +67,16 @@ public class CachePutOperationTests extends AbstractCacheOperationTests methodDetails = create(CachePut.class, SampleObject.class, "multiCacheValues", Long.class, SampleObject.class, SampleObject.class); - thrown.expect(IllegalArgumentException.class); - createDefaultOperation(methodDetails); + assertThatIllegalArgumentException().isThrownBy(() -> + createDefaultOperation(methodDetails)); } @Test public void invokeWithWrongParameters() { CachePutOperation operation = createSimpleOperation(); - thrown.expect(IllegalStateException.class); - operation.getValueParameter(2L); + assertThatIllegalStateException().isThrownBy(() -> + operation.getValueParameter(2L)); } @Test 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 42f049305f2..eec3fe20da8 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 @@ -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. @@ -24,13 +24,12 @@ import javax.cache.annotation.CacheMethodDetails; import javax.cache.annotation.CacheResolver; import javax.cache.annotation.CacheResult; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.springframework.cache.Cache; import org.springframework.cache.jcache.AbstractJCacheTests; +import static org.assertj.core.api.Assertions.assertThatIllegalStateException; import static org.junit.Assert.*; import static org.mockito.BDDMockito.*; @@ -39,10 +38,6 @@ import static org.mockito.BDDMockito.*; */ public class CacheResolverAdapterTests extends AbstractJCacheTests { - @Rule - public final ExpectedException thrown = ExpectedException.none(); - - @Test public void resolveSimpleCache() throws Exception { DefaultCacheInvocationContext dummyContext = createDummyContext(); @@ -58,8 +53,8 @@ public class CacheResolverAdapterTests extends AbstractJCacheTests { DefaultCacheInvocationContext dummyContext = createDummyContext(); CacheResolverAdapter adapter = new CacheResolverAdapter(getCacheResolver(dummyContext, null)); - thrown.expect(IllegalStateException.class); - adapter.resolveCaches(dummyContext); + assertThatIllegalStateException().isThrownBy(() -> + adapter.resolveCaches(dummyContext)); } protected CacheResolver getCacheResolver(CacheInvocationContext context, String cacheName) { 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 786af9f892b..ab16b7892c8 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 @@ -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. @@ -28,6 +28,7 @@ import org.junit.Test; import org.springframework.beans.factory.annotation.Value; +import static org.assertj.core.api.Assertions.assertThatIllegalStateException; import static org.junit.Assert.*; /** @@ -81,8 +82,9 @@ public class CacheResultOperationTests extends AbstractCacheOperationTests + operation.getAllParameters("bar")); } @Test @@ -91,8 +93,9 @@ public class CacheResultOperationTests extends AbstractCacheOperationTests + operation.getKeyParameters("bar")); } @Test 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 4aba6ddb838..1c9918bd681 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 @@ -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. @@ -26,9 +26,7 @@ import javax.cache.annotation.CacheResult; import javax.cache.annotation.CacheValue; import org.junit.Before; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.springframework.cache.Cache; import org.springframework.cache.CacheManager; @@ -57,9 +55,6 @@ public class JCacheErrorHandlerTests { private SimpleService simpleService; - @Rule - public final ExpectedException thrown = ExpectedException.none(); - @Before public void setup() { 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 fcd67ab279a..57b0cd11592 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 @@ -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. @@ -29,6 +29,7 @@ import org.springframework.cache.interceptor.NamedCacheResolver; import org.springframework.cache.jcache.AbstractJCacheTests; import org.springframework.util.ReflectionUtils; +import static org.assertj.core.api.Assertions.*; import static org.junit.Assert.*; /** @@ -47,15 +48,9 @@ public class JCacheInterceptorTests extends AbstractJCacheTests { AnnotatedJCacheableService service = new AnnotatedJCacheableService(cacheManager.getCache("default")); Method m = ReflectionUtils.findMethod(AnnotatedJCacheableService.class, "cache", String.class); - try { - interceptor.execute(dummyInvoker, service, m, new Object[] {"myId"}); - } - catch (IllegalStateException ex) { - assertTrue(ex.getMessage().contains("JSR-107 only supports a single cache")); - } - catch (Throwable ex) { - fail("Unexpected: " + ex); - } + assertThatIllegalStateException().isThrownBy(() -> + interceptor.execute(dummyInvoker, service, m, new Object[] {"myId"})) + .withMessageContaining("JSR-107 only supports a single cache"); } @Test @@ -66,22 +61,15 @@ public class JCacheInterceptorTests extends AbstractJCacheTests { AnnotatedJCacheableService service = new AnnotatedJCacheableService(cacheManager.getCache("default")); Method m = ReflectionUtils.findMethod(AnnotatedJCacheableService.class, "cache", String.class); - - try { - interceptor.execute(dummyInvoker, service, m, new Object[] {"myId"}); - } - catch (IllegalStateException ex) { - assertTrue(ex.getMessage().contains("Cache could not have been resolved for")); - } - catch (Throwable ex) { - fail("Unexpected: " + ex); - } + assertThatIllegalStateException().isThrownBy(() -> + interceptor.execute(dummyInvoker, service, m, new Object[] {"myId"})) + .withMessageContaining("Cache could not have been resolved for"); } @Test public void cacheManagerMandatoryIfCacheResolverNotSet() { - thrown.expect(IllegalStateException.class); - createOperationSource(null, null, null, defaultKeyGenerator); + assertThatIllegalStateException().isThrownBy(() -> + createOperationSource(null, null, null, defaultKeyGenerator)); } @Test diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/SampleObject.java b/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/SampleObject.java index 60a2ee5fd57..f0de3c094a6 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/SampleObject.java +++ b/spring-context-support/src/test/java/org/springframework/cache/jcache/interceptor/SampleObject.java @@ -1,3 +1,19 @@ +/* + * Copyright 2002-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cache.jcache.interceptor; import javax.cache.annotation.CacheKey; diff --git a/spring-context-support/src/test/java/org/springframework/cache/jcache/support/TestableCacheKeyGenerator.java b/spring-context-support/src/test/java/org/springframework/cache/jcache/support/TestableCacheKeyGenerator.java index 98e3b3acfa7..192b390e28c 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/jcache/support/TestableCacheKeyGenerator.java +++ b/spring-context-support/src/test/java/org/springframework/cache/jcache/support/TestableCacheKeyGenerator.java @@ -1,3 +1,19 @@ +/* + * Copyright 2002-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.cache.jcache.support; import java.lang.annotation.Annotation; diff --git a/spring-context-support/src/test/java/org/springframework/cache/transaction/TransactionAwareCacheDecoratorTests.java b/spring-context-support/src/test/java/org/springframework/cache/transaction/TransactionAwareCacheDecoratorTests.java index efea1ab7418..66e1d8e70ad 100644 --- a/spring-context-support/src/test/java/org/springframework/cache/transaction/TransactionAwareCacheDecoratorTests.java +++ b/spring-context-support/src/test/java/org/springframework/cache/transaction/TransactionAwareCacheDecoratorTests.java @@ -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,9 +16,7 @@ package org.springframework.cache.transaction; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.springframework.cache.Cache; import org.springframework.cache.concurrent.ConcurrentMapCache; @@ -28,6 +26,7 @@ import org.springframework.transaction.TransactionDefinition; import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.interceptor.DefaultTransactionAttribute; +import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.junit.Assert.*; /** @@ -35,15 +34,12 @@ import static org.junit.Assert.*; */ public class TransactionAwareCacheDecoratorTests { - @Rule - public final ExpectedException thrown = ExpectedException.none(); - private final PlatformTransactionManager txManager = new CallCountingTransactionManager(); @Test public void createWithNullTarget() { - this.thrown.expect(IllegalArgumentException.class); - new TransactionAwareCacheDecorator(null); + assertThatIllegalArgumentException().isThrownBy(() -> + new TransactionAwareCacheDecorator(null)); } @Test diff --git a/spring-context-support/src/test/java/org/springframework/mail/javamail/JavaMailSenderTests.java b/spring-context-support/src/test/java/org/springframework/mail/javamail/JavaMailSenderTests.java index 6fbacbfa8ff..8f2fc199cac 100644 --- a/spring-context-support/src/test/java/org/springframework/mail/javamail/JavaMailSenderTests.java +++ b/spring-context-support/src/test/java/org/springframework/mail/javamail/JavaMailSenderTests.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. @@ -35,15 +35,14 @@ import javax.mail.internet.AddressException; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.springframework.mail.MailParseException; import org.springframework.mail.MailSendException; import org.springframework.mail.SimpleMailMessage; import org.springframework.util.ObjectUtils; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.junit.Assert.*; /** @@ -53,10 +52,6 @@ import static org.junit.Assert.*; */ public class JavaMailSenderTests { - @Rule - public final ExpectedException thrown = ExpectedException.none(); - - @Test public void javaMailSenderWithSimpleMessage() throws MessagingException, IOException { MockJavaMailSender sender = new MockJavaMailSender(); @@ -511,9 +506,8 @@ public class JavaMailSenderTests { public void testConnectionWithFailure() throws MessagingException { MockJavaMailSender sender = new MockJavaMailSender(); sender.setHost(null); - - thrown.expect(MessagingException.class); - sender.testConnection(); + assertThatExceptionOfType(MessagingException.class).isThrownBy( + sender::testConnection); } diff --git a/spring-context-support/src/test/java/org/springframework/validation/beanvalidation2/SpringValidatorAdapterTests.java b/spring-context-support/src/test/java/org/springframework/validation/beanvalidation2/SpringValidatorAdapterTests.java index 91f311639f5..3c109116547 100644 --- a/spring-context-support/src/test/java/org/springframework/validation/beanvalidation2/SpringValidatorAdapterTests.java +++ b/spring-context-support/src/test/java/org/springframework/validation/beanvalidation2/SpringValidatorAdapterTests.java @@ -519,7 +519,8 @@ public class SpringValidatorAdapterTests { .addPropertyNode(f.getName()) .addConstraintViolation(); } - } catch (IllegalAccessException ex) { + } + catch (IllegalAccessException ex) { throw new IllegalStateException(ex); } diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/AfterAdviceBindingTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/AfterAdviceBindingTests.java index 418aee87934..02e1bc8a9fe 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/AfterAdviceBindingTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/AfterAdviceBindingTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 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. @@ -27,7 +27,7 @@ import org.springframework.tests.sample.beans.ITestBean; import org.springframework.tests.sample.beans.TestBean; import static org.junit.Assert.*; -import static org.mockito.BDDMockito.*; +import static org.mockito.Mockito.*; /** * Tests for various parameter binding scenarios with before advice. diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/AfterReturningAdviceBindingTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/AfterReturningAdviceBindingTests.java index 20c7c9b9683..403b7fae8d6 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/AfterReturningAdviceBindingTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/AfterReturningAdviceBindingTests.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. @@ -27,7 +27,7 @@ import org.springframework.tests.sample.beans.ITestBean; import org.springframework.tests.sample.beans.TestBean; import static org.junit.Assert.*; -import static org.mockito.BDDMockito.*; +import static org.mockito.Mockito.*; /** * Tests for various parameter binding scenarios with before advice. diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/AfterThrowingAdviceBindingTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/AfterThrowingAdviceBindingTests.java index 3c3bb3d53c8..47f019d58fa 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/AfterThrowingAdviceBindingTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/AfterThrowingAdviceBindingTests.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. @@ -23,7 +23,7 @@ import org.springframework.aop.aspectj.AfterThrowingAdviceBindingTestAspect.Afte import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.tests.sample.beans.ITestBean; -import static org.mockito.BDDMockito.*; +import static org.mockito.Mockito.*; /** * Tests for various parameter binding scenarios with before advice. diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/AroundAdviceBindingTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/AroundAdviceBindingTests.java index a06d7f393f0..da6ffcfa134 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/AroundAdviceBindingTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/AroundAdviceBindingTests.java @@ -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. @@ -29,7 +29,7 @@ import org.springframework.tests.sample.beans.ITestBean; import org.springframework.tests.sample.beans.TestBean; import static org.junit.Assert.*; -import static org.mockito.BDDMockito.*; +import static org.mockito.Mockito.*; /** * Tests for various parameter binding scenarios with before advice. diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/BeforeAdviceBindingTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/BeforeAdviceBindingTests.java index f5de6cb2a10..e26fa7499b9 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/BeforeAdviceBindingTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/BeforeAdviceBindingTests.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. @@ -27,7 +27,7 @@ import org.springframework.tests.sample.beans.ITestBean; import org.springframework.tests.sample.beans.TestBean; import static org.junit.Assert.*; -import static org.mockito.BDDMockito.*; +import static org.mockito.Mockito.*; /** * Tests for various parameter binding scenarios with before advice. diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/PropertyDependentAspectTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/PropertyDependentAspectTests.java index cc2d7623e0b..e0351dd83ea 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/PropertyDependentAspectTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/PropertyDependentAspectTests.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. @@ -21,6 +21,7 @@ import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; import org.junit.Test; + import org.springframework.aop.framework.Advised; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/spr3064/SPR3064Tests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/spr3064/SPR3064Tests.java index 6545200a870..a23636fa53e 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/spr3064/SPR3064Tests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/spr3064/SPR3064Tests.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. diff --git a/spring-context/src/test/java/org/springframework/aop/framework/AbstractAopProxyTests.java b/spring-context/src/test/java/org/springframework/aop/framework/AbstractAopProxyTests.java index ca2f75c6d7f..ce40d0364cf 100644 --- a/spring-context/src/test/java/org/springframework/aop/framework/AbstractAopProxyTests.java +++ b/spring-context/src/test/java/org/springframework/aop/framework/AbstractAopProxyTests.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. @@ -543,7 +543,6 @@ public abstract class AbstractAopProxyTests { * Check that although a method is eligible for advice chain optimization and * direct reflective invocation, it doesn't happen if we've asked to see the proxy, * so as to guarantee a consistent programming model. - * @throws Throwable */ @Test public void testTargetCanGetInvocationEvenIfNoAdviceChain() throws Throwable { diff --git a/spring-context/src/test/java/org/springframework/aop/framework/ObjenesisProxyTests.java b/spring-context/src/test/java/org/springframework/aop/framework/ObjenesisProxyTests.java index b994589c978..47552dfa6ee 100644 --- a/spring-context/src/test/java/org/springframework/aop/framework/ObjenesisProxyTests.java +++ b/spring-context/src/test/java/org/springframework/aop/framework/ObjenesisProxyTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 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. @@ -23,7 +23,7 @@ import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import static org.hamcrest.CoreMatchers.*; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.MatcherAssert.*; /** * Integration test for Objenesis proxy creation. diff --git a/spring-context/src/test/java/org/springframework/aop/target/CommonsPool2TargetSourceTests.java b/spring-context/src/test/java/org/springframework/aop/target/CommonsPool2TargetSourceTests.java index 1bcb1161287..eef79e982bc 100644 --- a/spring-context/src/test/java/org/springframework/aop/target/CommonsPool2TargetSourceTests.java +++ b/spring-context/src/test/java/org/springframework/aop/target/CommonsPool2TargetSourceTests.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. @@ -20,9 +20,7 @@ import java.util.NoSuchElementException; import org.junit.After; import org.junit.Before; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.springframework.aop.framework.Advised; import org.springframework.beans.factory.support.DefaultListableBeanFactory; @@ -48,9 +46,6 @@ import static org.junit.Assert.*; */ public class CommonsPool2TargetSourceTests { - @Rule - public final ExpectedException thrown = ExpectedException.none(); - /** * Initial count value set in bean factory XML */ diff --git a/spring-context/src/test/java/org/springframework/cache/AbstractCacheTests.java b/spring-context/src/test/java/org/springframework/cache/AbstractCacheTests.java index 95c282e3c61..c0342ed1e70 100644 --- a/spring-context/src/test/java/org/springframework/cache/AbstractCacheTests.java +++ b/spring-context/src/test/java/org/springframework/cache/AbstractCacheTests.java @@ -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,14 +17,12 @@ package org.springframework.cache; import java.util.List; +import java.util.UUID; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicInteger; -import java.util.UUID; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.*; @@ -35,9 +33,6 @@ import static org.junit.Assert.*; */ public abstract class AbstractCacheTests { - @Rule - public final ExpectedException thrown = ExpectedException.none(); - protected final static String CACHE_NAME = "testCache"; protected abstract T getCache(); diff --git a/spring-context/src/test/java/org/springframework/cache/AbstractValueAdaptingCacheTests.java b/spring-context/src/test/java/org/springframework/cache/AbstractValueAdaptingCacheTests.java index f296268c7f4..305939f5ee1 100644 --- a/spring-context/src/test/java/org/springframework/cache/AbstractValueAdaptingCacheTests.java +++ b/spring-context/src/test/java/org/springframework/cache/AbstractValueAdaptingCacheTests.java @@ -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,21 +16,18 @@ package org.springframework.cache; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.springframework.cache.support.AbstractValueAdaptingCache; +import static org.assertj.core.api.Assertions.*; + /** * @author Stephane Nicoll */ public abstract class AbstractValueAdaptingCacheTests extends AbstractCacheTests { - @Rule - public ExpectedException thrown = ExpectedException.none(); - protected final static String CACHE_NAME_NO_NULL = "testCacheNoNull"; protected abstract T getCache(boolean allowNull); @@ -39,12 +36,10 @@ public abstract class AbstractValueAdaptingCacheTests + cache.put(key, null)) + .withMessageContaining(CACHE_NAME_NO_NULL) + .withMessageContaining("is configured to not allow null values but null was provided"); } } diff --git a/spring-context/src/test/java/org/springframework/cache/CacheReproTests.java b/spring-context/src/test/java/org/springframework/cache/CacheReproTests.java index b9aa6f80081..8581e36f4b3 100644 --- a/spring-context/src/test/java/org/springframework/cache/CacheReproTests.java +++ b/spring-context/src/test/java/org/springframework/cache/CacheReproTests.java @@ -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. @@ -21,9 +21,7 @@ import java.util.Collections; import java.util.List; import java.util.Optional; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.mockito.Mockito; import org.springframework.cache.annotation.CachePut; @@ -43,6 +41,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.lang.Nullable; import org.springframework.tests.sample.beans.TestBean; +import static org.assertj.core.api.Assertions.assertThatIllegalStateException; import static org.junit.Assert.*; import static org.mockito.Mockito.*; @@ -55,10 +54,6 @@ import static org.mockito.Mockito.*; */ public class CacheReproTests { - @Rule - public final ExpectedException thrown = ExpectedException.none(); - - @Test public void spr11124MultipleAnnotations() throws Exception { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Spr11124Config.class); @@ -129,9 +124,9 @@ public class CacheReproTests { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Spr13081Config.class); Spr13081Service bean = context.getBean(Spr13081Service.class); - this.thrown.expect(IllegalStateException.class); - this.thrown.expectMessage(MyCacheResolver.class.getName()); - bean.getSimple(null); + assertThatIllegalStateException().isThrownBy(() -> + bean.getSimple(null)) + .withMessageContaining(MyCacheResolver.class.getName()); } @Test diff --git a/spring-context/src/test/java/org/springframework/cache/annotation/AnnotationCacheOperationSourceTests.java b/spring-context/src/test/java/org/springframework/cache/annotation/AnnotationCacheOperationSourceTests.java index 4177a5129f9..5054d0599a4 100644 --- a/spring-context/src/test/java/org/springframework/cache/annotation/AnnotationCacheOperationSourceTests.java +++ b/spring-context/src/test/java/org/springframework/cache/annotation/AnnotationCacheOperationSourceTests.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. @@ -26,15 +26,14 @@ import java.util.Collection; import java.util.Collections; import java.util.Iterator; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.springframework.cache.interceptor.CacheEvictOperation; import org.springframework.cache.interceptor.CacheOperation; import org.springframework.cache.interceptor.CacheableOperation; import org.springframework.core.annotation.AliasFor; +import static org.assertj.core.api.Assertions.assertThatIllegalStateException; import static org.hamcrest.CoreMatchers.*; import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.*; @@ -46,9 +45,6 @@ import static org.junit.Assert.*; */ public class AnnotationCacheOperationSourceTests { - @Rule - public final ExpectedException exception = ExpectedException.none(); - private final AnnotationCacheOperationSource source = new AnnotationCacheOperationSource(); @@ -156,8 +152,8 @@ public class AnnotationCacheOperationSourceTests { @Test public void keyAndKeyGeneratorCannotBeSetTogether() { - this.exception.expect(IllegalStateException.class); - getOps(AnnotatedClass.class, "invalidKeyAndKeyGeneratorSet"); + assertThatIllegalStateException().isThrownBy(() -> + getOps(AnnotatedClass.class, "invalidKeyAndKeyGeneratorSet")); } @Test @@ -190,8 +186,8 @@ public class AnnotationCacheOperationSourceTests { @Test public void cacheResolverAndCacheManagerCannotBeSetTogether() { - this.exception.expect(IllegalStateException.class); - getOps(AnnotatedClass.class, "invalidCacheResolverAndCacheManagerSet"); + assertThatIllegalStateException().isThrownBy(() -> + getOps(AnnotatedClass.class, "invalidCacheResolverAndCacheManagerSet")); } @Test diff --git a/spring-context/src/test/java/org/springframework/cache/concurrent/ConcurrentMapCacheTests.java b/spring-context/src/test/java/org/springframework/cache/concurrent/ConcurrentMapCacheTests.java index ca360917605..647bd31c048 100644 --- a/spring-context/src/test/java/org/springframework/cache/concurrent/ConcurrentMapCacheTests.java +++ b/spring-context/src/test/java/org/springframework/cache/concurrent/ConcurrentMapCacheTests.java @@ -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. @@ -28,6 +28,7 @@ import org.junit.Test; import org.springframework.cache.AbstractValueAdaptingCacheTests; import org.springframework.core.serializer.support.SerializationDelegate; +import static org.assertj.core.api.Assertions.*; import static org.junit.Assert.*; /** @@ -97,10 +98,11 @@ public class ConcurrentMapCacheTests public void testNonSerializableContent() { ConcurrentMapCache serializeCache = createCacheWithStoreByValue(); - this.thrown.expect(IllegalArgumentException.class); - this.thrown.expectMessage("Failed to serialize"); - this.thrown.expectMessage(this.cache.getClass().getName()); - serializeCache.put(createRandomKey(), this.cache); + assertThatIllegalArgumentException().isThrownBy(() -> + serializeCache.put(createRandomKey(), this.cache)) + .withMessageContaining("Failed to serialize") + .withMessageContaining(this.cache.getClass().getName()); + } @Test @@ -109,10 +111,10 @@ public class ConcurrentMapCacheTests String key = createRandomKey(); this.nativeCache.put(key, "Some garbage"); - this.thrown.expect(IllegalArgumentException.class); - this.thrown.expectMessage("Failed to deserialize"); - this.thrown.expectMessage("Some garbage"); - serializeCache.get(key); + assertThatIllegalArgumentException().isThrownBy(() -> + serializeCache.get(key)) + .withMessageContaining("Failed to deserialize") + .withMessageContaining("Some garbage"); } 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 ef970d4cec8..2926593e17b 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 @@ -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. @@ -30,8 +30,8 @@ import org.springframework.cache.Cache; import org.springframework.cache.CacheManager; import org.springframework.context.ConfigurableApplicationContext; -import static org.hamcrest.Matchers.*; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.*; import static org.junit.Assert.*; /** 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 e6a4f123198..4001b38c833 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 @@ -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. @@ -20,9 +20,7 @@ import java.util.Collections; import java.util.concurrent.atomic.AtomicLong; import org.junit.Before; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.springframework.cache.Cache; import org.springframework.cache.CacheManager; @@ -38,7 +36,7 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import static org.hamcrest.CoreMatchers.*; +import static org.assertj.core.api.Assertions.*; import static org.junit.Assert.*; import static org.mockito.BDDMockito.*; @@ -47,9 +45,6 @@ import static org.mockito.BDDMockito.*; */ public class CacheErrorHandlerTests { - @Rule - public final ExpectedException thrown = ExpectedException.none(); - private Cache cache; private CacheInterceptor cacheInterceptor; @@ -100,8 +95,9 @@ public class CacheErrorHandlerTests { this.cacheInterceptor.setErrorHandler(new SimpleCacheErrorHandler()); - this.thrown.expect(is(exception)); - this.simpleService.get(0L); + assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> + this.simpleService.get(0L)) + .withMessage("Test exception on get"); } @Test @@ -120,8 +116,9 @@ public class CacheErrorHandlerTests { this.cacheInterceptor.setErrorHandler(new SimpleCacheErrorHandler()); - this.thrown.expect(is(exception)); - this.simpleService.put(0L); + assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> + this.simpleService.put(0L)) + .withMessage("Test exception on put"); } @Test @@ -140,8 +137,9 @@ public class CacheErrorHandlerTests { this.cacheInterceptor.setErrorHandler(new SimpleCacheErrorHandler()); - this.thrown.expect(is(exception)); - this.simpleService.evict(0L); + assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> + this.simpleService.evict(0L)) + .withMessage("Test exception on evict"); } @Test @@ -155,13 +153,14 @@ public class CacheErrorHandlerTests { @Test public void clearFailProperException() { - UnsupportedOperationException exception = new UnsupportedOperationException("Test exception on evict"); + UnsupportedOperationException exception = new UnsupportedOperationException("Test exception on clear"); willThrow(exception).given(this.cache).clear(); this.cacheInterceptor.setErrorHandler(new SimpleCacheErrorHandler()); - this.thrown.expect(is(exception)); - this.simpleService.clear(); + assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() -> + this.simpleService.clear()) + .withMessage("Test exception on clear"); } 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 121c94f5e55..a6a461ecc20 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 @@ -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. @@ -20,9 +20,7 @@ import java.util.concurrent.atomic.AtomicLong; import org.junit.After; import org.junit.Before; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.springframework.cache.CacheManager; import org.springframework.cache.CacheTestUtils; @@ -36,6 +34,8 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import static org.assertj.core.api.Assertions.assertThatIllegalStateException; + /** * Provides various failure scenario linked to the use of {@link Cacheable#sync()}. * @@ -44,9 +44,6 @@ import org.springframework.context.annotation.Configuration; */ public class CacheSyncFailureTests { - @Rule - public final ExpectedException thrown = ExpectedException.none(); - private ConfigurableApplicationContext context; private SimpleService simpleService; @@ -66,37 +63,37 @@ public class CacheSyncFailureTests { @Test public void unlessSync() { - this.thrown.expect(IllegalStateException.class); - this.thrown.expectMessage("@Cacheable(sync=true) does not support unless attribute"); - this.simpleService.unlessSync("key"); + assertThatIllegalStateException().isThrownBy(() -> + this.simpleService.unlessSync("key")) + .withMessageContaining("@Cacheable(sync=true) does not support unless attribute"); } @Test public void severalCachesSync() { - this.thrown.expect(IllegalStateException.class); - this.thrown.expectMessage("@Cacheable(sync=true) only allows a single cache"); - this.simpleService.severalCachesSync("key"); + assertThatIllegalStateException().isThrownBy(() -> + this.simpleService.severalCachesSync("key")) + .withMessageContaining("@Cacheable(sync=true) only allows a single cache"); } @Test public void severalCachesWithResolvedSync() { - this.thrown.expect(IllegalStateException.class); - this.thrown.expectMessage("@Cacheable(sync=true) only allows a single cache"); - this.simpleService.severalCachesWithResolvedSync("key"); + assertThatIllegalStateException().isThrownBy(() -> + this.simpleService.severalCachesWithResolvedSync("key")) + .withMessageContaining("@Cacheable(sync=true) only allows a single cache"); } @Test public void syncWithAnotherOperation() { - this.thrown.expect(IllegalStateException.class); - this.thrown.expectMessage("@Cacheable(sync=true) cannot be combined with other cache operations"); - this.simpleService.syncWithAnotherOperation("key"); + assertThatIllegalStateException().isThrownBy(() -> + this.simpleService.syncWithAnotherOperation("key")) + .withMessageContaining("@Cacheable(sync=true) cannot be combined with other cache operations"); } @Test public void syncWithTwoGetOperations() { - this.thrown.expect(IllegalStateException.class); - this.thrown.expectMessage("Only one @Cacheable(sync=true) entry is allowed"); - this.simpleService.syncWithTwoGetOperations("key"); + assertThatIllegalStateException().isThrownBy(() -> + this.simpleService.syncWithTwoGetOperations("key")) + .withMessageContaining("Only one @Cacheable(sync=true) entry is allowed"); } 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 16e90635bc3..cbfbe9e8404 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 @@ -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. @@ -18,7 +18,7 @@ package org.springframework.cache.interceptor; import org.junit.Test; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.MatcherAssert.*; import static org.hamcrest.Matchers.*; /** 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 859777048d5..ae1a43c678e 100644 --- a/spring-context/src/test/java/org/springframework/context/AbstractApplicationContextTests.java +++ b/spring-context/src/test/java/org/springframework/context/AbstractApplicationContextTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 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. @@ -24,6 +24,7 @@ import java.util.Locale; import org.junit.Before; import org.junit.Test; + import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.xml.AbstractListableBeanFactoryTests; import org.springframework.tests.sample.beans.LifecycleBean; 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 649cea16276..3e91128b32c 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 @@ -31,9 +31,9 @@ public class AggressiveFactoryBeanInstantiationTests { public void directlyRegisteredFactoryBean() { try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) { context.register(SimpleFactoryBean.class); - context.addBeanFactoryPostProcessor((factory) -> { - BeanFactoryUtils.beanNamesForTypeIncludingAncestors(factory, String.class); - }); + context.addBeanFactoryPostProcessor(factory -> + BeanFactoryUtils.beanNamesForTypeIncludingAncestors(factory, String.class) + ); context.refresh(); } } @@ -42,9 +42,9 @@ public class AggressiveFactoryBeanInstantiationTests { public void beanMethodFactoryBean() { try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) { context.register(BeanMethodConfiguration.class); - context.addBeanFactoryPostProcessor((factory) -> { - BeanFactoryUtils.beanNamesForTypeIncludingAncestors(factory, String.class); - }); + context.addBeanFactoryPostProcessor(factory -> + BeanFactoryUtils.beanNamesForTypeIncludingAncestors(factory, String.class) + ); context.refresh(); } } 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 ecdfaf81e1e..b75348f4756 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 @@ -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. @@ -107,12 +107,9 @@ public class AnnotationBeanNameGeneratorTests { assertEquals("annotationBeanNameGeneratorTests.ComponentFromNonStringMeta", beanName); } - /** - * @since 4.0.1 - * @see https://jira.spring.io/browse/SPR-11360 - */ @Test public void generateBeanNameFromComposedControllerAnnotationWithoutName() { + // SPR-11360 BeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry(); AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(ComposedControllerAnnotationWithoutName.class); String beanName = this.beanNameGenerator.generateBeanName(bd, registry); @@ -120,12 +117,9 @@ public class AnnotationBeanNameGeneratorTests { assertEquals(expectedGeneratedBeanName, beanName); } - /** - * @since 4.0.1 - * @see https://jira.spring.io/browse/SPR-11360 - */ @Test public void generateBeanNameFromComposedControllerAnnotationWithBlankName() { + // SPR-11360 BeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry(); AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition(ComposedControllerAnnotationWithBlankName.class); String beanName = this.beanNameGenerator.generateBeanName(bd, registry); @@ -133,12 +127,9 @@ public class AnnotationBeanNameGeneratorTests { assertEquals(expectedGeneratedBeanName, beanName); } - /** - * @since 4.0.1 - * @see https://jira.spring.io/browse/SPR-11360 - */ @Test public void generateBeanNameFromComposedControllerAnnotationWithStringValue() { + // SPR-11360 BeanDefinitionRegistry registry = new SimpleBeanDefinitionRegistry(); AnnotatedBeanDefinition bd = new AnnotatedGenericBeanDefinition( ComposedControllerAnnotationWithStringValue.class); 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 a0eea4fa82e..a1719d5b807 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 @@ -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. @@ -33,7 +33,7 @@ import org.springframework.context.annotation6.Jsr330NamedForScanning; import org.springframework.core.ResolvableType; import org.springframework.util.ObjectUtils; -import static java.lang.String.*; +import static java.lang.String.format; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; import static org.junit.Assert.*; 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 fd1f651c9c2..b5819ecec63 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 @@ -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. @@ -20,7 +20,6 @@ import javax.annotation.Resource; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; - import org.junit.BeforeClass; import org.junit.Test; diff --git a/spring-context/src/test/java/org/springframework/context/annotation/BeanAge.java b/spring-context/src/test/java/org/springframework/context/annotation/BeanAge.java index 7d885c56973..f37a91701f8 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation/BeanAge.java +++ b/spring-context/src/test/java/org/springframework/context/annotation/BeanAge.java @@ -1,3 +1,19 @@ +/* + * Copyright 2002-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.context.annotation; import java.lang.annotation.ElementType; 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 d1cd2b90290..1f8b4037e94 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 @@ -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. @@ -25,7 +25,7 @@ import org.junit.Test; import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition; import org.springframework.beans.factory.config.BeanDefinition; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.MatcherAssert.*; import static org.hamcrest.Matchers.*; /** 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 3b976bc14b9..c8b09d159a8 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 @@ -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. @@ -513,9 +513,9 @@ public class ClassPathScanningCandidateComponentProviderTests { private void assertBeanDefinitionType(Set candidates, Class expectedType) { - candidates.forEach(c -> { - assertThat(c, is(instanceOf(expectedType))); - }); + candidates.forEach(c -> + assertThat(c, is(instanceOf(expectedType))) + ); } 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 dd7a88548e3..66a01ea8188 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 @@ -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. @@ -33,7 +33,6 @@ 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.springframework.aop.support.AopUtils; @@ -393,7 +392,9 @@ class ComponentScanWithCustomTypeFilter { @SuppressWarnings({ "rawtypes", "serial", "unchecked" }) public static CustomAutowireConfigurer customAutowireConfigurer() { CustomAutowireConfigurer cac = new CustomAutowireConfigurer(); - cac.setCustomQualifierTypes(new HashSet() {{ add(ComponentScanParserTests.CustomAnnotation.class); }}); + cac.setCustomQualifierTypes(new HashSet() {{ + add(ComponentScanParserTests.CustomAnnotation.class); + }}); return cac; } 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 810babd251c..cbc5ee97006 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2011 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. @@ -24,7 +24,7 @@ import org.springframework.context.annotation.componentscan.level2.Level2Config; import org.springframework.context.annotation.componentscan.level3.Level3Component; import static org.hamcrest.CoreMatchers.*; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.MatcherAssert.*; /** * Tests ensuring that configuration classes marked with @ComponentScan 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 1338560ec35..e84f8e93ae5 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 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,9 +16,9 @@ package org.springframework.context.annotation; -import org.junit.Rule; +import example.scannable.FooService; +import example.scannable.ScopedProxyTestBean; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.springframework.aop.support.AopUtils; import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; @@ -26,10 +26,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.tests.context.SimpleMapScope; import org.springframework.util.SerializationTestUtils; -import example.scannable.FooService; -import example.scannable.ScopedProxyTestBean; - -import static org.hamcrest.CoreMatchers.*; +import static org.assertj.core.api.Assertions.*; import static org.junit.Assert.*; /** @@ -39,10 +36,6 @@ import static org.junit.Assert.*; */ public class ComponentScanParserScopedProxyTests { - @Rule - public final ExpectedException exception = ExpectedException.none(); - - @Test public void testDefaultScopedProxy() { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( @@ -105,11 +98,10 @@ public class ComponentScanParserScopedProxyTests { @Test @SuppressWarnings("resource") public void testInvalidConfigScopedProxy() throws Exception { - exception.expect(BeanDefinitionParsingException.class); - exception.expectMessage(containsString("Cannot define both 'scope-resolver' and 'scoped-proxy' on tag")); - exception.expectMessage(containsString("Offending resource: class path resource [org/springframework/context/annotation/scopedProxyInvalidConfigTests.xml]")); - - new ClassPathXmlApplicationContext("org/springframework/context/annotation/scopedProxyInvalidConfigTests.xml"); + assertThatExceptionOfType(BeanDefinitionParsingException.class).isThrownBy(() -> + new ClassPathXmlApplicationContext("org/springframework/context/annotation/scopedProxyInvalidConfigTests.xml")) + .withMessageContaining("Cannot define both 'scope-resolver' and 'scoped-proxy' on tag") + .withMessageContaining("Offending resource: class path resource [org/springframework/context/annotation/scopedProxyInvalidConfigTests.xml]"); } } 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 d556a229c95..3f13a6a0215 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 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. @@ -25,7 +25,7 @@ import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import org.springframework.tests.sample.beans.TestBean; import static org.hamcrest.CoreMatchers.*; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.MatcherAssert.*; /** * Tests semantics of declaring {@link BeanFactoryPostProcessor}-returning @Bean 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 14a2f116e4f..5510e985b39 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 @@ -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. @@ -24,7 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.tests.sample.beans.TestBean; import static org.hamcrest.CoreMatchers.*; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.MatcherAssert.*; /** * Tests cornering the issue reported in SPR-8080. If the product of a @Bean method 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 226366e5f87..34177184f7c 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 @@ -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. @@ -31,8 +31,8 @@ import org.springframework.core.type.AnnotatedTypeMetadata; import org.springframework.core.type.AnnotationMetadata; import org.springframework.stereotype.Component; -import static org.hamcrest.Matchers.*; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.*; import static org.junit.Assert.*; /** 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 e3eed89c1e4..1875a401b04 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 @@ -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. @@ -25,7 +25,7 @@ import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.support.GenericXmlApplicationContext; import static org.hamcrest.CoreMatchers.*; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.MatcherAssert.*; /** * @author Chris Beams 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 4d0bc89fd8e..d17ae9b4518 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 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. @@ -24,7 +24,8 @@ import org.springframework.context.annotation.EnableLoadTimeWeaving.AspectJWeavi import org.springframework.context.support.GenericXmlApplicationContext; import org.springframework.instrument.classloading.LoadTimeWeaver; -import static org.mockito.BDDMockito.*; +import static org.mockito.ArgumentMatchers.*; +import static org.mockito.Mockito.*; /** * Unit tests for @EnableLoadTimeWeaving 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 8b239bd510a..f7b6bf9463c 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 @@ -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. @@ -36,7 +36,7 @@ import org.springframework.core.io.ResourceLoader; import org.springframework.core.type.AnnotationMetadata; import static org.hamcrest.CoreMatchers.*; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.MatcherAssert.*; /** * Integration tests for {@link ImportBeanDefinitionRegistrar}. 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 4916ca2d9e3..fdc52eb3191 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 @@ -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. @@ -53,8 +53,10 @@ import org.springframework.lang.Nullable; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.MatcherAssert.*; import static org.hamcrest.Matchers.*; +import static org.mockito.ArgumentMatchers.*; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.*; /** @@ -154,7 +156,7 @@ public class ImportSelectorTests { ordered.verify(beanFactory).registerBeanDefinition(eq("e"), any()); ordered.verify(beanFactory).registerBeanDefinition(eq("c"), any()); assertThat(TestImportGroup.instancesCount.get(), equalTo(2)); - assertThat(TestImportGroup.imports.size(), equalTo(2)); + assertThat(TestImportGroup.imports.size(), equalTo(2)); assertThat(TestImportGroup.allImports(), hasEntry( is(ParentConfiguration1.class.getName()), IsIterableContainingInOrder.contains(DeferredImportSelector1.class.getName(), @@ -529,7 +531,7 @@ public class ImportSelectorTests { static Map> allImports() { return TestImportGroup.imports.entrySet() .stream() - .collect(Collectors.toMap((entry) -> entry.getKey().getClassName(), + .collect(Collectors.toMap(entry -> entry.getKey().getClassName(), Map.Entry::getValue)); } private final List instanceImports = new ArrayList<>(); 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 fe01e16ae59..ec9502311a8 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2011 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. @@ -24,7 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import static org.hamcrest.CoreMatchers.*; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.MatcherAssert.*; /** * Tests changes introduced for SPR-8874, allowing beans of primitive types to be looked 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 dc2c43b928d..47ee37f94fc 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 @@ -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. @@ -25,9 +25,7 @@ import java.util.Iterator; import java.util.Properties; import javax.inject.Inject; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.springframework.beans.factory.BeanDefinitionStoreException; import org.springframework.beans.factory.FactoryBean; @@ -40,6 +38,7 @@ import org.springframework.core.io.support.PropertiesLoaderUtils; import org.springframework.core.io.support.PropertySourceFactory; import org.springframework.tests.sample.beans.TestBean; +import static org.assertj.core.api.Assertions.*; import static org.hamcrest.CoreMatchers.*; import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.*; @@ -53,9 +52,6 @@ import static org.junit.Assert.*; */ public class PropertySourceAnnotationTests { - @Rule - public ExpectedException thrown = ExpectedException.none(); - @Test public void withExplicitName() { @@ -226,9 +222,9 @@ public class PropertySourceAnnotationTests { @Test public void withMissingPropertySource() { - thrown.expect(BeanDefinitionStoreException.class); - thrown.expectCause(isA(FileNotFoundException.class)); - new AnnotationConfigApplicationContext(ConfigWithMissingPropertySource.class); + assertThatExceptionOfType(BeanDefinitionStoreException.class).isThrownBy(() -> + new AnnotationConfigApplicationContext(ConfigWithMissingPropertySource.class)) + .withCauseInstanceOf(FileNotFoundException.class); } @Test 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 e88b8e90d28..715d474af2f 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 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. @@ -23,7 +23,7 @@ import org.springframework.context.annotation.role.ComponentWithRole; import org.springframework.context.annotation.role.ComponentWithoutRole; import static org.hamcrest.CoreMatchers.*; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.MatcherAssert.*; /** * Tests the use of the @Role and @Description annotation on @Bean methods and @Component classes. 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 25c2f2066b9..fed1426f4b9 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 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,13 +17,12 @@ package org.springframework.context.annotation; import org.junit.After; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.springframework.beans.factory.BeanCreationException; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.hamcrest.MatcherAssert.*; import static org.hamcrest.core.Is.*; /** @@ -31,9 +30,6 @@ import static org.hamcrest.core.Is.*; */ public class Spr12278Tests { - @Rule - public final ExpectedException thrown = ExpectedException.none(); - private AnnotationConfigApplicationContext context; @After @@ -59,10 +55,9 @@ public class Spr12278Tests { @Test public void componentTwoSpecificConstructorsNoHint() { - thrown.expect(BeanCreationException.class); - thrown.expectMessage(NoSuchMethodException.class.getName()); - new AnnotationConfigApplicationContext(BaseConfiguration.class, - TwoSpecificConstructorsComponent.class); + assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() -> + new AnnotationConfigApplicationContext(BaseConfiguration.class, TwoSpecificConstructorsComponent.class)) + .withMessageContaining(NoSuchMethodException.class.getName()); } 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 96ab4214ed1..f7347718c1c 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 @@ -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. @@ -23,7 +23,7 @@ import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import static org.hamcrest.CoreMatchers.*; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.MatcherAssert.*; /** * Tests to verify that FactoryBean semantics are the same in Configuration 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 7f77d0bb723..017ea049198 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 @@ -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. @@ -22,11 +22,13 @@ import org.junit.Test; import org.springframework.beans.PropertyValues; import org.springframework.beans.factory.FactoryBean; +import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor; import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter; +import org.springframework.beans.factory.support.AbstractBeanFactory; import org.springframework.beans.factory.support.RootBeanDefinition; import static org.hamcrest.CoreMatchers.*; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.MatcherAssert.*; /** * Unit tests for SPR-8954, in which a custom {@link InstantiationAwareBeanPostProcessor} 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 30cfc9fcd95..467d870a88f 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 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. @@ -28,7 +28,7 @@ import org.springframework.context.annotation.Import; import org.springframework.stereotype.Component; import static org.hamcrest.CoreMatchers.*; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.MatcherAssert.*; /** * Unit tests ensuring that configuration class bean names as expressed via @Configuration 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 ed69fa8c1ff..e50815c7c7a 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 @@ -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. @@ -36,7 +36,7 @@ import org.springframework.core.io.ClassPathResource; import org.springframework.tests.sample.beans.TestBean; import static org.hamcrest.CoreMatchers.*; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.MatcherAssert.*; /** * System tests covering use of AspectJ {@link Aspect}s in conjunction with {@link Configuration} classes. 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 68763897894..8df4f819f85 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,9 +24,7 @@ import java.util.function.Supplier; import javax.annotation.Resource; import javax.inject.Provider; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.springframework.beans.factory.BeanClassLoaderAware; import org.springframework.beans.factory.BeanFactory; @@ -60,6 +58,7 @@ import org.springframework.tests.sample.beans.ITestBean; import org.springframework.tests.sample.beans.NestedTestBean; import org.springframework.tests.sample.beans.TestBean; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.junit.Assert.*; /** @@ -72,10 +71,6 @@ import static org.junit.Assert.*; */ public class ConfigurationClassProcessingTests { - @Rule - public final ExpectedException exception = ExpectedException.none(); - - @Test public void customBeanNameIsRespectedWhenConfiguredViaNameAttribute() { customBeanNameIsRespected(ConfigWithBeanWithCustomName.class, @@ -97,8 +92,8 @@ public class ConfigurationClassProcessingTests { assertSame(testBeanSupplier.get(), ac.getBean(beanName)); // method name should not be registered - exception.expect(NoSuchBeanDefinitionException.class); - ac.getBean("methodName"); + assertThatExceptionOfType(NoSuchBeanDefinitionException.class).isThrownBy(() -> + ac.getBean("methodName")); } @Test @@ -121,8 +116,8 @@ public class ConfigurationClassProcessingTests { Arrays.stream(factory.getAliases(beanName)).map(factory::getBean).forEach(alias -> assertSame(testBean, alias)); // method name should not be registered - exception.expect(NoSuchBeanDefinitionException.class); - factory.getBean("methodName"); + assertThatExceptionOfType(NoSuchBeanDefinitionException.class).isThrownBy(() -> + factory.getBean("methodName")); } @Test // SPR-11830 @@ -145,8 +140,8 @@ public class ConfigurationClassProcessingTests { @Test public void testFinalBeanMethod() { - exception.expect(BeanDefinitionParsingException.class); - initBeanFactory(ConfigWithFinalBean.class); + assertThatExceptionOfType(BeanDefinitionParsingException.class).isThrownBy(() -> + initBeanFactory(ConfigWithFinalBean.class)); } @Test 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 698c341f5e8..52b89cbb578 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 @@ -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. @@ -27,7 +27,7 @@ import org.springframework.tests.sample.beans.ITestBean; import org.springframework.tests.sample.beans.TestBean; import static org.hamcrest.CoreMatchers.*; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.MatcherAssert.*; /** * A configuration class that registers a non-static placeholder configurer {@code @Bean} 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 70d2f7c00cc..190a7a13b0b 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 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. @@ -27,7 +27,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.tests.sample.beans.TestBean; import static org.hamcrest.CoreMatchers.*; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.MatcherAssert.*; /** * Ensures that @Configuration is supported properly as a meta-annotation. 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 4cbf44a0950..4609644122c 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 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. @@ -30,7 +30,7 @@ import org.springframework.context.annotation.Import; import org.springframework.tests.sample.beans.TestBean; import static org.hamcrest.CoreMatchers.*; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.MatcherAssert.*; /** * Tests that @Import may be used both as a locally declared and meta-declared 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 941419cbe9b..271f8d0bb07 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2011 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. @@ -23,7 +23,7 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import static org.hamcrest.CoreMatchers.*; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.MatcherAssert.*; /** * Reproduces SPR-8756, which has been marked as "won't fix" for reasons 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 91945014e14..762a9a25d4e 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 @@ -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. @@ -25,7 +25,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Scope; import org.springframework.context.annotation.ScopedProxyMode; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.MatcherAssert.*; import static org.hamcrest.Matchers.*; /** 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 e0283e79008..3a8a56a3db3 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 @@ -30,7 +30,7 @@ import org.springframework.context.annotation.Import; import org.springframework.context.annotation.configuration.spr9031.scanpackage.Spr9031Component; import static org.hamcrest.CoreMatchers.*; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.MatcherAssert.*; /** * Unit tests cornering bug SPR-9031. 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 495439d3891..fb42253056c 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 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. @@ -26,7 +26,7 @@ import org.springframework.context.annotation.Import; import org.springframework.context.annotation.spr10546.scanpackage.AEnclosingConfig; import static org.hamcrest.CoreMatchers.*; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.MatcherAssert.*; /** * @author Rob Winch 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 bdcb7919409..3704e832fbb 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 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. @@ -25,7 +25,7 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext import org.springframework.stereotype.Component; import static org.hamcrest.CoreMatchers.*; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.MatcherAssert.*; /** * Tests cornering the regression reported in SPR-8761. diff --git a/spring-context/src/test/java/org/springframework/context/annotation6/ComponentForScanning.java b/spring-context/src/test/java/org/springframework/context/annotation6/ComponentForScanning.java index 8307f58a0bc..167ec8e0a2b 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation6/ComponentForScanning.java +++ b/spring-context/src/test/java/org/springframework/context/annotation6/ComponentForScanning.java @@ -1,3 +1,19 @@ +/* + * Copyright 2002-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.context.annotation6; import org.springframework.stereotype.Component; diff --git a/spring-context/src/test/java/org/springframework/context/annotation6/ConfigForScanning.java b/spring-context/src/test/java/org/springframework/context/annotation6/ConfigForScanning.java index 944f3c7fbc6..74875917f50 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation6/ConfigForScanning.java +++ b/spring-context/src/test/java/org/springframework/context/annotation6/ConfigForScanning.java @@ -1,3 +1,19 @@ +/* + * Copyright 2002-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.context.annotation6; import org.springframework.context.annotation.Bean; diff --git a/spring-context/src/test/java/org/springframework/context/annotation6/Jsr330NamedForScanning.java b/spring-context/src/test/java/org/springframework/context/annotation6/Jsr330NamedForScanning.java index 49567880a3f..d474a99d4a4 100644 --- a/spring-context/src/test/java/org/springframework/context/annotation6/Jsr330NamedForScanning.java +++ b/spring-context/src/test/java/org/springframework/context/annotation6/Jsr330NamedForScanning.java @@ -1,3 +1,19 @@ +/* + * Copyright 2002-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.context.annotation6; import javax.inject.Named; 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 abb272c2665..2291126015d 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 @@ -31,9 +31,7 @@ import javax.annotation.PostConstruct; import org.junit.After; import org.junit.Ignore; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.springframework.aop.framework.Advised; import org.springframework.aop.support.AopUtils; @@ -66,6 +64,7 @@ import org.springframework.util.Assert; import org.springframework.validation.annotation.Validated; import org.springframework.validation.beanvalidation.MethodValidationPostProcessor; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; import static org.junit.Assert.*; @@ -76,9 +75,6 @@ import static org.junit.Assert.*; */ public class AnnotationDrivenEventListenerTests { - @Rule - public final ExpectedException thrown = ExpectedException.none(); - private ConfigurableApplicationContext context; private EventCollector eventCollector; @@ -162,10 +158,10 @@ public class AnnotationDrivenEventListenerTests { failingContext.register(BasicConfiguration.class, InvalidMethodSignatureEventListener.class); - this.thrown.expect(BeanInitializationException.class); - this.thrown.expectMessage(InvalidMethodSignatureEventListener.class.getName()); - this.thrown.expectMessage("cannotBeCalled"); - failingContext.refresh(); + assertThatExceptionOfType(BeanInitializationException.class).isThrownBy(() -> + failingContext.refresh()) + .withMessageContaining(InvalidMethodSignatureEventListener.class.getName()) + .withMessageContaining("cannotBeCalled"); } @Test 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 69968f878e5..039984b5697 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 @@ -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. @@ -49,6 +49,7 @@ import org.springframework.tests.sample.beans.TestBean; import org.springframework.util.ReflectionUtils; import static org.junit.Assert.*; +import static org.mockito.ArgumentMatchers.*; import static org.mockito.BDDMockito.*; /** 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 5a8bc6fba5f..0fec681fa79 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 @@ -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. @@ -20,9 +20,7 @@ import java.io.IOException; import java.lang.reflect.Method; import java.lang.reflect.UndeclaredThrowableException; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.springframework.aop.framework.ProxyFactory; import org.springframework.context.ApplicationContext; @@ -33,9 +31,10 @@ import org.springframework.core.ResolvableTypeProvider; import org.springframework.core.annotation.Order; import org.springframework.util.ReflectionUtils; -import static org.hamcrest.Matchers.*; -import static org.hamcrest.core.Is.is; +import static org.assertj.core.api.Assertions.*; import static org.junit.Assert.*; +import static org.mockito.ArgumentMatchers.*; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.*; /** @@ -43,9 +42,6 @@ import static org.mockito.Mockito.*; */ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEventListenerTests { - @Rule - public final ExpectedException thrown = ExpectedException.none(); - private final SampleEvents sampleEvents = spy(new SampleEvents()); private final ApplicationContext context = mock(ApplicationContext.class); @@ -139,23 +135,23 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv public void listenerWithTooManyParameters() { Method method = ReflectionUtils.findMethod( SampleEvents.class, "tooManyParameters", String.class, String.class); - this.thrown.expect(IllegalStateException.class); - createTestInstance(method); + assertThatIllegalStateException().isThrownBy(() -> + createTestInstance(method)); } @Test public void listenerWithNoParameter() { Method method = ReflectionUtils.findMethod(SampleEvents.class, "noParameter"); - this.thrown.expect(IllegalStateException.class); - createTestInstance(method); + assertThatIllegalStateException().isThrownBy(() -> + createTestInstance(method)); } @Test public void listenerWithMoreThanOneParameter() { Method method = ReflectionUtils.findMethod( SampleEvents.class, "moreThanOneParameter", String.class, Integer.class); - this.thrown.expect(IllegalStateException.class); - createTestInstance(method); + assertThatIllegalStateException().isThrownBy(() -> + createTestInstance(method)); } @Test @@ -225,10 +221,10 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv SampleEvents.class, "generateRuntimeException", GenericTestEvent.class); GenericTestEvent event = createGenericTestEvent("fail"); - this.thrown.expect(IllegalStateException.class); - this.thrown.expectMessage("Test exception"); - this.thrown.expectCause(is((Throwable) isNull())); - invokeListener(method, event); + assertThatIllegalStateException().isThrownBy(() -> + invokeListener(method, event)) + .withMessageContaining("Test exception") + .withNoCause(); } @Test @@ -237,9 +233,9 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv SampleEvents.class, "generateCheckedException", GenericTestEvent.class); GenericTestEvent event = createGenericTestEvent("fail"); - this.thrown.expect(UndeclaredThrowableException.class); - this.thrown.expectCause(is(instanceOf(IOException.class))); - invokeListener(method, event); + assertThatExceptionOfType(UndeclaredThrowableException.class).isThrownBy(() -> + invokeListener(method, event)) + .withCauseInstanceOf(IOException.class); } @Test @@ -254,9 +250,9 @@ public class ApplicationListenerMethodAdapterTests extends AbstractApplicationEv InvalidProxyTestBean.class, "handleIt2", ApplicationEvent.class); StaticApplicationListenerMethodAdapter listener = new StaticApplicationListenerMethodAdapter(method, bean); - this.thrown.expect(IllegalStateException.class); - this.thrown.expectMessage("handleIt2"); - listener.onApplicationEvent(createGenericTestEvent("test")); + assertThatIllegalStateException().isThrownBy(() -> + listener.onApplicationEvent(createGenericTestEvent("test"))) + .withMessageContaining("handleIt2"); } @Test 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 e4e4f788684..48cc0ae2d55 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 @@ -32,7 +32,7 @@ import org.springframework.tests.sample.beans.ITestBean; import org.springframework.tests.sample.beans.TestBean; import static org.junit.Assert.*; -import static org.mockito.BDDMockito.*; +import static org.mockito.Mockito.*; /** * @author Dmitriy Kopylenko 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 88b4471b8dc..614de777ac3 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 @@ -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,6 +17,7 @@ package org.springframework.context.expression; import org.junit.Test; + import org.springframework.beans.factory.BeanIsNotAFactoryException; import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.NoSuchBeanDefinitionException; 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 01b827d7fbf..ec0509face8 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 @@ -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. @@ -20,6 +20,7 @@ import java.util.HashMap; import java.util.Map; import org.junit.Test; + import org.springframework.expression.Expression; import org.springframework.expression.spel.standard.SpelCompiler; import org.springframework.expression.spel.standard.SpelExpressionParser; 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 fa5391ebe50..244fe683262 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 @@ -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. @@ -19,14 +19,13 @@ package org.springframework.context.index; import java.io.IOException; import java.util.Set; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.springframework.core.io.ClassPathResource; +import static org.assertj.core.api.Assertions.*; +import static org.hamcrest.MatcherAssert.*; import static org.hamcrest.Matchers.*; -import static org.hamcrest.MatcherAssert.assertThat; /** * Tests for {@link CandidateComponentsIndexLoader}. @@ -35,10 +34,6 @@ import static org.hamcrest.MatcherAssert.assertThat; */ public class CandidateComponentsIndexLoaderTests { - @Rule - public final ExpectedException thrown = ExpectedException.none(); - - @Test public void validateIndexIsDisabledByDefault() { CandidateComponentsIndex index = CandidateComponentsIndexLoader.loadIndex(null); @@ -102,11 +97,10 @@ public class CandidateComponentsIndexLoaderTests { @Test public void loadIndexWithException() throws IOException { final IOException cause = new IOException("test exception"); - this.thrown.expect(IllegalStateException.class); - this.thrown.expectMessage("Unable to load indexes"); - this.thrown.expectCause(is(cause)); - CandidateComponentsIndexLoader.loadIndex(new CandidateComponentsTestClassLoader( - getClass().getClassLoader(), cause)); + assertThatIllegalStateException().isThrownBy(() -> { + CandidateComponentsTestClassLoader classLoader = new CandidateComponentsTestClassLoader(getClass().getClassLoader(), cause); + CandidateComponentsIndexLoader.loadIndex(classLoader); + }).withMessageContaining("Unable to load indexes").withCause(cause); } } 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 1eaed8cc031..84a182da135 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 @@ -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. @@ -23,7 +23,7 @@ import java.util.Set; import org.junit.Test; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.MatcherAssert.*; import static org.hamcrest.Matchers.*; /** 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 7375e2212ad..5cfb3b7b347 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 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. @@ -25,7 +25,7 @@ import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.core.env.Environment; import static org.hamcrest.CoreMatchers.*; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.MatcherAssert.*; /** * Tests covering the integration of the {@link Environment} into 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 208e3489f5b..f68e583f816 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 @@ -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. @@ -31,9 +31,9 @@ import org.springframework.core.env.AbstractEnvironment; import org.springframework.core.env.StandardEnvironmentTests; import org.springframework.stereotype.Component; -import static java.lang.String.format; +import static java.lang.String.*; import static org.hamcrest.CoreMatchers.*; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.MatcherAssert.*; /** * Tests integration between Environment and SecurityManagers. See SPR-9970. diff --git a/spring-context/src/test/java/org/springframework/context/support/FactoryBeanAndApplicationListener.java b/spring-context/src/test/java/org/springframework/context/support/FactoryBeanAndApplicationListener.java index cd68925cc97..c392ed73e7d 100644 --- a/spring-context/src/test/java/org/springframework/context/support/FactoryBeanAndApplicationListener.java +++ b/spring-context/src/test/java/org/springframework/context/support/FactoryBeanAndApplicationListener.java @@ -1,3 +1,19 @@ +/* + * Copyright 2002-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.context.support; import org.springframework.beans.factory.FactoryBean; 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 650196ff835..8f225e44132 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 @@ -1,3 +1,19 @@ +/* + * Copyright 2002-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.context.support; import org.junit.Test; @@ -6,7 +22,7 @@ import org.springframework.context.ApplicationContext; import org.springframework.util.ClassUtils; import static org.hamcrest.CoreMatchers.*; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.MatcherAssert.*; /** * Unit tests for {@link GenericXmlApplicationContext}. 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 c9f40d4562d..c675c94c58e 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 @@ -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. @@ -19,9 +19,7 @@ package org.springframework.context.support; import java.util.Optional; import java.util.Properties; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.springframework.beans.factory.BeanDefinitionStoreException; import org.springframework.beans.factory.support.DefaultListableBeanFactory; @@ -35,6 +33,7 @@ import org.springframework.mock.env.MockEnvironment; import org.springframework.mock.env.MockPropertySource; import org.springframework.tests.sample.beans.TestBean; +import static org.assertj.core.api.Assertions.assertThatIllegalStateException; import static org.hamcrest.CoreMatchers.*; import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.*; @@ -47,9 +46,6 @@ import static org.springframework.beans.factory.support.BeanDefinitionBuilder.*; */ public class PropertySourcesPlaceholderConfigurerTests { - @Rule - public ExpectedException thrown = ExpectedException.none(); - @Test public void replacementFromEnvironmentProperties() { @@ -251,7 +247,9 @@ public class PropertySourcesPlaceholderConfigurerTests { PropertySourcesPlaceholderConfigurer ppc = new PropertySourcesPlaceholderConfigurer(); ppc.setLocalOverride(override); - ppc.setProperties(new Properties() {{ setProperty("foo", "local"); }}); + ppc.setProperties(new Properties() {{ + setProperty("foo", "local"); + }}); ppc.setEnvironment(new MockEnvironment().withProperty("foo", "enclosing")); ppc.postProcessBeanFactory(bf); if (override) { @@ -327,8 +325,8 @@ public class PropertySourcesPlaceholderConfigurerTests { @Test public void getAppliedPropertySourcesTooEarly() throws Exception { PropertySourcesPlaceholderConfigurer ppc = new PropertySourcesPlaceholderConfigurer(); - thrown.expect(IllegalStateException.class); - ppc.getAppliedPropertySources(); + assertThatIllegalStateException().isThrownBy( + ppc::getAppliedPropertySources); } @Test 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 6b66d14cbfa..f40043f3d3d 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 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. @@ -21,7 +21,6 @@ import java.util.Map; import org.junit.AfterClass; import org.junit.BeforeClass; - import org.junit.Test; import org.springframework.beans.factory.BeanCreationException; @@ -30,7 +29,7 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.context.ConfigurableApplicationContext; import static org.hamcrest.CoreMatchers.*; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.MatcherAssert.*; import static org.springframework.beans.factory.support.BeanDefinitionBuilder.*; /** 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 b5bb82ebe7e..c943fc5b5dd 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 @@ -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. @@ -21,9 +21,7 @@ import java.util.HashMap; import java.util.Locale; import java.util.Map; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.springframework.beans.MutablePropertyValues; import org.springframework.beans.factory.support.PropertiesBeanDefinitionReader; @@ -35,6 +33,7 @@ import org.springframework.context.MessageSourceResolvable; import org.springframework.context.NoSuchMessageException; import org.springframework.core.io.ClassPathResource; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.junit.Assert.*; /** @@ -55,9 +54,6 @@ public class StaticMessageSourceTests extends AbstractApplicationContextTests { protected StaticApplicationContext sac; - @Rule - public final ExpectedException exception = ExpectedException.none(); - @Test @Override @@ -183,8 +179,8 @@ public class StaticMessageSourceTests extends AbstractApplicationContextTests { String[] codes4 = new String[] {"message.format.example99", "message.format.example98"}; MessageSourceResolvable resolvable4 = new DefaultMessageSourceResolvable(codes4); - exception.expect(NoSuchMessageException.class); - sac.getMessage(resolvable4, Locale.US); + assertThatExceptionOfType(NoSuchMessageException.class).isThrownBy(() -> + sac.getMessage(resolvable4, Locale.US)); } @Override 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 e594c66a56b..88171f2cf36 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 @@ -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. @@ -26,13 +26,12 @@ import java.util.TimeZone; import org.joda.time.DateTimeZone; import org.joda.time.format.DateTimeFormat; import org.joda.time.format.DateTimeFormatter; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.springframework.format.annotation.DateTimeFormat.ISO; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.assertj.core.api.Assertions.assertThatIllegalStateException; +import static org.hamcrest.MatcherAssert.*; import static org.hamcrest.Matchers.*; /** @@ -45,9 +44,6 @@ public class DateFormatterTests { private static final TimeZone UTC = TimeZone.getTimeZone("UTC"); - @Rule - public ExpectedException thrown = ExpectedException.none(); - @Test public void shouldPrintAndParseDefault() throws Exception { @@ -175,9 +171,9 @@ public class DateFormatterTests { public void shouldThrowOnUnsupportedStylePattern() throws Exception { DateFormatter formatter = new DateFormatter(); formatter.setStylePattern("OO"); - thrown.expect(IllegalStateException.class); - thrown.expectMessage("Unsupported style pattern 'OO'"); - formatter.parse("2009", Locale.US); + assertThatIllegalStateException().isThrownBy(() -> + formatter.parse("2009", Locale.US)) + .withMessageContaining("Unsupported style pattern 'OO'"); } @Test 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 2eb80a9e398..1c22b2124e4 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 @@ -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. @@ -20,8 +20,8 @@ import org.joda.time.format.DateTimeFormat; import org.joda.time.format.DateTimeFormatter; import org.junit.Test; +import static org.hamcrest.MatcherAssert.*; import static org.hamcrest.Matchers.*; -import static org.hamcrest.MatcherAssert.assertThat; /** * @author Phillip Webb 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 1171d4bf0a0..fa919d435b0 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 @@ -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. @@ -21,8 +21,8 @@ import java.time.format.FormatStyle; import org.junit.Test; +import static org.hamcrest.MatcherAssert.*; import static org.hamcrest.Matchers.*; -import static org.hamcrest.MatcherAssert.assertThat; /** * @author Phillip Webb 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 74b4dec54ee..c3bb3fdec0d 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 @@ -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. @@ -34,9 +34,7 @@ import javax.management.ObjectInstance; import javax.management.ObjectName; import javax.management.modelmbean.ModelMBeanInfo; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.springframework.aop.framework.ProxyFactory; import org.springframework.beans.factory.FactoryBean; @@ -57,6 +55,8 @@ import org.springframework.jmx.support.RegistrationPolicy; import org.springframework.tests.aop.interceptor.NopInterceptor; import org.springframework.tests.sample.beans.TestBean; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.junit.Assert.*; /** @@ -72,9 +72,6 @@ import static org.junit.Assert.*; */ public class MBeanExporterTests extends AbstractMBeanServerTests { - @Rule - public final ExpectedException thrown = ExpectedException.none(); - private static final String OBJECT_NAME = "spring:test=jmxMBeanAdaptor"; @@ -85,8 +82,8 @@ public class MBeanExporterTests extends AbstractMBeanServerTests { listeners.put("*", null); MBeanExporter exporter = new MBeanExporter(); - thrown.expect(IllegalArgumentException.class); - exporter.setNotificationListenerMappings(listeners); + assertThatIllegalArgumentException().isThrownBy(() -> + exporter.setNotificationListenerMappings(listeners)); } @Test @@ -179,8 +176,8 @@ public class MBeanExporterTests extends AbstractMBeanServerTests { ObjectInstance instance = server.getObjectInstance(ObjectNameManager.getInstance("spring:mbean=true")); assertNotNull(instance); - thrown.expect(InstanceNotFoundException.class); - server.getObjectInstance(ObjectNameManager.getInstance("spring:mbean=false")); + assertThatExceptionOfType(InstanceNotFoundException.class).isThrownBy(() -> + server.getObjectInstance(ObjectNameManager.getInstance("spring:mbean=false"))); } finally { ctx.close(); @@ -484,36 +481,36 @@ public class MBeanExporterTests extends AbstractMBeanServerTests { @Test public void testSetAutodetectModeToOutOfRangeNegativeValue() { MBeanExporter exporter = new MBeanExporter(); - thrown.expect(IllegalArgumentException.class); - exporter.setAutodetectMode(-1); + assertThatIllegalArgumentException().isThrownBy(() -> + exporter.setAutodetectMode(-1)); } @Test public void testSetAutodetectModeToOutOfRangePositiveValue() { MBeanExporter exporter = new MBeanExporter(); - thrown.expect(IllegalArgumentException.class); - exporter.setAutodetectMode(5); + assertThatIllegalArgumentException().isThrownBy(() -> + exporter.setAutodetectMode(5)); } @Test public void testSetAutodetectModeNameToAnEmptyString() { MBeanExporter exporter = new MBeanExporter(); - thrown.expect(IllegalArgumentException.class); - exporter.setAutodetectModeName(""); + assertThatIllegalArgumentException().isThrownBy(() -> + exporter.setAutodetectModeName("")); } @Test public void testSetAutodetectModeNameToAWhitespacedString() { MBeanExporter exporter = new MBeanExporter(); - thrown.expect(IllegalArgumentException.class); - exporter.setAutodetectModeName(" \t"); + assertThatIllegalArgumentException().isThrownBy(() -> + exporter.setAutodetectModeName(" \t")); } @Test public void testSetAutodetectModeNameToARubbishValue() { MBeanExporter exporter = new MBeanExporter(); - thrown.expect(IllegalArgumentException.class); - exporter.setAutodetectModeName("That Hansel is... *sssooo* hot right now!"); + assertThatIllegalArgumentException().isThrownBy(() -> + exporter.setAutodetectModeName("That Hansel is... *sssooo* hot right now!")); } @Test @@ -522,16 +519,16 @@ public class MBeanExporterTests extends AbstractMBeanServerTests { Map beans = new HashMap<>(); beans.put(OBJECT_NAME, "beanName"); exporter.setBeans(beans); - thrown.expect(MBeanExportException.class); - start(exporter); + assertThatExceptionOfType(MBeanExportException.class).isThrownBy(() -> + start(exporter)); } @Test public void testNotRunningInBeanFactoryAndAutodetectionIsOn() throws Exception { MBeanExporter exporter = new MBeanExporter(); exporter.setAutodetectMode(MBeanExporter.AUTODETECT_ALL); - thrown.expect(MBeanExportException.class); - start(exporter); + assertThatExceptionOfType(MBeanExportException.class).isThrownBy(() -> + start(exporter)); } @Test // SPR-2158 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 a10eedf7a97..42935d61749 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 @@ -20,9 +20,7 @@ import javax.management.MBeanServer; import javax.management.ObjectName; import org.junit.After; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; @@ -41,6 +39,7 @@ import org.springframework.jmx.support.ObjectNameManager; import org.springframework.jmx.support.RegistrationPolicy; import org.springframework.mock.env.MockEnvironment; +import static org.assertj.core.api.Assertions.*; import static org.junit.Assert.*; /** @@ -52,9 +51,6 @@ import static org.junit.Assert.*; */ public class EnableMBeanExportConfigurationTests { - @Rule - public final ExpectedException thrown = ExpectedException.none(); - private AnnotationConfigApplicationContext ctx; @@ -85,19 +81,19 @@ public class EnableMBeanExportConfigurationTests { @Test @SuppressWarnings("resource") public void testPackagePrivateExtensionCantBeExposed() { - this.thrown.expect(InvalidMetadataException.class); - this.thrown.expectMessage(PackagePrivateTestBean.class.getName()); - this.thrown.expectMessage("must be public"); - new AnnotationConfigApplicationContext(PackagePrivateConfiguration.class); + assertThatExceptionOfType(InvalidMetadataException.class).isThrownBy(() -> + new AnnotationConfigApplicationContext(PackagePrivateConfiguration.class)) + .withMessageContaining(PackagePrivateTestBean.class.getName()) + .withMessageContaining("must be public"); } @Test @SuppressWarnings("resource") public void testPackagePrivateImplementationCantBeExposed() { - this.thrown.expect(InvalidMetadataException.class); - this.thrown.expectMessage(PackagePrivateAnnotationTestBean.class.getName()); - this.thrown.expectMessage("must be public"); - new AnnotationConfigApplicationContext(PackagePrivateInterfaceImplementationConfiguration.class); + assertThatExceptionOfType(InvalidMetadataException.class).isThrownBy(() -> + new AnnotationConfigApplicationContext(PackagePrivateInterfaceImplementationConfiguration.class)) + .withMessageContaining(PackagePrivateAnnotationTestBean.class.getName()) + .withMessageContaining("must be public"); } @Test diff --git a/spring-context/src/test/java/org/springframework/jmx/export/assembler/IAdditionalTestMethods.java b/spring-context/src/test/java/org/springframework/jmx/export/assembler/IAdditionalTestMethods.java index d6b59fc5ffa..96854210b71 100644 --- a/spring-context/src/test/java/org/springframework/jmx/export/assembler/IAdditionalTestMethods.java +++ b/spring-context/src/test/java/org/springframework/jmx/export/assembler/IAdditionalTestMethods.java @@ -1,3 +1,18 @@ +/* + * Copyright 2002-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.springframework.jmx.export.assembler; 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 fb945dd3d13..eba0f81d21d 100644 --- a/spring-context/src/test/java/org/springframework/jndi/JndiLocatorDelegateTests.java +++ b/spring-context/src/test/java/org/springframework/jndi/JndiLocatorDelegateTests.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. @@ -21,8 +21,8 @@ import javax.naming.spi.NamingManager; import org.junit.Test; +import static org.hamcrest.MatcherAssert.*; import static org.hamcrest.Matchers.*; -import static org.hamcrest.MatcherAssert.assertThat; /** * Tests for {@link JndiLocatorDelegate}. 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 566b70cff68..3b320328ced 100644 --- a/spring-context/src/test/java/org/springframework/jndi/JndiTemplateEditorTests.java +++ b/spring-context/src/test/java/org/springframework/jndi/JndiTemplateEditorTests.java @@ -1,6 +1,5 @@ - /* - * Copyright 2002-2012 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. 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 23f7bd13b43..0b10b0f0a61 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 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. @@ -22,7 +22,7 @@ import java.lang.annotation.RetentionPolicy; import org.junit.Test; import static org.hamcrest.CoreMatchers.*; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.MatcherAssert.*; /** * Unit tests for {@link AnnotationAsyncExecutionInterceptor}. 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 aef751d4990..4790394e1a8 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 @@ -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. @@ -91,7 +91,7 @@ public class AsyncResultTests { String value = "val"; final Set values = new HashSet<>(1); ListenableFuture future = AsyncResult.forValue(value); - future.addCallback(values::add, (ex) -> fail("Failure callback not expected: " + ex)); + future.addCallback(values::add, ex -> fail("Failure callback not expected: " + ex)); assertSame(value, values.iterator().next()); assertSame(value, future.get()); assertSame(value, future.completable().get()); @@ -103,7 +103,7 @@ public class AsyncResultTests { IOException ex = new IOException(); final Set values = new HashSet<>(1); ListenableFuture future = AsyncResult.forExecutionException(ex); - future.addCallback((result) -> fail("Success callback not expected: " + result), values::add); + future.addCallback(result -> fail("Success callback not expected: " + result), values::add); assertSame(ex, values.iterator().next()); try { future.get(); 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 426d26cde10..cf703e796a7 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 @@ -320,7 +320,7 @@ public class EnableAsyncTests { Awaitility.await() .atMost(500, TimeUnit.MILLISECONDS) .pollInterval(10, TimeUnit.MILLISECONDS) - .until(()-> asyncBean.getThreadOfExecution() != null); + .until(() -> asyncBean.getThreadOfExecution() != null); assertThat(asyncBean.getThreadOfExecution().getName(), startsWith("Custom-")); ctx.close(); } 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 88fb35f603b..6f7be728acd 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 @@ -21,8 +21,8 @@ import org.junit.Test; import org.springframework.context.support.GenericXmlApplicationContext; /** - * Tests ensuring that tasks scheduled using the element - * are never marked lazy, even if the enclosing element declares + * Tests ensuring that tasks scheduled using the <task:scheduled> element + * are never marked lazy, even if the enclosing <beans> element declares * default-lazy-init="true". See SPR-8498 * * @author Mike Youngstrom 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 ecd9b8f7643..73015d47c46 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 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,11 +16,11 @@ package org.springframework.scripting.groovy; -import groovy.lang.GroovyClassLoader; - import java.lang.reflect.Method; +import groovy.lang.GroovyClassLoader; import org.junit.Test; + import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.context.support.StaticApplicationContext; import org.springframework.util.ReflectionUtils; diff --git a/spring-context/src/test/java/org/springframework/scripting/groovy/Log.java b/spring-context/src/test/java/org/springframework/scripting/groovy/Log.java index 380edb41ab1..905d65192f2 100644 --- a/spring-context/src/test/java/org/springframework/scripting/groovy/Log.java +++ b/spring-context/src/test/java/org/springframework/scripting/groovy/Log.java @@ -1,3 +1,19 @@ +/* + * Copyright 2002-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.scripting.groovy; import java.lang.annotation.Documented; diff --git a/spring-context/src/test/java/org/springframework/scripting/groovy/TestService.java b/spring-context/src/test/java/org/springframework/scripting/groovy/TestService.java index 54226d085f2..aedebb2e769 100644 --- a/spring-context/src/test/java/org/springframework/scripting/groovy/TestService.java +++ b/spring-context/src/test/java/org/springframework/scripting/groovy/TestService.java @@ -1,3 +1,19 @@ +/* + * Copyright 2002-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.scripting.groovy; public interface TestService { diff --git a/spring-context/src/test/java/org/springframework/scripting/groovy/TestServiceImpl.java b/spring-context/src/test/java/org/springframework/scripting/groovy/TestServiceImpl.java index 9e771dde0de..2e20636217d 100644 --- a/spring-context/src/test/java/org/springframework/scripting/groovy/TestServiceImpl.java +++ b/spring-context/src/test/java/org/springframework/scripting/groovy/TestServiceImpl.java @@ -1,3 +1,19 @@ +/* + * Copyright 2002-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.springframework.scripting.groovy; @Log 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 88528856b1c..05803f58fa7 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 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. @@ -32,7 +32,7 @@ import org.springframework.tests.Assume; import org.springframework.tests.TestGroup; import static org.junit.Assert.*; -import static org.mockito.BDDMockito.*; +import static org.mockito.Mockito.*; /** * @author Rick Evans diff --git a/spring-context/src/test/java/org/springframework/tests/mock/jndi/package-info.java b/spring-context/src/test/java/org/springframework/tests/mock/jndi/package-info.java index 166b1410956..baff7e5567d 100644 --- a/spring-context/src/test/java/org/springframework/tests/mock/jndi/package-info.java +++ b/spring-context/src/test/java/org/springframework/tests/mock/jndi/package-info.java @@ -1,19 +1,3 @@ -/* - * Copyright 2002-2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - /** * The simplest implementation of the JNDI SPI that could possibly work. * 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 5ccacd3dec6..ad8f200cd91 100644 --- a/spring-context/src/test/java/org/springframework/validation/DataBinderFieldAccessTests.java +++ b/spring-context/src/test/java/org/springframework/validation/DataBinderFieldAccessTests.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. @@ -19,9 +19,7 @@ package org.springframework.validation; import java.beans.PropertyEditorSupport; import java.util.Map; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.springframework.beans.MutablePropertyValues; import org.springframework.beans.NotWritablePropertyException; @@ -30,6 +28,7 @@ import org.springframework.beans.PropertyValue; import org.springframework.tests.sample.beans.FieldAccessBean; import org.springframework.tests.sample.beans.TestBean; +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.junit.Assert.*; /** @@ -39,9 +38,6 @@ import static org.junit.Assert.*; */ public class DataBinderFieldAccessTests { - @Rule - public final ExpectedException thrown = ExpectedException.none(); - @Test public void bindingNoErrors() throws Exception { FieldAccessBean rod = new FieldAccessBean(); @@ -147,8 +143,8 @@ public class DataBinderFieldAccessTests { MutablePropertyValues pvs = new MutablePropertyValues(); pvs.addPropertyValue(new PropertyValue("spouse.name", "Kerry")); - thrown.expect(NullValueInNestedPathException.class); - binder.bind(pvs); + assertThatExceptionOfType(NullValueInNestedPathException.class).isThrownBy(() -> + binder.bind(pvs)); } @Test 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 1caf30011b2..74a03989444 100644 --- a/spring-context/src/test/java/org/springframework/validation/DataBinderTests.java +++ b/spring-context/src/test/java/org/springframework/validation/DataBinderTests.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. @@ -36,9 +36,7 @@ import java.util.Optional; import java.util.Set; import java.util.TreeSet; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.springframework.beans.BeanWrapper; import org.springframework.beans.InvalidPropertyException; @@ -69,6 +67,7 @@ import org.springframework.tests.sample.beans.TestBean; import org.springframework.util.ObjectUtils; import org.springframework.util.StringUtils; +import static org.assertj.core.api.Assertions.assertThatIllegalStateException; import static org.junit.Assert.*; /** @@ -79,10 +78,6 @@ import static org.junit.Assert.*; */ public class DataBinderTests { - @Rule - public final ExpectedException expectedException = ExpectedException.none(); - - @Test public void testBindingNoErrors() throws BindException { TestBean rod = new TestBean(); @@ -2022,12 +2017,11 @@ public class DataBinderTests { @Test // SPR-14888 public void testSetAutoGrowCollectionLimitAfterInitialization() { - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("DataBinder is already initialized - call setAutoGrowCollectionLimit before other configuration methods"); - DataBinder binder = new DataBinder(new BeanWithIntegerList()); binder.registerCustomEditor(String.class, new StringTrimmerEditor(true)); - binder.setAutoGrowCollectionLimit(257); + assertThatIllegalStateException().isThrownBy(() -> + binder.setAutoGrowCollectionLimit(257)) + .withMessageContaining("DataBinder is already initialized - call setAutoGrowCollectionLimit before other configuration methods"); } @Test // SPR-15009 @@ -2092,13 +2086,13 @@ public class DataBinderTests { @Test // SPR-15009 public void testCallSetMessageCodesResolverTwice() { - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage("DataBinder is already initialized with MessageCodesResolver"); TestBean testBean = new TestBean(); DataBinder binder = new DataBinder(testBean, "testBean"); binder.setMessageCodesResolver(new DefaultMessageCodesResolver()); - binder.setMessageCodesResolver(new DefaultMessageCodesResolver()); + assertThatIllegalStateException().isThrownBy(() -> + binder.setMessageCodesResolver(new DefaultMessageCodesResolver())) + .withMessageContaining("DataBinder is already initialized with MessageCodesResolver"); } 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 004e191ccd3..1dcd8a46216 100644 --- a/spring-context/src/test/java/org/springframework/validation/DefaultMessageCodesResolverTests.java +++ b/spring-context/src/test/java/org/springframework/validation/DefaultMessageCodesResolverTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 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. @@ -21,8 +21,8 @@ import org.junit.Test; import org.springframework.tests.sample.beans.TestBean; import org.springframework.validation.DefaultMessageCodesResolver.Format; +import static org.hamcrest.MatcherAssert.*; import static org.hamcrest.Matchers.*; -import static org.hamcrest.MatcherAssert.assertThat; /** * Tests for {@link DefaultMessageCodesResolver}. 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 e2e536f5f6d..d365f8f10ae 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 @@ -474,10 +474,10 @@ public class SpringValidatorAdapterTests { .addPropertyNode(f.getName()) .addConstraintViolation(); } - } catch (IllegalAccessException ex) { + } + catch (IllegalAccessException ex) { throw new IllegalStateException(ex); } - }); return fieldsErros.isEmpty(); } diff --git a/spring-core/src/test/java/org/springframework/core/ConventionsTests.java b/spring-core/src/test/java/org/springframework/core/ConventionsTests.java index c60c34ccada..89883de97d6 100644 --- a/spring-core/src/test/java/org/springframework/core/ConventionsTests.java +++ b/spring-core/src/test/java/org/springframework/core/ConventionsTests.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. @@ -25,15 +25,14 @@ import java.util.Set; import io.reactivex.Observable; import io.reactivex.Single; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import org.springframework.tests.sample.objects.TestObject; import org.springframework.util.ClassUtils; +import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.junit.Assert.*; /** @@ -44,10 +43,6 @@ import static org.junit.Assert.*; */ public class ConventionsTests { - @Rule - public final ExpectedException exception = ExpectedException.none(); - - @Test public void simpleObject() { assertEquals("Incorrect singular variable name", @@ -76,8 +71,8 @@ public class ConventionsTests { @Test public void emptyList() { - this.exception.expect(IllegalArgumentException.class); - Conventions.getVariableName(new ArrayList<>()); + assertThatIllegalArgumentException().isThrownBy(() -> + Conventions.getVariableName(new ArrayList<>())); } @Test diff --git a/spring-core/src/test/java/org/springframework/core/ParameterizedTypeReferenceTests.java b/spring-core/src/test/java/org/springframework/core/ParameterizedTypeReferenceTests.java index 94e3a533029..31f88be2f3d 100644 --- a/spring-core/src/test/java/org/springframework/core/ParameterizedTypeReferenceTests.java +++ b/spring-core/src/test/java/org/springframework/core/ParameterizedTypeReferenceTests.java @@ -1,11 +1,11 @@ /* - * 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. * You may obtain a copy of the License at * - * https://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/spring-core/src/test/java/org/springframework/core/PrioritizedParameterNameDiscovererTests.java b/spring-core/src/test/java/org/springframework/core/PrioritizedParameterNameDiscovererTests.java index 7d94fc3853a..442d5941b5c 100644 --- a/spring-core/src/test/java/org/springframework/core/PrioritizedParameterNameDiscovererTests.java +++ b/spring-core/src/test/java/org/springframework/core/PrioritizedParameterNameDiscovererTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 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. @@ -21,6 +21,7 @@ import java.lang.reflect.Method; import java.util.Arrays; import org.junit.Test; + import org.springframework.tests.sample.objects.TestObject; import static org.junit.Assert.*; diff --git a/spring-core/src/test/java/org/springframework/core/ResolvableTypeTests.java b/spring-core/src/test/java/org/springframework/core/ResolvableTypeTests.java index 92daa675b7a..aee434ccada 100644 --- a/spring-core/src/test/java/org/springframework/core/ResolvableTypeTests.java +++ b/spring-core/src/test/java/org/springframework/core/ResolvableTypeTests.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. @@ -42,9 +42,7 @@ import java.util.SortedSet; import java.util.TreeSet; import java.util.concurrent.Callable; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; import org.mockito.Captor; @@ -53,10 +51,11 @@ import org.mockito.junit.MockitoJUnitRunner; import org.springframework.core.ResolvableType.VariableResolver; import org.springframework.util.MultiValueMap; +import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; import static org.junit.Assert.*; -import static org.mockito.BDDMockito.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.*; /** @@ -70,9 +69,6 @@ import static org.mockito.BDDMockito.*; @RunWith(MockitoJUnitRunner.class) public class ResolvableTypeTests { - @Rule - public ExpectedException thrown = ExpectedException.none(); - @Captor private ArgumentCaptor> typeVariableCaptor; @@ -138,9 +134,9 @@ public class ResolvableTypeTests { @Test public void forInstanceMustNotBeNull() { - this.thrown.expect(IllegalArgumentException.class); - this.thrown.expectMessage("Instance must not be null"); - ResolvableType.forInstance(null); + assertThatIllegalArgumentException().isThrownBy(() -> + ResolvableType.forInstance(null)) + .withMessageContaining("Instance must not be null"); } @Test @@ -191,9 +187,9 @@ public class ResolvableTypeTests { @Test public void forFieldMustNotBeNull() throws Exception { - this.thrown.expect(IllegalArgumentException.class); - this.thrown.expectMessage("Field must not be null"); - ResolvableType.forField(null); + assertThatIllegalArgumentException().isThrownBy(() -> + ResolvableType.forField(null)) + .withMessageContaining("Field must not be null"); } @Test @@ -205,9 +201,9 @@ public class ResolvableTypeTests { @Test public void forConstructorParameterMustNotBeNull() throws Exception { - this.thrown.expect(IllegalArgumentException.class); - this.thrown.expectMessage("Constructor must not be null"); - ResolvableType.forConstructorParameter(null, 0); + assertThatIllegalArgumentException().isThrownBy(() -> + ResolvableType.forConstructorParameter(null, 0)) + .withMessageContaining("Constructor must not be null"); } @Test @@ -219,9 +215,9 @@ public class ResolvableTypeTests { @Test public void forMethodParameterByIndexMustNotBeNull() throws Exception { - this.thrown.expect(IllegalArgumentException.class); - this.thrown.expectMessage("Method must not be null"); - ResolvableType.forMethodParameter(null, 0); + assertThatIllegalArgumentException().isThrownBy(() -> + ResolvableType.forMethodParameter(null, 0)) + .withMessageContaining("Method must not be null"); } @Test @@ -257,9 +253,9 @@ public class ResolvableTypeTests { @Test public void forMethodParameterMustNotBeNull() throws Exception { - this.thrown.expect(IllegalArgumentException.class); - this.thrown.expectMessage("MethodParameter must not be null"); - ResolvableType.forMethodParameter(null); + assertThatIllegalArgumentException().isThrownBy(() -> + ResolvableType.forMethodParameter(null)) + .withMessageContaining("MethodParameter must not be null"); } @Test // SPR-16210 @@ -284,9 +280,9 @@ public class ResolvableTypeTests { @Test public void forMethodReturnMustNotBeNull() throws Exception { - this.thrown.expect(IllegalArgumentException.class); - this.thrown.expectMessage("Method must not be null"); - ResolvableType.forMethodReturnType(null); + assertThatIllegalArgumentException().isThrownBy(() -> + ResolvableType.forMethodReturnType(null)) + .withMessageContaining("Method must not be null"); } @Test @@ -963,9 +959,9 @@ public class ResolvableTypeTests { @Test public void isAssignableFromMustNotBeNull() throws Exception { - this.thrown.expect(IllegalArgumentException.class); - this.thrown.expectMessage("Type must not be null"); - ResolvableType.forClass(Object.class).isAssignableFrom((ResolvableType) null); + assertThatIllegalArgumentException().isThrownBy(() -> + ResolvableType.forClass(Object.class).isAssignableFrom((ResolvableType) null)) + .withMessageContaining("Type must not be null"); } @Test @@ -1226,9 +1222,9 @@ public class ResolvableTypeTests { @Test public void forClassWithMismatchedGenerics() throws Exception { - thrown.expect(IllegalArgumentException.class); - thrown.expectMessage("Mismatched number of generics specified"); - ResolvableType.forClassWithGenerics(Map.class, Integer.class); + assertThatIllegalArgumentException().isThrownBy(() -> + ResolvableType.forClassWithGenerics(Map.class, Integer.class)) + .withMessageContaining("Mismatched number of generics specified"); } @Test diff --git a/spring-core/src/test/java/org/springframework/core/SerializableTypeWrapperTests.java b/spring-core/src/test/java/org/springframework/core/SerializableTypeWrapperTests.java index 6b710642f12..fafe35b37b4 100644 --- a/spring-core/src/test/java/org/springframework/core/SerializableTypeWrapperTests.java +++ b/spring-core/src/test/java/org/springframework/core/SerializableTypeWrapperTests.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. @@ -31,7 +31,7 @@ import java.util.List; import org.junit.Test; -import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.MatcherAssert.*; import static org.hamcrest.Matchers.*; /** diff --git a/spring-core/src/test/java/org/springframework/core/annotation/AnnotatedElementUtilsTests.java b/spring-core/src/test/java/org/springframework/core/annotation/AnnotatedElementUtilsTests.java index 6c1e1a1cbef..b5af764caba 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/AnnotatedElementUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/AnnotatedElementUtilsTests.java @@ -35,11 +35,13 @@ import javax.annotation.Resource; import javax.annotation.meta.When; import org.junit.Ignore; -import org.junit.Rule; import org.junit.Test; import org.junit.internal.ArrayComparisonFailure; -import org.junit.rules.ExpectedException; +import org.springframework.core.annotation.AnnotationUtilsTests.ExtendsBaseClassWithGenericAnnotatedMethod; +import org.springframework.core.annotation.AnnotationUtilsTests.ImplementsInterfaceWithGenericAnnotatedMethod; +import org.springframework.core.annotation.AnnotationUtilsTests.WebController; +import org.springframework.core.annotation.AnnotationUtilsTests.WebMapping; import org.springframework.lang.NonNullApi; import org.springframework.lang.Nullable; import org.springframework.stereotype.Component; @@ -48,8 +50,8 @@ import org.springframework.util.MultiValueMap; import static java.util.Arrays.*; import static java.util.stream.Collectors.*; +import static org.assertj.core.api.Assertions.*; import static org.assertj.core.api.Assertions.assertThat; -import static org.hamcrest.Matchers.*; import static org.junit.Assert.*; import static org.springframework.core.annotation.AnnotatedElementUtils.*; import static org.springframework.core.annotation.AnnotationUtilsTests.*; @@ -69,9 +71,6 @@ public class AnnotatedElementUtilsTests { private static final String TX_NAME = Transactional.class.getName(); - @Rule - public final ExpectedException exception = ExpectedException.none(); - @Test public void getMetaAnnotationTypesOnNonAnnotatedClass() { @@ -512,16 +511,11 @@ public class AnnotatedElementUtilsTests { @Test public void getMergedAnnotationAttributesWithInvalidConventionBasedComposedAnnotation() { Class element = InvalidConventionBasedComposedContextConfigClass.class; - exception.expect(AnnotationConfigurationException.class); - exception.expectMessage(either(containsString("attribute 'value' and its alias 'locations'")).or( - containsString("attribute 'locations' and its alias 'value'"))); - exception.expectMessage(either( - containsString("values of [{duplicateDeclaration}] and [{requiredLocationsDeclaration}]")).or( - containsString("values of [{requiredLocationsDeclaration}] and [{duplicateDeclaration}]"))); - exception.expectMessage(either( - containsString("but only one is permitted")).or( - containsString("Different @AliasFor mirror values for annotation"))); - getMergedAnnotationAttributes(element, ContextConfig.class); + assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> + getMergedAnnotationAttributes(element, ContextConfig.class)) + .withMessageContaining("Different @AliasFor mirror values for annotation") + .withMessageContaining("attribute 'locations' and its alias 'value'") + .withMessageContaining("values of [{requiredLocationsDeclaration}] and [{duplicateDeclaration}]"); } @Test diff --git a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationAttributesTests.java b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationAttributesTests.java index c424220ace0..bad139c8e1c 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationAttributesTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationAttributesTests.java @@ -21,12 +21,11 @@ import java.lang.annotation.RetentionPolicy; import java.util.Arrays; import java.util.List; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.springframework.core.annotation.AnnotationUtilsTests.ImplicitAliasesContextConfig; +import static org.assertj.core.api.Assertions.*; import static org.hamcrest.CoreMatchers.*; import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.Assert.*; @@ -43,9 +42,6 @@ public class AnnotationAttributesTests { private AnnotationAttributes attributes = new AnnotationAttributes(); - @Rule - public final ExpectedException exception = ExpectedException.none(); - @Test public void typeSafeAttributeAccess() { @@ -80,9 +76,9 @@ public class AnnotationAttributesTests { @Test public void unresolvableClass() throws Exception { attributes.put("unresolvableClass", new ClassNotFoundException("myclass")); - exception.expect(IllegalArgumentException.class); - exception.expectMessage(containsString("myclass")); - attributes.getClass("unresolvableClass"); + assertThatIllegalArgumentException().isThrownBy(() -> + attributes.getClass("unresolvableClass")) + .withMessageContaining("myclass"); } @Test @@ -132,31 +128,31 @@ public class AnnotationAttributesTests { @Test public void getEnumWithNullAttributeName() { - exception.expect(IllegalArgumentException.class); - exception.expectMessage("must not be null or empty"); - attributes.getEnum(null); + assertThatIllegalArgumentException().isThrownBy(() -> + attributes.getEnum(null)) + .withMessageContaining("must not be null or empty"); } @Test public void getEnumWithEmptyAttributeName() { - exception.expect(IllegalArgumentException.class); - exception.expectMessage("must not be null or empty"); - attributes.getEnum(""); + assertThatIllegalArgumentException().isThrownBy(() -> + attributes.getEnum("")) + .withMessageContaining("must not be null or empty"); } @Test public void getEnumWithUnknownAttributeName() { - exception.expect(IllegalArgumentException.class); - exception.expectMessage("Attribute 'bogus' not found"); - attributes.getEnum("bogus"); + assertThatIllegalArgumentException().isThrownBy(() -> + attributes.getEnum("bogus")) + .withMessageContaining("Attribute 'bogus' not found"); } @Test public void getEnumWithTypeMismatch() { attributes.put("color", "RED"); - exception.expect(IllegalArgumentException.class); - exception.expectMessage(containsString("Attribute 'color' is of type String, but Enum was expected")); - attributes.getEnum("color"); + assertThatIllegalArgumentException().isThrownBy(() -> + attributes.getEnum("color")) + .withMessageContaining("Attribute 'color' is of type String, but Enum was expected"); } @Test diff --git a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationBackCompatibiltyTests.java b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationBackCompatibiltyTests.java index c2738a3d1f7..f616fdcd6d8 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationBackCompatibiltyTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationBackCompatibiltyTests.java @@ -21,7 +21,7 @@ import java.lang.annotation.RetentionPolicy; import org.junit.Test; -import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.*; /** * Tests to ensure back-compatibility with Spring Framework 5.1. diff --git a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationIntrospectionFailureTests.java b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationIntrospectionFailureTests.java index 8b45d0bec48..7342461b443 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationIntrospectionFailureTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationIntrospectionFailureTests.java @@ -49,9 +49,9 @@ public class AnnotationIntrospectionFailureTests { Annotation annotation = withExampleAnnotation.getAnnotations()[0]; Method method = annotation.annotationType().getMethod("value"); method.setAccessible(true); - assertThatExceptionOfType(TypeNotPresentException.class).isThrownBy(() -> { - ReflectionUtils.invokeMethod(method, annotation); - }).withCauseInstanceOf(ClassNotFoundException.class); + assertThatExceptionOfType(TypeNotPresentException.class).isThrownBy(() -> + ReflectionUtils.invokeMethod(method, annotation)) + .withCauseInstanceOf(ClassNotFoundException.class); } @Test diff --git a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationTypeMappingsTests.java b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationTypeMappingsTests.java index 772f4a3e748..410bd623846 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationTypeMappingsTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationTypeMappingsTests.java @@ -98,46 +98,42 @@ public class AnnotationTypeMappingsTests { @Test public void forAnnotationTypeWhenHasAliasForWithBothValueAndAttributeThrowsException() { - assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy( - () -> AnnotationTypeMappings.forAnnotationType( - AliasForWithBothValueAndAttribute.class)).withMessage( - "In @AliasFor declared on attribute 'test' in annotation [" - + AliasForWithBothValueAndAttribute.class.getName() - + "], attribute 'attribute' and its alias 'value' are present with values of 'foo' and 'bar', but only one is permitted."); + assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> + AnnotationTypeMappings.forAnnotationType(AliasForWithBothValueAndAttribute.class)) + .withMessage("In @AliasFor declared on attribute 'test' in annotation [" + + AliasForWithBothValueAndAttribute.class.getName() + + "], attribute 'attribute' and its alias 'value' are present with values of 'foo' and 'bar', but only one is permitted."); } @Test public void forAnnotationTypeWhenAliasForToSelfNonExistingAttribute() { - assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy( - () -> AnnotationTypeMappings.forAnnotationType( - AliasForToSelfNonExistingAttribute.class)).withMessage( - "@AliasFor declaration on attribute 'test' in annotation [" - + AliasForToSelfNonExistingAttribute.class.getName() - + "] declares an alias for 'missing' which is not present."); + assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> + AnnotationTypeMappings.forAnnotationType(AliasForToSelfNonExistingAttribute.class)) + .withMessage("@AliasFor declaration on attribute 'test' in annotation [" + + AliasForToSelfNonExistingAttribute.class.getName() + + "] declares an alias for 'missing' which is not present."); } @Test public void forAnnotationTypeWhenAliasForToOtherNonExistingAttribute() { - assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy( - () -> AnnotationTypeMappings.forAnnotationType( - AliasForToOtherNonExistingAttribute.class)).withMessage( - "Attribute 'test' in annotation [" - + AliasForToOtherNonExistingAttribute.class.getName() - + "] is declared as an @AliasFor nonexistent " - + "attribute 'missing' in annotation [" - + AliasForToOtherNonExistingAttributeTarget.class.getName() - + "]."); + assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> + AnnotationTypeMappings.forAnnotationType(AliasForToOtherNonExistingAttribute.class)) + .withMessage("Attribute 'test' in annotation [" + + AliasForToOtherNonExistingAttribute.class.getName() + + "] is declared as an @AliasFor nonexistent " + + "attribute 'missing' in annotation [" + + AliasForToOtherNonExistingAttributeTarget.class.getName() + + "]."); } @Test public void forAnnotationTypeWhenAliasForToSelf() { - assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy( - () -> AnnotationTypeMappings.forAnnotationType( - AliasForToSelf.class)).withMessage( - "@AliasFor declaration on attribute 'test' in annotation [" - + AliasForToSelf.class.getName() - + "] points to itself. Specify 'annotation' to point to " - + "a same-named attribute on a meta-annotation."); + assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> + AnnotationTypeMappings.forAnnotationType(AliasForToSelf.class)) + .withMessage("@AliasFor declaration on attribute 'test' in annotation [" + + AliasForToSelf.class.getName() + + "] points to itself. Specify 'annotation' to point to " + + "a same-named attribute on a meta-annotation."); } @Test @@ -151,82 +147,75 @@ public class AnnotationTypeMappingsTests { @Test public void forAnnotationTypeWhenAliasForWithIncompatibleReturnTypes() { - assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy( - () -> AnnotationTypeMappings.forAnnotationType( - AliasForWithIncompatibleReturnTypes.class)).withMessage( - "Misconfigured aliases: attribute 'test' in annotation [" - + AliasForWithIncompatibleReturnTypes.class.getName() - + "] and attribute 'test' in annotation [" - + AliasForWithIncompatibleReturnTypesTarget.class.getName() - + "] must declare the same return type."); + assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> + AnnotationTypeMappings.forAnnotationType(AliasForWithIncompatibleReturnTypes.class)) + .withMessage("Misconfigured aliases: attribute 'test' in annotation [" + + AliasForWithIncompatibleReturnTypes.class.getName() + + "] and attribute 'test' in annotation [" + + AliasForWithIncompatibleReturnTypesTarget.class.getName() + + "] must declare the same return type."); } @Test public void forAnnotationTypeWhenAliasForToSelfNonAnnotatedAttribute() { - assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy( - () -> AnnotationTypeMappings.forAnnotationType( - AliasForToSelfNonAnnotatedAttribute.class)).withMessage( - "Attribute 'other' in annotation [" - + AliasForToSelfNonAnnotatedAttribute.class.getName() - + "] must be declared as an @AliasFor 'test'."); + assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> + AnnotationTypeMappings.forAnnotationType(AliasForToSelfNonAnnotatedAttribute.class)) + .withMessage("Attribute 'other' in annotation [" + + AliasForToSelfNonAnnotatedAttribute.class.getName() + + "] must be declared as an @AliasFor 'test'."); } @Test public void forAnnotationTypeWhenAliasForToSelfAnnotatedToOtherAttribute() { - assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy( - () -> AnnotationTypeMappings.forAnnotationType( - AliasForToSelfAnnotatedToOtherAttribute.class)).withMessage( - "Attribute 'b' in annotation [" - + AliasForToSelfAnnotatedToOtherAttribute.class.getName() - + "] must be declared as an @AliasFor 'a', not 'c'."); + assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> + AnnotationTypeMappings.forAnnotationType(AliasForToSelfAnnotatedToOtherAttribute.class)) + .withMessage("Attribute 'b' in annotation [" + + AliasForToSelfAnnotatedToOtherAttribute.class.getName() + + "] must be declared as an @AliasFor 'a', not 'c'."); } @Test public void forAnnotationTypeWhenAliasForNonMetaAnnotated() { - assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy( - () -> AnnotationTypeMappings.forAnnotationType( - AliasForNonMetaAnnotated.class)).withMessage( - "@AliasFor declaration on attribute 'test' in annotation [" - + AliasForNonMetaAnnotated.class.getName() - + "] declares an alias for attribute 'test' in annotation [" - + AliasForNonMetaAnnotatedTarget.class.getName() - + "] which is not meta-present."); + assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> + AnnotationTypeMappings.forAnnotationType(AliasForNonMetaAnnotated.class)) + .withMessage("@AliasFor declaration on attribute 'test' in annotation [" + + AliasForNonMetaAnnotated.class.getName() + + "] declares an alias for attribute 'test' in annotation [" + + AliasForNonMetaAnnotatedTarget.class.getName() + + "] which is not meta-present."); } @Test public void forAnnotationTypeWhenAliasForSelfWithDifferentDefaults() { - assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy( - () -> AnnotationTypeMappings.forAnnotationType( - AliasForSelfWithDifferentDefaults.class)).withMessage( - "Misconfigured aliases: attribute 'a' in annotation [" - + AliasForSelfWithDifferentDefaults.class.getName() - + "] and attribute 'b' in annotation [" - + AliasForSelfWithDifferentDefaults.class.getName() - + "] must declare the same default value."); + assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> + AnnotationTypeMappings.forAnnotationType(AliasForSelfWithDifferentDefaults.class)) + .withMessage("Misconfigured aliases: attribute 'a' in annotation [" + + AliasForSelfWithDifferentDefaults.class.getName() + + "] and attribute 'b' in annotation [" + + AliasForSelfWithDifferentDefaults.class.getName() + + "] must declare the same default value."); } @Test public void forAnnotationTypeWhenAliasForSelfWithMissingDefault() { - assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy( - () -> AnnotationTypeMappings.forAnnotationType( - AliasForSelfWithMissingDefault.class)).withMessage( - "Misconfigured aliases: attribute 'a' in annotation [" - + AliasForSelfWithMissingDefault.class.getName() - + "] and attribute 'b' in annotation [" - + AliasForSelfWithMissingDefault.class.getName() - + "] must declare default values."); + assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> + AnnotationTypeMappings.forAnnotationType(AliasForSelfWithMissingDefault.class)) + .withMessage("Misconfigured aliases: attribute 'a' in annotation [" + + AliasForSelfWithMissingDefault.class.getName() + + "] and attribute 'b' in annotation [" + + AliasForSelfWithMissingDefault.class.getName() + + "] must declare default values."); } @Test public void forAnnotationTypeWhenAliasWithExplicitMirrorAndDifferentDefaults() { - assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy( - () -> AnnotationTypeMappings.forAnnotationType( - AliasWithExplicitMirrorAndDifferentDefaults.class)).withMessage( - "Misconfigured aliases: attribute 'a' in annotation [" - + AliasWithExplicitMirrorAndDifferentDefaults.class.getName() - + "] and attribute 'c' in annotation [" - + AliasWithExplicitMirrorAndDifferentDefaults.class.getName() - + "] must declare the same default value."); + assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> + AnnotationTypeMappings.forAnnotationType(AliasWithExplicitMirrorAndDifferentDefaults.class)) + .withMessage("Misconfigured aliases: attribute 'a' in annotation [" + + AliasWithExplicitMirrorAndDifferentDefaults.class.getName() + + "] and attribute 'c' in annotation [" + + AliasWithExplicitMirrorAndDifferentDefaults.class.getName() + + "] must declare the same default value."); } @Test @@ -399,13 +388,12 @@ public class AnnotationTypeMappingsTests { public void resolveMirrorsWhenHasDifferentValuesThrowsException() { AnnotationTypeMapping mapping = AnnotationTypeMappings.forAnnotationType( AliasPair.class).get(0); - assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy( - () -> resolveMirrorSets(mapping, WithDifferentValueAliasPair.class, - AliasPair.class)).withMessage( - "Different @AliasFor mirror values for annotation [" - + AliasPair.class.getName() + "] declared on " - + WithDifferentValueAliasPair.class.getName() - + ", attribute 'a' and its alias 'b' are declared with values of [test1] and [test2]."); + assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> + resolveMirrorSets(mapping, WithDifferentValueAliasPair.class, AliasPair.class)) + .withMessage("Different @AliasFor mirror values for annotation [" + + AliasPair.class.getName() + "] declared on " + + WithDifferentValueAliasPair.class.getName() + + ", attribute 'a' and its alias 'b' are declared with values of [test1] and [test2]."); } @Test diff --git a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java index 7b4faea5c19..fe121014337 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java @@ -33,9 +33,7 @@ import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; import org.junit.Before; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.springframework.core.Ordered; import org.springframework.core.annotation.subpackage.NonPublicAnnotatedClass; @@ -44,6 +42,7 @@ import org.springframework.stereotype.Component; import static java.util.Arrays.*; import static java.util.stream.Collectors.*; +import static org.assertj.core.api.Assertions.*; import static org.hamcrest.Matchers.*; import static org.junit.Assert.*; import static org.springframework.core.annotation.AnnotationUtils.*; @@ -61,10 +60,6 @@ import static org.springframework.core.annotation.AnnotationUtils.*; @SuppressWarnings("deprecation") public class AnnotationUtilsTests { - @Rule - public final ExpectedException exception = ExpectedException.none(); - - @Before public void clearCacheBeforeTests() { AnnotationUtils.clearCache(); @@ -497,13 +492,12 @@ public class AnnotationUtilsTests { @Test public void getAnnotationAttributesWithAttributeAliasesWithDifferentValues() throws Exception { - exception.expect(AnnotationConfigurationException.class); - exception.expectMessage(containsString("attribute 'path' and its alias 'value'")); - exception.expectMessage(containsString("values of [{/test}] and [{/enigma}]")); - Method method = WebController.class.getMethod("handleMappedWithDifferentPathAndValueAttributes"); WebMapping webMapping = method.getAnnotation(WebMapping.class); - getAnnotationAttributes(webMapping); + assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> + getAnnotationAttributes(webMapping)) + .withMessageContaining("attribute 'path' and its alias 'value'") + .withMessageContaining("values of [{/test}] and [{/enigma}]"); } @Test @@ -570,14 +564,12 @@ public class AnnotationUtilsTests { @Test public void getRepeatableAnnotationsDeclaredOnClassWithMissingAttributeAliasDeclaration() throws Exception { - exception.expect(AnnotationConfigurationException.class); - exception.expectMessage(startsWith("Attribute 'value' in")); - exception.expectMessage(containsString(BrokenContextConfig.class.getName())); - exception.expectMessage(either( - containsString("@AliasFor [location]")).or( - containsString("@AliasFor 'location'"))); + assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> + getRepeatableAnnotations(BrokenConfigHierarchyTestCase.class, BrokenContextConfig.class, BrokenHierarchy.class)) + .withMessageStartingWith("Attribute 'value' in") + .withMessageContaining(BrokenContextConfig.class.getName()) + .withMessageContaining("@AliasFor 'location'"); - getRepeatableAnnotations(BrokenConfigHierarchyTestCase.class, BrokenContextConfig.class, BrokenHierarchy.class); } @Test @@ -748,13 +740,12 @@ public class AnnotationUtilsTests { ImplicitAliasesWithMissingDefaultValuesContextConfig config = clazz.getAnnotation(annotationType); assertNotNull(config); - exception.expect(AnnotationConfigurationException.class); - exception.expectMessage(startsWith("Misconfigured aliases:")); - exception.expectMessage(containsString("attribute 'location1' in annotation [" + annotationType.getName() + "]")); - exception.expectMessage(containsString("attribute 'location2' in annotation [" + annotationType.getName() + "]")); - exception.expectMessage(containsString("default values")); - - synthesizeAnnotation(config, clazz); + assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> + synthesizeAnnotation(config, clazz)) + .withMessageStartingWith("Misconfigured aliases:") + .withMessageContaining("attribute 'location1' in annotation [" + annotationType.getName() + "]") + .withMessageContaining("attribute 'location2' in annotation [" + annotationType.getName() + "]") + .withMessageContaining("default values"); } @Test @@ -763,14 +754,12 @@ public class AnnotationUtilsTests { Class annotationType = ImplicitAliasesWithDifferentDefaultValuesContextConfig.class; ImplicitAliasesWithDifferentDefaultValuesContextConfig config = clazz.getAnnotation(annotationType); assertNotNull(config); - - exception.expect(AnnotationConfigurationException.class); - exception.expectMessage(startsWith("Misconfigured aliases:")); - exception.expectMessage(containsString("attribute 'location1' in annotation [" + annotationType.getName() + "]")); - exception.expectMessage(containsString("attribute 'location2' in annotation [" + annotationType.getName() + "]")); - exception.expectMessage(containsString("same default value")); - - synthesizeAnnotation(config, clazz); + assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> + synthesizeAnnotation(config, clazz)) + .withMessageStartingWith("Misconfigured aliases:") + .withMessageContaining("attribute 'location1' in annotation [" + annotationType.getName() + "]") + .withMessageContaining("attribute 'location2' in annotation [" + annotationType.getName() + "]") + .withMessageContaining("same default value"); } @Test @@ -780,16 +769,14 @@ public class AnnotationUtilsTests { ImplicitAliasesWithDuplicateValuesContextConfig config = clazz.getAnnotation(annotationType); assertNotNull(config); - exception.expect(AnnotationConfigurationException.class); - exception.expectMessage(either(startsWith("In annotation")).or(startsWith("Different @AliasFor mirror values"))); - exception.expectMessage(containsString(annotationType.getName())); - exception.expectMessage(containsString("declared on class")); - exception.expectMessage(containsString(clazz.getName())); - exception.expectMessage(either(containsString("attribute 'location1' and its alias 'location2'")).or( - containsString("attribute 'location2' and its alias 'location1'"))); - exception.expectMessage(either(containsString("with values of [1] and [2]")).or( - containsString("with values of [2] and [1]"))); - synthesizeAnnotation(config, clazz).location1(); + assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> + synthesizeAnnotation(config, clazz).location1()) + .withMessageStartingWith("Different @AliasFor mirror values") + .withMessageContaining(annotationType.getName()) + .withMessageContaining("declared on class") + .withMessageContaining(clazz.getName()) + .withMessageContaining("attribute 'location1' and its alias 'location2'") + .withMessageContaining("with values of [1] and [2]"); } @Test @@ -940,22 +927,18 @@ public class AnnotationUtilsTests { } private void assertMissingTextAttribute(Map attributes) { - exception.expect(IllegalArgumentException.class); - exception.expectMessage(either(allOf(startsWith("Attributes map"), - containsString("returned null for required attribute 'text'"), - containsString("defined by annotation type [" + AnnotationWithoutDefaults.class.getName() + "]"))).or( - containsString("No value found for attribute named 'text' in merged annotation"))); - synthesizeAnnotation(attributes, AnnotationWithoutDefaults.class, null); + assertThatIllegalArgumentException().isThrownBy(() -> + synthesizeAnnotation(attributes, AnnotationWithoutDefaults.class, null)) + .withMessageContaining("No value found for attribute named 'text' in merged annotation"); } @Test public void synthesizeAnnotationFromMapWithAttributeOfIncorrectType() throws Exception { Map map = Collections.singletonMap(VALUE, 42L); - exception.expect(IllegalArgumentException.class); - exception.expectMessage(containsString( - "Attribute 'value' in annotation org.springframework.stereotype.Component " + - "should be compatible with java.lang.String but a java.lang.Long value was returned")); - synthesizeAnnotation(map, Component.class, null); + assertThatIllegalArgumentException().isThrownBy(() -> + synthesizeAnnotation(map, Component.class, null)) + .withMessageContaining("Attribute 'value' in annotation org.springframework.stereotype.Component " + + "should be compatible with java.lang.String but a java.lang.Long value was returned"); } @Test diff --git a/spring-core/src/test/java/org/springframework/core/annotation/AttributeMethodsTests.java b/spring-core/src/test/java/org/springframework/core/annotation/AttributeMethodsTests.java index 6d5b821d993..6f0fdc22814 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/AttributeMethodsTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/AttributeMethodsTests.java @@ -157,8 +157,8 @@ public class AttributeMethodsTests { given(annotation.value()).willThrow(TypeNotPresentException.class); AttributeMethods attributes = AttributeMethods.forAnnotationType( annotation.annotationType()); - assertThatIllegalStateException().isThrownBy( - () -> attributes.validate(annotation)); + assertThatIllegalStateException().isThrownBy(() -> + attributes.validate(annotation)); } @Test diff --git a/spring-core/src/test/java/org/springframework/core/annotation/ComposedRepeatableAnnotationsTests.java b/spring-core/src/test/java/org/springframework/core/annotation/ComposedRepeatableAnnotationsTests.java index c7306bef790..7d6ad5e1c29 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/ComposedRepeatableAnnotationsTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/ComposedRepeatableAnnotationsTests.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. @@ -26,13 +26,10 @@ import java.lang.reflect.AnnotatedElement; import java.util.Iterator; import java.util.Set; -import org.junit.Rule; +import org.assertj.core.api.ThrowableAssert.ThrowingCallable; import org.junit.Test; -import org.junit.rules.ExpectedException; -import static org.hamcrest.CoreMatchers.isA; -import static org.hamcrest.Matchers.containsString; -import static org.hamcrest.Matchers.startsWith; +import static org.assertj.core.api.Assertions.*; import static org.junit.Assert.*; import static org.springframework.core.annotation.AnnotatedElementUtils.*; @@ -51,33 +48,29 @@ import static org.springframework.core.annotation.AnnotatedElementUtils.*; */ public class ComposedRepeatableAnnotationsTests { - @Rule - public final ExpectedException exception = ExpectedException.none(); - @Test public void getNonRepeatableAnnotation() { - expectNonRepeatableAnnotation(); - getMergedRepeatableAnnotations(getClass(), NonRepeatable.class); + expectNonRepeatableAnnotation(() -> + getMergedRepeatableAnnotations(getClass(), NonRepeatable.class)); } @Test public void getInvalidRepeatableAnnotationContainerMissingValueAttribute() { - expectContainerMissingValueAttribute(); - getMergedRepeatableAnnotations(getClass(), InvalidRepeatable.class, ContainerMissingValueAttribute.class); + expectContainerMissingValueAttribute(() -> + getMergedRepeatableAnnotations(getClass(), InvalidRepeatable.class, ContainerMissingValueAttribute.class)); } @Test public void getInvalidRepeatableAnnotationContainerWithNonArrayValueAttribute() { - expectContainerWithNonArrayValueAttribute(); - getMergedRepeatableAnnotations(getClass(), InvalidRepeatable.class, ContainerWithNonArrayValueAttribute.class); + expectContainerWithNonArrayValueAttribute(() -> + getMergedRepeatableAnnotations(getClass(), InvalidRepeatable.class, ContainerWithNonArrayValueAttribute.class)); } @Test public void getInvalidRepeatableAnnotationContainerWithArrayValueAttributeButWrongComponentType() { - expectContainerWithArrayValueAttributeButWrongComponentType(); - getMergedRepeatableAnnotations(getClass(), InvalidRepeatable.class, - ContainerWithArrayValueAttributeButWrongComponentType.class); + expectContainerWithArrayValueAttributeButWrongComponentType(() -> + getMergedRepeatableAnnotations(getClass(), InvalidRepeatable.class, ContainerWithArrayValueAttributeButWrongComponentType.class)); } @Test @@ -122,27 +115,27 @@ public class ComposedRepeatableAnnotationsTests { @Test public void findNonRepeatableAnnotation() { - expectNonRepeatableAnnotation(); - findMergedRepeatableAnnotations(getClass(), NonRepeatable.class); + expectNonRepeatableAnnotation(() -> + findMergedRepeatableAnnotations(getClass(), NonRepeatable.class)); } @Test public void findInvalidRepeatableAnnotationContainerMissingValueAttribute() { - expectContainerMissingValueAttribute(); - findMergedRepeatableAnnotations(getClass(), InvalidRepeatable.class, ContainerMissingValueAttribute.class); + expectContainerMissingValueAttribute(() -> + findMergedRepeatableAnnotations(getClass(), InvalidRepeatable.class, ContainerMissingValueAttribute.class)); } @Test public void findInvalidRepeatableAnnotationContainerWithNonArrayValueAttribute() { - expectContainerWithNonArrayValueAttribute(); - findMergedRepeatableAnnotations(getClass(), InvalidRepeatable.class, ContainerWithNonArrayValueAttribute.class); + expectContainerWithNonArrayValueAttribute(() -> + findMergedRepeatableAnnotations(getClass(), InvalidRepeatable.class, ContainerWithNonArrayValueAttribute.class)); } @Test public void findInvalidRepeatableAnnotationContainerWithArrayValueAttributeButWrongComponentType() { - expectContainerWithArrayValueAttributeButWrongComponentType(); - findMergedRepeatableAnnotations(getClass(), InvalidRepeatable.class, - ContainerWithArrayValueAttributeButWrongComponentType.class); + expectContainerWithArrayValueAttributeButWrongComponentType(() -> + findMergedRepeatableAnnotations(getClass(), InvalidRepeatable.class, + ContainerWithArrayValueAttributeButWrongComponentType.class)); } @Test @@ -184,36 +177,36 @@ public class ComposedRepeatableAnnotationsTests { assertFindRepeatableAnnotations(ComposedContainerClass.class); } - private void expectNonRepeatableAnnotation() { - exception.expect(IllegalArgumentException.class); - exception.expectMessage(startsWith("Annotation type must be a repeatable annotation")); - exception.expectMessage(containsString("failed to resolve container type for")); - exception.expectMessage(containsString(NonRepeatable.class.getName())); + private void expectNonRepeatableAnnotation(ThrowingCallable throwingCallable) { + assertThatIllegalArgumentException().isThrownBy(throwingCallable) + .withMessageStartingWith("Annotation type must be a repeatable annotation") + .withMessageContaining("failed to resolve container type for") + .withMessageContaining(NonRepeatable.class.getName()); } - private void expectContainerMissingValueAttribute() { - exception.expect(AnnotationConfigurationException.class); - exception.expectMessage(startsWith("Invalid declaration of container type")); - exception.expectMessage(containsString(ContainerMissingValueAttribute.class.getName())); - exception.expectMessage(containsString("for repeatable annotation")); - exception.expectMessage(containsString(InvalidRepeatable.class.getName())); - exception.expectCause(isA(NoSuchMethodException.class)); + private void expectContainerMissingValueAttribute(ThrowingCallable throwingCallable) { + assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(throwingCallable) + .withMessageStartingWith("Invalid declaration of container type") + .withMessageContaining(ContainerMissingValueAttribute.class.getName()) + .withMessageContaining("for repeatable annotation") + .withMessageContaining(InvalidRepeatable.class.getName()) + .withCauseExactlyInstanceOf(NoSuchMethodException.class); } - private void expectContainerWithNonArrayValueAttribute() { - exception.expect(AnnotationConfigurationException.class); - exception.expectMessage(startsWith("Container type")); - exception.expectMessage(containsString(ContainerWithNonArrayValueAttribute.class.getName())); - exception.expectMessage(containsString("must declare a 'value' attribute for an array of type")); - exception.expectMessage(containsString(InvalidRepeatable.class.getName())); + private void expectContainerWithNonArrayValueAttribute(ThrowingCallable throwingCallable) { + assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(throwingCallable) + .withMessageStartingWith("Container type") + .withMessageContaining(ContainerWithNonArrayValueAttribute.class.getName()) + .withMessageContaining("must declare a 'value' attribute for an array of type") + .withMessageContaining(InvalidRepeatable.class.getName()); } - private void expectContainerWithArrayValueAttributeButWrongComponentType() { - exception.expect(AnnotationConfigurationException.class); - exception.expectMessage(startsWith("Container type")); - exception.expectMessage(containsString(ContainerWithArrayValueAttributeButWrongComponentType.class.getName())); - exception.expectMessage(containsString("must declare a 'value' attribute for an array of type")); - exception.expectMessage(containsString(InvalidRepeatable.class.getName())); + private void expectContainerWithArrayValueAttributeButWrongComponentType(ThrowingCallable throwingCallable) { + assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(throwingCallable) + .withMessageStartingWith("Container type") + .withMessageContaining(ContainerWithArrayValueAttributeButWrongComponentType.class.getName()) + .withMessageContaining("must declare a 'value' attribute for an array of type") + .withMessageContaining(InvalidRepeatable.class.getName()); } private void assertGetRepeatableAnnotations(AnnotatedElement element) { diff --git a/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationClassLoaderTests.java b/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationClassLoaderTests.java index 33cf316d6ad..eafd0498186 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationClassLoaderTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationClassLoaderTests.java @@ -25,7 +25,7 @@ import org.junit.Test; import org.springframework.core.OverridingClassLoader; -import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.*; /** * Tests for {@link MergedAnnotation} to ensure the correct class loader is diff --git a/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationPredicatesTests.java b/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationPredicatesTests.java index 575601d1000..351a764c511 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationPredicatesTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationPredicatesTests.java @@ -101,8 +101,8 @@ public class MergedAnnotationPredicatesTests { @Test public void firstRunOfWhenValueExtractorIsNullThrowsException() { - assertThatIllegalArgumentException().isThrownBy( - () -> MergedAnnotationPredicates.firstRunOf(null)); + assertThatIllegalArgumentException().isThrownBy(() -> + MergedAnnotationPredicates.firstRunOf(null)); } @Test @@ -117,8 +117,8 @@ public class MergedAnnotationPredicatesTests { @Test public void uniqueWhenKeyExtractorIsNullThrowsException() { - assertThatIllegalArgumentException().isThrownBy( - () -> MergedAnnotationPredicates.unique(null)); + assertThatIllegalArgumentException().isThrownBy(() -> + MergedAnnotationPredicates.unique(null)); } private char firstCharOfValue(MergedAnnotation annotation) { diff --git a/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsCollectionTests.java b/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsCollectionTests.java index db1be5b3f4e..c02b481d65f 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsCollectionTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsCollectionTests.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -53,9 +53,9 @@ public class MergedAnnotationsCollectionTests { public void createWhenAnnotationIsNotDirectlyPresentThrowsException() { MergedAnnotation annotation = mock(MergedAnnotation.class); given(annotation.isDirectlyPresent()).willReturn(false); - assertThatIllegalArgumentException().isThrownBy(() -> { - MergedAnnotationsCollection.of(Collections.singleton(annotation)); - }).withMessage("Annotation must be directly present"); + assertThatIllegalArgumentException().isThrownBy(() -> + MergedAnnotationsCollection.of(Collections.singleton(annotation))) + .withMessage("Annotation must be directly present"); } @Test @@ -63,9 +63,9 @@ public class MergedAnnotationsCollectionTests { MergedAnnotation annotation = mock(MergedAnnotation.class); given(annotation.isDirectlyPresent()).willReturn(true); given(annotation.getAggregateIndex()).willReturn(1); - assertThatIllegalArgumentException().isThrownBy(() -> { - MergedAnnotationsCollection.of(Collections.singleton(annotation)); - }).withMessage("Annotation must have aggregate index of zero"); + assertThatIllegalArgumentException().isThrownBy(() -> + MergedAnnotationsCollection.of(Collections.singleton(annotation))) + .withMessage("Annotation must have aggregate index of zero"); } @Test diff --git a/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsRepeatableAnnotationTests.java b/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsRepeatableAnnotationTests.java index c8ecea29e73..f49fec54ce1 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsRepeatableAnnotationTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsRepeatableAnnotationTests.java @@ -27,15 +27,11 @@ import java.lang.reflect.AnnotatedElement; import java.util.Set; import org.assertj.core.api.ThrowableTypeAssert; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.springframework.core.annotation.MergedAnnotations.SearchStrategy; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; +import static org.assertj.core.api.Assertions.*; /** * Tests for {@link MergedAnnotations} and {@link RepeatableContainers} that @@ -48,39 +44,35 @@ public class MergedAnnotationsRepeatableAnnotationTests { // See SPR-13973 - @Rule - public ExpectedException exception = ExpectedException.none(); - @Test public void inheritedAnnotationsWhenNonRepeatableThrowsException() { - assertThatIllegalArgumentException().isThrownBy( - () -> getAnnotations(null, NonRepeatable.class, - SearchStrategy.INHERITED_ANNOTATIONS, getClass())).satisfies( - this::nonRepeatableRequirements); + assertThatIllegalArgumentException().isThrownBy(() -> + getAnnotations(null, NonRepeatable.class, SearchStrategy.INHERITED_ANNOTATIONS, getClass())) + .satisfies(this::nonRepeatableRequirements); } @Test public void inheritedAnnotationsWhenContainerMissingValueAttributeThrowsException() { - assertThatAnnotationConfigurationException().isThrownBy( - () -> getAnnotations(ContainerMissingValueAttribute.class, - InvalidRepeatable.class, SearchStrategy.INHERITED_ANNOTATIONS, - getClass())).satisfies(this::missingValueAttributeRequirements); + assertThatAnnotationConfigurationException().isThrownBy(() -> + getAnnotations(ContainerMissingValueAttribute.class, InvalidRepeatable.class, + SearchStrategy.INHERITED_ANNOTATIONS, getClass())) + .satisfies(this::missingValueAttributeRequirements); } @Test public void inheritedAnnotationsWhenWhenNonArrayValueAttributeThrowsException() { - assertThatAnnotationConfigurationException().isThrownBy( - () -> getAnnotations(ContainerWithNonArrayValueAttribute.class, - InvalidRepeatable.class, SearchStrategy.INHERITED_ANNOTATIONS, - getClass())).satisfies(this::nonArrayValueAttributeRequirements); + assertThatAnnotationConfigurationException().isThrownBy(() -> + getAnnotations(ContainerWithNonArrayValueAttribute.class, InvalidRepeatable.class, + SearchStrategy.INHERITED_ANNOTATIONS, getClass())) + .satisfies(this::nonArrayValueAttributeRequirements); } @Test public void inheritedAnnotationsWhenWrongComponentTypeThrowsException() { - assertThatAnnotationConfigurationException().isThrownBy(() -> getAnnotations( - ContainerWithArrayValueAttributeButWrongComponentType.class, - InvalidRepeatable.class, SearchStrategy.INHERITED_ANNOTATIONS, - getClass())).satisfies(this::wrongComponentTypeRequirements); + assertThatAnnotationConfigurationException().isThrownBy(() -> + getAnnotations(ContainerWithArrayValueAttributeButWrongComponentType.class, + InvalidRepeatable.class, SearchStrategy.INHERITED_ANNOTATIONS, getClass())) + .satisfies(this::wrongComponentTypeRequirements); } @Test @@ -142,33 +134,33 @@ public class MergedAnnotationsRepeatableAnnotationTests { @Test public void exhaustiveWhenNonRepeatableThrowsException() { - assertThatIllegalArgumentException().isThrownBy(() -> getAnnotations(null, - NonRepeatable.class, SearchStrategy.EXHAUSTIVE, getClass())).satisfies( - this::nonRepeatableRequirements); + assertThatIllegalArgumentException().isThrownBy(() -> + getAnnotations(null, NonRepeatable.class, SearchStrategy.EXHAUSTIVE, getClass())) + .satisfies(this::nonRepeatableRequirements); } @Test public void exhaustiveWhenContainerMissingValueAttributeThrowsException() { - assertThatAnnotationConfigurationException().isThrownBy( - () -> getAnnotations(ContainerMissingValueAttribute.class, - InvalidRepeatable.class, SearchStrategy.EXHAUSTIVE, - getClass())).satisfies(this::missingValueAttributeRequirements); + assertThatAnnotationConfigurationException().isThrownBy(() -> + getAnnotations(ContainerMissingValueAttribute.class, InvalidRepeatable.class, + SearchStrategy.EXHAUSTIVE, getClass())) + .satisfies(this::missingValueAttributeRequirements); } @Test public void exhaustiveWhenWhenNonArrayValueAttributeThrowsException() { - assertThatAnnotationConfigurationException().isThrownBy( - () -> getAnnotations(ContainerWithNonArrayValueAttribute.class, - InvalidRepeatable.class, SearchStrategy.EXHAUSTIVE, - getClass())).satisfies(this::nonArrayValueAttributeRequirements); + assertThatAnnotationConfigurationException().isThrownBy(() -> + getAnnotations(ContainerWithNonArrayValueAttribute.class, InvalidRepeatable.class, + SearchStrategy.EXHAUSTIVE, getClass())) + .satisfies(this::nonArrayValueAttributeRequirements); } @Test public void exhaustiveWhenWrongComponentTypeThrowsException() { - assertThatAnnotationConfigurationException().isThrownBy(() -> getAnnotations( - ContainerWithArrayValueAttributeButWrongComponentType.class, - InvalidRepeatable.class, SearchStrategy.EXHAUSTIVE, - getClass())).satisfies(this::wrongComponentTypeRequirements); + assertThatAnnotationConfigurationException().isThrownBy(() -> + getAnnotations(ContainerWithArrayValueAttributeButWrongComponentType.class, + InvalidRepeatable.class, SearchStrategy.EXHAUSTIVE, getClass())) + .satisfies(this::wrongComponentTypeRequirements); } @Test @@ -246,7 +238,6 @@ public class MergedAnnotationsRepeatableAnnotationTests { } private void missingValueAttributeRequirements(Exception ex) { - ex.printStackTrace(); assertThat(ex.getMessage()).startsWith( "Invalid declaration of container type").contains( ContainerMissingValueAttribute.class.getName(), diff --git a/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsTests.java b/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsTests.java index e07a0cefebd..83e4f9426d5 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/MergedAnnotationsTests.java @@ -441,11 +441,9 @@ public class MergedAnnotationsTests { @Test public void getWithInheritedAnnotationsFromInvalidConventionBasedComposedAnnotation() { - assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy( - () -> MergedAnnotations.from( - InvalidConventionBasedComposedContextConfigurationClass.class, - SearchStrategy.INHERITED_ANNOTATIONS).get( - ContextConfiguration.class)); + assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> + MergedAnnotations.from(InvalidConventionBasedComposedContextConfigurationClass.class, + SearchStrategy.INHERITED_ANNOTATIONS).get(ContextConfiguration.class)); } @Test @@ -1215,11 +1213,10 @@ public class MergedAnnotationsTests { @Test public void getDirectWithAttributeAliasesWithDifferentValues() throws Exception { Method method = WebController.class.getMethod("handleMappedWithDifferentPathAndValueAttributes"); - assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy( - () -> MergedAnnotations.from(method).get( - RequestMapping.class)).withMessageContaining( - "attribute 'path' and its alias 'value'").withMessageContaining( - "values of [{/test}] and [{/enigma}]"); + assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> + MergedAnnotations.from(method).get(RequestMapping.class)) + .withMessageContaining("attribute 'path' and its alias 'value'") + .withMessageContaining("values of [{/test}] and [{/enigma}]"); } @Test @@ -1281,14 +1278,12 @@ public class MergedAnnotationsTests { public void getRepeatableDeclaredOnClassWithMissingAttributeAliasDeclaration() { RepeatableContainers containers = RepeatableContainers.of( BrokenContextConfiguration.class, BrokenHierarchy.class); - assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy( - () -> MergedAnnotations.from(BrokenHierarchyClass.class, - SearchStrategy.EXHAUSTIVE, containers, - AnnotationFilter.PLAIN).get( - BrokenHierarchy.class)).withMessageStartingWith( - "Attribute 'value' in").withMessageContaining( - BrokenContextConfiguration.class.getName()).withMessageContaining( - "@AliasFor 'location'"); + assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> + MergedAnnotations.from(BrokenHierarchyClass.class, SearchStrategy.EXHAUSTIVE, containers, + AnnotationFilter.PLAIN).get(BrokenHierarchy.class)) + .withMessageStartingWith("Attribute 'value' in") + .withMessageContaining(BrokenContextConfiguration.class.getName()) + .withMessageContaining("@AliasFor 'location'"); } @Test @@ -1429,11 +1424,11 @@ public class MergedAnnotationsTests { public void synthesizeWhenAliasForIsMissingAttributeDeclaration() throws Exception { AliasForWithMissingAttributeDeclaration annotation = AliasForWithMissingAttributeDeclarationClass.class.getAnnotation( AliasForWithMissingAttributeDeclaration.class); - assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy( - () -> MergedAnnotation.from(annotation)).withMessageStartingWith( - "@AliasFor declaration on attribute 'foo' in annotation").withMessageContaining( - AliasForWithMissingAttributeDeclaration.class.getName()).withMessageContaining( - "points to itself"); + assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> + MergedAnnotation.from(annotation)) + .withMessageStartingWith("@AliasFor declaration on attribute 'foo' in annotation") + .withMessageContaining(AliasForWithMissingAttributeDeclaration.class.getName()) + .withMessageContaining("points to itself"); } @Test @@ -1441,33 +1436,33 @@ public class MergedAnnotationsTests { throws Exception { AliasForWithDuplicateAttributeDeclaration annotation = AliasForWithDuplicateAttributeDeclarationClass.class.getAnnotation( AliasForWithDuplicateAttributeDeclaration.class); - assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy( - () -> MergedAnnotation.from(annotation)).withMessageStartingWith( - "In @AliasFor declared on attribute 'foo' in annotation").withMessageContaining( - AliasForWithDuplicateAttributeDeclaration.class.getName()).withMessageContaining( - "attribute 'attribute' and its alias 'value' are present with values of 'baz' and 'bar'"); + assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> + MergedAnnotation.from(annotation)) + .withMessageStartingWith("In @AliasFor declared on attribute 'foo' in annotation") + .withMessageContaining(AliasForWithDuplicateAttributeDeclaration.class.getName()) + .withMessageContaining("attribute 'attribute' and its alias 'value' are present with values of 'baz' and 'bar'"); } @Test public void synthesizeWhenAttributeAliasForNonexistentAttribute() throws Exception { AliasForNonexistentAttribute annotation = AliasForNonexistentAttributeClass.class.getAnnotation( AliasForNonexistentAttribute.class); - assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy( - () -> MergedAnnotation.from(annotation)).withMessageStartingWith( - "@AliasFor declaration on attribute 'foo' in annotation").withMessageContaining( - AliasForNonexistentAttribute.class.getName()).withMessageContaining( - "declares an alias for 'bar' which is not present"); + assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> + MergedAnnotation.from(annotation)) + .withMessageStartingWith("@AliasFor declaration on attribute 'foo' in annotation") + .withMessageContaining(AliasForNonexistentAttribute.class.getName()) + .withMessageContaining("declares an alias for 'bar' which is not present"); } @Test public void synthesizeWhenAttributeAliasWithoutMirroredAliasFor() throws Exception { AliasForWithoutMirroredAliasFor annotation = AliasForWithoutMirroredAliasForClass.class.getAnnotation( AliasForWithoutMirroredAliasFor.class); - assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy( - () -> MergedAnnotation.from(annotation)).withMessageStartingWith( - "Attribute 'bar' in").withMessageContaining( - AliasForWithoutMirroredAliasFor.class.getName()).withMessageContaining( - "@AliasFor 'foo'"); + assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> + MergedAnnotation.from(annotation)) + .withMessageStartingWith("Attribute 'bar' in") + .withMessageContaining(AliasForWithoutMirroredAliasFor.class.getName()) + .withMessageContaining("@AliasFor 'foo'"); } @Test @@ -1475,11 +1470,11 @@ public class MergedAnnotationsTests { throws Exception { AliasForWithMirroredAliasForWrongAttribute annotation = AliasForWithMirroredAliasForWrongAttributeClass.class.getAnnotation( AliasForWithMirroredAliasForWrongAttribute.class); - assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy( - () -> MergedAnnotation.from(annotation)).withMessage( - "@AliasFor declaration on attribute 'bar' in annotation [" - + AliasForWithMirroredAliasForWrongAttribute.class.getName() - + "] declares an alias for 'quux' which is not present."); + assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> + MergedAnnotation.from(annotation)) + .withMessage("@AliasFor declaration on attribute 'bar' in annotation [" + + AliasForWithMirroredAliasForWrongAttribute.class.getName() + + "] declares an alias for 'quux' which is not present."); } @Test @@ -1487,13 +1482,13 @@ public class MergedAnnotationsTests { throws Exception { AliasForAttributeOfDifferentType annotation = AliasForAttributeOfDifferentTypeClass.class.getAnnotation( AliasForAttributeOfDifferentType.class); - assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy( - () -> MergedAnnotation.from(annotation)).withMessageStartingWith( - "Misconfigured aliases").withMessageContaining( - AliasForAttributeOfDifferentType.class.getName()).withMessageContaining( - "attribute 'foo'").withMessageContaining( - "attribute 'bar'").withMessageContaining( - "same return type"); + assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> + MergedAnnotation.from(annotation)) + .withMessageStartingWith("Misconfigured aliases") + .withMessageContaining(AliasForAttributeOfDifferentType.class.getName()) + .withMessageContaining("attribute 'foo'") + .withMessageContaining("attribute 'bar'") + .withMessageContaining("same return type"); } @Test @@ -1501,13 +1496,13 @@ public class MergedAnnotationsTests { throws Exception { AliasForWithMissingDefaultValues annotation = AliasForWithMissingDefaultValuesClass.class.getAnnotation( AliasForWithMissingDefaultValues.class); - assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy( - () -> MergedAnnotation.from(annotation)).withMessageStartingWith( - "Misconfigured aliases").withMessageContaining( - AliasForWithMissingDefaultValues.class.getName()).withMessageContaining( - "attribute 'foo' in annotation").withMessageContaining( - "attribute 'bar' in annotation").withMessageContaining( - "default values"); + assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> + MergedAnnotation.from(annotation)) + .withMessageStartingWith("Misconfigured aliases") + .withMessageContaining(AliasForWithMissingDefaultValues.class.getName()) + .withMessageContaining("attribute 'foo' in annotation") + .withMessageContaining("attribute 'bar' in annotation") + .withMessageContaining("default values"); } @Test @@ -1515,13 +1510,13 @@ public class MergedAnnotationsTests { throws Exception { AliasForAttributeWithDifferentDefaultValue annotation = AliasForAttributeWithDifferentDefaultValueClass.class.getAnnotation( AliasForAttributeWithDifferentDefaultValue.class); - assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy( - () -> MergedAnnotation.from(annotation)).withMessageStartingWith( - "Misconfigured aliases").withMessageContaining( - AliasForAttributeWithDifferentDefaultValue.class.getName()).withMessageContaining( - "attribute 'foo' in annotation").withMessageContaining( - "attribute 'bar' in annotation").withMessageContaining( - "same default value"); + assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> + MergedAnnotation.from(annotation)) + .withMessageStartingWith("Misconfigured aliases") + .withMessageContaining(AliasForAttributeWithDifferentDefaultValue.class.getName()) + .withMessageContaining("attribute 'foo' in annotation") + .withMessageContaining("attribute 'bar' in annotation") + .withMessageContaining("same default value"); } @Test @@ -1529,13 +1524,13 @@ public class MergedAnnotationsTests { throws Exception { AliasedComposedTestConfigurationNotMetaPresent annotation = AliasedComposedTestConfigurationNotMetaPresentClass.class.getAnnotation( AliasedComposedTestConfigurationNotMetaPresent.class); - assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy( - () -> MergedAnnotation.from(annotation)).withMessageStartingWith( - "@AliasFor declaration on attribute 'xmlConfigFile' in annotation").withMessageContaining( - AliasedComposedTestConfigurationNotMetaPresent.class.getName()).withMessageContaining( - "declares an alias for attribute 'location' in annotation").withMessageContaining( - TestConfiguration.class.getName()).withMessageContaining( - "not meta-present"); + assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> + MergedAnnotation.from(annotation)) + .withMessageStartingWith("@AliasFor declaration on attribute 'xmlConfigFile' in annotation") + .withMessageContaining(AliasedComposedTestConfigurationNotMetaPresent.class.getName()) + .withMessageContaining("declares an alias for attribute 'location' in annotation") + .withMessageContaining(TestConfiguration.class.getName()) + .withMessageContaining("not meta-present"); } @Test @@ -1630,16 +1625,12 @@ public class MergedAnnotationsTests { Class annotationType = ImplicitAliasesWithMissingDefaultValuesTestConfiguration.class; ImplicitAliasesWithMissingDefaultValuesTestConfiguration config = clazz.getAnnotation( annotationType); - assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy( - () -> MergedAnnotation.from(clazz, config)).withMessageStartingWith( - "Misconfigured aliases:").withMessageContaining( - "attribute 'location1' in annotation [" - + annotationType.getName() - + "]").withMessageContaining( - "attribute 'location2' in annotation [" - + annotationType.getName() - + "]").withMessageContaining( - "default values"); + assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> + MergedAnnotation.from(clazz, config)) + .withMessageStartingWith("Misconfigured aliases:") + .withMessageContaining("attribute 'location1' in annotation [" + annotationType.getName() + "]") + .withMessageContaining("attribute 'location2' in annotation [" + annotationType.getName() + "]") + .withMessageContaining("default values"); } @Test @@ -1649,16 +1640,12 @@ public class MergedAnnotationsTests { Class annotationType = ImplicitAliasesWithDifferentDefaultValuesTestConfiguration.class; ImplicitAliasesWithDifferentDefaultValuesTestConfiguration config = clazz.getAnnotation( annotationType); - assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy( - () -> MergedAnnotation.from(clazz, config)).withMessageStartingWith( - "Misconfigured aliases:").withMessageContaining( - "attribute 'location1' in annotation [" - + annotationType.getName() - + "]").withMessageContaining( - "attribute 'location2' in annotation [" - + annotationType.getName() - + "]").withMessageContaining( - "same default value"); + assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> + MergedAnnotation.from(clazz, config)) + .withMessageStartingWith("Misconfigured aliases:") + .withMessageContaining("attribute 'location1' in annotation [" + annotationType.getName() + "]") + .withMessageContaining("attribute 'location2' in annotation [" + annotationType.getName() + "]") + .withMessageContaining("same default value"); } @Test @@ -1667,13 +1654,13 @@ public class MergedAnnotationsTests { Class annotationType = ImplicitAliasesWithDuplicateValuesTestConfiguration.class; ImplicitAliasesWithDuplicateValuesTestConfiguration config = clazz.getAnnotation( annotationType); - assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy( - () -> MergedAnnotation.from(clazz, config)).withMessageStartingWith( - "Different @AliasFor mirror values for annotation").withMessageContaining( - annotationType.getName()).withMessageContaining( - "declared on class").withMessageContaining( - clazz.getName()).withMessageContaining( - "are declared with values of"); + assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> + MergedAnnotation.from(clazz, config)) + .withMessageStartingWith("Different @AliasFor mirror values for annotation") + .withMessageContaining(annotationType.getName()) + .withMessageContaining("declared on class") + .withMessageContaining(clazz.getName()) + .withMessageContaining("are declared with values of"); } @Test @@ -1755,9 +1742,8 @@ public class MergedAnnotationsTests { @Test public void synthesizeWhenAttributeAliasesWithDifferentValues() throws Exception { - assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy( - () -> MergedAnnotation.from(TestConfigurationMismatch.class.getAnnotation( - TestConfiguration.class)).synthesize()); + assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> + MergedAnnotation.from(TestConfigurationMismatch.class.getAnnotation(TestConfiguration.class)).synthesize()); } @Test @@ -1827,12 +1813,10 @@ public class MergedAnnotationsTests { } private void testMissingTextAttribute(Map attributes) { - assertThatExceptionOfType(NoSuchElementException.class).isThrownBy(() -> { - MergedAnnotation annotation = MergedAnnotation.of( - AnnotationWithoutDefaults.class, attributes); - annotation.synthesize(); - }).withMessage("No value found for attribute named 'text' in merged annotation " - + AnnotationWithoutDefaults.class.getName()); + assertThatExceptionOfType(NoSuchElementException.class).isThrownBy(() -> + MergedAnnotation.of(AnnotationWithoutDefaults.class, attributes).synthesize()) + .withMessage("No value found for attribute named 'text' in merged annotation " + + AnnotationWithoutDefaults.class.getName()); } @Test @@ -1841,10 +1825,11 @@ public class MergedAnnotationsTests { MergedAnnotation annotation = MergedAnnotation.of(Component.class, map); // annotation.synthesize(); - assertThatIllegalStateException().isThrownBy( - () -> annotation.synthesize()).withMessage( - "Attribute 'value' in annotation org.springframework.stereotype.Component " - + "should be compatible with java.lang.String but a java.lang.Long value was returned"); + assertThatIllegalStateException().isThrownBy(() -> + annotation.synthesize()) + .withMessage("Attribute 'value' in annotation " + + "org.springframework.stereotype.Component should be " + + "compatible with java.lang.String but a java.lang.Long value was returned"); } @Test diff --git a/spring-core/src/test/java/org/springframework/core/annotation/MissingMergedAnnotationTests.java b/spring-core/src/test/java/org/springframework/core/annotation/MissingMergedAnnotationTests.java index 8b5ac6fbca3..626394e5d5f 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/MissingMergedAnnotationTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/MissingMergedAnnotationTests.java @@ -262,12 +262,12 @@ public class MissingMergedAnnotationTests { @Test public void synthesizeWithPredicateWhenPredicateMatchesThrowsNoSuchElementException() { assertThatNoSuchElementException().isThrownBy( - () -> this.missing.synthesize((annotation) -> true)); + () -> this.missing.synthesize(annotation -> true)); } @Test public void synthesizeWithPredicateWhenPredicateDoesNotMatchReturnsEmpty() { - assertThat(this.missing.synthesize((annotation) -> false)).isEmpty(); + assertThat(this.missing.synthesize(annotation -> false)).isEmpty(); } @Test diff --git a/spring-core/src/test/java/org/springframework/core/annotation/PackagesAnnotationFilterTests.java b/spring-core/src/test/java/org/springframework/core/annotation/PackagesAnnotationFilterTests.java index c83b3a9e2a9..871ac15efda 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/PackagesAnnotationFilterTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/PackagesAnnotationFilterTests.java @@ -18,8 +18,7 @@ package org.springframework.core.annotation; import org.junit.Test; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; +import static org.assertj.core.api.Assertions.*; /** * Tests for {@link PackagesAnnotationFilter}. @@ -30,23 +29,23 @@ public class PackagesAnnotationFilterTests { @Test public void createWhenPackagesIsNullThrowsException() { - assertThatIllegalArgumentException().isThrownBy( - () -> new PackagesAnnotationFilter((String[]) null)).withMessage( - "Packages array must not be null"); + assertThatIllegalArgumentException().isThrownBy(() -> + new PackagesAnnotationFilter((String[]) null)) + .withMessage("Packages array must not be null"); } @Test public void createWhenPackagesContainsNullThrowsException() { - assertThatIllegalArgumentException().isThrownBy( - () -> new PackagesAnnotationFilter((String) null)).withMessage( - "Packages array must not have empty elements"); + assertThatIllegalArgumentException().isThrownBy(() -> + new PackagesAnnotationFilter((String) null)) + .withMessage("Packages array must not have empty elements"); } @Test public void createWhenPackagesContainsEmptyTextThrowsException() { - assertThatIllegalArgumentException().isThrownBy( - () -> new PackagesAnnotationFilter("")).withMessage( - "Packages array must not have empty elements"); + assertThatIllegalArgumentException().isThrownBy(() -> + new PackagesAnnotationFilter("")) + .withMessage("Packages array must not have empty elements"); } @Test diff --git a/spring-core/src/test/java/org/springframework/core/annotation/RepeatableContainersTests.java b/spring-core/src/test/java/org/springframework/core/annotation/RepeatableContainersTests.java index 25806cf148b..80caa6643ef 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/RepeatableContainersTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/RepeatableContainersTests.java @@ -93,20 +93,19 @@ public class RepeatableContainersTests { @Test public void ofExplicitWhenHasNoValueThrowsException() { - assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy( - () -> RepeatableContainers.of(ExplicitRepeatable.class, - InvalidNoValue.class)).withMessageContaining( - "Invalid declaration of container type [" - + InvalidNoValue.class.getName() - + "] for repeatable annotation [" - + ExplicitRepeatable.class.getName() + "]"); + assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> + RepeatableContainers.of(ExplicitRepeatable.class, InvalidNoValue.class)) + .withMessageContaining("Invalid declaration of container type [" + + InvalidNoValue.class.getName() + + "] for repeatable annotation [" + + ExplicitRepeatable.class.getName() + "]"); } @Test public void ofExplicitWhenValueIsNotArrayThrowsException() { - assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy( - () -> RepeatableContainers.of(ExplicitRepeatable.class, - InvalidNotArray.class)).withMessage("Container type [" + assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> + RepeatableContainers.of(ExplicitRepeatable.class, InvalidNotArray.class)) + .withMessage("Container type [" + InvalidNotArray.class.getName() + "] must declare a 'value' attribute for an array of type [" + ExplicitRepeatable.class.getName() + "]"); @@ -114,9 +113,9 @@ public class RepeatableContainersTests { @Test public void ofExplicitWhenValueIsArrayOfWrongTypeThrowsException() { - assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy( - () -> RepeatableContainers.of(ExplicitRepeatable.class, - InvalidWrongArrayType.class)).withMessage("Container type [" + assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() -> + RepeatableContainers.of(ExplicitRepeatable.class, InvalidWrongArrayType.class)) + .withMessage("Container type [" + InvalidWrongArrayType.class.getName() + "] must declare a 'value' attribute for an array of type [" + ExplicitRepeatable.class.getName() + "]"); @@ -124,9 +123,9 @@ public class RepeatableContainersTests { @Test public void ofExplicitWhenAnnotationIsNullThrowsException() { - assertThatIllegalArgumentException().isThrownBy( - () -> RepeatableContainers.of(null, null)).withMessage( - "Repeatable must not be null"); + assertThatIllegalArgumentException().isThrownBy(() -> + RepeatableContainers.of(null, null)) + .withMessage("Repeatable must not be null"); } @Test @@ -139,11 +138,11 @@ public class RepeatableContainersTests { @Test public void ofExplicitWhenContainerIsNullAndNotRepeatableThrowsException() { - assertThatIllegalArgumentException().isThrownBy(() -> RepeatableContainers.of( - ExplicitRepeatable.class, null)).withMessage( - "Annotation type must be a repeatable annotation: " - + "failed to resolve container type for " - + ExplicitRepeatable.class.getName()); + assertThatIllegalArgumentException().isThrownBy(() -> + RepeatableContainers.of(ExplicitRepeatable.class, null)) + .withMessage("Annotation type must be a repeatable annotation: " + + "failed to resolve container type for " + + ExplicitRepeatable.class.getName()); } @Test diff --git a/spring-core/src/test/java/org/springframework/core/codec/AbstractDecoderTestCase.java b/spring-core/src/test/java/org/springframework/core/codec/AbstractDecoderTestCase.java index cbbb3b47569..0003600740d 100644 --- a/spring-core/src/test/java/org/springframework/core/codec/AbstractDecoderTestCase.java +++ b/spring-core/src/test/java/org/springframework/core/codec/AbstractDecoderTestCase.java @@ -303,7 +303,7 @@ public abstract class AbstractDecoderTestCase> } /** - * Test a standard {@link Decoder#decodeToMono) decode} scenario. For example: + * Test a standard {@link Decoder#decodeToMono decode} scenario. For example: *
 	 * byte[] bytes1 = ...
 	 * byte[] bytes2 = ...
@@ -330,7 +330,7 @@ public abstract class AbstractDecoderTestCase>
 	}
 
 	/**
-	 * Test a standard {@link Decoder#decodeToMono) decode} scenario. For example:
+	 * Test a standard {@link Decoder#decodeToMono decode} scenario. For example:
 	 * 
 	 * byte[] bytes1 = ...
 	 * byte[] bytes2 = ...
diff --git a/spring-core/src/test/java/org/springframework/core/codec/AbstractEncoderTestCase.java b/spring-core/src/test/java/org/springframework/core/codec/AbstractEncoderTestCase.java
index e75bc5d808d..2b392b2208c 100644
--- a/spring-core/src/test/java/org/springframework/core/codec/AbstractEncoderTestCase.java
+++ b/spring-core/src/test/java/org/springframework/core/codec/AbstractEncoderTestCase.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.
@@ -32,9 +32,9 @@ import org.springframework.lang.Nullable;
 import org.springframework.util.Assert;
 import org.springframework.util.MimeType;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static java.nio.charset.StandardCharsets.*;
 import static org.junit.Assert.*;
-import static org.springframework.core.io.buffer.DataBufferUtils.release;
+import static org.springframework.core.io.buffer.DataBufferUtils.*;
 
 /**
  * Abstract base class for {@link Encoder} unit tests. Subclasses need to implement
diff --git a/spring-core/src/test/java/org/springframework/core/codec/CharSequenceEncoderTests.java b/spring-core/src/test/java/org/springframework/core/codec/CharSequenceEncoderTests.java
index b80c41e29da..f0a0aad2622 100644
--- a/spring-core/src/test/java/org/springframework/core/codec/CharSequenceEncoderTests.java
+++ b/spring-core/src/test/java/org/springframework/core/codec/CharSequenceEncoderTests.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.
@@ -25,10 +25,7 @@ import reactor.core.publisher.Flux;
 import org.springframework.core.ResolvableType;
 import org.springframework.util.MimeTypeUtils;
 
-import static java.nio.charset.StandardCharsets.ISO_8859_1;
-import static java.nio.charset.StandardCharsets.US_ASCII;
-import static java.nio.charset.StandardCharsets.UTF_16;
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static java.nio.charset.StandardCharsets.*;
 import static org.junit.Assert.*;
 
 /**
diff --git a/spring-core/src/test/java/org/springframework/core/codec/ResourceEncoderTests.java b/spring-core/src/test/java/org/springframework/core/codec/ResourceEncoderTests.java
index 744688504c2..839ca6db21a 100644
--- a/spring-core/src/test/java/org/springframework/core/codec/ResourceEncoderTests.java
+++ b/spring-core/src/test/java/org/springframework/core/codec/ResourceEncoderTests.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.
@@ -32,7 +32,7 @@ import org.springframework.lang.Nullable;
 import org.springframework.util.MimeType;
 import org.springframework.util.MimeTypeUtils;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static java.nio.charset.StandardCharsets.*;
 import static org.junit.Assert.*;
 
 /**
diff --git a/spring-core/src/test/java/org/springframework/core/convert/converter/ConvertingComparatorTests.java b/spring-core/src/test/java/org/springframework/core/convert/converter/ConvertingComparatorTests.java
index 5cd934c18b0..ed3a08aa15d 100644
--- a/spring-core/src/test/java/org/springframework/core/convert/converter/ConvertingComparatorTests.java
+++ b/spring-core/src/test/java/org/springframework/core/convert/converter/ConvertingComparatorTests.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.
@@ -30,7 +30,7 @@ import org.springframework.core.convert.support.DefaultConversionService;
 import org.springframework.util.comparator.ComparableComparator;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.MatcherAssert.*;
 
 /**
  * Tests for {@link ConvertingComparator}.
diff --git a/spring-core/src/test/java/org/springframework/core/convert/converter/DefaultConversionServiceTests.java b/spring-core/src/test/java/org/springframework/core/convert/converter/DefaultConversionServiceTests.java
index fcfc11d88c7..113a08bb4a7 100644
--- a/spring-core/src/test/java/org/springframework/core/convert/converter/DefaultConversionServiceTests.java
+++ b/spring-core/src/test/java/org/springframework/core/convert/converter/DefaultConversionServiceTests.java
@@ -367,7 +367,7 @@ public class DefaultConversionServiceTests {
 		Stream result = (Stream) this.conversionService.convert(source,
 				TypeDescriptor.valueOf(String[].class),
 				new TypeDescriptor(getClass().getDeclaredField("genericStream")));
-		assertEquals(8, result.mapToInt((x) -> x).sum());
+		assertEquals(8, result.mapToInt(x -> x).sum());
 	}
 
 	@Test
diff --git a/spring-core/src/test/java/org/springframework/core/convert/support/ByteBufferConverterTests.java b/spring-core/src/test/java/org/springframework/core/convert/support/ByteBufferConverterTests.java
index 6b5b0441989..95df8e14268 100644
--- a/spring-core/src/test/java/org/springframework/core/convert/support/ByteBufferConverterTests.java
+++ b/spring-core/src/test/java/org/springframework/core/convert/support/ByteBufferConverterTests.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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.
@@ -23,7 +23,7 @@ import org.junit.Test;
 
 import org.springframework.core.convert.converter.Converter;
 
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.MatcherAssert.*;
 import static org.hamcrest.Matchers.*;
 
 /**
diff --git a/spring-core/src/test/java/org/springframework/core/convert/support/StreamConverterTests.java b/spring-core/src/test/java/org/springframework/core/convert/support/StreamConverterTests.java
index f0fc2faf003..812283aee3b 100644
--- a/spring-core/src/test/java/org/springframework/core/convert/support/StreamConverterTests.java
+++ b/spring-core/src/test/java/org/springframework/core/convert/support/StreamConverterTests.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.
@@ -21,17 +21,14 @@ import java.util.List;
 import java.util.stream.Stream;
 
 import org.junit.Before;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.core.convert.ConversionFailedException;
 import org.springframework.core.convert.ConverterNotFoundException;
 import org.springframework.core.convert.TypeDescriptor;
 import org.springframework.core.convert.converter.Converter;
 
-import static org.hamcrest.CoreMatchers.*;
-import static org.hamcrest.core.Is.is;
+import static org.assertj.core.api.Assertions.*;
 import static org.junit.Assert.*;
 
 /**
@@ -42,9 +39,6 @@ import static org.junit.Assert.*;
  */
 public class StreamConverterTests {
 
-	@Rule
-	public final ExpectedException thrown = ExpectedException.none();
-
 	private final GenericConversionService conversionService = new GenericConversionService();
 
 	private final StreamConverter streamConverter = new StreamConverter(this.conversionService);
@@ -112,10 +106,9 @@ public class StreamConverterTests {
 	public void convertFromStreamToArrayNoConverter() throws NoSuchFieldException {
 		Stream stream = Arrays.asList(1, 2, 3).stream();
 		TypeDescriptor arrayOfLongs = new TypeDescriptor(Types.class.getField("arrayOfLongs"));
-
-		thrown.expect(ConversionFailedException.class);
-		thrown.expectCause(is(instanceOf(ConverterNotFoundException.class)));
-		this.conversionService.convert(stream, arrayOfLongs);
+		assertThatExceptionOfType(ConversionFailedException.class).isThrownBy(() ->
+				this.conversionService.convert(stream, arrayOfLongs))
+			.withCauseInstanceOf(ConverterNotFoundException.class);
 	}
 
 	@Test
@@ -130,7 +123,7 @@ public class StreamConverterTests {
 		assertTrue("Converted object must be a stream", result instanceof Stream);
 		@SuppressWarnings("unchecked")
 		Stream content = (Stream) result;
-		assertEquals(6, content.mapToInt((x) -> x).sum());
+		assertEquals(6, content.mapToInt(x -> x).sum());
 	}
 
 	@Test
@@ -178,9 +171,10 @@ public class StreamConverterTests {
 
 	@Test
 	public void shouldFailToConvertIfNoStream() throws NoSuchFieldException {
-		thrown.expect(IllegalStateException.class);
-		this.streamConverter.convert(new Object(), new TypeDescriptor(Types.class.getField("listOfStrings")),
-				new TypeDescriptor(Types.class.getField("arrayOfLongs")));
+		TypeDescriptor sourceType = new TypeDescriptor(Types.class.getField("listOfStrings"));
+		TypeDescriptor targetType = new TypeDescriptor(Types.class.getField("arrayOfLongs"));
+		assertThatIllegalStateException().isThrownBy(() ->
+			this.streamConverter.convert(new Object(), sourceType, targetType));
 	}
 
 
diff --git a/spring-core/src/test/java/org/springframework/core/env/CustomEnvironmentTests.java b/spring-core/src/test/java/org/springframework/core/env/CustomEnvironmentTests.java
index 8b24b2742e9..c51cd889e8b 100644
--- a/spring-core/src/test/java/org/springframework/core/env/CustomEnvironmentTests.java
+++ b/spring-core/src/test/java/org/springframework/core/env/CustomEnvironmentTests.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.
@@ -23,7 +23,7 @@ import java.util.Set;
 import org.junit.Test;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.MatcherAssert.*;
 
 /**
  * Unit tests covering the extensibility of {@link AbstractEnvironment}.
@@ -74,7 +74,10 @@ public class CustomEnvironmentTests {
 			@Override
 			@SuppressWarnings("serial")
 			protected Set getReservedDefaultProfiles() {
-				return new HashSet() {{ add("rd1"); add("rd2");  }};
+				return new HashSet() {{
+						add("rd1");
+						add("rd2");
+				}};
 			}
 		}
 
diff --git a/spring-core/src/test/java/org/springframework/core/env/ProfilesTests.java b/spring-core/src/test/java/org/springframework/core/env/ProfilesTests.java
index 60f1b8b9526..a121e3fed0e 100644
--- a/spring-core/src/test/java/org/springframework/core/env/ProfilesTests.java
+++ b/spring-core/src/test/java/org/springframework/core/env/ProfilesTests.java
@@ -21,12 +21,11 @@ import java.util.List;
 import java.util.function.Predicate;
 import java.util.function.Supplier;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.util.StringUtils;
 
+import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
 import static org.junit.Assert.*;
 
 /**
@@ -39,35 +38,32 @@ import static org.junit.Assert.*;
  */
 public class ProfilesTests {
 
-	@Rule
-	public ExpectedException thrown = ExpectedException.none();
-
 	@Test
 	public void ofWhenNullThrowsException() {
-		this.thrown.expect(IllegalArgumentException.class);
-		this.thrown.expectMessage("Must specify at least one profile");
-		Profiles.of((String[]) null);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Profiles.of((String[]) null))
+			.withMessageContaining("Must specify at least one profile");
 	}
 
 	@Test
 	public void ofWhenEmptyThrowsException() {
-		this.thrown.expect(IllegalArgumentException.class);
-		this.thrown.expectMessage("Must specify at least one profile");
-		Profiles.of();
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Profiles.of())
+			.withMessageContaining("Must specify at least one profile");
 	}
 
 	@Test
 	public void ofNullElement() {
-		this.thrown.expect(IllegalArgumentException.class);
-		this.thrown.expectMessage("must contain text");
-		Profiles.of((String) null);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Profiles.of((String) null))
+			.withMessageContaining("must contain text");
 	}
 
 	@Test
 	public void ofEmptyElement() {
-		this.thrown.expect(IllegalArgumentException.class);
-		this.thrown.expectMessage("must contain text");
-		Profiles.of("  ");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Profiles.of("  "))
+			.withMessageContaining("must contain text");
 	}
 
 	@Test
@@ -124,7 +120,7 @@ public class ProfilesTests {
 		assertFalse(profiles.matches(activeProfiles("spring")));
 		assertTrue(profiles.matches(activeProfiles("framework")));
 	}
-	
+
 	@Test
 	public void ofSingleInvertedExpression() {
 		Profiles profiles = Profiles.of("(!spring)");
@@ -305,7 +301,7 @@ public class ProfilesTests {
 			assertTrue(ex.getMessage().contains("Malformed"));
 		}
 	}
-	
+
 	private static Predicate activeProfiles(String... profiles) {
 		return new MockActiveProfiles(profiles);
 	}
diff --git a/spring-core/src/test/java/org/springframework/core/env/PropertySourceTests.java b/spring-core/src/test/java/org/springframework/core/env/PropertySourceTests.java
index 6b2ffde8201..763dc4ab690 100644
--- a/spring-core/src/test/java/org/springframework/core/env/PropertySourceTests.java
+++ b/spring-core/src/test/java/org/springframework/core/env/PropertySourceTests.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.
@@ -25,7 +25,7 @@ import java.util.Properties;
 import org.junit.Test;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.MatcherAssert.*;
 
 /**
  * Unit tests for {@link PropertySource} implementations.
@@ -38,10 +38,18 @@ public class PropertySourceTests {
 	@Test
 	@SuppressWarnings("serial")
 	public void equals() {
-		Map map1 = new HashMap() {{ put("a", "b"); }};
-		Map map2 = new HashMap() {{ put("c", "d"); }};
-		Properties props1 = new Properties() {{ setProperty("a", "b"); }};
-		Properties props2 = new Properties() {{ setProperty("c", "d"); }};
+		Map map1 = new HashMap() {{
+			put("a", "b");
+		}};
+		Map map2 = new HashMap() {{
+			put("c", "d");
+		}};
+		Properties props1 = new Properties() {{
+			setProperty("a", "b");
+		}};
+		Properties props2 = new Properties() {{
+			setProperty("c", "d");
+		}};
 
 		MapPropertySource mps = new MapPropertySource("mps", map1);
 		assertThat(mps, equalTo(mps));
@@ -62,8 +70,12 @@ public class PropertySourceTests {
 	@Test
 	@SuppressWarnings("serial")
 	public void collectionsOperations() {
-		Map map1 = new HashMap() {{ put("a", "b"); }};
-		Map map2 = new HashMap() {{ put("c", "d"); }};
+		Map map1 = new HashMap() {{
+			put("a", "b");
+		}};
+		Map map2 = new HashMap() {{
+			put("c", "d");
+		}};
 
 		PropertySource ps1 = new MapPropertySource("ps1", map1);
 		ps1.getSource();
diff --git a/spring-core/src/test/java/org/springframework/core/env/SimpleCommandLineParserTests.java b/spring-core/src/test/java/org/springframework/core/env/SimpleCommandLineParserTests.java
index a69c4e09df4..28448b23d98 100644
--- a/spring-core/src/test/java/org/springframework/core/env/SimpleCommandLineParserTests.java
+++ b/spring-core/src/test/java/org/springframework/core/env/SimpleCommandLineParserTests.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2011 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.
@@ -22,7 +22,7 @@ import java.util.List;
 import org.junit.Test;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.MatcherAssert.*;
 
 public class SimpleCommandLineParserTests {
 
diff --git a/spring-core/src/test/java/org/springframework/core/env/SimpleCommandLinePropertySourceTests.java b/spring-core/src/test/java/org/springframework/core/env/SimpleCommandLinePropertySourceTests.java
index c795d8d6fe2..6223f6cfcac 100644
--- a/spring-core/src/test/java/org/springframework/core/env/SimpleCommandLinePropertySourceTests.java
+++ b/spring-core/src/test/java/org/springframework/core/env/SimpleCommandLinePropertySourceTests.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2013 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.
@@ -21,7 +21,7 @@ import java.util.List;
 import org.junit.Test;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.MatcherAssert.*;
 
 /**
  * Unit tests for {@link SimpleCommandLinePropertySource}.
diff --git a/spring-core/src/test/java/org/springframework/core/env/SystemEnvironmentPropertySourceTests.java b/spring-core/src/test/java/org/springframework/core/env/SystemEnvironmentPropertySourceTests.java
index 0ee93a40045..4e930f9f11f 100644
--- a/spring-core/src/test/java/org/springframework/core/env/SystemEnvironmentPropertySourceTests.java
+++ b/spring-core/src/test/java/org/springframework/core/env/SystemEnvironmentPropertySourceTests.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.
@@ -25,7 +25,7 @@ import org.junit.Before;
 import org.junit.Test;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.MatcherAssert.*;
 
 /**
  * Unit tests for {@link SystemEnvironmentPropertySource}.
diff --git a/spring-core/src/test/java/org/springframework/core/io/PathResourceTests.java b/spring-core/src/test/java/org/springframework/core/io/PathResourceTests.java
index 69d619df4bb..338083716df 100644
--- a/spring-core/src/test/java/org/springframework/core/io/PathResourceTests.java
+++ b/spring-core/src/test/java/org/springframework/core/io/PathResourceTests.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.
@@ -31,11 +31,12 @@ import java.nio.file.Paths;
 import org.hamcrest.Matchers;
 import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 import org.junit.rules.TemporaryFolder;
 
 import org.springframework.util.FileCopyUtils;
 
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
+import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
 import static org.hamcrest.Matchers.*;
 import static org.junit.Assert.*;
 import static org.mockito.BDDMockito.*;
@@ -68,32 +69,29 @@ public class PathResourceTests {
 	}
 
 
-	@Rule
-	public ExpectedException thrown = ExpectedException.none();
-
 	@Rule
 	public TemporaryFolder temporaryFolder = new TemporaryFolder();
 
 
 	@Test
 	public void nullPath() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage("Path must not be null");
-		new PathResource((Path) null);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				new PathResource((Path) null))
+			.withMessageContaining("Path must not be null");
 	}
 
 	@Test
 	public void nullPathString() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage("Path must not be null");
-		new PathResource((String) null);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				new PathResource((String) null))
+			.withMessageContaining("Path must not be null");
 	}
 
 	@Test
 	public void nullUri() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage("URI must not be null");
-		new PathResource((URI) null);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				new PathResource((URI) null))
+			.withMessageContaining("URI must not be null");
 	}
 
 	@Test
@@ -174,15 +172,15 @@ public class PathResourceTests {
 	@Test
 	public void getInputStreamForDir() throws IOException {
 		PathResource resource = new PathResource(TEST_DIR);
-		thrown.expect(FileNotFoundException.class);
-		resource.getInputStream();
+		assertThatExceptionOfType(FileNotFoundException.class).isThrownBy(
+				resource::getInputStream);
 	}
 
 	@Test
 	public void getInputStreamDoesNotExist() throws IOException {
 		PathResource resource = new PathResource(NON_EXISTING_FILE);
-		thrown.expect(FileNotFoundException.class);
-		resource.getInputStream();
+		assertThatExceptionOfType(FileNotFoundException.class).isThrownBy(
+				resource::getInputStream);
 	}
 
 	@Test
@@ -210,8 +208,8 @@ public class PathResourceTests {
 		given(path.normalize()).willReturn(path);
 		given(path.toFile()).willThrow(new UnsupportedOperationException());
 		PathResource resource = new PathResource(path);
-		thrown.expect(FileNotFoundException.class);
-		resource.getFile();
+		assertThatExceptionOfType(FileNotFoundException.class).isThrownBy(
+				resource::getFile);
 	}
 
 	@Test
@@ -291,8 +289,8 @@ public class PathResourceTests {
 	@Test
 	public void directoryOutputStream() throws IOException {
 		PathResource resource = new PathResource(TEST_DIR);
-		thrown.expect(FileNotFoundException.class);
-		resource.getOutputStream();
+		assertThatExceptionOfType(FileNotFoundException.class).isThrownBy(
+				resource::getOutputStream);
 	}
 
 	@Test
@@ -327,8 +325,8 @@ public class PathResourceTests {
 	@Test
 	public void getReadableByteChannelDoesNotExist() throws IOException {
 		PathResource resource = new PathResource(NON_EXISTING_FILE);
-		thrown.expect(FileNotFoundException.class);
-		resource.readableChannel();
+		assertThatExceptionOfType(FileNotFoundException.class).isThrownBy(
+				resource::readableChannel);
 	}
 
 	@Test
diff --git a/spring-core/src/test/java/org/springframework/core/io/buffer/DataBufferTests.java b/spring-core/src/test/java/org/springframework/core/io/buffer/DataBufferTests.java
index 4716fa14e29..1512f660514 100644
--- a/spring-core/src/test/java/org/springframework/core/io/buffer/DataBufferTests.java
+++ b/spring-core/src/test/java/org/springframework/core/io/buffer/DataBufferTests.java
@@ -291,7 +291,8 @@ public class DataBufferTests extends AbstractDataBufferAllocatingTestCase {
 			int len = inputStream.read(result);
 			assertEquals(3, len);
 			assertArrayEquals(bytes, result);
-		} finally {
+		}
+		finally {
 			inputStream.close();
 		}
 
diff --git a/spring-core/src/test/java/org/springframework/core/io/buffer/DataBufferUtilsTests.java b/spring-core/src/test/java/org/springframework/core/io/buffer/DataBufferUtilsTests.java
index ec76af56aff..c80ebd3f988 100644
--- a/spring-core/src/test/java/org/springframework/core/io/buffer/DataBufferUtilsTests.java
+++ b/spring-core/src/test/java/org/springframework/core/io/buffer/DataBufferUtilsTests.java
@@ -49,7 +49,7 @@ import org.springframework.core.io.Resource;
 import org.springframework.core.io.buffer.support.DataBufferTestUtils;
 
 import static org.junit.Assert.*;
-import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.Mockito.*;
 
 /**
diff --git a/spring-core/src/test/java/org/springframework/core/io/buffer/LeakAwareDataBufferFactoryTests.java b/spring-core/src/test/java/org/springframework/core/io/buffer/LeakAwareDataBufferFactoryTests.java
index dba57c7f953..026436366fb 100644
--- a/spring-core/src/test/java/org/springframework/core/io/buffer/LeakAwareDataBufferFactoryTests.java
+++ b/spring-core/src/test/java/org/springframework/core/io/buffer/LeakAwareDataBufferFactoryTests.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.
@@ -19,7 +19,7 @@ package org.springframework.core.io.buffer;
 import org.junit.Test;
 
 import static org.junit.Assert.*;
-import static org.springframework.core.io.buffer.DataBufferUtils.release;
+import static org.springframework.core.io.buffer.DataBufferUtils.*;
 
 /**
  * @author Arjen Poutsma
@@ -51,4 +51,4 @@ public class LeakAwareDataBufferFactoryTests {
 		this.bufferFactory.checkForLeaks();
 	}
 
-}
\ No newline at end of file
+}
diff --git a/spring-core/src/test/java/org/springframework/core/io/buffer/PooledDataBufferTests.java b/spring-core/src/test/java/org/springframework/core/io/buffer/PooledDataBufferTests.java
index e6786b88437..2792f7a802f 100644
--- a/spring-core/src/test/java/org/springframework/core/io/buffer/PooledDataBufferTests.java
+++ b/spring-core/src/test/java/org/springframework/core/io/buffer/PooledDataBufferTests.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.
@@ -22,8 +22,7 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
 
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
 
 /**
  * @author Arjen Poutsma
diff --git a/spring-core/src/test/java/org/springframework/core/io/buffer/support/DataBufferTestUtilsTests.java b/spring-core/src/test/java/org/springframework/core/io/buffer/support/DataBufferTestUtilsTests.java
index de32526ccf9..c2912edab50 100644
--- a/spring-core/src/test/java/org/springframework/core/io/buffer/support/DataBufferTestUtilsTests.java
+++ b/spring-core/src/test/java/org/springframework/core/io/buffer/support/DataBufferTestUtilsTests.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.
@@ -23,8 +23,7 @@ import org.junit.Test;
 import org.springframework.core.io.buffer.AbstractDataBufferAllocatingTestCase;
 import org.springframework.core.io.buffer.DataBuffer;
 
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.*;
 
 /**
  * @author Arjen Poutsma
diff --git a/spring-core/src/test/java/org/springframework/core/io/support/EncodedResourceTests.java b/spring-core/src/test/java/org/springframework/core/io/support/EncodedResourceTests.java
index 4239826f50c..13a1d24aa82 100644
--- a/spring-core/src/test/java/org/springframework/core/io/support/EncodedResourceTests.java
+++ b/spring-core/src/test/java/org/springframework/core/io/support/EncodedResourceTests.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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.
@@ -19,6 +19,7 @@ package org.springframework.core.io.support;
 import java.nio.charset.Charset;
 
 import org.junit.Test;
+
 import org.springframework.core.io.DescriptiveResource;
 import org.springframework.core.io.Resource;
 
diff --git a/spring-core/src/test/java/org/springframework/core/io/support/SpringFactoriesLoaderTests.java b/spring-core/src/test/java/org/springframework/core/io/support/SpringFactoriesLoaderTests.java
index e6273f7d89b..d995b65c431 100644
--- a/spring-core/src/test/java/org/springframework/core/io/support/SpringFactoriesLoaderTests.java
+++ b/spring-core/src/test/java/org/springframework/core/io/support/SpringFactoriesLoaderTests.java
@@ -19,10 +19,9 @@ package org.springframework.core.io.support;
 import java.lang.reflect.Modifier;
 import java.util.List;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
+import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
 import static org.junit.Assert.*;
 
 /**
@@ -34,9 +33,6 @@ import static org.junit.Assert.*;
  */
 public class SpringFactoriesLoaderTests {
 
-	@Rule
-	public final ExpectedException exception = ExpectedException.none();
-
 	@Test
 	public void loadFactoriesInCorrectOrder() {
 		List factories = SpringFactoriesLoader.loadFactories(DummyFactory.class, null);
@@ -55,10 +51,10 @@ public class SpringFactoriesLoaderTests {
 
 	@Test
 	public void attemptToLoadFactoryOfIncompatibleType() {
-		exception.expect(IllegalArgumentException.class);
-		exception.expectMessage("Unable to instantiate factory class [org.springframework.core.io.support.MyDummyFactory1] for factory type [java.lang.String]");
-
-		SpringFactoriesLoader.loadFactories(String.class, null);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				SpringFactoriesLoader.loadFactories(String.class, null))
+			.withMessageContaining("Unable to instantiate factory class "
+					+ "[org.springframework.core.io.support.MyDummyFactory1] for factory type [java.lang.String]");
 	}
 
 }
diff --git a/spring-core/src/test/java/org/springframework/core/task/SimpleAsyncTaskExecutorTests.java b/spring-core/src/test/java/org/springframework/core/task/SimpleAsyncTaskExecutorTests.java
index 4cdbcba2380..8c6ccee6805 100644
--- a/spring-core/src/test/java/org/springframework/core/task/SimpleAsyncTaskExecutorTests.java
+++ b/spring-core/src/test/java/org/springframework/core/task/SimpleAsyncTaskExecutorTests.java
@@ -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,12 +18,12 @@ package org.springframework.core.task;
 
 import java.util.concurrent.ThreadFactory;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.util.ConcurrencyThrottleSupport;
 
+import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
+import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
 import static org.hamcrest.CoreMatchers.*;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.Assert.*;
@@ -35,17 +35,13 @@ import static org.junit.Assert.*;
  */
 public class SimpleAsyncTaskExecutorTests {
 
-	@Rule
-	public final ExpectedException exception = ExpectedException.none();
-
-
 	@Test
 	public void cannotExecuteWhenConcurrencyIsSwitchedOff() throws Exception {
 		SimpleAsyncTaskExecutor executor = new SimpleAsyncTaskExecutor();
 		executor.setConcurrencyLimit(ConcurrencyThrottleSupport.NO_CONCURRENCY);
 		assertTrue(executor.isThrottleActive());
-		exception.expect(IllegalStateException.class);
-		executor.execute(new NoOpRunnable());
+		assertThatIllegalStateException().isThrownBy(() ->
+				executor.execute(new NoOpRunnable()));
 	}
 
 	@Test
@@ -80,8 +76,8 @@ public class SimpleAsyncTaskExecutorTests {
 
 	@Test
 	public void throwsExceptionWhenSuppliedWithNullRunnable() throws Exception {
-		exception.expect(IllegalArgumentException.class);
-		new SimpleAsyncTaskExecutor().execute(null);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				new SimpleAsyncTaskExecutor().execute(null));
 	}
 
 	private void executeAndWait(SimpleAsyncTaskExecutor executor, Runnable task, Object monitor) {
diff --git a/spring-core/src/test/java/org/springframework/core/type/AbstractAnnotationMetadataTests.java b/spring-core/src/test/java/org/springframework/core/type/AbstractAnnotationMetadataTests.java
index 398dc3fcb93..825931add39 100644
--- a/spring-core/src/test/java/org/springframework/core/type/AbstractAnnotationMetadataTests.java
+++ b/spring-core/src/test/java/org/springframework/core/type/AbstractAnnotationMetadataTests.java
@@ -5,7 +5,7 @@
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
+ *      https://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/spring-core/src/test/java/org/springframework/core/type/AbstractClassMetadataMemberClassTests.java b/spring-core/src/test/java/org/springframework/core/type/AbstractClassMetadataMemberClassTests.java
index d4e39e6bf09..30adea86ea5 100644
--- a/spring-core/src/test/java/org/springframework/core/type/AbstractClassMetadataMemberClassTests.java
+++ b/spring-core/src/test/java/org/springframework/core/type/AbstractClassMetadataMemberClassTests.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2011 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.
@@ -19,7 +19,7 @@ package org.springframework.core.type;
 import org.junit.Test;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.MatcherAssert.*;
 
 /**
  * Abstract base class for testing implementations of
diff --git a/spring-core/src/test/java/org/springframework/core/type/AbstractMethodMetadataTests.java b/spring-core/src/test/java/org/springframework/core/type/AbstractMethodMetadataTests.java
index 61e99347e30..0bad995d994 100644
--- a/spring-core/src/test/java/org/springframework/core/type/AbstractMethodMetadataTests.java
+++ b/spring-core/src/test/java/org/springframework/core/type/AbstractMethodMetadataTests.java
@@ -5,7 +5,7 @@
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
+ *      https://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/spring-core/src/test/java/org/springframework/core/type/CachingMetadataReaderLeakTests.java b/spring-core/src/test/java/org/springframework/core/type/CachingMetadataReaderLeakTests.java
index aa4c66af8d1..2aa08cb0e70 100644
--- a/spring-core/src/test/java/org/springframework/core/type/CachingMetadataReaderLeakTests.java
+++ b/spring-core/src/test/java/org/springframework/core/type/CachingMetadataReaderLeakTests.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.
@@ -29,7 +29,7 @@ import org.springframework.tests.Assume;
 import org.springframework.tests.TestGroup;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.MatcherAssert.*;
 
 /**
  * Unit tests for checking the behaviour of {@link CachingMetadataReaderFactory} under
diff --git a/spring-core/src/test/java/org/springframework/core/type/StandardAnnotationMetadataTests.java b/spring-core/src/test/java/org/springframework/core/type/StandardAnnotationMetadataTests.java
index 325ecee6e4a..49413a0af0b 100644
--- a/spring-core/src/test/java/org/springframework/core/type/StandardAnnotationMetadataTests.java
+++ b/spring-core/src/test/java/org/springframework/core/type/StandardAnnotationMetadataTests.java
@@ -5,7 +5,7 @@
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
+ *      https://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/spring-core/src/test/java/org/springframework/core/type/StandardMethodMetadataTests.java b/spring-core/src/test/java/org/springframework/core/type/StandardMethodMetadataTests.java
index b55fa6f08e2..397e239aa97 100644
--- a/spring-core/src/test/java/org/springframework/core/type/StandardMethodMetadataTests.java
+++ b/spring-core/src/test/java/org/springframework/core/type/StandardMethodMetadataTests.java
@@ -5,7 +5,7 @@
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
+ *      https://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/spring-core/src/test/java/org/springframework/core/type/classreading/AnnotationMetadataReadingVisitorTests.java b/spring-core/src/test/java/org/springframework/core/type/classreading/AnnotationMetadataReadingVisitorTests.java
index 804ed66923e..4ddcac74e61 100644
--- a/spring-core/src/test/java/org/springframework/core/type/classreading/AnnotationMetadataReadingVisitorTests.java
+++ b/spring-core/src/test/java/org/springframework/core/type/classreading/AnnotationMetadataReadingVisitorTests.java
@@ -5,7 +5,7 @@
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
+ *      https://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -25,7 +25,6 @@ import org.springframework.core.io.Resource;
 import org.springframework.core.io.ResourceLoader;
 import org.springframework.core.type.AbstractAnnotationMetadataTests;
 import org.springframework.core.type.AnnotationMetadata;
-import org.springframework.core.type.classreading.AnnotationMetadataReadingVisitor;
 import org.springframework.util.ClassUtils;
 
 import static org.assertj.core.api.Assertions.*;
diff --git a/spring-core/src/test/java/org/springframework/core/type/classreading/MergedAnnotationMetadataVisitorTests.java b/spring-core/src/test/java/org/springframework/core/type/classreading/MergedAnnotationMetadataVisitorTests.java
index 39732cee77f..a87e22f9c3f 100644
--- a/spring-core/src/test/java/org/springframework/core/type/classreading/MergedAnnotationMetadataVisitorTests.java
+++ b/spring-core/src/test/java/org/springframework/core/type/classreading/MergedAnnotationMetadataVisitorTests.java
@@ -5,7 +5,7 @@
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
+ *      https://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/spring-core/src/test/java/org/springframework/core/type/classreading/MethodMetadataReadingVisitorTests.java b/spring-core/src/test/java/org/springframework/core/type/classreading/MethodMetadataReadingVisitorTests.java
index fad7baad573..2e7a969802d 100644
--- a/spring-core/src/test/java/org/springframework/core/type/classreading/MethodMetadataReadingVisitorTests.java
+++ b/spring-core/src/test/java/org/springframework/core/type/classreading/MethodMetadataReadingVisitorTests.java
@@ -5,7 +5,7 @@
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
+ *      https://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -25,8 +25,6 @@ import org.springframework.core.io.Resource;
 import org.springframework.core.io.ResourceLoader;
 import org.springframework.core.type.AbstractMethodMetadataTests;
 import org.springframework.core.type.AnnotationMetadata;
-import org.springframework.core.type.classreading.AnnotationMetadataReadingVisitor;
-import org.springframework.core.type.classreading.MethodMetadataReadingVisitor;
 import org.springframework.util.ClassUtils;
 
 import static org.assertj.core.api.Assertions.*;
diff --git a/spring-core/src/test/java/org/springframework/core/type/classreading/SimpleAnnotationMetadataTests.java b/spring-core/src/test/java/org/springframework/core/type/classreading/SimpleAnnotationMetadataTests.java
index 59726d67633..96d920825fb 100644
--- a/spring-core/src/test/java/org/springframework/core/type/classreading/SimpleAnnotationMetadataTests.java
+++ b/spring-core/src/test/java/org/springframework/core/type/classreading/SimpleAnnotationMetadataTests.java
@@ -5,7 +5,7 @@
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
+ *      https://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/spring-core/src/test/java/org/springframework/core/type/classreading/SimpleMethodMetadataTests.java b/spring-core/src/test/java/org/springframework/core/type/classreading/SimpleMethodMetadataTests.java
index 3118a460a0e..0ca9bbc75b5 100644
--- a/spring-core/src/test/java/org/springframework/core/type/classreading/SimpleMethodMetadataTests.java
+++ b/spring-core/src/test/java/org/springframework/core/type/classreading/SimpleMethodMetadataTests.java
@@ -5,7 +5,7 @@
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
+ *      https://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
diff --git a/spring-core/src/test/java/org/springframework/tests/Matchers.java b/spring-core/src/test/java/org/springframework/tests/Matchers.java
index aa3d24848f6..1ffd980e958 100644
--- a/spring-core/src/test/java/org/springframework/tests/Matchers.java
+++ b/spring-core/src/test/java/org/springframework/tests/Matchers.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2012 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.
@@ -20,7 +20,6 @@ import org.hamcrest.BaseMatcher;
 import org.hamcrest.Description;
 import org.hamcrest.Matcher;
 import org.junit.Rule;
-import org.junit.rules.ExpectedException;
 
 /**
  * Additional hamcrest matchers.
diff --git a/spring-core/src/test/java/org/springframework/tests/MockitoUtils.java b/spring-core/src/test/java/org/springframework/tests/MockitoUtils.java
index 3b039ae07b4..9d3ee35dbfc 100644
--- a/spring-core/src/test/java/org/springframework/tests/MockitoUtils.java
+++ b/spring-core/src/test/java/org/springframework/tests/MockitoUtils.java
@@ -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.
@@ -23,7 +23,7 @@ import org.mockito.internal.stubbing.InvocationContainerImpl;
 import org.mockito.internal.util.MockUtil;
 import org.mockito.invocation.Invocation;
 
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.MatcherAssert.*;
 import static org.hamcrest.Matchers.*;
 
 /**
diff --git a/spring-core/src/test/java/org/springframework/tests/TestGroupTests.java b/spring-core/src/test/java/org/springframework/tests/TestGroupTests.java
index ee107ba7ed3..ca28df6f9fe 100644
--- a/spring-core/src/test/java/org/springframework/tests/TestGroupTests.java
+++ b/spring-core/src/test/java/org/springframework/tests/TestGroupTests.java
@@ -20,11 +20,10 @@ import java.util.Collections;
 import java.util.EnumSet;
 import java.util.Set;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
+import static org.hamcrest.MatcherAssert.*;
 import static org.hamcrest.Matchers.*;
 
 /**
@@ -35,10 +34,6 @@ import static org.hamcrest.Matchers.*;
  */
 public class TestGroupTests {
 
-	@Rule
-	public ExpectedException thrown = ExpectedException.none();
-
-
 	@Test
 	public void parseNull() {
 		assertThat(TestGroup.parse(null), equalTo(Collections.emptySet()));
@@ -68,11 +63,11 @@ public class TestGroupTests {
 
 	@Test
 	public void parseMissing() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage("Unable to find test group 'missing' when parsing " +
-				"testGroups value: 'performance, missing'. Available groups include: " +
-				"[LONG_RUNNING,PERFORMANCE,CI]");
-		TestGroup.parse("performance, missing");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				TestGroup.parse("performance, missing"))
+			.withMessageContaining("Unable to find test group 'missing' when parsing " +
+					"testGroups value: 'performance, missing'. Available groups include: " +
+					"[LONG_RUNNING,PERFORMANCE,CI]");
 	}
 
 	@Test
@@ -89,11 +84,11 @@ public class TestGroupTests {
 
 	@Test
 	public void parseAllExceptMissing() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage("Unable to find test group 'missing' when parsing " +
-				"testGroups value: 'all-missing'. Available groups include: " +
-				"[LONG_RUNNING,PERFORMANCE,CI]");
-		TestGroup.parse("all-missing");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				TestGroup.parse("all-missing"))
+			.withMessageContaining("Unable to find test group 'missing' when parsing " +
+					"testGroups value: 'all-missing'. Available groups include: " +
+					"[LONG_RUNNING,PERFORMANCE,CI]");
 	}
 
 }
diff --git a/spring-core/src/test/java/org/springframework/tests/package-info.java b/spring-core/src/test/java/org/springframework/tests/package-info.java
index d217689eb4b..cd59135cfd1 100644
--- a/spring-core/src/test/java/org/springframework/tests/package-info.java
+++ b/spring-core/src/test/java/org/springframework/tests/package-info.java
@@ -1,19 +1,3 @@
-/*
- * Copyright 2002-2013 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
 /**
  * Shared utilities that are used internally throughout the test suite but are not
  * published. This package should not be confused with {@code org.springframework.test}
diff --git a/spring-core/src/test/java/org/springframework/util/AntPathMatcherTests.java b/spring-core/src/test/java/org/springframework/util/AntPathMatcherTests.java
index 9d5082a1fd7..c5988418f8e 100644
--- a/spring-core/src/test/java/org/springframework/util/AntPathMatcherTests.java
+++ b/spring-core/src/test/java/org/springframework/util/AntPathMatcherTests.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.
@@ -23,11 +23,9 @@ import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
-import static org.hamcrest.CoreMatchers.*;
+import static org.assertj.core.api.Assertions.*;
 import static org.junit.Assert.*;
 
 /**
@@ -44,9 +42,6 @@ public class AntPathMatcherTests {
 
 	private final AntPathMatcher pathMatcher = new AntPathMatcher();
 
-	@Rule
-	public final ExpectedException exception = ExpectedException.none();
-
 
 	@Test
 	public void match() {
@@ -401,9 +396,9 @@ public class AntPathMatcherTests {
 	 */
 	@Test
 	public void extractUriTemplateVarsRegexCapturingGroups() {
-		exception.expect(IllegalArgumentException.class);
-		exception.expectMessage(containsString("The number of capturing groups in the pattern"));
-		pathMatcher.extractUriTemplateVariables("/web/{id:foo(bar)?}", "/web/foobar");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				pathMatcher.extractUriTemplateVariables("/web/{id:foo(bar)?}", "/web/foobar"))
+			.withMessageContaining("The number of capturing groups in the pattern");
 	}
 
 	@Test
@@ -439,8 +434,8 @@ public class AntPathMatcherTests {
 
 	@Test
 	public void combineWithTwoFileExtensionPatterns() {
-		exception.expect(IllegalArgumentException.class);
-		pathMatcher.combine("/*.html", "/*.txt");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				pathMatcher.combine("/*.html", "/*.txt"));
 	}
 
 	@Test
diff --git a/spring-core/src/test/java/org/springframework/util/AssertTests.java b/spring-core/src/test/java/org/springframework/util/AssertTests.java
index 02c8067f792..c37fccd18a8 100644
--- a/spring-core/src/test/java/org/springframework/util/AssertTests.java
+++ b/spring-core/src/test/java/org/springframework/util/AssertTests.java
@@ -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.
@@ -20,12 +20,10 @@ import java.util.Collection;
 import java.util.Map;
 import java.util.function.Supplier;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import static java.util.Collections.*;
-import static org.hamcrest.CoreMatchers.*;
+import static org.assertj.core.api.Assertions.*;
 
 /**
  * Unit tests for the {@link Assert} class.
@@ -39,9 +37,6 @@ import static org.hamcrest.CoreMatchers.*;
  */
 public class AssertTests {
 
-	@Rule
-	public final ExpectedException thrown = ExpectedException.none();
-
 
 	@Test
 	public void stateWithMessage() {
@@ -50,9 +45,8 @@ public class AssertTests {
 
 	@Test
 	public void stateWithFalseExpressionAndMessage() {
-		thrown.expect(IllegalStateException.class);
-		thrown.expectMessage("enigma");
-		Assert.state(false, "enigma");
+		assertThatIllegalStateException().isThrownBy(() ->
+		Assert.state(false, "enigma")).withMessageContaining("enigma");
 	}
 
 	@Test
@@ -62,16 +56,16 @@ public class AssertTests {
 
 	@Test
 	public void stateWithFalseExpressionAndMessageSupplier() {
-		thrown.expect(IllegalStateException.class);
-		thrown.expectMessage("enigma");
-		Assert.state(false, () -> "enigma");
+		assertThatIllegalStateException().isThrownBy(() ->
+				Assert.state(false, () -> "enigma"))
+			.withMessageContaining("enigma");
 	}
 
 	@Test
 	public void stateWithFalseExpressionAndNullMessageSupplier() {
-		thrown.expect(IllegalStateException.class);
-		thrown.expectMessage(equalTo(null));
-		Assert.state(false, (Supplier) null);
+		assertThatIllegalStateException().isThrownBy(() ->
+				Assert.state(false, (Supplier) null))
+			.withMessage(null);
 	}
 
 	@Test
@@ -81,9 +75,9 @@ public class AssertTests {
 
 	@Test
 	public void isTrueWithFalse() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage("enigma");
-		Assert.isTrue(false, "enigma");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.isTrue(false, "enigma"))
+			.withMessageContaining("enigma");
 	}
 
 	@Test
@@ -93,16 +87,16 @@ public class AssertTests {
 
 	@Test
 	public void isTrueWithFalseAndMessageSupplier() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage("enigma");
-		Assert.isTrue(false, () -> "enigma");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.isTrue(false, () -> "enigma"))
+			.withMessageContaining("enigma");
 	}
 
 	@Test
 	public void isTrueWithFalseAndNullMessageSupplier() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage(equalTo(null));
-		Assert.isTrue(false, (Supplier) null);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.isTrue(false, (Supplier) null))
+			.withMessage(null);
 	}
 
 	@Test
@@ -117,16 +111,16 @@ public class AssertTests {
 
 	@Test
 	public void isNullWithNonNullObjectAndMessageSupplier() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage("enigma");
-		Assert.isNull("foo", () -> "enigma");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.isNull("foo", () -> "enigma"))
+			.withMessageContaining("enigma");
 	}
 
 	@Test
 	public void isNullWithNonNullObjectAndNullMessageSupplier() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage(equalTo(null));
-		Assert.isNull("foo", (Supplier) null);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.isNull("foo", (Supplier) null))
+			.withMessage(null);
 	}
 
 	@Test
@@ -141,16 +135,16 @@ public class AssertTests {
 
 	@Test
 	public void notNullWithNullAndMessageSupplier() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage("enigma");
-		Assert.notNull(null, () -> "enigma");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.notNull(null, () -> "enigma"))
+			.withMessageContaining("enigma");
 	}
 
 	@Test
 	public void notNullWithNullAndNullMessageSupplier() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage(equalTo(null));
-		Assert.notNull(null, (Supplier) null);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.notNull(null, (Supplier) null))
+			.withMessage(null);
 	}
 
 	@Test
@@ -165,16 +159,16 @@ public class AssertTests {
 
 	@Test
 	public void hasLengthWithEmptyString() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage("enigma");
-		Assert.hasLength("", "enigma");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.hasLength("", "enigma"))
+			.withMessageContaining("enigma");
 	}
 
 	@Test
 	public void hasLengthWithNull() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage("enigma");
-		Assert.hasLength(null, "enigma");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.hasLength(null, "enigma"))
+			.withMessageContaining("enigma");
 	}
 
 	@Test
@@ -189,23 +183,23 @@ public class AssertTests {
 
 	@Test
 	public void hasLengthWithEmptyStringAndMessageSupplier() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage("enigma");
-		Assert.hasLength("", () -> "enigma");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.hasLength("", () -> "enigma"))
+			.withMessageContaining("enigma");
 	}
 
 	@Test
 	public void hasLengthWithNullAndMessageSupplier() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage("enigma");
-		Assert.hasLength(null, () -> "enigma");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.hasLength(null, () -> "enigma"))
+			.withMessageContaining("enigma");
 	}
 
 	@Test
 	public void hasLengthWithNullAndNullMessageSupplier() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage(equalTo(null));
-		Assert.hasLength(null, (Supplier) null);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.hasLength(null, (Supplier) null))
+			.withMessage(null);
 	}
 
 	@Test
@@ -215,23 +209,23 @@ public class AssertTests {
 
 	@Test
 	public void hasTextWithWhitespaceOnly() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage("enigma");
-		Assert.hasText("\t ", "enigma");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.hasText("\t ", "enigma"))
+			.withMessageContaining("enigma");
 	}
 
 	@Test
 	public void hasTextWithEmptyString() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage("enigma");
-		Assert.hasText("", "enigma");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.hasText("", "enigma"))
+			.withMessageContaining("enigma");
 	}
 
 	@Test
 	public void hasTextWithNull() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage("enigma");
-		Assert.hasText(null, "enigma");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.hasText(null, "enigma"))
+			.withMessageContaining("enigma");
 	}
 
 	@Test
@@ -241,30 +235,29 @@ public class AssertTests {
 
 	@Test
 	public void hasTextWithWhitespaceOnlyAndMessageSupplier() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage("enigma");
-		Assert.hasText("\t ", () -> "enigma");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.hasText("\t ", () -> "enigma"))
+			.withMessageContaining("enigma");
 	}
 
 	@Test
 	public void hasTextWithEmptyStringAndMessageSupplier() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage("enigma");
-		Assert.hasText("", () -> "enigma");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+		Assert.hasText("", () -> "enigma")).withMessageContaining("enigma");
 	}
 
 	@Test
 	public void hasTextWithNullAndMessageSupplier() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage("enigma");
-		Assert.hasText(null, () -> "enigma");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.hasText(null, () -> "enigma"))
+			.withMessageContaining("enigma");
 	}
 
 	@Test
 	public void hasTextWithNullAndNullMessageSupplier() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage(equalTo(null));
-		Assert.hasText(null, (Supplier) null);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.hasText(null, (Supplier) null))
+			.withMessage(null);
 	}
 
 	@Test
@@ -309,16 +302,16 @@ public class AssertTests {
 
 	@Test
 	public void doesNotContainWithSubstringPresentInSearchStringAndMessageSupplier() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage("enigma");
-		Assert.doesNotContain("1234", "23", () -> "enigma");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.doesNotContain("1234", "23", () -> "enigma"))
+			.withMessageContaining("enigma");
 	}
 
 	@Test
 	public void doesNotContainWithNullMessageSupplier() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage(equalTo(null));
-		Assert.doesNotContain("1234", "23", (Supplier) null);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.doesNotContain("1234", "23", (Supplier) null))
+			.withMessage(null);
 	}
 
 	@Test
@@ -328,16 +321,16 @@ public class AssertTests {
 
 	@Test
 	public void notEmptyArrayWithEmptyArray() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage("enigma");
-		Assert.notEmpty(new String[] {}, "enigma");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.notEmpty(new String[] {}, "enigma"))
+			.withMessageContaining("enigma");
 	}
 
 	@Test
 	public void notEmptyArrayWithNullArray() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage("enigma");
-		Assert.notEmpty((Object[]) null, "enigma");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.notEmpty((Object[]) null, "enigma"))
+			.withMessageContaining("enigma");
 	}
 
 	@Test
@@ -347,23 +340,23 @@ public class AssertTests {
 
 	@Test
 	public void notEmptyArrayWithEmptyArrayAndMessageSupplier() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage("enigma");
-		Assert.notEmpty(new String[] {}, () -> "enigma");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.notEmpty(new String[] {}, () -> "enigma"))
+			.withMessageContaining("enigma");
 	}
 
 	@Test
 	public void notEmptyArrayWithNullArrayAndMessageSupplier() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage("enigma");
-		Assert.notEmpty((Object[]) null, () -> "enigma");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.notEmpty((Object[]) null, () -> "enigma"))
+			.withMessageContaining("enigma");
 	}
 
 	@Test
 	public void notEmptyArrayWithEmptyArrayAndNullMessageSupplier() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage(equalTo(null));
-		Assert.notEmpty(new String[] {}, (Supplier) null);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.notEmpty(new String[] {}, (Supplier) null))
+			.withMessage(null);
 	}
 
 	@Test
@@ -393,16 +386,16 @@ public class AssertTests {
 
 	@Test
 	public void noNullElementsWithNullElementsAndMessageSupplier() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage("enigma");
-		Assert.noNullElements(new String[] { "foo", null, "bar" }, () -> "enigma");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.noNullElements(new String[] { "foo", null, "bar" }, () -> "enigma"))
+			.withMessageContaining("enigma");
 	}
 
 	@Test
 	public void noNullElementsWithNullElementsAndNullMessageSupplier() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage(equalTo(null));
-		Assert.noNullElements(new String[] { "foo", null, "bar" }, (Supplier) null);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.noNullElements(new String[] { "foo", null, "bar" }, (Supplier) null))
+			.withMessage(null);
 	}
 
 	@Test
@@ -412,16 +405,16 @@ public class AssertTests {
 
 	@Test
 	public void notEmptyCollectionWithEmptyCollection() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage("enigma");
-		Assert.notEmpty(emptyList(), "enigma");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.notEmpty(emptyList(), "enigma"))
+			.withMessageContaining("enigma");
 	}
 
 	@Test
 	public void notEmptyCollectionWithNullCollection() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage("enigma");
-		Assert.notEmpty((Collection) null, "enigma");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.notEmpty((Collection) null, "enigma"))
+			.withMessageContaining("enigma");
 	}
 
 	@Test
@@ -431,23 +424,23 @@ public class AssertTests {
 
 	@Test
 	public void notEmptyCollectionWithEmptyCollectionAndMessageSupplier() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage("enigma");
-		Assert.notEmpty(emptyList(), () -> "enigma");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.notEmpty(emptyList(), () -> "enigma"))
+			.withMessageContaining("enigma");
 	}
 
 	@Test
 	public void notEmptyCollectionWithNullCollectionAndMessageSupplier() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage("enigma");
-		Assert.notEmpty((Collection) null, () -> "enigma");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.notEmpty((Collection) null, () -> "enigma"))
+			.withMessageContaining("enigma");
 	}
 
 	@Test
 	public void notEmptyCollectionWithEmptyCollectionAndNullMessageSupplier() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage(equalTo(null));
-		Assert.notEmpty(emptyList(), (Supplier) null);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.notEmpty(emptyList(), (Supplier) null))
+			.withMessage(null);
 	}
 
 	@Test
@@ -457,16 +450,16 @@ public class AssertTests {
 
 	@Test
 	public void notEmptyMapWithNullMap() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage("enigma");
-		Assert.notEmpty((Map) null, "enigma");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.notEmpty((Map) null, "enigma"))
+			.withMessageContaining("enigma");
 	}
 
 	@Test
 	public void notEmptyMapWithEmptyMap() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage("enigma");
-		Assert.notEmpty(emptyMap(), "enigma");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.notEmpty(emptyMap(), "enigma"))
+			.withMessageContaining("enigma");
 	}
 
 	@Test
@@ -476,23 +469,23 @@ public class AssertTests {
 
 	@Test
 	public void notEmptyMapWithEmptyMapAndMessageSupplier() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage("enigma");
-		Assert.notEmpty(emptyMap(), () -> "enigma");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.notEmpty(emptyMap(), () -> "enigma"))
+			.withMessageContaining("enigma");
 	}
 
 	@Test
 	public void notEmptyMapWithNullMapAndMessageSupplier() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage("enigma");
-		Assert.notEmpty((Map) null, () -> "enigma");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.notEmpty((Map) null, () -> "enigma"))
+			.withMessageContaining("enigma");
 	}
 
 	@Test
 	public void notEmptyMapWithEmptyMapAndNullMessageSupplier() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage(equalTo(null));
-		Assert.notEmpty(emptyMap(), (Supplier) null);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.notEmpty(emptyMap(), (Supplier) null))
+			.withMessage(null);
 	}
 
 	@Test
@@ -502,45 +495,44 @@ public class AssertTests {
 
 	@Test
 	public void isInstanceOfWithNullType() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage("Type to check against must not be null");
-		Assert.isInstanceOf(null, "foo", "enigma");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.isInstanceOf(null, "foo", "enigma"))
+			.withMessageContaining("Type to check against must not be null");
 	}
 
 	@Test
 	public void isInstanceOfWithNullInstance() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage("enigma: null");
-		Assert.isInstanceOf(String.class, null, "enigma");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.isInstanceOf(String.class, null, "enigma"))
+			.withMessageContaining("enigma: null");
 	}
 
 	@Test
 	public void isInstanceOfWithTypeMismatchAndNullMessage() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage("Object of class [java.lang.Long] must be an instance of class java.lang.String");
-		Assert.isInstanceOf(String.class, 42L, (String) null);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.isInstanceOf(String.class, 42L, (String) null))
+			.withMessageContaining("Object of class [java.lang.Long] must be an instance of class java.lang.String");
 	}
 
 	@Test
 	public void isInstanceOfWithTypeMismatchAndCustomMessage() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage("Custom message: java.lang.Long");
-		Assert.isInstanceOf(String.class, 42L, "Custom message");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.isInstanceOf(String.class, 42L, "Custom message"))
+			.withMessageContaining("Custom message: java.lang.Long");
 	}
 
 	@Test
 	public void isInstanceOfWithTypeMismatchAndCustomMessageWithSeparator() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage(
-				"Custom message: Object of class [java.lang.Long] must be an instance of class java.lang.String");
-		Assert.isInstanceOf(String.class, 42L, "Custom message:");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.isInstanceOf(String.class, 42L, "Custom message:"))
+			.withMessageContaining("Custom message: Object of class [java.lang.Long] must be an instance of class java.lang.String");
 	}
 
 	@Test
 	public void isInstanceOfWithTypeMismatchAndCustomMessageWithSpace() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage("Custom message for java.lang.Long");
-		Assert.isInstanceOf(String.class, 42L, "Custom message for ");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.isInstanceOf(String.class, 42L, "Custom message for "))
+			.withMessageContaining("Custom message for java.lang.Long");
 	}
 
 	@Test
@@ -550,30 +542,30 @@ public class AssertTests {
 
 	@Test
 	public void isInstanceOfWithNullTypeAndMessageSupplier() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage("Type to check against must not be null");
-		Assert.isInstanceOf(null, "foo", () -> "enigma");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.isInstanceOf(null, "foo", () -> "enigma"))
+			.withMessageContaining("Type to check against must not be null");
 	}
 
 	@Test
 	public void isInstanceOfWithNullInstanceAndMessageSupplier() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage("enigma: null");
-		Assert.isInstanceOf(String.class, null, () -> "enigma");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.isInstanceOf(String.class, null, () -> "enigma"))
+			.withMessageContaining("enigma: null");
 	}
 
 	@Test
 	public void isInstanceOfWithTypeMismatchAndNullMessageSupplier() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage("Object of class [java.lang.Long] must be an instance of class java.lang.String");
-		Assert.isInstanceOf(String.class, 42L, (Supplier) null);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.isInstanceOf(String.class, 42L, (Supplier) null))
+			.withMessageContaining("Object of class [java.lang.Long] must be an instance of class java.lang.String");
 	}
 
 	@Test
 	public void isInstanceOfWithTypeMismatchAndMessageSupplier() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage("enigma: java.lang.Long");
-		Assert.isInstanceOf(String.class, 42L, () -> "enigma");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.isInstanceOf(String.class, 42L, () -> "enigma"))
+			.withMessageContaining("enigma: java.lang.Long");
 	}
 
 	@Test
@@ -583,44 +575,44 @@ public class AssertTests {
 
 	@Test
 	public void isAssignableWithNullSupertype() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage("Super type to check against must not be null");
-		Assert.isAssignable(null, Integer.class, "enigma");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.isAssignable(null, Integer.class, "enigma"))
+			.withMessageContaining("Super type to check against must not be null");
 	}
 
 	@Test
 	public void isAssignableWithNullSubtype() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage("enigma: null");
-		Assert.isAssignable(Integer.class, null, "enigma");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.isAssignable(Integer.class, null, "enigma"))
+			.withMessageContaining("enigma: null");
 	}
 
 	@Test
 	public void isAssignableWithTypeMismatchAndNullMessage() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage("class java.lang.Integer is not assignable to class java.lang.String");
-		Assert.isAssignable(String.class, Integer.class, (String) null);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.isAssignable(String.class, Integer.class, (String) null))
+			.withMessageContaining("class java.lang.Integer is not assignable to class java.lang.String");
 	}
 
 	@Test
 	public void isAssignableWithTypeMismatchAndCustomMessage() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage("Custom message: class java.lang.Integer");
-		Assert.isAssignable(String.class, Integer.class, "Custom message");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.isAssignable(String.class, Integer.class, "Custom message"))
+			.withMessageContaining("Custom message: class java.lang.Integer");
 	}
 
 	@Test
 	public void isAssignableWithTypeMismatchAndCustomMessageWithSeparator() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage("Custom message: class java.lang.Integer is not assignable to class java.lang.String");
-		Assert.isAssignable(String.class, Integer.class, "Custom message:");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.isAssignable(String.class, Integer.class, "Custom message:"))
+			.withMessageContaining("Custom message: class java.lang.Integer is not assignable to class java.lang.String");
 	}
 
 	@Test
 	public void isAssignableWithTypeMismatchAndCustomMessageWithSpace() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage("Custom message for class java.lang.Integer");
-		Assert.isAssignable(String.class, Integer.class, "Custom message for ");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.isAssignable(String.class, Integer.class, "Custom message for "))
+			.withMessageContaining("Custom message for class java.lang.Integer");
 	}
 
 	@Test
@@ -630,30 +622,30 @@ public class AssertTests {
 
 	@Test
 	public void isAssignableWithNullSupertypeAndMessageSupplier() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage("Super type to check against must not be null");
-		Assert.isAssignable(null, Integer.class, () -> "enigma");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.isAssignable(null, Integer.class, () -> "enigma"))
+			.withMessageContaining("Super type to check against must not be null");
 	}
 
 	@Test
 	public void isAssignableWithNullSubtypeAndMessageSupplier() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage("enigma: null");
-		Assert.isAssignable(Integer.class, null, () -> "enigma");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.isAssignable(Integer.class, null, () -> "enigma"))
+			.withMessageContaining("enigma: null");
 	}
 
 	@Test
 	public void isAssignableWithTypeMismatchAndNullMessageSupplier() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage("class java.lang.Integer is not assignable to class java.lang.String");
-		Assert.isAssignable(String.class, Integer.class, (Supplier) null);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.isAssignable(String.class, Integer.class, (Supplier) null))
+			.withMessageContaining("class java.lang.Integer is not assignable to class java.lang.String");
 	}
 
 	@Test
 	public void isAssignableWithTypeMismatchAndMessageSupplier() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage("enigma: class java.lang.Integer");
-		Assert.isAssignable(String.class, Integer.class, () -> "enigma");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				Assert.isAssignable(String.class, Integer.class, () -> "enigma"))
+			.withMessageContaining("enigma: class java.lang.Integer");
 	}
 
 	@Test
@@ -663,9 +655,9 @@ public class AssertTests {
 
 	@Test
 	public void stateWithFalseExpression() {
-		thrown.expect(IllegalStateException.class);
-		thrown.expectMessage("enigma");
-		Assert.state(false, "enigma");
+		assertThatIllegalStateException().isThrownBy(() ->
+				Assert.state(false, "enigma"))
+			.withMessageContaining("enigma");
 	}
 
 }
diff --git a/spring-core/src/test/java/org/springframework/util/ConcurrentReferenceHashMapTests.java b/spring-core/src/test/java/org/springframework/util/ConcurrentReferenceHashMapTests.java
index 6525ffdda4f..e20290694da 100644
--- a/spring-core/src/test/java/org/springframework/util/ConcurrentReferenceHashMapTests.java
+++ b/spring-core/src/test/java/org/springframework/util/ConcurrentReferenceHashMapTests.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.
@@ -30,9 +30,7 @@ import java.util.Set;
 import java.util.WeakHashMap;
 
 import org.junit.Ignore;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.lang.Nullable;
 import org.springframework.util.ConcurrentReferenceHashMap.Entry;
@@ -41,6 +39,7 @@ import org.springframework.util.ConcurrentReferenceHashMap.Restructure;
 import org.springframework.util.comparator.ComparableComparator;
 import org.springframework.util.comparator.NullSafeComparator;
 
+import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.*;
 import static org.junit.Assert.*;
@@ -55,9 +54,6 @@ public class ConcurrentReferenceHashMapTests {
 	private static final Comparator NULL_SAFE_STRING_SORT = new NullSafeComparator(
 			new ComparableComparator(), true);
 
-	@Rule
-	public ExpectedException thrown = ExpectedException.none();
-
 	private TestWeakConcurrentCache map = new TestWeakConcurrentCache<>();
 
 
@@ -106,25 +102,25 @@ public class ConcurrentReferenceHashMapTests {
 	@Test
 	public void shouldNeedNonNegativeInitialCapacity() {
 		new ConcurrentReferenceHashMap(0, 1);
-		this.thrown.expect(IllegalArgumentException.class);
-		this.thrown.expectMessage("Initial capacity must not be negative");
-		new TestWeakConcurrentCache(-1, 1);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				new TestWeakConcurrentCache(-1, 1))
+			.withMessageContaining("Initial capacity must not be negative");
 	}
 
 	@Test
 	public void shouldNeedPositiveLoadFactor() {
 		new ConcurrentReferenceHashMap(0, 0.1f, 1);
-		this.thrown.expect(IllegalArgumentException.class);
-		this.thrown.expectMessage("Load factor must be positive");
-		new TestWeakConcurrentCache(0, 0.0f, 1);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				new TestWeakConcurrentCache(0, 0.0f, 1))
+			.withMessageContaining("Load factor must be positive");
 	}
 
 	@Test
 	public void shouldNeedPositiveConcurrencyLevel() {
 		new ConcurrentReferenceHashMap(1, 1);
-		this.thrown.expect(IllegalArgumentException.class);
-		this.thrown.expectMessage("Concurrency level must be positive");
-		new TestWeakConcurrentCache(1, 0);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				new TestWeakConcurrentCache(1, 0))
+			.withMessageContaining("Concurrency level must be positive");
 	}
 
 	@Test
diff --git a/spring-core/src/test/java/org/springframework/util/ExponentialBackOffTests.java b/spring-core/src/test/java/org/springframework/util/ExponentialBackOffTests.java
index 7846b33887b..03b0cd93416 100644
--- a/spring-core/src/test/java/org/springframework/util/ExponentialBackOffTests.java
+++ b/spring-core/src/test/java/org/springframework/util/ExponentialBackOffTests.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.
@@ -16,13 +16,12 @@
 
 package org.springframework.util;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.util.backoff.BackOffExecution;
 import org.springframework.util.backoff.ExponentialBackOff;
 
+import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
 import static org.junit.Assert.*;
 
 /**
@@ -31,9 +30,6 @@ import static org.junit.Assert.*;
  */
 public class ExponentialBackOffTests {
 
-	@Rule
-	public final ExpectedException thrown = ExpectedException.none();
-
 	@Test
 	public void defaultInstance() {
 		ExponentialBackOff backOff = new ExponentialBackOff();
@@ -109,9 +105,8 @@ public class ExponentialBackOffTests {
 	@Test
 	public void invalidInterval() {
 		ExponentialBackOff backOff = new ExponentialBackOff();
-
-		thrown.expect(IllegalArgumentException.class);
-		backOff.setMultiplier(0.9);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				backOff.setMultiplier(0.9));
 	}
 
 	@Test
diff --git a/spring-core/src/test/java/org/springframework/util/FastByteArrayOutputStreamTests.java b/spring-core/src/test/java/org/springframework/util/FastByteArrayOutputStreamTests.java
index 7f784398615..1a718d752db 100644
--- a/spring-core/src/test/java/org/springframework/util/FastByteArrayOutputStreamTests.java
+++ b/spring-core/src/test/java/org/springframework/util/FastByteArrayOutputStreamTests.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.
@@ -35,9 +35,9 @@ public class FastByteArrayOutputStreamTests {
 
 	private static final int INITIAL_CAPACITY = 256;
 
-	private final FastByteArrayOutputStream os = new FastByteArrayOutputStream(INITIAL_CAPACITY);;
+	private final FastByteArrayOutputStream os = new FastByteArrayOutputStream(INITIAL_CAPACITY);
 
-	private final byte[] helloBytes = "Hello World".getBytes(StandardCharsets.UTF_8);;
+	private final byte[] helloBytes = "Hello World".getBytes(StandardCharsets.UTF_8);
 
 
 	@Test
diff --git a/spring-core/src/test/java/org/springframework/util/MethodInvokerTests.java b/spring-core/src/test/java/org/springframework/util/MethodInvokerTests.java
index a199fd39786..59b2c86b28c 100644
--- a/spring-core/src/test/java/org/springframework/util/MethodInvokerTests.java
+++ b/spring-core/src/test/java/org/springframework/util/MethodInvokerTests.java
@@ -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.
@@ -20,10 +20,9 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
 import static org.junit.Assert.*;
 
 /**
@@ -34,10 +33,6 @@ import static org.junit.Assert.*;
  */
 public class MethodInvokerTests {
 
-	@Rule
-	public final ExpectedException exception = ExpectedException.none();
-
-
 	@Test
 	public void plainMethodInvoker() throws Exception {
 		// sanity check: singleton, non-static should work
@@ -80,8 +75,8 @@ public class MethodInvokerTests {
 		mi.setTargetMethod("supertypes2");
 		mi.setArguments(new ArrayList<>(), new ArrayList<>(), "hello", Boolean.TRUE);
 
-		exception.expect(NoSuchMethodException.class);
-		mi.prepare();
+		assertThatExceptionOfType(NoSuchMethodException.class).isThrownBy(
+				mi::prepare);
 	}
 
 	@Test
@@ -91,8 +86,8 @@ public class MethodInvokerTests {
 		methodInvoker.setTargetMethod("greet");
 		methodInvoker.setArguments("no match");
 
-		exception.expect(NoSuchMethodException.class);
-		methodInvoker.prepare();
+		assertThatExceptionOfType(NoSuchMethodException.class).isThrownBy(
+				methodInvoker::prepare);
 	}
 
 	@Test
diff --git a/spring-core/src/test/java/org/springframework/util/ObjectUtilsTests.java b/spring-core/src/test/java/org/springframework/util/ObjectUtilsTests.java
index 79ef18b5a81..ad463840123 100644
--- a/spring-core/src/test/java/org/springframework/util/ObjectUtilsTests.java
+++ b/spring-core/src/test/java/org/springframework/util/ObjectUtilsTests.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.
@@ -24,10 +24,9 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Set;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
+import static org.assertj.core.api.Assertions.*;
 import static org.hamcrest.CoreMatchers.*;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.Assert.*;
@@ -43,10 +42,6 @@ import static org.springframework.util.ObjectUtils.*;
  */
 public class ObjectUtilsTests {
 
-	@Rule
-	public final ExpectedException exception = ExpectedException.none();
-
-
 	@Test
 	public void isCheckedException() {
 		assertTrue(ObjectUtils.isCheckedException(new Exception()));
@@ -170,8 +165,8 @@ public class ObjectUtilsTests {
 
 	@Test
 	public void toObjectArrayWithNonArrayType() {
-		exception.expect(IllegalArgumentException.class);
-		ObjectUtils.toObjectArray("Not an []");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				ObjectUtils.toObjectArray("Not an []"));
 	}
 
 	@Test
@@ -808,10 +803,9 @@ public class ObjectUtilsTests {
 		assertThat(ObjectUtils.caseInsensitiveValueOf(Tropes.values(), "foo"), is(Tropes.FOO));
 		assertThat(ObjectUtils.caseInsensitiveValueOf(Tropes.values(), "BAR"), is(Tropes.BAR));
 
-		exception.expect(IllegalArgumentException.class);
-		exception.expectMessage(
-				is("Constant [bogus] does not exist in enum type org.springframework.util.ObjectUtilsTests$Tropes"));
-		ObjectUtils.caseInsensitiveValueOf(Tropes.values(), "bogus");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				ObjectUtils.caseInsensitiveValueOf(Tropes.values(), "bogus"))
+			.withMessage("Constant [bogus] does not exist in enum type org.springframework.util.ObjectUtilsTests$Tropes");
 	}
 
 	private void assertEqualHashCodes(int expected, Object array) {
diff --git a/spring-core/src/test/java/org/springframework/util/SocketUtilsTests.java b/spring-core/src/test/java/org/springframework/util/SocketUtilsTests.java
index 5592be69a2e..eee15cd6479 100644
--- a/spring-core/src/test/java/org/springframework/util/SocketUtilsTests.java
+++ b/spring-core/src/test/java/org/springframework/util/SocketUtilsTests.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.
@@ -22,14 +22,11 @@ import java.net.ServerSocket;
 import java.util.SortedSet;
 import javax.net.ServerSocketFactory;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
-import static org.hamcrest.CoreMatchers.*;
+import static org.assertj.core.api.Assertions.*;
 import static org.junit.Assert.*;
-import static org.springframework.util.SocketUtils.PORT_RANGE_MIN;
-import static org.springframework.util.SocketUtils.PORT_RANGE_MAX;
+import static org.springframework.util.SocketUtils.*;
 
 /**
  * Unit tests for {@link SocketUtils}.
@@ -39,9 +36,6 @@ import static org.springframework.util.SocketUtils.PORT_RANGE_MAX;
  */
 public class SocketUtilsTests {
 
-	@Rule
-	public final ExpectedException exception = ExpectedException.none();
-
 	@Test
 	public void canBeInstantiated() {
 		// Just making sure somebody doesn't try to make SocketUtils abstract,
@@ -54,14 +48,14 @@ public class SocketUtilsTests {
 
 	@Test
 	public void findAvailableTcpPortWithZeroMinPort() {
-		exception.expect(IllegalArgumentException.class);
-		SocketUtils.findAvailableTcpPort(0);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				SocketUtils.findAvailableTcpPort(0));
 	}
 
 	@Test
 	public void findAvailableTcpPortWithNegativeMinPort() {
-		exception.expect(IllegalArgumentException.class);
-		SocketUtils.findAvailableTcpPort(-500);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				SocketUtils.findAvailableTcpPort(-500));
 	}
 
 	@Test
@@ -82,11 +76,11 @@ public class SocketUtilsTests {
 		int port = SocketUtils.findAvailableTcpPort();
 		ServerSocket socket = ServerSocketFactory.getDefault().createServerSocket(port, 1, InetAddress.getByName("localhost"));
 		try {
-			exception.expect(IllegalStateException.class);
-			exception.expectMessage(startsWith("Could not find an available TCP port"));
-			exception.expectMessage(endsWith("after 1 attempts"));
 			// will only look for the exact port
-			SocketUtils.findAvailableTcpPort(port, port);
+			assertThatIllegalStateException().isThrownBy(() ->
+					SocketUtils.findAvailableTcpPort(port, port))
+				.withMessageStartingWith("Could not find an available TCP port")
+				.withMessageEndingWith("after 1 attempts");
 		}
 		finally {
 			socket.close();
@@ -129,8 +123,8 @@ public class SocketUtilsTests {
 
 	@Test
 	public void findAvailableTcpPortsWithRequestedNumberGreaterThanSizeOfRange() {
-		exception.expect(IllegalArgumentException.class);
-		findAvailableTcpPorts(50, 45000, 45010);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				findAvailableTcpPorts(50, 45000, 45010));
 	}
 
 
@@ -138,14 +132,14 @@ public class SocketUtilsTests {
 
 	@Test
 	public void findAvailableUdpPortWithZeroMinPort() {
-		exception.expect(IllegalArgumentException.class);
-		SocketUtils.findAvailableUdpPort(0);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				SocketUtils.findAvailableUdpPort(0));
 	}
 
 	@Test
 	public void findAvailableUdpPortWithNegativeMinPort() {
-		exception.expect(IllegalArgumentException.class);
-		SocketUtils.findAvailableUdpPort(-500);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				SocketUtils.findAvailableUdpPort(-500));
 	}
 
 	@Test
@@ -159,11 +153,11 @@ public class SocketUtilsTests {
 		int port = SocketUtils.findAvailableUdpPort();
 		DatagramSocket socket = new DatagramSocket(port, InetAddress.getByName("localhost"));
 		try {
-			exception.expect(IllegalStateException.class);
-			exception.expectMessage(startsWith("Could not find an available UDP port"));
-			exception.expectMessage(endsWith("after 1 attempts"));
 			// will only look for the exact port
-			SocketUtils.findAvailableUdpPort(port, port);
+			assertThatIllegalStateException().isThrownBy(() ->
+					SocketUtils.findAvailableUdpPort(port, port))
+				.withMessageStartingWith("Could not find an available UDP port")
+				.withMessageEndingWith("after 1 attempts");
 		}
 		finally {
 			socket.close();
@@ -206,8 +200,8 @@ public class SocketUtilsTests {
 
 	@Test
 	public void findAvailableUdpPortsWithRequestedNumberGreaterThanSizeOfRange() {
-		exception.expect(IllegalArgumentException.class);
-		findAvailableUdpPorts(50, 45000, 45010);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				findAvailableUdpPorts(50, 45000, 45010));
 	}
 
 
diff --git a/spring-core/src/test/java/org/springframework/util/StopWatchTests.java b/spring-core/src/test/java/org/springframework/util/StopWatchTests.java
index db1c5e5393f..2b8e279e071 100644
--- a/spring-core/src/test/java/org/springframework/util/StopWatchTests.java
+++ b/spring-core/src/test/java/org/springframework/util/StopWatchTests.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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,10 @@
 
 package org.springframework.util;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
+import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
 import static org.junit.Assert.*;
 
 /**
@@ -31,9 +31,6 @@ public class StopWatchTests {
 
 	private final StopWatch sw = new StopWatch();
 
-	@Rule
-	public final ExpectedException exception = ExpectedException.none();
-
 	@Test
 	public void validUsage() throws Exception {
 		String id = "myId";
@@ -122,20 +119,20 @@ public class StopWatchTests {
 		assertFalse(toString.contains(name1));
 		assertFalse(toString.contains(name2));
 
-		exception.expect(UnsupportedOperationException.class);
-		sw.getTaskInfo();
+		assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(
+				sw::getTaskInfo);
 	}
 
 	@Test
 	public void failureToStartBeforeGettingTimings() {
-		exception.expect(IllegalStateException.class);
-		sw.getLastTaskTimeMillis();
+		assertThatIllegalStateException().isThrownBy(
+				sw::getLastTaskTimeMillis);
 	}
 
 	@Test
 	public void failureToStartBeforeStop() {
-		exception.expect(IllegalStateException.class);
-		sw.stop();
+		assertThatIllegalStateException().isThrownBy(
+				sw::stop);
 	}
 
 	@Test
@@ -144,8 +141,8 @@ public class StopWatchTests {
 		sw.stop();
 		sw.start("");
 		assertTrue(sw.isRunning());
-		exception.expect(IllegalStateException.class);
-		sw.start("");
+		assertThatIllegalStateException().isThrownBy(() ->
+				sw.start(""));
 	}
 
 }
diff --git a/spring-core/src/test/java/org/springframework/util/StreamUtilsTests.java b/spring-core/src/test/java/org/springframework/util/StreamUtilsTests.java
index 88a3457818d..cb3ea8b32b2 100644
--- a/spring-core/src/test/java/org/springframework/util/StreamUtilsTests.java
+++ b/spring-core/src/test/java/org/springframework/util/StreamUtilsTests.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2013 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.
@@ -29,9 +29,9 @@ import org.junit.Before;
 import org.junit.Test;
 import org.mockito.InOrder;
 
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.MatcherAssert.*;
 import static org.hamcrest.Matchers.*;
-import static org.mockito.BDDMockito.*;
+import static org.mockito.Mockito.*;
 
 /**
  * Tests for {@link StreamUtils}.
diff --git a/spring-core/src/test/java/org/springframework/util/comparator/BooleanComparatorTests.java b/spring-core/src/test/java/org/springframework/util/comparator/BooleanComparatorTests.java
index 9d38975cda5..7b8e380167e 100644
--- a/spring-core/src/test/java/org/springframework/util/comparator/BooleanComparatorTests.java
+++ b/spring-core/src/test/java/org/springframework/util/comparator/BooleanComparatorTests.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2012 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.
@@ -21,7 +21,7 @@ import java.util.Comparator;
 import org.junit.Test;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.MatcherAssert.*;
 
 /**
  * Tests for {@link BooleanComparator}.
diff --git a/spring-core/src/test/java/org/springframework/util/comparator/ComparableComparatorTests.java b/spring-core/src/test/java/org/springframework/util/comparator/ComparableComparatorTests.java
index 98dec57896b..99ddea3877f 100644
--- a/spring-core/src/test/java/org/springframework/util/comparator/ComparableComparatorTests.java
+++ b/spring-core/src/test/java/org/springframework/util/comparator/ComparableComparatorTests.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.
@@ -18,10 +18,9 @@ package org.springframework.util.comparator;
 
 import java.util.Comparator;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
 import static org.junit.Assert.*;
 
 /**
@@ -33,9 +32,6 @@ import static org.junit.Assert.*;
  */
 public class ComparableComparatorTests {
 
-	@Rule
-	public ExpectedException thrown = ExpectedException.none();
-
 	@Test
 	public void testComparableComparator() {
 		Comparator c = new ComparableComparator<>();
@@ -50,8 +46,8 @@ public class ComparableComparatorTests {
 		Comparator c = new ComparableComparator();
 		Object o1 = new Object();
 		Object o2 = new Object();
-		thrown.expect(ClassCastException.class);
-		c.compare(o1, o2);
+		assertThatExceptionOfType(ClassCastException.class).isThrownBy(() ->
+				c.compare(o1, o2));
 	}
 
 }
diff --git a/spring-core/src/test/java/org/springframework/util/comparator/CompoundComparatorTests.java b/spring-core/src/test/java/org/springframework/util/comparator/CompoundComparatorTests.java
index f0bc075a231..86dc6a41ba5 100644
--- a/spring-core/src/test/java/org/springframework/util/comparator/CompoundComparatorTests.java
+++ b/spring-core/src/test/java/org/springframework/util/comparator/CompoundComparatorTests.java
@@ -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,9 +18,9 @@ package org.springframework.util.comparator;
 
 import java.util.Comparator;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
+
+import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
 
 /**
  * Test for {@link CompoundComparator}.
@@ -32,14 +32,11 @@ import org.junit.rules.ExpectedException;
 @Deprecated
 public class CompoundComparatorTests {
 
-	@Rule
-	public ExpectedException thrown = ExpectedException.none();
-
 	@Test
 	public void shouldNeedAtLeastOneComparator() {
 		Comparator c = new CompoundComparator<>();
-		thrown.expect(IllegalStateException.class);
-		c.compare("foo", "bar");
+		assertThatIllegalStateException().isThrownBy(() ->
+				c.compare("foo", "bar"));
 	}
 
 }
diff --git a/spring-core/src/test/java/org/springframework/util/comparator/InstanceComparatorTests.java b/spring-core/src/test/java/org/springframework/util/comparator/InstanceComparatorTests.java
index 26dfbfa1731..4acb24b9364 100644
--- a/spring-core/src/test/java/org/springframework/util/comparator/InstanceComparatorTests.java
+++ b/spring-core/src/test/java/org/springframework/util/comparator/InstanceComparatorTests.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.
@@ -21,7 +21,7 @@ import java.util.Comparator;
 import org.junit.Test;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.MatcherAssert.*;
 
 /**
  * Tests for {@link InstanceComparator}.
diff --git a/spring-core/src/test/java/org/springframework/util/concurrent/SettableListenableFutureTests.java b/spring-core/src/test/java/org/springframework/util/concurrent/SettableListenableFutureTests.java
index 3eba146727d..eebe16bbe90 100644
--- a/spring-core/src/test/java/org/springframework/util/concurrent/SettableListenableFutureTests.java
+++ b/spring-core/src/test/java/org/springframework/util/concurrent/SettableListenableFutureTests.java
@@ -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.
@@ -27,7 +27,7 @@ import org.junit.Test;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.*;
 import static org.junit.Assert.*;
-import static org.mockito.Mockito.any;
+import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.*;
 
 /**
diff --git a/spring-core/src/test/java/org/springframework/util/unit/DataSizeTests.java b/spring-core/src/test/java/org/springframework/util/unit/DataSizeTests.java
index bed4d029de7..a3a6a43c7be 100644
--- a/spring-core/src/test/java/org/springframework/util/unit/DataSizeTests.java
+++ b/spring-core/src/test/java/org/springframework/util/unit/DataSizeTests.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.
@@ -16,10 +16,9 @@
 
 package org.springframework.util.unit;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
+import static org.assertj.core.api.Assertions.*;
 import static org.junit.Assert.*;
 
 /**
@@ -29,9 +28,6 @@ import static org.junit.Assert.*;
  */
 public class DataSizeTests {
 
-	@Rule
-	public final ExpectedException thrown = ExpectedException.none();
-
 	@Test
 	public void ofBytesToBytes() {
 		assertEquals(1024, DataSize.ofBytes(1024).toBytes());
@@ -214,10 +210,9 @@ public class DataSizeTests {
 
 	@Test
 	public void parseWithUnsupportedUnit() {
-		this.thrown.expect(IllegalArgumentException.class);
-		this.thrown.expectMessage("3WB");
-		this.thrown.expectMessage("is not a valid data size");
-		DataSize.parse("3WB");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				DataSize.parse("3WB"))
+			.withMessage("'3WB' is not a valid data size");
 	}
 
 }
diff --git a/spring-core/src/test/java/org/springframework/util/xml/AbstractStaxHandlerTestCase.java b/spring-core/src/test/java/org/springframework/util/xml/AbstractStaxHandlerTestCase.java
index fc5f5f8db49..b0fe8488823 100644
--- a/spring-core/src/test/java/org/springframework/util/xml/AbstractStaxHandlerTestCase.java
+++ b/spring-core/src/test/java/org/springframework/util/xml/AbstractStaxHandlerTestCase.java
@@ -33,8 +33,8 @@ import org.xml.sax.InputSource;
 import org.xml.sax.XMLReader;
 import org.xmlunit.util.Predicate;
 
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.xmlunit.matchers.CompareMatcher.isSimilarTo;
+import static org.hamcrest.MatcherAssert.*;
+import static org.xmlunit.matchers.CompareMatcher.*;
 
 /**
  * @author Arjen Poutsma
diff --git a/spring-core/src/test/java/org/springframework/util/xml/AbstractStaxXMLReaderTestCase.java b/spring-core/src/test/java/org/springframework/util/xml/AbstractStaxXMLReaderTestCase.java
index 65f321be43e..91f573a321c 100644
--- a/spring-core/src/test/java/org/springframework/util/xml/AbstractStaxXMLReaderTestCase.java
+++ b/spring-core/src/test/java/org/springframework/util/xml/AbstractStaxXMLReaderTestCase.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.
@@ -44,6 +44,7 @@ import org.springframework.tests.MockitoUtils;
 import org.springframework.tests.MockitoUtils.InvocationArgumentsAdapter;
 
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.BDDMockito.*;
 
 /**
diff --git a/spring-core/src/test/java/org/springframework/util/xml/DomContentHandlerTests.java b/spring-core/src/test/java/org/springframework/util/xml/DomContentHandlerTests.java
index 4acb19d65eb..18b9a4338dd 100644
--- a/spring-core/src/test/java/org/springframework/util/xml/DomContentHandlerTests.java
+++ b/spring-core/src/test/java/org/springframework/util/xml/DomContentHandlerTests.java
@@ -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.
@@ -27,7 +27,7 @@ import org.w3c.dom.Element;
 import org.xml.sax.InputSource;
 import org.xml.sax.XMLReader;
 
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.MatcherAssert.*;
 import static org.xmlunit.matchers.CompareMatcher.*;
 
 /**
diff --git a/spring-core/src/test/java/org/springframework/util/xml/SimpleNamespaceContextTests.java b/spring-core/src/test/java/org/springframework/util/xml/SimpleNamespaceContextTests.java
index 75388867530..5a19439ac0d 100644
--- a/spring-core/src/test/java/org/springframework/util/xml/SimpleNamespaceContextTests.java
+++ b/spring-core/src/test/java/org/springframework/util/xml/SimpleNamespaceContextTests.java
@@ -24,7 +24,7 @@ import javax.xml.XMLConstants;
 import org.junit.Test;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.MatcherAssert.*;
 
 /**
  * @author Arjen Poutsma
diff --git a/spring-core/src/test/java/org/springframework/util/xml/StaxEventXMLReaderTests.java b/spring-core/src/test/java/org/springframework/util/xml/StaxEventXMLReaderTests.java
index 46e74c71064..1f454e6db7f 100644
--- a/spring-core/src/test/java/org/springframework/util/xml/StaxEventXMLReaderTests.java
+++ b/spring-core/src/test/java/org/springframework/util/xml/StaxEventXMLReaderTests.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.
@@ -27,6 +27,7 @@ import org.xml.sax.Attributes;
 import org.xml.sax.ContentHandler;
 import org.xml.sax.InputSource;
 
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.Mockito.*;
 
 public class StaxEventXMLReaderTests extends AbstractStaxXMLReaderTestCase {
diff --git a/spring-core/src/test/java/org/springframework/util/xml/StaxResultTests.java b/spring-core/src/test/java/org/springframework/util/xml/StaxResultTests.java
index 1390eb26f6b..2d79f48a799 100644
--- a/spring-core/src/test/java/org/springframework/util/xml/StaxResultTests.java
+++ b/spring-core/src/test/java/org/springframework/util/xml/StaxResultTests.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.
@@ -16,9 +16,9 @@
 
 package org.springframework.util.xml;
 
-import org.junit.Before;
-import org.junit.Test;
-
+import java.io.Reader;
+import java.io.StringReader;
+import java.io.StringWriter;
 import javax.xml.stream.XMLEventWriter;
 import javax.xml.stream.XMLOutputFactory;
 import javax.xml.stream.XMLStreamWriter;
@@ -26,14 +26,13 @@ import javax.xml.transform.Source;
 import javax.xml.transform.Transformer;
 import javax.xml.transform.TransformerFactory;
 import javax.xml.transform.stream.StreamSource;
-import java.io.Reader;
-import java.io.StringReader;
-import java.io.StringWriter;
+
+import org.junit.Before;
+import org.junit.Test;
 
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.xmlunit.matchers.CompareMatcher.isSimilarTo;
+import static org.junit.Assert.*;
+import static org.xmlunit.matchers.CompareMatcher.*;
 
 /**
  * @author Arjen Poutsma
diff --git a/spring-core/src/test/java/org/springframework/util/xml/StaxSourceTests.java b/spring-core/src/test/java/org/springframework/util/xml/StaxSourceTests.java
index f1361d2ac12..8e5ed2a06a9 100644
--- a/spring-core/src/test/java/org/springframework/util/xml/StaxSourceTests.java
+++ b/spring-core/src/test/java/org/springframework/util/xml/StaxSourceTests.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2012 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,11 +16,8 @@
 
 package org.springframework.util.xml;
 
-import org.junit.Before;
-import org.junit.Test;
-import org.w3c.dom.Document;
-import org.xml.sax.InputSource;
-
+import java.io.StringReader;
+import java.io.StringWriter;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.stream.XMLEventReader;
@@ -30,13 +27,15 @@ import javax.xml.transform.Transformer;
 import javax.xml.transform.TransformerFactory;
 import javax.xml.transform.dom.DOMResult;
 import javax.xml.transform.stream.StreamResult;
-import java.io.StringReader;
-import java.io.StringWriter;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.w3c.dom.Document;
+import org.xml.sax.InputSource;
 
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.xmlunit.matchers.CompareMatcher.isSimilarTo;
+import static org.junit.Assert.*;
+import static org.xmlunit.matchers.CompareMatcher.*;
 
 /**
  * @author Arjen Poutsma
diff --git a/spring-core/src/test/java/org/springframework/util/xml/StaxStreamXMLReaderTests.java b/spring-core/src/test/java/org/springframework/util/xml/StaxStreamXMLReaderTests.java
index 6b753918e60..f449de96c10 100644
--- a/spring-core/src/test/java/org/springframework/util/xml/StaxStreamXMLReaderTests.java
+++ b/spring-core/src/test/java/org/springframework/util/xml/StaxStreamXMLReaderTests.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.
@@ -30,6 +30,7 @@ import org.xml.sax.InputSource;
 import org.xml.sax.Locator;
 
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.Mockito.*;
 
 public class StaxStreamXMLReaderTests extends AbstractStaxXMLReaderTestCase {
diff --git a/spring-core/src/test/java/org/springframework/util/xml/XMLEventStreamReaderTests.java b/spring-core/src/test/java/org/springframework/util/xml/XMLEventStreamReaderTests.java
index b7ea3737d94..a2dc9164958 100644
--- a/spring-core/src/test/java/org/springframework/util/xml/XMLEventStreamReaderTests.java
+++ b/spring-core/src/test/java/org/springframework/util/xml/XMLEventStreamReaderTests.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2013 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,22 +16,22 @@
 
 package org.springframework.util.xml;
 
-import org.junit.Before;
-import org.junit.Test;
-import org.w3c.dom.Node;
-import org.xmlunit.util.Predicate;
-
+import java.io.StringReader;
+import java.io.StringWriter;
 import javax.xml.stream.XMLEventReader;
 import javax.xml.stream.XMLInputFactory;
 import javax.xml.transform.Transformer;
 import javax.xml.transform.TransformerFactory;
 import javax.xml.transform.stax.StAXSource;
 import javax.xml.transform.stream.StreamResult;
-import java.io.StringReader;
-import java.io.StringWriter;
 
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.xmlunit.matchers.CompareMatcher.isSimilarTo;
+import org.junit.Before;
+import org.junit.Test;
+import org.w3c.dom.Node;
+import org.xmlunit.util.Predicate;
+
+import static org.hamcrest.MatcherAssert.*;
+import static org.xmlunit.matchers.CompareMatcher.*;
 
 public class XMLEventStreamReaderTests {
 
diff --git a/spring-core/src/test/java/org/springframework/util/xml/XMLEventStreamWriterTests.java b/spring-core/src/test/java/org/springframework/util/xml/XMLEventStreamWriterTests.java
index cf324f7041e..bf68c625561 100644
--- a/spring-core/src/test/java/org/springframework/util/xml/XMLEventStreamWriterTests.java
+++ b/spring-core/src/test/java/org/springframework/util/xml/XMLEventStreamWriterTests.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2012 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,18 +16,18 @@
 
 package org.springframework.util.xml;
 
+import java.io.StringWriter;
+import javax.xml.stream.XMLEventFactory;
+import javax.xml.stream.XMLEventWriter;
+import javax.xml.stream.XMLOutputFactory;
+
 import org.junit.Before;
 import org.junit.Test;
 import org.w3c.dom.Node;
 import org.xmlunit.util.Predicate;
 
-import javax.xml.stream.XMLEventFactory;
-import javax.xml.stream.XMLEventWriter;
-import javax.xml.stream.XMLOutputFactory;
-import java.io.StringWriter;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.xmlunit.matchers.CompareMatcher.isSimilarTo;
+import static org.hamcrest.MatcherAssert.*;
+import static org.xmlunit.matchers.CompareMatcher.*;
 
 public class XMLEventStreamWriterTests {
 
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 fca12ada60c..6501564e435 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
@@ -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.
@@ -23,6 +23,7 @@ import java.util.LinkedHashMap;
 import java.util.Map;
 
 import org.junit.Test;
+
 import org.springframework.expression.spel.ast.InlineMap;
 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/SpelReproTests.java b/spring-expression/src/test/java/org/springframework/expression/spel/SpelReproTests.java
index 3aa8d9e9775..6a28f8b75b5 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
@@ -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.
@@ -35,9 +35,7 @@ import java.util.Map;
 import java.util.Properties;
 import java.util.concurrent.atomic.AtomicInteger;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.core.MethodParameter;
 import org.springframework.core.convert.TypeDescriptor;
@@ -62,6 +60,7 @@ import org.springframework.expression.spel.support.StandardTypeLocator;
 import org.springframework.expression.spel.testresources.le.div.mod.reserved.Reserver;
 import org.springframework.util.ObjectUtils;
 
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.*;
 import static org.junit.Assert.*;
@@ -77,9 +76,6 @@ import static org.junit.Assert.*;
  */
 public class SpelReproTests extends AbstractExpressionTests {
 
-	@Rule
-	public ExpectedException thrown = ExpectedException.none();
-
 
 	@Test
 	public void NPE_SPR5661() {
@@ -1283,14 +1279,13 @@ public class SpelReproTests extends AbstractExpressionTests {
 		doTestSpr10146(">foo", "EL1070E: Problem parsing left operand");
 		doTestSpr10146("&&foo", "EL1070E: Problem parsing left operand");
 		doTestSpr10146("||foo", "EL1070E: Problem parsing left operand");
-		doTestSpr10146("&foo", "EL1069E: missing expected character '&'");
-		doTestSpr10146("|foo", "EL1069E: missing expected character '|'");
+		doTestSpr10146("|foo", "EL1069E: Missing expected character '|'");
 	}
 
 	private void doTestSpr10146(String expression, String expectedMessage) {
-		thrown.expect(SpelParseException.class);
-		thrown.expectMessage(expectedMessage);
-		new SpelExpressionParser().parseExpression(expression);
+		assertThatExceptionOfType(SpelParseException.class).isThrownBy(() ->
+				new SpelExpressionParser().parseExpression(expression))
+			.withMessageContaining(expectedMessage);
 	}
 
 	@Test
@@ -1314,10 +1309,9 @@ public class SpelReproTests extends AbstractExpressionTests {
 
 	@Test
 	public void SPR10328() {
-		thrown.expect(SpelParseException.class);
-		thrown.expectMessage("EL1071E: A required selection expression has not been specified");
-		Expression exp = parser.parseExpression("$[]");
-		exp.getValue(Arrays.asList("foo", "bar", "baz"));
+		assertThatExceptionOfType(SpelParseException.class).isThrownBy(() ->
+				parser.parseExpression("$[]"))
+			.withMessageContaining("EL1071E: A required selection expression has not been specified");
 	}
 
 	@Test
@@ -1407,9 +1401,9 @@ public class SpelReproTests extends AbstractExpressionTests {
 		StandardEvaluationContext context = new StandardEvaluationContext();
 		Spr11142 rootObject = new Spr11142();
 		Expression expression = parser.parseExpression("something");
-		thrown.expect(SpelEvaluationException.class);
-		thrown.expectMessage("'something' cannot be found");
-		expression.getValue(context, rootObject);
+		assertThatExceptionOfType(SpelEvaluationException.class).isThrownBy(() ->
+				expression.getValue(context, rootObject))
+			.withMessageContaining("'something' cannot be found");
 	}
 
 	@Test
diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/testresources/ArrayContainer.java b/spring-expression/src/test/java/org/springframework/expression/spel/testresources/ArrayContainer.java
index b54c0b5af94..1e180f8134a 100644
--- a/spring-expression/src/test/java/org/springframework/expression/spel/testresources/ArrayContainer.java
+++ b/spring-expression/src/test/java/org/springframework/expression/spel/testresources/ArrayContainer.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.
@@ -13,7 +13,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
- package org.springframework.expression.spel.testresources;
+
+package org.springframework.expression.spel.testresources;
 
 /**
  * Hold the various kinds of primitive array for access through the test evaluation context.
@@ -21,6 +22,7 @@
  * @author Andy Clement
  */
 public class ArrayContainer {
+
 	public int[] ints = new int[3];
 	public long[] longs = new long[3];
 	public double[] doubles = new double[3];
diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/testresources/Company.java b/spring-expression/src/test/java/org/springframework/expression/spel/testresources/Company.java
index d22526ee671..fc11f45ce95 100644
--- a/spring-expression/src/test/java/org/springframework/expression/spel/testresources/Company.java
+++ b/spring-expression/src/test/java/org/springframework/expression/spel/testresources/Company.java
@@ -1,6 +1,19 @@
-/**
+/*
+ * Copyright 2002-2019 the original author or authors.
  *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
+
 package org.springframework.expression.spel.testresources;
 
 ///CLOVER:OFF
diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/testresources/Fruit.java b/spring-expression/src/test/java/org/springframework/expression/spel/testresources/Fruit.java
index 8ea3816ee87..7fef936ed78 100644
--- a/spring-expression/src/test/java/org/springframework/expression/spel/testresources/Fruit.java
+++ b/spring-expression/src/test/java/org/springframework/expression/spel/testresources/Fruit.java
@@ -1,6 +1,19 @@
-/**
+/*
+ * Copyright 2002-2019 the original author or authors.
  *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
+
 package org.springframework.expression.spel.testresources;
 
 import java.awt.Color;
diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/testresources/Person.java b/spring-expression/src/test/java/org/springframework/expression/spel/testresources/Person.java
index 9487f87ce64..418ff975ed6 100644
--- a/spring-expression/src/test/java/org/springframework/expression/spel/testresources/Person.java
+++ b/spring-expression/src/test/java/org/springframework/expression/spel/testresources/Person.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2002-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.springframework.expression.spel.testresources;
 
 ///CLOVER:OFF
diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/testresources/PlaceOfBirth.java b/spring-expression/src/test/java/org/springframework/expression/spel/testresources/PlaceOfBirth.java
index 78abc874b19..10c4acd1c13 100644
--- a/spring-expression/src/test/java/org/springframework/expression/spel/testresources/PlaceOfBirth.java
+++ b/spring-expression/src/test/java/org/springframework/expression/spel/testresources/PlaceOfBirth.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2002-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.springframework.expression.spel.testresources;
 
 ///CLOVER:OFF
diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/testresources/TestAddress.java b/spring-expression/src/test/java/org/springframework/expression/spel/testresources/TestAddress.java
index 251703fbc81..3bc88ff9f43 100644
--- a/spring-expression/src/test/java/org/springframework/expression/spel/testresources/TestAddress.java
+++ b/spring-expression/src/test/java/org/springframework/expression/spel/testresources/TestAddress.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2002-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.springframework.expression.spel.testresources;
 
 import java.util.List;
diff --git a/spring-expression/src/test/java/org/springframework/expression/spel/testresources/TestPerson.java b/spring-expression/src/test/java/org/springframework/expression/spel/testresources/TestPerson.java
index 78cb049e253..ad1f58480e5 100644
--- a/spring-expression/src/test/java/org/springframework/expression/spel/testresources/TestPerson.java
+++ b/spring-expression/src/test/java/org/springframework/expression/spel/testresources/TestPerson.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2002-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.springframework.expression.spel.testresources;
 
 public class TestPerson {
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 fd7fca10ab9..a0fe8090e8b 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
@@ -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.
@@ -17,12 +17,9 @@
 package org.springframework.jdbc.config;
 
 import java.util.function.Predicate;
-
 import javax.sql.DataSource;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.beans.PropertyValue;
 import org.springframework.beans.factory.config.BeanDefinition;
@@ -39,6 +36,7 @@ import org.springframework.jdbc.datasource.init.DataSourceInitializer;
 import org.springframework.tests.Assume;
 import org.springframework.tests.TestGroup;
 
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
 import static org.hamcrest.CoreMatchers.*;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.Assert.*;
@@ -53,9 +51,6 @@ import static org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseFacto
  */
 public class JdbcNamespaceIntegrationTests {
 
-	@Rule
-	public ExpectedException expected = ExpectedException.none();
-
 
 	@Test
 	public void createEmbeddedDatabase() throws Exception {
@@ -78,25 +73,24 @@ public class JdbcNamespaceIntegrationTests {
 	@Test
 	public void createWithAnonymousDataSourceAndDefaultDatabaseName() throws Exception {
 		assertCorrectSetupForSingleDataSource("jdbc-config-db-name-default-and-anonymous-datasource.xml",
-			(url) -> url.endsWith(DEFAULT_DATABASE_NAME));
+			url -> url.endsWith(DEFAULT_DATABASE_NAME));
 	}
 
 	@Test
 	public void createWithImplicitDatabaseName() throws Exception {
-		assertCorrectSetupForSingleDataSource("jdbc-config-db-name-implicit.xml", (url) -> url.endsWith("dataSource"));
+		assertCorrectSetupForSingleDataSource("jdbc-config-db-name-implicit.xml", url -> url.endsWith("dataSource"));
 	}
 
 	@Test
 	public void createWithExplicitDatabaseName() throws Exception {
-		assertCorrectSetupForSingleDataSource("jdbc-config-db-name-explicit.xml", (url) -> url.endsWith("customDbName"));
+		assertCorrectSetupForSingleDataSource("jdbc-config-db-name-explicit.xml", url -> url.endsWith("customDbName"));
 	}
 
 	@Test
 	public void createWithGeneratedDatabaseName() throws Exception {
-		Predicate urlPredicate = (url) -> url.startsWith("jdbc:hsqldb:mem:");
-		urlPredicate.and((url) -> !url.endsWith("dataSource"));
-		urlPredicate.and((url) -> !url.endsWith("shouldBeOverriddenByGeneratedName"));
-
+		Predicate urlPredicate = url -> url.startsWith("jdbc:hsqldb:mem:");
+		urlPredicate.and(url -> !url.endsWith("dataSource"));
+		urlPredicate.and(url -> !url.endsWith("shouldBeOverriddenByGeneratedName"));
 		assertCorrectSetupForSingleDataSource("jdbc-config-db-name-generated.xml", urlPredicate);
 	}
 
@@ -118,8 +112,9 @@ public class JdbcNamespaceIntegrationTests {
 			JdbcTemplate template = new JdbcTemplate(dataSource);
 			assertNumRowsInTestTable(template, 1);
 			context.getBean(DataSourceInitializer.class).destroy();
-			expected.expect(BadSqlGrammarException.class); // Table has been dropped
-			assertNumRowsInTestTable(template, 1);
+			// Table has been dropped
+			assertThatExceptionOfType(BadSqlGrammarException.class).isThrownBy(() ->
+					assertNumRowsInTestTable(template, 1));
 		}
 		finally {
 			context.close();
@@ -134,8 +129,9 @@ public class JdbcNamespaceIntegrationTests {
 			JdbcTemplate template = new JdbcTemplate(dataSource);
 			assertNumRowsInTestTable(template, 1);
 			context.getBean(EmbeddedDatabaseFactoryBean.class).destroy();
-			expected.expect(BadSqlGrammarException.class); // Table has been dropped
-			assertNumRowsInTestTable(template, 1);
+			// Table has been dropped
+			assertThatExceptionOfType(BadSqlGrammarException.class).isThrownBy(() ->
+					assertNumRowsInTestTable(template, 1));
 		}
 		finally {
 			context.close();
@@ -150,8 +146,9 @@ public class JdbcNamespaceIntegrationTests {
 			JdbcTemplate template = new JdbcTemplate(dataSource);
 			assertNumRowsInTestTable(template, 1);
 			context.getBean(EmbeddedDatabaseFactoryBean.class).destroy();
-			expected.expect(BadSqlGrammarException.class); // Table has been dropped
-			assertNumRowsInTestTable(template, 1);
+			 // Table has been dropped
+			assertThatExceptionOfType(BadSqlGrammarException.class).isThrownBy(() ->
+					assertNumRowsInTestTable(template, 1));
 		}
 		finally {
 			context.close();
diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/core/AbstractRowMapperTests.java b/spring-jdbc/src/test/java/org/springframework/jdbc/core/AbstractRowMapperTests.java
index 4f4b233323d..605d969b661 100644
--- a/spring-jdbc/src/test/java/org/springframework/jdbc/core/AbstractRowMapperTests.java
+++ b/spring-jdbc/src/test/java/org/springframework/jdbc/core/AbstractRowMapperTests.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.
@@ -32,6 +32,7 @@ import org.springframework.jdbc.datasource.SingleConnectionDataSource;
 import org.springframework.jdbc.support.SQLStateSQLExceptionTranslator;
 
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.BDDMockito.*;
 
 /**
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 1d8df5fe7fc..316fdeae41c 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
@@ -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.
@@ -18,9 +18,7 @@ package org.springframework.jdbc.core;
 
 import java.util.List;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.beans.TypeMismatchException;
 import org.springframework.dao.InvalidDataAccessApiUsageException;
@@ -30,6 +28,7 @@ import org.springframework.jdbc.core.test.ExtendedPerson;
 import org.springframework.jdbc.core.test.Person;
 import org.springframework.jdbc.core.test.SpacePerson;
 
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
 import static org.junit.Assert.*;
 
 /**
@@ -38,16 +37,13 @@ import static org.junit.Assert.*;
  */
 public class BeanPropertyRowMapperTests extends AbstractRowMapperTests {
 
-	@Rule
-	public ExpectedException thrown = ExpectedException.none();
-
 
 	@Test
 	@SuppressWarnings({ "unchecked", "rawtypes" })
 	public void testOverridingDifferentClassDefinedForMapping() {
 		BeanPropertyRowMapper mapper = new BeanPropertyRowMapper(Person.class);
-		thrown.expect(InvalidDataAccessApiUsageException.class);
-		mapper.setMappedClass(Long.class);
+		assertThatExceptionOfType(InvalidDataAccessApiUsageException.class).isThrownBy(() ->
+				mapper.setMappedClass(Long.class));
 	}
 
 	@Test
@@ -104,19 +100,17 @@ public class BeanPropertyRowMapperTests extends AbstractRowMapperTests {
 	@Test
 	public void testMappingWithUnpopulatedFieldsNotAccepted() throws Exception {
 		Mock mock = new Mock();
-		thrown.expect(InvalidDataAccessApiUsageException.class);
-		mock.getJdbcTemplate().query(
-				"select name, age, birth_date, balance from people",
-				new BeanPropertyRowMapper<>(ExtendedPerson.class, true));
+		assertThatExceptionOfType(InvalidDataAccessApiUsageException.class).isThrownBy(() ->
+				mock.getJdbcTemplate().query("select name, age, birth_date, balance from people",
+						new BeanPropertyRowMapper<>(ExtendedPerson.class, true)));
 	}
 
 	@Test
 	public void testMappingNullValue() throws Exception {
 		BeanPropertyRowMapper mapper = new BeanPropertyRowMapper<>(Person.class);
 		Mock mock = new Mock(MockType.TWO);
-		thrown.expect(TypeMismatchException.class);
-		mock.getJdbcTemplate().query(
-				"select name, null as age, birth_date, balance from people", mapper);
+		assertThatExceptionOfType(TypeMismatchException.class).isThrownBy(() ->
+				mock.getJdbcTemplate().query("select name, null as age, birth_date, balance from people", mapper));
 	}
 
 	@Test
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 a9dfc2f862b..09f3628232e 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
@@ -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.
@@ -29,13 +29,13 @@ import java.util.Map;
 import javax.sql.DataSource;
 
 import org.junit.Before;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.dao.IncorrectResultSizeDataAccessException;
 
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.BDDMockito.*;
 
 /**
@@ -46,9 +46,6 @@ import static org.mockito.BDDMockito.*;
  */
 public class JdbcTemplateQueryTests {
 
-	@Rule
-	public ExpectedException thrown = ExpectedException.none();
-
 	private Connection connection;
 
 	private DataSource dataSource;
@@ -147,14 +144,10 @@ public class JdbcTemplateQueryTests {
 		String sql = "select pass from t_account where first_name='Alef'";
 		given(this.resultSet.next()).willReturn(true, true, false);
 		given(this.resultSet.getString(1)).willReturn("pass");
-		this.thrown.expect(IncorrectResultSizeDataAccessException.class);
-		try {
-			this.template.queryForObject(sql, String.class);
-		}
-		finally {
-			verify(this.resultSet).close();
-			verify(this.statement).close();
-		}
+		assertThatExceptionOfType(IncorrectResultSizeDataAccessException.class).isThrownBy(() ->
+				this.template.queryForObject(sql, String.class));
+		verify(this.resultSet).close();
+		verify(this.statement).close();
 	}
 
 	@Test
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 a596548b14a..42b81a5e5b4 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
@@ -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.
@@ -36,9 +36,7 @@ import java.util.Map;
 import javax.sql.DataSource;
 
 import org.junit.Before;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.dao.DataAccessException;
 import org.springframework.dao.InvalidDataAccessApiUsageException;
@@ -54,11 +52,12 @@ import org.springframework.jdbc.support.SQLStateSQLExceptionTranslator;
 import org.springframework.util.LinkedCaseInsensitiveMap;
 import org.springframework.util.StringUtils;
 
+import static org.assertj.core.api.Assertions.*;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.*;
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.BDDMockito.*;
-import static org.springframework.tests.Matchers.*;
 
 /**
  * Mock object based tests for JdbcTemplate.
@@ -84,9 +83,6 @@ public class JdbcTemplateTests {
 
 	private CallableStatement callableStatement;
 
-	@Rule
-	public ExpectedException thrown = ExpectedException.none();
-
 
 	@Before
 	public void setup() throws Exception {
@@ -140,16 +136,12 @@ public class JdbcTemplateTests {
 		given(this.preparedStatement.executeUpdate()).willThrow(sqlException);
 
 		Dispatcher d = new Dispatcher(idParam, sql);
-		this.thrown.expect(UncategorizedSQLException.class);
-		this.thrown.expect(exceptionCause(equalTo(sqlException)));
-		try {
-			this.template.update(d);
-		}
-		finally {
-			verify(this.preparedStatement).setInt(1, idParam);
-			verify(this.preparedStatement).close();
-			verify(this.connection, atLeastOnce()).close();
-		}
+		assertThatExceptionOfType(UncategorizedSQLException.class).isThrownBy(() ->
+				this.template.update(d))
+			.withCause(sqlException);
+		verify(this.preparedStatement).setInt(1, idParam);
+		verify(this.preparedStatement).close();
+		verify(this.connection, atLeastOnce()).close();
 	}
 
 	@Test
@@ -171,9 +163,8 @@ public class JdbcTemplateTests {
 	@Test
 	public void testStringsWithPreparedStatementSetter() throws Exception {
 		final Integer argument = 99;
-		doTestStrings(null, null, null, argument, (template, sql, rch) -> template.query(sql, ps -> {
-			ps.setObject(1, argument);
-		}, rch));
+		doTestStrings(null, null, null, argument, (template, sql, rch) ->
+			template.query(sql, ps -> ps.setObject(1, argument), rch));
 	}
 
 	@Test
@@ -326,11 +317,12 @@ public class JdbcTemplateTests {
 		given(this.resultSet.next()).willReturn(true);
 		given(this.connection.createStatement()).willReturn(this.preparedStatement);
 
-		this.thrown.expect(sameInstance(runtimeException));
 		try {
-			this.template.query(sql, (RowCallbackHandler) rs -> {
-				throw runtimeException;
-			});
+			assertThatExceptionOfType(RuntimeException.class).isThrownBy(() ->
+					this.template.query(sql, (RowCallbackHandler) rs -> {
+						throw runtimeException;
+					}))
+				.withMessage(runtimeException.getMessage());
 		}
 		finally {
 			verify(this.resultSet).close();
@@ -382,14 +374,11 @@ public class JdbcTemplateTests {
 		given(this.statement.executeUpdate(sql)).willThrow(sqlException);
 		given(this.connection.createStatement()).willReturn(this.statement);
 
-		this.thrown.expect(exceptionCause(sameInstance(sqlException)));
-		try {
-			this.template.update(sql);
-		}
-		finally {
-			verify(this.statement).close();
-			verify(this.connection, atLeastOnce()).close();
-		}
+		assertThatExceptionOfType(DataAccessException.class).isThrownBy(() ->
+				this.template.update(sql))
+			.withCause(sqlException);
+		verify(this.statement).close();
+		verify(this.connection, atLeastOnce()).close();
 	}
 
 	@Test
@@ -478,15 +467,11 @@ public class JdbcTemplateTests {
 		given(this.connection.createStatement()).willReturn(this.statement);
 
 		JdbcTemplate template = new JdbcTemplate(this.dataSource, false);
-		this.thrown.expect(InvalidDataAccessApiUsageException.class);
-		try {
-			template.batchUpdate(sql);
-		}
-		finally {
-			verify(this.statement, never()).addBatch(anyString());
-			verify(this.statement).close();
-			verify(this.connection, atLeastOnce()).close();
-		}
+		assertThatExceptionOfType(InvalidDataAccessApiUsageException.class).isThrownBy(() ->
+				template.batchUpdate(sql));
+		verify(this.statement, never()).addBatch(anyString());
+		verify(this.statement).close();
+		verify(this.connection, atLeastOnce()).close();
 	}
 
 	@Test
@@ -689,10 +674,10 @@ public class JdbcTemplateTests {
 			}
 		};
 
-		this.thrown.expect(DataAccessException.class);
-		this.thrown.expect(exceptionCause(sameInstance(sqlException)));
 		try {
-			this.template.batchUpdate(sql, setter);
+			assertThatExceptionOfType(DataAccessException.class).isThrownBy(() ->
+					this.template.batchUpdate(sql, setter))
+				.withCause(sqlException);
 		}
 		finally {
 			verify(this.preparedStatement, times(2)).addBatch();
@@ -795,9 +780,9 @@ public class JdbcTemplateTests {
 		JdbcTemplate template = new JdbcTemplate(this.dataSource, false);
 		RowCountCallbackHandler rcch = new RowCountCallbackHandler();
 
-		this.thrown.expect(CannotGetJdbcConnectionException.class);
-		this.thrown.expect(exceptionCause(sameInstance(sqlException)));
-		template.query("SELECT ID, FORENAME FROM CUSTMR WHERE ID < 3", rcch);
+		assertThatExceptionOfType(CannotGetJdbcConnectionException.class).isThrownBy(() ->
+				template.query("SELECT ID, FORENAME FROM CUSTMR WHERE ID < 3", rcch))
+			.withCause(sqlException);
 	}
 
 	@Test
@@ -810,9 +795,9 @@ public class JdbcTemplateTests {
 		this.template.afterPropertiesSet();
 		RowCountCallbackHandler rcch = new RowCountCallbackHandler();
 
-		this.thrown.expect(CannotGetJdbcConnectionException.class);
-		this.thrown.expect(exceptionCause(sameInstance(sqlException)));
-		this.template.query("SELECT ID, FORENAME FROM CUSTMR WHERE ID < 3", rcch);
+		assertThatExceptionOfType(CannotGetJdbcConnectionException.class).isThrownBy(() ->
+				this.template.query("SELECT ID, FORENAME FROM CUSTMR WHERE ID < 3", rcch))
+			.withCause(sqlException);
 	}
 
 	@Test
@@ -851,9 +836,9 @@ public class JdbcTemplateTests {
 			this.template.afterPropertiesSet();
 		}
 		RowCountCallbackHandler rcch = new RowCountCallbackHandler();
-		this.thrown.expect(CannotGetJdbcConnectionException.class);
-		this.thrown.expect(exceptionCause(sameInstance(sqlException)));
-		this.template.query("SELECT ID, FORENAME FROM CUSTMR WHERE ID < 3", rcch);
+		assertThatExceptionOfType(CannotGetJdbcConnectionException.class).isThrownBy(() ->
+				this.template.query("SELECT ID, FORENAME FROM CUSTMR WHERE ID < 3", rcch))
+			.withCause(sqlException);
 	}
 
 	@Test
@@ -880,16 +865,12 @@ public class JdbcTemplateTests {
 		given(this.preparedStatement.executeUpdate()).willThrow(sqlException);
 
 		PreparedStatementSetter pss = ps -> ps.setString(1, name);
-		this.thrown.expect(DataAccessException.class);
-		this.thrown.expect(exceptionCause(sameInstance(sqlException)));
-		try {
-			new JdbcTemplate(this.dataSource).update(sql, pss);
-		}
-		finally {
-			verify(this.preparedStatement).setString(1, name);
-			verify(this.preparedStatement).close();
-			verify(this.connection, atLeastOnce()).close();
-		}
+		assertThatExceptionOfType(DataAccessException.class).isThrownBy(() ->
+				new JdbcTemplate(this.dataSource).update(sql, pss))
+			.withCause(sqlException);
+		verify(this.preparedStatement).setString(1, name);
+		verify(this.preparedStatement).close();
+		verify(this.connection, atLeastOnce()).close();
 	}
 
 	@Test
@@ -920,18 +901,14 @@ public class JdbcTemplateTests {
 
 		JdbcTemplate t = new JdbcTemplate(this.dataSource);
 		t.setIgnoreWarnings(false);
-		this.thrown.expect(SQLWarningException.class);
-		this.thrown.expect(exceptionCause(sameInstance(warnings)));
-		try {
-			t.query(sql, rs -> {
-				rs.getByte(1);
-			});
-		}
-		finally {
-			verify(this.resultSet).close();
-			verify(this.preparedStatement).close();
-			verify(this.connection).close();
-		}
+
+		ResultSetExtractor extractor = rs -> rs.getByte(1);
+		assertThatExceptionOfType(SQLWarningException.class).isThrownBy(() ->
+				t.query(sql, extractor))
+			.withCause(warnings);
+		verify(this.resultSet).close();
+		verify(this.preparedStatement).close();
+		verify(this.connection).close();
 	}
 
 	@Test
@@ -946,9 +923,8 @@ public class JdbcTemplateTests {
 		// Too long: truncation
 
 		this.template.setIgnoreWarnings(true);
-		this.template.query(sql, rs -> {
-			rs.getByte(1);
-		});
+		RowCallbackHandler rch = rs -> rs.getByte(1);
+		this.template.query(sql, rch);
 
 		verify(this.resultSet).close();
 		verify(this.preparedStatement).close();
@@ -964,19 +940,14 @@ public class JdbcTemplateTests {
 		mockDatabaseMetaData(false);
 		given(this.connection.createStatement()).willReturn(this.preparedStatement);
 
-		this.thrown.expect(BadSqlGrammarException.class);
-		this.thrown.expect(exceptionCause(sameInstance(sqlException)));
-		try {
-			this.template.query(sql, (RowCallbackHandler) rs -> {
-				throw sqlException;
-			});
-			fail("Should have thrown BadSqlGrammarException");
-		}
-		finally {
-			verify(this.resultSet).close();
-			verify(this.preparedStatement).close();
-			verify(this.connection, atLeastOnce()).close();
-		}
+		assertThatExceptionOfType(BadSqlGrammarException.class).isThrownBy(() ->
+				this.template.query(sql, (RowCallbackHandler) rs -> {
+					throw sqlException;
+				}))
+			.withCause(sqlException);
+		verify(this.resultSet).close();
+		verify(this.preparedStatement).close();
+		verify(this.connection, atLeastOnce()).close();
 	}
 
 	@Test
@@ -992,18 +963,14 @@ public class JdbcTemplateTests {
 		template.setDatabaseProductName("MySQL");
 		template.afterPropertiesSet();
 
-		this.thrown.expect(BadSqlGrammarException.class);
-		this.thrown.expect(exceptionCause(sameInstance(sqlException)));
-		try {
-			template.query(sql, (RowCallbackHandler) rs -> {
-				throw sqlException;
-			});
-		}
-		finally {
-			verify(this.resultSet).close();
-			verify(this.preparedStatement).close();
-			verify(this.connection).close();
-		}
+		assertThatExceptionOfType(BadSqlGrammarException.class).isThrownBy(() ->
+				template.query(sql, (RowCallbackHandler) rs -> {
+					throw sqlException;
+				}))
+			.withCause(sqlException);
+		verify(this.resultSet).close();
+		verify(this.preparedStatement).close();
+		verify(this.connection).close();
 	}
 
 	/**
@@ -1026,18 +993,14 @@ public class JdbcTemplateTests {
 		template.setExceptionTranslator(new SQLStateSQLExceptionTranslator());
 		template.afterPropertiesSet();
 
-		this.thrown.expect(BadSqlGrammarException.class);
-		this.thrown.expect(exceptionCause(sameInstance(sqlException)));
-		try {
-			template.query(sql, (RowCallbackHandler) rs -> {
-				throw sqlException;
-			});
-		}
-		finally {
-			verify(this.resultSet).close();
-			verify(this.preparedStatement).close();
-			verify(this.connection).close();
-		}
+		assertThatExceptionOfType(BadSqlGrammarException.class).isThrownBy(() ->
+				template.query(sql, (RowCallbackHandler) rs -> {
+					throw sqlException;
+				}))
+			.withCause(sqlException);
+		verify(this.resultSet).close();
+		verify(this.preparedStatement).close();
+		verify(this.connection).close();
 	}
 
 	@Test
@@ -1047,25 +1010,14 @@ public class JdbcTemplateTests {
 		given(this.preparedStatement.executeQuery()).willReturn(resultSet2);
 		given(this.connection.createStatement()).willReturn(this.statement);
 
-		try {
-			this.template.query("my query", (ResultSetExtractor) rs -> {
-				throw new InvalidDataAccessApiUsageException("");
-			});
-			fail("Should have thrown InvalidDataAccessApiUsageException");
-		}
-		catch (InvalidDataAccessApiUsageException ex) {
-			// ok
-		}
-
-		try {
-			this.template.query(con -> con.prepareStatement("my query"), (ResultSetExtractor) rs2 -> {
-				throw new InvalidDataAccessApiUsageException("");
-			});
-			fail("Should have thrown InvalidDataAccessApiUsageException");
-		}
-		catch (InvalidDataAccessApiUsageException ex) {
-			// ok
-		}
+		assertThatExceptionOfType(InvalidDataAccessApiUsageException.class).isThrownBy(() ->
+				this.template.query("my query", (ResultSetExtractor) rs -> {
+					throw new InvalidDataAccessApiUsageException("");
+				}));
+		assertThatExceptionOfType(InvalidDataAccessApiUsageException.class).isThrownBy(() ->
+				this.template.query(con -> con.prepareStatement("my query"), (ResultSetExtractor) rs2 -> {
+					throw new InvalidDataAccessApiUsageException("");
+				}));
 
 		verify(this.resultSet).close();
 		verify(resultSet2).close();
@@ -1083,15 +1035,11 @@ public class JdbcTemplateTests {
 			throw new InvalidDataAccessApiUsageException("");
 		});
 
-		this.thrown.expect(InvalidDataAccessApiUsageException.class);
-		try {
-			this.template.call(conn -> conn.prepareCall("my query"), Collections.singletonList(param));
-		}
-		finally {
-			verify(this.resultSet).close();
-			verify(this.callableStatement).close();
-			verify(this.connection).close();
-		}
+		assertThatExceptionOfType(InvalidDataAccessApiUsageException.class).isThrownBy(() ->
+				this.template.call(conn -> conn.prepareCall("my query"), Collections.singletonList(param)));
+		verify(this.resultSet).close();
+		verify(this.callableStatement).close();
+		verify(this.connection).close();
 	}
 
 	@Test
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 798c1b5967a..1b0661e158d 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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.
@@ -33,6 +33,7 @@ import org.springframework.jdbc.support.SQLStateSQLExceptionTranslator;
 import org.springframework.tests.sample.beans.TestBean;
 
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.BDDMockito.*;
 
 /**
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 c3bf3327a52..ed5193a13c7 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
@@ -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.
@@ -32,9 +32,7 @@ import javax.sql.DataSource;
 
 import org.junit.Before;
 import org.junit.Ignore;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 import org.mockito.InOrder;
 
 import org.springframework.jdbc.Customer;
@@ -43,7 +41,9 @@ import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.jdbc.core.PreparedStatementCallback;
 import org.springframework.jdbc.core.SqlParameterValue;
 
+import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.BDDMockito.*;
 
 /**
@@ -75,9 +75,6 @@ public class NamedParameterJdbcTemplateTests {
 	private static final String[] COLUMN_NAMES = new String[] {"id", "forename"};
 
 
-	@Rule
-	public ExpectedException thrown = ExpectedException.none();
-
 	private Connection connection;
 
 	private DataSource dataSource;
@@ -112,14 +109,14 @@ public class NamedParameterJdbcTemplateTests {
 
 	@Test
 	public void testNullDataSourceProvidedToCtor() {
-		thrown.expect(IllegalArgumentException.class);
-		new NamedParameterJdbcTemplate((DataSource) null);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				new NamedParameterJdbcTemplate((DataSource) null));
 	}
 
 	@Test
 	public void testNullJdbcTemplateProvidedToCtor() {
-		thrown.expect(IllegalArgumentException.class);
-		new NamedParameterJdbcTemplate((JdbcOperations) null);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+		new NamedParameterJdbcTemplate((JdbcOperations) null));
 	}
 
 	@Test
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 e651a3d1421..eaff70960f6 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
@@ -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.
@@ -37,6 +37,7 @@ import org.junit.Test;
 import org.springframework.jdbc.core.RowMapper;
 
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.BDDMockito.*;
 
 /**
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 90266a1488e..97ca33b481a 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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.
@@ -26,9 +26,7 @@ import javax.sql.DataSource;
 
 import org.junit.Assert;
 import org.junit.Before;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.dao.InvalidDataAccessApiUsageException;
 import org.springframework.jdbc.BadSqlGrammarException;
@@ -36,10 +34,9 @@ import org.springframework.jdbc.core.SqlOutParameter;
 import org.springframework.jdbc.core.SqlParameter;
 import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
 
-import static org.hamcrest.Matchers.*;
+import static org.assertj.core.api.Assertions.*;
 import static org.junit.Assert.*;
 import static org.mockito.BDDMockito.*;
-import static org.springframework.tests.Matchers.*;
 
 /**
  * Tests for {@link SimpleJdbcCall}.
@@ -57,9 +54,6 @@ public class SimpleJdbcCallTests {
 
 	private CallableStatement callableStatement;
 
-	@Rule
-	public ExpectedException thrown = ExpectedException.none();
-
 
 	@Before
 	public void setUp() throws Exception {
@@ -83,10 +77,10 @@ public class SimpleJdbcCallTests {
 		given(callableStatement.execute()).willThrow(sqlException);
 		given(connection.prepareCall("{call " + NO_SUCH_PROC + "()}")).willReturn(callableStatement);
 		SimpleJdbcCall sproc = new SimpleJdbcCall(dataSource).withProcedureName(NO_SUCH_PROC);
-		thrown.expect(BadSqlGrammarException.class);
-		thrown.expect(exceptionCause(sameInstance(sqlException)));
 		try {
-			sproc.execute();
+			assertThatExceptionOfType(BadSqlGrammarException.class).isThrownBy(() ->
+					sproc.execute())
+				.withCause(sqlException);
 		}
 		finally {
 			verify(callableStatement).close();
@@ -99,8 +93,8 @@ public class SimpleJdbcCallTests {
 		final String MY_PROC = "my_proc";
 		SimpleJdbcCall sproc = new SimpleJdbcCall(dataSource).withProcedureName(MY_PROC);
 		// Shouldn't succeed in adding unnamed parameter
-		thrown.expect(InvalidDataAccessApiUsageException.class);
-		sproc.addDeclaredParameter(new SqlParameter(1));
+		assertThatExceptionOfType(InvalidDataAccessApiUsageException.class).isThrownBy(() ->
+				sproc.addDeclaredParameter(new SqlParameter(1)));
 	}
 
 	@Test
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 d44fd02b3a0..12ff4a40d99 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
@@ -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.
@@ -24,12 +24,11 @@ import javax.sql.DataSource;
 
 import org.junit.After;
 import org.junit.Before;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.dao.InvalidDataAccessApiUsageException;
 
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
 import static org.mockito.BDDMockito.*;
 
 /**
@@ -45,9 +44,6 @@ public class SimpleJdbcInsertTests {
 
 	private DataSource dataSource;
 
-	@Rule
-	public ExpectedException thrown = ExpectedException.none();
-
 
 	@Before
 	public void setUp() throws Exception {
@@ -77,13 +73,9 @@ public class SimpleJdbcInsertTests {
 
 		SimpleJdbcInsert insert = new SimpleJdbcInsert(dataSource).withTableName("x");
 		// Shouldn't succeed in inserting into table which doesn't exist
-		thrown.expect(InvalidDataAccessApiUsageException.class);
-		try {
-			insert.execute(new HashMap<>());
-		}
-		finally {
-			verify(resultSet).close();
-		}
+		assertThatExceptionOfType(InvalidDataAccessApiUsageException.class).isThrownBy(() ->
+				insert.execute(new HashMap<>()));
+		verify(resultSet).close();
 	}
 
 }
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 7bf50d21125..3b012e6c388 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
@@ -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.
@@ -25,7 +25,7 @@ import org.junit.Test;
 import org.springframework.jdbc.core.JdbcTemplate;
 
 import static org.junit.Assert.*;
-import static org.mockito.BDDMockito.*;
+import static org.mockito.Mockito.*;
 
 /**
  * @author Juergen Hoeller
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 e4a90d5e3c4..c4b8be7b892 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
@@ -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.
@@ -21,9 +21,7 @@ import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.dao.DataAccessException;
 import org.springframework.dao.IncorrectResultSizeDataAccessException;
@@ -31,6 +29,7 @@ import org.springframework.jdbc.LobRetrievalFailureException;
 import org.springframework.jdbc.support.lob.LobCreator;
 import org.springframework.jdbc.support.lob.LobHandler;
 
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
 import static org.junit.Assert.*;
 import static org.mockito.BDDMockito.*;
 
@@ -39,9 +38,6 @@ import static org.mockito.BDDMockito.*;
  */
 public class LobSupportTests {
 
-	@Rule
-	public ExpectedException thrown = ExpectedException.none();
-
 	@Test
 	public void testCreatingPreparedStatementCallback() throws SQLException {
 		LobHandler handler = mock(LobHandler.class);
@@ -77,13 +73,9 @@ public class LobSupportTests {
 	public void testAbstractLobStreamingResultSetExtractorNoRows() throws SQLException {
 		ResultSet rset = mock(ResultSet.class);
 		AbstractLobStreamingResultSetExtractor lobRse = getResultSetExtractor(false);
-		thrown.expect(IncorrectResultSizeDataAccessException.class);
-		try {
-			lobRse.extractData(rset);
-		}
-		finally {
-			verify(rset).next();
-		}
+		assertThatExceptionOfType(IncorrectResultSizeDataAccessException.class).isThrownBy(() ->
+				lobRse.extractData(rset));
+		verify(rset).next();
 	}
 
 	@Test
@@ -101,13 +93,9 @@ public class LobSupportTests {
 		ResultSet rset = mock(ResultSet.class);
 		given(rset.next()).willReturn(true, true, false);
 		AbstractLobStreamingResultSetExtractor lobRse = getResultSetExtractor(false);
-		thrown.expect(IncorrectResultSizeDataAccessException.class);
-		try {
-			lobRse.extractData(rset);
-		}
-		finally {
-			verify(rset).clearWarnings();
-		}
+		assertThatExceptionOfType(IncorrectResultSizeDataAccessException.class).isThrownBy(() ->
+				lobRse.extractData(rset));
+		verify(rset).clearWarnings();
 	}
 
 	@Test
@@ -116,8 +104,8 @@ public class LobSupportTests {
 		ResultSet rset = mock(ResultSet.class);
 		given(rset.next()).willReturn(true);
 		AbstractLobStreamingResultSetExtractor lobRse = getResultSetExtractor(true);
-		thrown.expect(LobRetrievalFailureException.class);
-		lobRse.extractData(rset);
+		assertThatExceptionOfType(LobRetrievalFailureException.class).isThrownBy(() ->
+				lobRse.extractData(rset));
 	}
 
 	private AbstractLobStreamingResultSetExtractor getResultSetExtractor(final boolean ex) {
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 0fff5911ecb..491cdddc5a2 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2013 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.
@@ -24,9 +24,7 @@ import java.sql.SQLException;
 import java.sql.Types;
 
 import org.junit.Before;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Captor;
 import org.mockito.MockitoAnnotations;
@@ -34,9 +32,11 @@ import org.mockito.MockitoAnnotations;
 import org.springframework.jdbc.support.lob.LobCreator;
 import org.springframework.jdbc.support.lob.LobHandler;
 
+import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.*;
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.BDDMockito.*;
 
 /**
@@ -57,9 +57,6 @@ import static org.mockito.BDDMockito.*;
  */
 public class SqlLobValueTests  {
 
-	@Rule
-	public ExpectedException thrown = ExpectedException.none();
-
 	private PreparedStatement preparedStatement;
 	private LobHandler handler;
 	private LobCreator creator;
@@ -95,8 +92,8 @@ public class SqlLobValueTests  {
 	@Test
 	public void test3() throws SQLException {
 		SqlLobValue lob = new SqlLobValue(new InputStreamReader(new ByteArrayInputStream("Bla".getBytes())), 12);
-		thrown.expect(IllegalArgumentException.class);
-		lob.setTypeValue(preparedStatement, 1, Types.BLOB, "test");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				lob.setTypeValue(preparedStatement, 1, Types.BLOB, "test"));
 	}
 
 	@Test
@@ -131,8 +128,8 @@ public class SqlLobValueTests  {
 	@Test
 	public void test7() throws SQLException {
 		SqlLobValue lob = new SqlLobValue("bla".getBytes());
-		thrown.expect(IllegalArgumentException.class);
-		lob.setTypeValue(preparedStatement, 1, Types.CLOB, "test");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				lob.setTypeValue(preparedStatement, 1, Types.CLOB, "test"));
 	}
 
 	@Test
@@ -192,8 +189,8 @@ public class SqlLobValueTests  {
 	@Test
 	public void testOtherSqlType() throws SQLException {
 		SqlLobValue lob = new SqlLobValue("Bla", handler);
-		thrown.expect(IllegalArgumentException.class);
-		lob.setTypeValue(preparedStatement, 1, Types.SMALLINT, "test");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				lob.setTypeValue(preparedStatement, 1, Types.SMALLINT, "test"));
 	}
 
 }
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 7939865e5c4..fcb772bacfa 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
@@ -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.
@@ -210,7 +210,7 @@ public class DataSourceTransactionManagerTests  {
 
 		final DataSource dsToUse = (lazyConnection ? new LazyConnectionDataSourceProxy(ds) : ds);
 		tm = new DataSourceTransactionManager(dsToUse);
-		 TransactionTemplate tt = new TransactionTemplate(tm);
+		TransactionTemplate tt = new TransactionTemplate(tm);
 		assertTrue("Hasn't thread connection", !TransactionSynchronizationManager.hasResource(dsToUse));
 		assertTrue("Synchronization not active", !TransactionSynchronizationManager.isSynchronizationActive());
 
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 30238667310..6970af2b7f5 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
@@ -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.
@@ -23,7 +23,7 @@ import javax.sql.DataSource;
 
 import org.junit.Test;
 
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.MatcherAssert.*;
 import static org.hamcrest.Matchers.*;
 import static org.mockito.BDDMockito.*;
 
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 bd58b560b10..81f42527dc7 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2013 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.
@@ -22,7 +22,7 @@ import java.util.Properties;
 import org.junit.Test;
 
 import static org.junit.Assert.*;
-import static org.mockito.BDDMockito.*;
+import static org.mockito.Mockito.*;
 
 /**
  * @author Rod Johnson
diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/TestDataSourceWrapper.java b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/TestDataSourceWrapper.java
index 5e5b5afd6ec..3e57656a326 100644
--- a/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/TestDataSourceWrapper.java
+++ b/spring-jdbc/src/test/java/org/springframework/jdbc/datasource/TestDataSourceWrapper.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2002-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.springframework.jdbc.datasource;
 
 import java.sql.Connection;
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 808d1f63739..c6241dfbd21 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
@@ -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.
@@ -17,6 +17,7 @@
 package org.springframework.jdbc.datasource.embedded;
 
 import org.junit.Test;
+
 import org.springframework.core.io.ClassRelativeResourceLoader;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.jdbc.datasource.init.CannotReadScriptException;
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 406e08bb346..bbcdf7de154 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
@@ -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.
@@ -27,7 +27,7 @@ import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
 import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
 import org.springframework.transaction.support.TransactionSynchronizationManager;
 
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.MatcherAssert.*;
 import static org.hamcrest.Matchers.*;
 
 /**
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 7f7efa51ee8..58b1021dad1 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
@@ -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.
@@ -24,8 +24,8 @@ import org.junit.Test;
 import org.springframework.jdbc.datasource.DataSourceUtils;
 import org.springframework.transaction.support.TransactionSynchronizationManager;
 
-import static org.hamcrest.Matchers.*;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.*;
 import static org.junit.Assert.*;
 import static org.mockito.Mockito.*;
 
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 8d6e1213ba2..059117751e6 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
@@ -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,9 +17,10 @@
 package org.springframework.jdbc.datasource.init;
 
 import org.junit.Test;
+
 import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
 
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.MatcherAssert.*;
 import static org.hamcrest.Matchers.*;
 
 /**
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 2354e1bb614..0070d77fe31 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
@@ -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.
@@ -183,7 +183,7 @@ public class ScriptUtilsUnitTests {
 
 		assertFalse(containsSqlScriptDelimiters("select 1; select '\\n\n';", "\n"));
 		assertTrue(containsSqlScriptDelimiters("select 1\n select 2", "\n"));
-		
+
 		assertFalse(containsSqlScriptDelimiters("select 1\n select 2", "\n\n"));
 		assertTrue(containsSqlScriptDelimiters("select 1\n\n select 2", "\n\n"));
 
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 aff7abab2dc..acf5658fc2e 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
@@ -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.
@@ -20,10 +20,9 @@ import java.util.HashMap;
 import java.util.Map;
 import javax.sql.DataSource;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
 import static org.junit.Assert.*;
 
 /**
@@ -34,9 +33,6 @@ public class MapDataSourceLookupTests {
 
 	private static final String DATA_SOURCE_NAME = "dataSource";
 
-	@Rule
-	public final ExpectedException exception = ExpectedException.none();
-
 
 	@Test
 	@SuppressWarnings({ "unchecked", "rawtypes" })
@@ -44,8 +40,8 @@ public class MapDataSourceLookupTests {
 		MapDataSourceLookup lookup = new MapDataSourceLookup();
 		Map dataSources = lookup.getDataSources();
 
-		exception.expect(UnsupportedOperationException.class);
-		dataSources.put("", "");
+		assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() ->
+				dataSources.put("", ""));
 	}
 
 	@Test
@@ -94,16 +90,16 @@ public class MapDataSourceLookupTests {
 		dataSources.put(DATA_SOURCE_NAME, new Object());
 		MapDataSourceLookup lookup = new MapDataSourceLookup(dataSources);
 
-		exception.expect(ClassCastException.class);
-		lookup.getDataSource(DATA_SOURCE_NAME);
+		assertThatExceptionOfType(ClassCastException.class).isThrownBy(() ->
+				lookup.getDataSource(DATA_SOURCE_NAME));
 	}
 
 	@Test
 	public void getDataSourceWhereSuppliedMapHasNoEntryForSpecifiedKey() throws Exception {
 		MapDataSourceLookup lookup = new MapDataSourceLookup();
 
-		exception.expect(DataSourceLookupFailureException.class);
-		lookup.getDataSource(DATA_SOURCE_NAME);
+		assertThatExceptionOfType(DataSourceLookupFailureException.class).isThrownBy(() ->
+				lookup.getDataSource(DATA_SOURCE_NAME));
 	}
 
 }
diff --git a/spring-jdbc/src/test/java/org/springframework/jdbc/object/CustomerMapper.java b/spring-jdbc/src/test/java/org/springframework/jdbc/object/CustomerMapper.java
index b4af1a4e485..87251dee2d3 100644
--- a/spring-jdbc/src/test/java/org/springframework/jdbc/object/CustomerMapper.java
+++ b/spring-jdbc/src/test/java/org/springframework/jdbc/object/CustomerMapper.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2002-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.springframework.jdbc.object;
 
 import java.sql.ResultSet;
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 cae8805342c..0af7dbc9caa 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
@@ -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.
@@ -19,12 +19,9 @@ package org.springframework.jdbc.object;
 import java.sql.Types;
 import java.util.HashMap;
 import java.util.Map;
-
 import javax.sql.DataSource;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.dao.InvalidDataAccessApiUsageException;
 import org.springframework.jdbc.core.JdbcTemplate;
@@ -33,8 +30,7 @@ import org.springframework.jdbc.core.SqlOutParameter;
 import org.springframework.jdbc.core.SqlParameter;
 import org.springframework.jdbc.datasource.DriverManagerDataSource;
 
-import static org.hamcrest.CoreMatchers.*;
-
+import static org.assertj.core.api.Assertions.*;
 import static org.junit.Assert.*;
 
 /**
@@ -46,14 +42,11 @@ public class RdbmsOperationTests {
 
 	private final TestRdbmsOperation operation = new TestRdbmsOperation();
 
-	@Rule
-	public final ExpectedException exception = ExpectedException.none();
-
 
 	@Test
 	public void emptySql() {
-		exception.expect(InvalidDataAccessApiUsageException.class);
-		operation.compile();
+		assertThatExceptionOfType(InvalidDataAccessApiUsageException.class).isThrownBy(
+				operation::compile);
 	}
 
 	@Test
@@ -61,8 +54,8 @@ public class RdbmsOperationTests {
 		operation.setDataSource(new DriverManagerDataSource());
 		operation.setSql("select * from mytable");
 		operation.compile();
-		exception.expect(InvalidDataAccessApiUsageException.class);
-		operation.setTypes(new int[] { Types.INTEGER });
+		assertThatExceptionOfType(InvalidDataAccessApiUsageException.class).isThrownBy(() ->
+				operation.setTypes(new int[] { Types.INTEGER }));
 	}
 
 	@Test
@@ -70,40 +63,39 @@ public class RdbmsOperationTests {
 		operation.setDataSource(new DriverManagerDataSource());
 		operation.setSql("select * from mytable");
 		operation.compile();
-		exception.expect(InvalidDataAccessApiUsageException.class);
-		operation.declareParameter(new SqlParameter(Types.INTEGER));
+		assertThatExceptionOfType(InvalidDataAccessApiUsageException.class).isThrownBy(() ->
+				operation.declareParameter(new SqlParameter(Types.INTEGER)));
 	}
 
 	@Test
 	public void tooFewParameters() {
 		operation.setSql("select * from mytable");
 		operation.setTypes(new int[] { Types.INTEGER });
-		exception.expect(InvalidDataAccessApiUsageException.class);
-		operation.validateParameters((Object[]) null);
+		assertThatExceptionOfType(InvalidDataAccessApiUsageException.class).isThrownBy(() ->
+				operation.validateParameters((Object[]) null));
 	}
 
 	@Test
 	public void tooFewMapParameters() {
 		operation.setSql("select * from mytable");
 		operation.setTypes(new int[] { Types.INTEGER });
-		exception.expect(InvalidDataAccessApiUsageException.class);
-		operation.validateNamedParameters((Map) null);
+		assertThatExceptionOfType(InvalidDataAccessApiUsageException.class).isThrownBy(() ->
+				operation.validateNamedParameters((Map) null));
 	}
 
 	@Test
 	public void operationConfiguredViaJdbcTemplateMustGetDataSource() throws Exception {
 		operation.setSql("foo");
-
-		exception.expect(InvalidDataAccessApiUsageException.class);
-		exception.expectMessage(containsString("ataSource"));
-		operation.compile();
+		assertThatExceptionOfType(InvalidDataAccessApiUsageException.class).isThrownBy(() ->
+				operation.compile())
+			.withMessageContaining("ataSource");
 	}
 
 	@Test
 	public void tooManyParameters() {
 		operation.setSql("select * from mytable");
-		exception.expect(InvalidDataAccessApiUsageException.class);
-		operation.validateParameters(new Object[] { 1, 2 });
+		assertThatExceptionOfType(InvalidDataAccessApiUsageException.class).isThrownBy(() ->
+				operation.validateParameters(new Object[] { 1, 2 }));
 	}
 
 	@Test
@@ -111,8 +103,8 @@ public class RdbmsOperationTests {
 		operation.setSql("select * from mytable");
 		Map params = new HashMap<>();
 		params.put("col1", "value");
-		exception.expect(InvalidDataAccessApiUsageException.class);
-		operation.validateNamedParameters(params);
+		assertThatExceptionOfType(InvalidDataAccessApiUsageException.class).isThrownBy(() ->
+				operation.validateNamedParameters(params));
 	}
 
 	@Test
@@ -128,8 +120,8 @@ public class RdbmsOperationTests {
 	public void emptyDataSource() {
 		SqlOperation operation = new SqlOperation() {};
 		operation.setSql("select * from mytable");
-		exception.expect(InvalidDataAccessApiUsageException.class);
-		operation.compile();
+		assertThatExceptionOfType(InvalidDataAccessApiUsageException.class).isThrownBy(
+				operation::compile);
 	}
 
 	@Test
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 9e8fcc66eb9..5e3441557f7 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
@@ -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.
@@ -30,9 +30,7 @@ import java.util.Map;
 import javax.sql.DataSource;
 
 import org.junit.Before;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.dao.IncorrectResultSizeDataAccessException;
 import org.springframework.dao.InvalidDataAccessApiUsageException;
@@ -41,9 +39,11 @@ import org.springframework.jdbc.core.SqlParameter;
 import org.springframework.lang.Nullable;
 import org.springframework.util.StringUtils;
 
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.*;
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.BDDMockito.*;
 
 /**
@@ -82,9 +82,6 @@ public class SqlQueryTests  {
 	private static final String[] COLUMN_NAMES = new String[] {"id", "forename"};
 	private static final int[] COLUMN_TYPES = new int[] {Types.INTEGER, Types.VARCHAR};
 
-	@Rule
-	public ExpectedException thrown = ExpectedException.none();
-
 	private Connection connection;
 	private DataSource dataSource;
 	private PreparedStatement preparedStatement;
@@ -141,8 +138,8 @@ public class SqlQueryTests  {
 		query.declareParameter(new SqlParameter(COLUMN_NAMES[1], COLUMN_TYPES[1]));
 		query.compile();
 
-		thrown.expect(InvalidDataAccessApiUsageException.class);
-		query.execute();
+		assertThatExceptionOfType(InvalidDataAccessApiUsageException.class).isThrownBy(
+				query::execute);
 	}
 
 	@Test
@@ -159,8 +156,8 @@ public class SqlQueryTests  {
 		query.declareParameter(new SqlParameter(COLUMN_NAMES[1], COLUMN_TYPES[1]));
 		query.compile();
 
-		thrown.expect(InvalidDataAccessApiUsageException.class);
-		query.executeByNamedParam(Collections.singletonMap(COLUMN_NAMES[0], "value"));
+		assertThatExceptionOfType(InvalidDataAccessApiUsageException.class).isThrownBy(() ->
+				query.executeByNamedParam(Collections.singletonMap(COLUMN_NAMES[0], "value")));
 	}
 
 	@Test
@@ -353,17 +350,13 @@ public class SqlQueryTests  {
 		}
 
 		CustomerQuery query = new CustomerQuery(dataSource);
-		thrown.expect(IncorrectResultSizeDataAccessException.class);
-		try {
-			query.findCustomer("rod");
-		}
-		finally {
-			verify(preparedStatement).setString(1, "rod");
-			verify(connection).prepareStatement(SELECT_ID_FORENAME_WHERE);
-			verify(resultSet).close();
-			verify(preparedStatement).close();
-			verify(connection).close();
-		}
+		assertThatExceptionOfType(IncorrectResultSizeDataAccessException.class).isThrownBy(() ->
+				query.findCustomer("rod"));
+		verify(preparedStatement).setString(1, "rod");
+		verify(connection).prepareStatement(SELECT_ID_FORENAME_WHERE);
+		verify(resultSet).close();
+		verify(preparedStatement).close();
+		verify(connection).close();
 	}
 
 	@Test
@@ -509,8 +502,8 @@ public class SqlQueryTests  {
 
 		// Query should not succeed since parameter declaration did not specify parameter name
 		CustomerQuery query = new CustomerQuery(dataSource);
-		thrown.expect(InvalidDataAccessApiUsageException.class);
-		query.findCustomer(1);
+		assertThatExceptionOfType(InvalidDataAccessApiUsageException.class).isThrownBy(() ->
+				query.findCustomer(1));
 	}
 
 	@Test
@@ -711,8 +704,8 @@ public class SqlQueryTests  {
 		}
 
 		CustomerQuery query = new CustomerQuery(dataSource);
-		thrown.expect(InvalidDataAccessApiUsageException.class);
-		query.findCustomers(1);
+		assertThatExceptionOfType(InvalidDataAccessApiUsageException.class).isThrownBy(() ->
+				query.findCustomers(1));
 	}
 
 	@Test
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 e871dd0796b..9fd74fdb70c 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
@@ -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.
@@ -28,15 +28,14 @@ import javax.sql.DataSource;
 
 import org.junit.After;
 import org.junit.Before;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.jdbc.JdbcUpdateAffectedIncorrectNumberOfRowsException;
 import org.springframework.jdbc.core.SqlParameter;
 import org.springframework.jdbc.support.GeneratedKeyHolder;
 import org.springframework.jdbc.support.KeyHolder;
 
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
 import static org.junit.Assert.*;
 import static org.mockito.BDDMockito.*;
 
@@ -68,9 +67,6 @@ public class SqlUpdateTests {
 	private static final String INSERT_GENERATE_KEYS =
 			"insert into show (name) values(?)";
 
-	@Rule
-	public ExpectedException thrown = ExpectedException.none();
-
 	private DataSource dataSource;
 
 	private Connection connection;
@@ -275,8 +271,8 @@ public class SqlUpdateTests {
 
 		MaxRowsUpdater pc = new MaxRowsUpdater();
 
-		thrown.expect(JdbcUpdateAffectedIncorrectNumberOfRowsException.class);
-		pc.run();
+		assertThatExceptionOfType(JdbcUpdateAffectedIncorrectNumberOfRowsException.class).isThrownBy(
+				pc::run);
 	}
 
 	@Test
@@ -294,9 +290,9 @@ public class SqlUpdateTests {
 	public void testNotRequiredRows() throws SQLException {
 		given(preparedStatement.executeUpdate()).willReturn(2);
 		given(connection.prepareStatement(UPDATE)).willReturn(preparedStatement);
-		thrown.expect(JdbcUpdateAffectedIncorrectNumberOfRowsException.class);
 		RequiredRowsUpdater pc = new RequiredRowsUpdater();
-		pc.run();
+		assertThatExceptionOfType(JdbcUpdateAffectedIncorrectNumberOfRowsException.class).isThrownBy(
+				pc::run);
 	}
 
 	private class Updater extends SqlUpdate {
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 a475d45de45..f364658ec67 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
@@ -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.
@@ -30,9 +30,7 @@ import javax.sql.DataSource;
 
 import org.junit.After;
 import org.junit.Before;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.dao.DataAccessException;
 import org.springframework.dao.InvalidDataAccessApiUsageException;
@@ -52,7 +50,9 @@ import org.springframework.jdbc.support.SQLStateSQLExceptionTranslator;
 import org.springframework.lang.Nullable;
 import org.springframework.transaction.support.TransactionSynchronizationManager;
 
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.BDDMockito.*;
 
 /**
@@ -62,9 +62,6 @@ import static org.mockito.BDDMockito.*;
  */
 public class StoredProcedureTests {
 
-	@Rule
-	public ExpectedException thrown = ExpectedException.none();
-
 	private DataSource dataSource;
 	private Connection connection;
 	private CallableStatement callableStatement;
@@ -97,8 +94,8 @@ public class StoredProcedureTests {
 				callableStatement);
 
 		NoSuchStoredProcedure sproc = new NoSuchStoredProcedure(dataSource);
-		thrown.expect(BadSqlGrammarException.class);
-		sproc.execute();
+		assertThatExceptionOfType(BadSqlGrammarException.class).isThrownBy(
+				sproc::execute);
 	}
 
 	private void testAddInvoice(final int amount, final int custid) throws Exception {
@@ -164,8 +161,6 @@ public class StoredProcedureTests {
 	/**
 	 * Confirm no connection was used to get metadata. Does not use superclass replay
 	 * mechanism.
-	 *
-	 * @throws Exception
 	 */
 	@Test
 	public void testStoredProcedureConfiguredViaJdbcTemplateWithCustomExceptionTranslator()
@@ -203,8 +198,6 @@ public class StoredProcedureTests {
 
 	/**
 	 * Confirm our JdbcTemplate is used
-	 *
-	 * @throws Exception
 	 */
 	@Test
 	public void testStoredProcedureConfiguredViaJdbcTemplate() throws Exception {
@@ -235,17 +228,16 @@ public class StoredProcedureTests {
 	public void testUnnamedParameter() throws Exception {
 		this.verifyClosedAfter = false;
 		// Shouldn't succeed in creating stored procedure with unnamed parameter
-		thrown.expect(InvalidDataAccessApiUsageException.class);
-		new UnnamedParameterStoredProcedure(dataSource);
+		assertThatExceptionOfType(InvalidDataAccessApiUsageException.class).isThrownBy(() ->
+		new UnnamedParameterStoredProcedure(dataSource));
 	}
 
 	@Test
 	public void testMissingParameter() throws Exception {
 		this.verifyClosedAfter = false;
 		MissingParameterStoredProcedure mp = new MissingParameterStoredProcedure(dataSource);
-		thrown.expect(InvalidDataAccessApiUsageException.class);
-		mp.execute();
-		fail("Shouldn't succeed in running stored procedure with missing required parameter");
+		assertThatExceptionOfType(InvalidDataAccessApiUsageException.class).isThrownBy(
+				mp::execute);
 	}
 
 	@Test
@@ -256,8 +248,8 @@ public class StoredProcedureTests {
 		given(connection.prepareCall("{call " + StoredProcedureExceptionTranslator.SQL + "()}")
 				).willReturn(callableStatement);
 		StoredProcedureExceptionTranslator sproc = new StoredProcedureExceptionTranslator(dataSource);
-		thrown.expect(CustomDataException.class);
-		sproc.execute();
+		assertThatExceptionOfType(CustomDataException.class).isThrownBy(
+				sproc::execute);
 	}
 
 	@Test
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 1f10d43d7f5..536dc0a1095 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
@@ -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.
@@ -31,7 +31,7 @@ import org.springframework.jdbc.support.lob.DefaultLobHandler;
 import org.springframework.jdbc.support.lob.LobCreator;
 import org.springframework.jdbc.support.lob.LobHandler;
 
-import static org.mockito.BDDMockito.*;
+import static org.mockito.Mockito.*;
 
 /**
  * @author Juergen Hoeller
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 f27a61a10ab..4b5a938a5e2 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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.
@@ -19,16 +19,14 @@ package org.springframework.jdbc.support;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.dao.DataRetrievalFailureException;
 import org.springframework.dao.InvalidDataAccessApiUsageException;
 
-import static java.util.Arrays.asList;
+import static java.util.Arrays.*;
 import static java.util.Collections.*;
-import static org.hamcrest.CoreMatchers.*;
+import static org.assertj.core.api.Assertions.*;
 import static org.junit.Assert.*;
 
 /**
@@ -43,9 +41,6 @@ public class KeyHolderTests {
 
 	private final KeyHolder kh = new GeneratedKeyHolder();
 
-	@Rule
-	public final ExpectedException exception = ExpectedException.none();
-
 
 	@Test
 	public void singleKey() {
@@ -58,18 +53,18 @@ public class KeyHolderTests {
 	public void singleKeyNonNumeric() {
 		kh.getKeyList().addAll(singletonList(singletonMap("key", "1")));
 
-		exception.expect(DataRetrievalFailureException.class);
-		exception.expectMessage(startsWith("The generated key is not of a supported numeric type."));
-		kh.getKey().intValue();
+		assertThatExceptionOfType(DataRetrievalFailureException.class).isThrownBy(() ->
+				kh.getKey().intValue())
+			.withMessageStartingWith("The generated key is not of a supported numeric type.");
 	}
 
 	@Test
 	public void noKeyReturnedInMap() {
 		kh.getKeyList().addAll(singletonList(emptyMap()));
 
-		exception.expect(DataRetrievalFailureException.class);
-		exception.expectMessage(startsWith("Unable to retrieve the generated key."));
-		kh.getKey();
+		assertThatExceptionOfType(DataRetrievalFailureException.class).isThrownBy(() ->
+				kh.getKey())
+			.withMessageStartingWith("Unable to retrieve the generated key.");
 	}
 
 	@Test
@@ -81,9 +76,9 @@ public class KeyHolderTests {
 		kh.getKeyList().addAll(singletonList(m));
 
 		assertEquals("two keys should be in the map", 2, kh.getKeys().size());
-		exception.expect(InvalidDataAccessApiUsageException.class);
-		exception.expectMessage(startsWith("The getKey method should only be used when a single key is returned."));
-		kh.getKey();
+		assertThatExceptionOfType(InvalidDataAccessApiUsageException.class).isThrownBy(() ->
+				kh.getKey())
+			.withMessageStartingWith("The getKey method should only be used when a single key is returned.");
 	}
 
 	@Test
@@ -95,9 +90,9 @@ public class KeyHolderTests {
 		kh.getKeyList().addAll(asList(m, m));
 
 		assertEquals("two rows should be in the list", 2, kh.getKeyList().size());
-		exception.expect(InvalidDataAccessApiUsageException.class);
-		exception.expectMessage(startsWith("The getKeys method should only be used when keys for a single row are returned."));
-		kh.getKeys();
+		assertThatExceptionOfType(InvalidDataAccessApiUsageException.class).isThrownBy(() ->
+				kh.getKeys())
+			.withMessageStartingWith("The getKeys method should only be used when keys for a single row are returned.");
 	}
 
 }
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 59cf7a34e60..0ff7ef90aa4 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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.
@@ -20,9 +20,7 @@ import java.sql.BatchUpdateException;
 import java.sql.DataTruncation;
 import java.sql.SQLException;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.dao.CannotAcquireLockException;
 import org.springframework.dao.CannotSerializeTransactionException;
@@ -35,6 +33,7 @@ import org.springframework.jdbc.BadSqlGrammarException;
 import org.springframework.jdbc.InvalidResultSetAccessException;
 import org.springframework.lang.Nullable;
 
+import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
 import static org.junit.Assert.*;
 
 /**
@@ -56,9 +55,6 @@ public class SQLErrorCodeSQLExceptionTranslatorTests {
 		ERROR_CODES.setCannotSerializeTransactionCodes(new String[] { "9" });
 	}
 
-	@Rule
-	public final ExpectedException exception = ExpectedException.none();
-
 
 	@Test
 	public void errorCodeTranslation() {
@@ -177,8 +173,8 @@ public class SQLErrorCodeSQLExceptionTranslatorTests {
 		assertEquals(invResEx, diex.getCause());
 
 		// Shouldn't custom translate this - invalid class
-		exception.expect(IllegalArgumentException.class);
-		customTranslation.setExceptionClass(String.class);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				customTranslation.setExceptionClass(String.class));
 	}
 
 }
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 29d7578c9df..16d6b158bbd 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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.
@@ -19,6 +19,7 @@ package org.springframework.jdbc.support;
 import java.sql.SQLException;
 
 import org.junit.Test;
+
 import org.springframework.jdbc.BadSqlGrammarException;
 import org.springframework.jdbc.UncategorizedSQLException;
 
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 a2891a99466..7d1a0abd0c4 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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.
@@ -20,9 +20,7 @@ import java.lang.reflect.Method;
 import javax.jms.JMSException;
 import javax.jms.Session;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.context.ApplicationContext;
 import org.springframework.jms.StubTextMessage;
@@ -50,10 +48,6 @@ import static org.mockito.Mockito.*;
  */
 public abstract class AbstractJmsAnnotationDrivenTests {
 
-	@Rule
-	public final ExpectedException thrown = ExpectedException.none();
-
-
 	@Test
 	public abstract void sampleConfiguration();
 
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 989e1dda19f..1a8c3d966bc 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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.
@@ -19,7 +19,6 @@ package org.springframework.jms.annotation;
 import javax.jms.JMSException;
 import javax.jms.MessageListener;
 
-import org.hamcrest.core.Is;
 import org.junit.Test;
 
 import org.springframework.context.ApplicationContext;
@@ -29,6 +28,8 @@ import org.springframework.jms.config.SimpleJmsListenerEndpoint;
 import org.springframework.jms.listener.adapter.ListenerExecutionFailedException;
 import org.springframework.messaging.handler.annotation.support.MethodArgumentNotValidException;
 
+import static org.assertj.core.api.Assertions.*;
+
 /**
  * @author Stephane Nicoll
  */
@@ -87,9 +88,9 @@ public class AnnotationDrivenNamespaceTests extends AbstractJmsAnnotationDrivenT
 		ApplicationContext context = new ClassPathXmlApplicationContext(
 				"annotation-driven-custom-handler-method-factory.xml", getClass());
 
-		thrown.expect(ListenerExecutionFailedException.class);
-		thrown.expectCause(Is.isA(MethodArgumentNotValidException.class));
-		testJmsHandlerMethodFactoryConfiguration(context);
+		assertThatExceptionOfType(ListenerExecutionFailedException.class).isThrownBy(() ->
+				testJmsHandlerMethodFactoryConfiguration(context))
+			.withCauseInstanceOf(MethodArgumentNotValidException.class);
 	}
 
 	@Override
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 462f067b716..e5e8ef7297c 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
@@ -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.
@@ -18,15 +18,10 @@ package org.springframework.jms.annotation;
 
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
-
 import javax.jms.JMSException;
 import javax.jms.MessageListener;
 
-import org.hamcrest.core.Is;
-
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.beans.factory.BeanCreationException;
 import org.springframework.context.ConfigurableApplicationContext;
@@ -50,6 +45,7 @@ import org.springframework.messaging.handler.annotation.support.MessageHandlerMe
 import org.springframework.messaging.handler.annotation.support.MethodArgumentNotValidException;
 import org.springframework.stereotype.Component;
 
+import static org.assertj.core.api.Assertions.*;
 import static org.junit.Assert.*;
 
 /**
@@ -58,10 +54,6 @@ import static org.junit.Assert.*;
  */
 public class EnableJmsTests extends AbstractJmsAnnotationDrivenTests {
 
-	@Rule
-	public final ExpectedException thrown = ExpectedException.none();
-
-
 	@Override
 	@Test
 	public void sampleConfiguration() {
@@ -140,9 +132,9 @@ public class EnableJmsTests extends AbstractJmsAnnotationDrivenTests {
 		ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(
 				EnableJmsHandlerMethodFactoryConfig.class, ValidationBean.class);
 
-		thrown.expect(ListenerExecutionFailedException.class);
-		thrown.expectCause(Is.isA(MethodArgumentNotValidException.class));
-		testJmsHandlerMethodFactoryConfiguration(context);
+		assertThatExceptionOfType(ListenerExecutionFailedException.class).isThrownBy(() ->
+				testJmsHandlerMethodFactoryConfiguration(context))
+			.withCauseInstanceOf(MethodArgumentNotValidException.class);
 	}
 
 	@Override
@@ -186,9 +178,10 @@ public class EnableJmsTests extends AbstractJmsAnnotationDrivenTests {
 	@Test
 	@SuppressWarnings("resource")
 	public void unknownFactory() {
-		thrown.expect(BeanCreationException.class);
-		thrown.expectMessage("customFactory");  // not found
-		new AnnotationConfigApplicationContext(EnableJmsSampleConfig.class, CustomBean.class);
+		 // not found
+		assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() ->
+				new AnnotationConfigApplicationContext(EnableJmsSampleConfig.class, CustomBean.class))
+			.withMessageContaining("customFactory");
 	}
 
 	@Test
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 f96dc358801..dce439bcfcd 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
@@ -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.
@@ -22,9 +22,7 @@ import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
 import java.lang.reflect.Method;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.aop.support.AopUtils;
 import org.springframework.beans.factory.BeanCreationException;
@@ -47,7 +45,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.ReflectionUtils;
 
-import static org.hamcrest.CoreMatchers.*;
+import static org.assertj.core.api.Assertions.*;
 import static org.junit.Assert.*;
 import static org.mockito.Mockito.*;
 
@@ -57,10 +55,6 @@ import static org.mockito.Mockito.*;
  */
 public class JmsListenerAnnotationBeanPostProcessorTests {
 
-	@Rule
-	public final ExpectedException thrown = ExpectedException.none();
-
-
 	@Test
 	public void simpleMessageListener() throws Exception {
 		ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(
@@ -171,10 +165,10 @@ public class JmsListenerAnnotationBeanPostProcessorTests {
 	@Test
 	@SuppressWarnings("resource")
 	public void invalidProxy() {
-		thrown.expect(BeanCreationException.class);
-		thrown.expectCause(is(instanceOf(IllegalStateException.class)));
-		thrown.expectMessage("handleIt2");
-		new AnnotationConfigApplicationContext(Config.class, ProxyConfig.class, InvalidProxyTestBean.class);
+		assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() ->
+				new AnnotationConfigApplicationContext(Config.class, ProxyConfig.class, InvalidProxyTestBean.class))
+			.withCauseInstanceOf(IllegalStateException.class)
+			.withMessageContaining("handleIt2");
 	}
 
 
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 6aabb74ddb7..3e000df5b9b 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
@@ -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.
@@ -21,9 +21,7 @@ import javax.jms.MessageListener;
 import javax.jms.Session;
 import javax.transaction.TransactionManager;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.beans.DirectFieldAccessor;
 import org.springframework.jms.StubConnectionFactory;
@@ -42,6 +40,7 @@ import org.springframework.jms.support.destination.DynamicDestinationResolver;
 import org.springframework.util.backoff.BackOff;
 import org.springframework.util.backoff.FixedBackOff;
 
+import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
 import static org.junit.Assert.*;
 import static org.mockito.Mockito.*;
 
@@ -59,10 +58,6 @@ public class JmsListenerContainerFactoryTests {
 	private final TransactionManager transactionManager = mock(TransactionManager.class);
 
 
-	@Rule
-	public final ExpectedException thrown = ExpectedException.none();
-
-
 	@Test
 	public void createSimpleContainer() {
 		SimpleJmsListenerContainerFactory factory = new SimpleJmsListenerContainerFactory();
@@ -130,8 +125,8 @@ public class JmsListenerContainerFactoryTests {
 
 		SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
 		endpoint.setMessageListener(new MessageListenerAdapter());
-		this.thrown.expect(IllegalStateException.class);
-		factory.createListenerContainer(endpoint);
+		assertThatIllegalStateException().isThrownBy(() ->
+				factory.createListenerContainer(endpoint));
 	}
 
 	@Test
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 d9aeb3b1bb9..97b616b85df 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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,12 +17,12 @@
 package org.springframework.jms.config;
 
 import org.junit.Before;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.beans.factory.support.StaticListableBeanFactory;
 
+import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
+import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
 import static org.junit.Assert.*;
 
 /**
@@ -37,10 +37,6 @@ public class JmsListenerEndpointRegistrarTests {
 	private final JmsListenerContainerTestFactory containerFactory = new JmsListenerContainerTestFactory();
 
 
-	@Rule
-	public final ExpectedException thrown = ExpectedException.none();
-
-
 	@Before
 	public void setup() {
 		this.registrar.setEndpointRegistry(this.registry);
@@ -50,14 +46,14 @@ public class JmsListenerEndpointRegistrarTests {
 
 	@Test
 	public void registerNullEndpoint() {
-		this.thrown.expect(IllegalArgumentException.class);
-		this.registrar.registerEndpoint(null, this.containerFactory);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				this.registrar.registerEndpoint(null, this.containerFactory));
 	}
 
 	@Test
 	public void registerNullEndpointId() {
-		this.thrown.expect(IllegalArgumentException.class);
-		this.registrar.registerEndpoint(new SimpleJmsListenerEndpoint(), this.containerFactory);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				this.registrar.registerEndpoint(new SimpleJmsListenerEndpoint(), this.containerFactory));
 	}
 
 	@Test
@@ -65,8 +61,8 @@ public class JmsListenerEndpointRegistrarTests {
 		SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
 		endpoint.setId("");
 
-		this.thrown.expect(IllegalArgumentException.class);
-		this.registrar.registerEndpoint(endpoint, this.containerFactory);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				this.registrar.registerEndpoint(endpoint, this.containerFactory));
 	}
 
 	@Test
@@ -87,9 +83,9 @@ public class JmsListenerEndpointRegistrarTests {
 		endpoint.setId("some id");
 		this.registrar.registerEndpoint(endpoint, null);
 
-		this.thrown.expect(IllegalStateException.class);
-		this.thrown.expectMessage(endpoint.toString());
-		this.registrar.afterPropertiesSet();
+		assertThatIllegalStateException().isThrownBy(() ->
+				this.registrar.afterPropertiesSet())
+			.withMessageContaining(endpoint.toString());
 	}
 
 	@Test
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 1b4310d112e..bb8a8bac3e9 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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,9 +16,10 @@
 
 package org.springframework.jms.config;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
+
+import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
+import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
 
 /**
  * @author Stephane Nicoll
@@ -30,34 +31,30 @@ public class JmsListenerEndpointRegistryTests {
 	private final JmsListenerContainerTestFactory containerFactory = new JmsListenerContainerTestFactory();
 
 
-	@Rule
-	public final ExpectedException thrown = ExpectedException.none();
-
-
 	@Test
 	public void createWithNullEndpoint() {
-		thrown.expect(IllegalArgumentException.class);
-		registry.registerListenerContainer(null, containerFactory);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				registry.registerListenerContainer(null, containerFactory));
 	}
 
 	@Test
 	public void createWithNullEndpointId() {
-		thrown.expect(IllegalArgumentException.class);
-		registry.registerListenerContainer(new SimpleJmsListenerEndpoint(), containerFactory);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				registry.registerListenerContainer(new SimpleJmsListenerEndpoint(), containerFactory));
 	}
 
 	@Test
 	public void createWithNullContainerFactory() {
-		thrown.expect(IllegalArgumentException.class);
-		registry.registerListenerContainer(createEndpoint("foo", "myDestination"), null);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				registry.registerListenerContainer(createEndpoint("foo", "myDestination"), null));
 	}
 
 	@Test
 	public void createWithDuplicateEndpointId() {
 		registry.registerListenerContainer(createEndpoint("test", "queue"), containerFactory);
 
-		thrown.expect(IllegalStateException.class);
-		registry.registerListenerContainer(createEndpoint("test", "queue"), containerFactory);
+		assertThatIllegalStateException().isThrownBy(() ->
+				registry.registerListenerContainer(createEndpoint("test", "queue"), containerFactory));
 	}
 
 
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 864948d5832..e9d6e1d9586 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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,9 +18,7 @@ package org.springframework.jms.config;
 
 import javax.jms.MessageListener;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.beans.DirectFieldAccessor;
 import org.springframework.jms.listener.DefaultMessageListenerContainer;
@@ -30,6 +28,8 @@ import org.springframework.jms.listener.adapter.MessageListenerAdapter;
 import org.springframework.jms.listener.endpoint.JmsActivationSpecConfig;
 import org.springframework.jms.listener.endpoint.JmsMessageEndpointManager;
 
+import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
+import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
 import static org.junit.Assert.*;
 import static org.mockito.Mockito.*;
 
@@ -38,10 +38,6 @@ import static org.mockito.Mockito.*;
  */
 public class JmsListenerEndpointTests {
 
-	@Rule
-	public final ExpectedException thrown = ExpectedException.none();
-
-
 	@Test
 	public void setupJmsMessageContainerFullConfig() {
 		DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
@@ -99,8 +95,8 @@ public class JmsListenerEndpointTests {
 		DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
 		SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
 
-		thrown.expect(IllegalStateException.class);
-		endpoint.setupListenerContainer(container);
+		assertThatIllegalStateException().isThrownBy(() ->
+				endpoint.setupListenerContainer(container));
 	}
 
 	@Test
@@ -109,8 +105,8 @@ public class JmsListenerEndpointTests {
 		SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
 		endpoint.setMessageListener(new MessageListenerAdapter());
 
-		thrown.expect(IllegalArgumentException.class);
-		endpoint.setupListenerContainer(container);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				endpoint.setupListenerContainer(container));
 	}
 
 }
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 169b3275d6c..2d1f67f6123 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
@@ -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.
@@ -29,11 +29,9 @@ import javax.jms.QueueSender;
 import javax.jms.Session;
 import javax.jms.TextMessage;
 
-import org.hamcrest.Matchers;
 import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 import org.junit.rules.TestName;
 
 import org.springframework.beans.DirectFieldAccessor;
@@ -64,13 +62,9 @@ import org.springframework.validation.Errors;
 import org.springframework.validation.Validator;
 import org.springframework.validation.annotation.Validated;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.BDDMockito.given;
-import static org.mockito.BDDMockito.mock;
-import static org.mockito.BDDMockito.verify;
+import static org.assertj.core.api.Assertions.*;
+import static org.junit.Assert.*;
+import static org.mockito.BDDMockito.*;
 
 /**
  * @author Stephane Nicoll
@@ -87,9 +81,6 @@ public class MethodJmsListenerEndpointTests {
 	@Rule
 	public final TestName name = new TestName();
 
-	@Rule
-	public final ExpectedException thrown = ExpectedException.none();
-
 
 	@Before
 	public void setup() {
@@ -103,8 +94,8 @@ public class MethodJmsListenerEndpointTests {
 		endpoint.setBean(this);
 		endpoint.setMethod(getTestMethod());
 
-		this.thrown.expect(IllegalStateException.class);
-		endpoint.createMessageListener(this.container);
+		assertThatIllegalStateException().isThrownBy(() ->
+				endpoint.createMessageListener(this.container));
 	}
 
 	@Test
@@ -387,17 +378,17 @@ public class MethodJmsListenerEndpointTests {
 		Session session = mock(Session.class);
 		given(session.createTextMessage("content")).willReturn(reply);
 
-		this.thrown.expect(ReplyFailureException.class);
-		this.thrown.expectCause(Matchers.isA(InvalidDestinationException.class));
-		listener.onMessage(createSimpleJmsTextMessage("content"), session);
+		assertThatExceptionOfType(ReplyFailureException.class).isThrownBy(() ->
+				listener.onMessage(createSimpleJmsTextMessage("content"), session))
+			.withCauseInstanceOf(InvalidDestinationException.class);
 	}
 
 	@Test
 	public void invalidSendTo() {
-		this.thrown.expect(IllegalStateException.class);
-		this.thrown.expectMessage("firstDestination");
-		this.thrown.expectMessage("secondDestination");
-		createDefaultInstance(String.class);
+		assertThatIllegalStateException().isThrownBy(() ->
+				createDefaultInstance(String.class))
+			.withMessageContaining("firstDestination")
+			.withMessageContaining("secondDestination");
 	}
 
 	@Test
@@ -424,8 +415,9 @@ public class MethodJmsListenerEndpointTests {
 		MessagingMessageListenerAdapter listener = createInstance(customFactory, method);
 		Session session = mock(Session.class);
 
-		this.thrown.expect(ListenerExecutionFailedException.class);
-		listener.onMessage(createSimpleJmsTextMessage("invalid value"), session); // test is an invalid value
+		// test is an invalid value
+		assertThatExceptionOfType(ListenerExecutionFailedException.class).isThrownBy(() ->
+				listener.onMessage(createSimpleJmsTextMessage("invalid value"), session));
 
 	}
 
@@ -436,10 +428,11 @@ public class MethodJmsListenerEndpointTests {
 		MessagingMessageListenerAdapter listener = createDefaultInstance(Integer.class);
 		Session session = mock(Session.class);
 
-		this.thrown.expect(ListenerExecutionFailedException.class);
-		this.thrown.expectCause(Matchers.isA(MessageConversionException.class));
-		this.thrown.expectMessage(getDefaultListenerMethod(Integer.class).toGenericString()); // ref to method
-		listener.onMessage(createSimpleJmsTextMessage("test"), session); // test is not a valid integer
+		// test is not a valid integer
+		assertThatExceptionOfType(ListenerExecutionFailedException.class).isThrownBy(() ->
+				listener.onMessage(createSimpleJmsTextMessage("test"), session))
+			.withCauseInstanceOf(MessageConversionException.class)
+			.withMessageContaining(getDefaultListenerMethod(Integer.class).toGenericString()); // ref to method
 	}
 
 	@Test
@@ -447,9 +440,10 @@ public class MethodJmsListenerEndpointTests {
 		MessagingMessageListenerAdapter listener = createDefaultInstance(Message.class);
 		Session session = mock(Session.class);
 
-		this.thrown.expect(ListenerExecutionFailedException.class);
-		this.thrown.expectCause(Matchers.isA(MessageConversionException.class));
-		listener.onMessage(createSimpleJmsTextMessage("test"), session);  // Message as Message
+		// Message as Message
+		assertThatExceptionOfType(ListenerExecutionFailedException.class).isThrownBy(() ->
+				listener.onMessage(createSimpleJmsTextMessage("test"), session))
+			.withCauseInstanceOf(MessageConversionException.class);
 	}
 
 
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 1a7ec1d664d..8a2ddb1327c 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
@@ -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.
@@ -26,11 +26,8 @@ import javax.jms.MessageNotWriteableException;
 import javax.jms.Session;
 import javax.jms.TextMessage;
 
-import org.hamcrest.core.StringContains;
 import org.junit.Before;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 import org.mockito.ArgumentCaptor;
 import org.mockito.BDDMockito;
 import org.mockito.Captor;
@@ -51,7 +48,9 @@ import org.springframework.messaging.MessagingException;
 import org.springframework.messaging.converter.GenericMessageConverter;
 import org.springframework.messaging.support.MessageBuilder;
 
+import static org.assertj.core.api.Assertions.*;
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.BDDMockito.*;
 
 /**
@@ -61,9 +60,6 @@ import static org.mockito.BDDMockito.*;
  */
 public class JmsMessagingTemplateTests {
 
-	@Rule
-	public final ExpectedException thrown = ExpectedException.none();
-
 	@Captor
 	private ArgumentCaptor messageCreator;
 
@@ -169,8 +165,8 @@ public class JmsMessagingTemplateTests {
 	public void sendNoDefaultSet() {
 		Message message = createTextMessage();
 
-		this.thrown.expect(IllegalStateException.class);
-		this.messagingTemplate.send(message);
+		assertThatIllegalStateException().isThrownBy(() ->
+				this.messagingTemplate.send(message));
 	}
 
 	@Test
@@ -227,8 +223,8 @@ public class JmsMessagingTemplateTests {
 
 	@Test
 	public void convertAndSendNoDefaultSet() throws JMSException {
-		this.thrown.expect(IllegalStateException.class);
-		this.messagingTemplate.convertAndSend("my Payload");
+		assertThatIllegalStateException().isThrownBy(() ->
+				this.messagingTemplate.convertAndSend("my Payload"));
 	}
 
 	@Test
@@ -244,9 +240,9 @@ public class JmsMessagingTemplateTests {
 		this.messagingTemplate.convertAndSend("myQueue", "msg to convert");
 		verify(this.jmsTemplate).send(eq("myQueue"), this.messageCreator.capture());
 
-		this.thrown.expect(org.springframework.messaging.converter.MessageConversionException.class);
-		this.thrown.expectMessage(new StringContains("Test exception"));
-		this.messageCreator.getValue().createMessage(mock(Session.class));
+		assertThatExceptionOfType(org.springframework.messaging.converter.MessageConversionException.class).isThrownBy(() ->
+				this.messageCreator.getValue().createMessage(mock(Session.class)))
+			.withMessageContaining("Test exception");
 	}
 
 	@Test
@@ -316,8 +312,8 @@ public class JmsMessagingTemplateTests {
 
 	@Test
 	public void receiveNoDefaultSet() {
-		this.thrown.expect(IllegalStateException.class);
-		this.messagingTemplate.receive();
+		assertThatIllegalStateException().isThrownBy(
+				this.messagingTemplate::receive);
 	}
 
 	@Test
@@ -381,8 +377,8 @@ public class JmsMessagingTemplateTests {
 		javax.jms.Message jmsMessage = createJmsTextMessage("Hello");
 		given(this.jmsTemplate.receive("myQueue")).willReturn(jmsMessage);
 
-		this.thrown.expect(org.springframework.messaging.converter.MessageConversionException.class);
-		this.messagingTemplate.receiveAndConvert("myQueue", Writer.class);
+		assertThatExceptionOfType(org.springframework.messaging.converter.MessageConversionException.class).isThrownBy(() ->
+				this.messagingTemplate.receiveAndConvert("myQueue", Writer.class));
 	}
 
 	@Test
@@ -444,8 +440,8 @@ public class JmsMessagingTemplateTests {
 	public void sendAndReceiveNoDefaultSet() {
 		Message message = createTextMessage();
 
-		this.thrown.expect(IllegalStateException.class);
-		this.messagingTemplate.sendAndReceive(message);
+		assertThatIllegalStateException().isThrownBy(() ->
+				this.messagingTemplate.sendAndReceive(message));
 	}
 
 	@Test
@@ -494,8 +490,8 @@ public class JmsMessagingTemplateTests {
 
 	@Test
 	public void convertSendAndReceiveNoDefaultSet() throws JMSException {
-		this.thrown.expect(IllegalStateException.class);
-		this.messagingTemplate.convertSendAndReceive("my Payload", String.class);
+		assertThatIllegalStateException().isThrownBy(() ->
+				this.messagingTemplate.convertSendAndReceive("my Payload", String.class));
 	}
 
 	@Test
@@ -507,8 +503,8 @@ public class JmsMessagingTemplateTests {
 		this.messagingTemplate.setJmsMessageConverter(messageConverter);
 		invokeMessageCreator();
 
-		this.thrown.expect(org.springframework.messaging.converter.MessageConversionException.class);
-		this.messagingTemplate.send("myQueue", message);
+		assertThatExceptionOfType(org.springframework.messaging.converter.MessageConversionException.class).isThrownBy(() ->
+				this.messagingTemplate.send("myQueue", message));
 	}
 
 	@Test
@@ -520,16 +516,16 @@ public class JmsMessagingTemplateTests {
 		this.messagingTemplate.setJmsMessageConverter(messageConverter);
 		given(this.jmsTemplate.receive("myQueue")).willReturn(message);
 
-		this.thrown.expect(org.springframework.messaging.converter.MessageConversionException.class);
-		this.messagingTemplate.receive("myQueue");
+		assertThatExceptionOfType(org.springframework.messaging.converter.MessageConversionException.class).isThrownBy(() ->
+				this.messagingTemplate.receive("myQueue"));
 	}
 
 	@Test
 	public void convertMessageNotReadableException() throws JMSException {
 		willThrow(MessageNotReadableException.class).given(this.jmsTemplate).receive("myQueue");
 
-		this.thrown.expect(MessagingException.class);
-		this.messagingTemplate.receive("myQueue");
+		assertThatExceptionOfType(MessagingException.class).isThrownBy(() ->
+				this.messagingTemplate.receive("myQueue"));
 	}
 
 	@Test
@@ -537,8 +533,8 @@ public class JmsMessagingTemplateTests {
 		Destination destination = new Destination() {};
 		willThrow(DestinationResolutionException.class).given(this.jmsTemplate).send(eq(destination), any());
 
-		this.thrown.expect(org.springframework.messaging.core.DestinationResolutionException.class);
-		this.messagingTemplate.send(destination, createTextMessage());
+		assertThatExceptionOfType(org.springframework.messaging.core.DestinationResolutionException.class).isThrownBy(() ->
+				this.messagingTemplate.send(destination, createTextMessage()));
 	}
 
 	@Test
@@ -546,8 +542,8 @@ public class JmsMessagingTemplateTests {
 		Destination destination = new Destination() {};
 		willThrow(DestinationResolutionException.class).given(this.jmsTemplate).receive(destination);
 
-		this.thrown.expect(org.springframework.messaging.core.DestinationResolutionException.class);
-		this.messagingTemplate.receive(destination);
+		assertThatExceptionOfType(org.springframework.messaging.core.DestinationResolutionException.class).isThrownBy(() ->
+				this.messagingTemplate.receive(destination));
 	}
 
 	@Test
@@ -558,8 +554,8 @@ public class JmsMessagingTemplateTests {
 		this.messagingTemplate.setJmsMessageConverter(messageConverter);
 		invokeMessageCreator();
 
-		this.thrown.expect(org.springframework.messaging.converter.MessageConversionException.class);
-		this.messagingTemplate.send("myQueue", message);
+		assertThatExceptionOfType(org.springframework.messaging.converter.MessageConversionException.class).isThrownBy(() ->
+				this.messagingTemplate.send("myQueue", message));
 	}
 
 	@Test
@@ -570,16 +566,16 @@ public class JmsMessagingTemplateTests {
 		this.messagingTemplate.setJmsMessageConverter(messageConverter);
 		invokeMessageCreator();
 
-		this.thrown.expect(org.springframework.messaging.converter.MessageConversionException.class);
-		this.messagingTemplate.send("myQueue", message);
+		assertThatExceptionOfType(org.springframework.messaging.converter.MessageConversionException.class).isThrownBy(() ->
+				this.messagingTemplate.send("myQueue", message));
 	}
 
 	@Test
 	public void convertInvalidDestinationExceptionOnSendAndReceiveWithName() {
 		willThrow(InvalidDestinationException.class).given(this.jmsTemplate).sendAndReceive(eq("unknownQueue"), any());
 
-		this.thrown.expect(org.springframework.messaging.core.DestinationResolutionException.class);
-		this.messagingTemplate.sendAndReceive("unknownQueue", createTextMessage());
+		assertThatExceptionOfType(org.springframework.messaging.core.DestinationResolutionException.class).isThrownBy(() ->
+				this.messagingTemplate.sendAndReceive("unknownQueue", createTextMessage()));
 	}
 
 	@Test
@@ -587,8 +583,8 @@ public class JmsMessagingTemplateTests {
 		Destination destination = new Destination() {};
 		willThrow(InvalidDestinationException.class).given(this.jmsTemplate).sendAndReceive(eq(destination), any());
 
-		this.thrown.expect(org.springframework.messaging.core.DestinationResolutionException.class);
-		this.messagingTemplate.sendAndReceive(destination, createTextMessage());
+		assertThatExceptionOfType(org.springframework.messaging.core.DestinationResolutionException.class).isThrownBy(() ->
+				this.messagingTemplate.sendAndReceive(destination, createTextMessage()));
 	}
 
 	private void invokeMessageCreator() {
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 e50cad68c68..ff433785a80 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
@@ -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.
@@ -24,7 +24,7 @@ import org.junit.Test;
 import org.springframework.jms.core.JmsTemplate;
 
 import static org.junit.Assert.*;
-import static org.mockito.BDDMockito.*;
+import static org.mockito.Mockito.*;
 
 /**
  * @author Mark Pollack
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 1c4f2f5a3ed..b122fae38be 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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.
@@ -20,24 +20,19 @@ import javax.jms.Destination;
 import javax.jms.JMSException;
 import javax.jms.Session;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.jms.support.destination.DestinationResolver;
 
-import static org.junit.Assert.assertSame;
-import static org.mockito.BDDMockito.given;
-import static org.mockito.Mockito.mock;
+import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
+import static org.junit.Assert.*;
+import static org.mockito.BDDMockito.*;
 
 /**
  * @author Stephane Nicoll
  */
 public class JmsResponseTests {
 
-	@Rule
-	public final ExpectedException thrown = ExpectedException.none();
-
 	@Test
 	public void destinationDoesNotUseDestinationResolver() throws JMSException {
 		Destination destination = mock(Destination.class);
@@ -59,26 +54,26 @@ public class JmsResponseTests {
 
 	@Test
 	public void createWithNulResponse() {
-		thrown.expect(IllegalArgumentException.class);
-		JmsResponse.forQueue(null, "myQueue");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				JmsResponse.forQueue(null, "myQueue"));
 	}
 
 	@Test
 	public void createWithNullQueueName() {
-		thrown.expect(IllegalArgumentException.class);
-		JmsResponse.forQueue("foo", null);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				JmsResponse.forQueue("foo", null));
 	}
 
 	@Test
 	public void createWithNullTopicName() {
-		thrown.expect(IllegalArgumentException.class);
-		JmsResponse.forTopic("foo", null);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				JmsResponse.forTopic("foo", null));
 	}
 
 	@Test
 	public void createWithNulDestination() {
-		thrown.expect(IllegalArgumentException.class);
-		JmsResponse.forDestination("foo", null);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				JmsResponse.forDestination("foo", null));
 	}
 
 }
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 f5cec599379..81312385db2 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
@@ -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.
@@ -38,6 +38,7 @@ import org.springframework.jms.support.converter.MessageConversionException;
 import org.springframework.jms.support.converter.SimpleMessageConverter;
 
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.BDDMockito.*;
 
 /**
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 e5a54706223..cad904547b3 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
@@ -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.
@@ -30,9 +30,7 @@ import javax.jms.Topic;
 
 import com.fasterxml.jackson.annotation.JsonView;
 import org.junit.Before;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.beans.factory.support.StaticListableBeanFactory;
 import org.springframework.jms.StubTextMessage;
@@ -47,7 +45,9 @@ import org.springframework.messaging.handler.annotation.support.DefaultMessageHa
 import org.springframework.messaging.support.MessageBuilder;
 import org.springframework.util.ReflectionUtils;
 
+import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.BDDMockito.*;
 
 /**
@@ -55,9 +55,6 @@ import static org.mockito.BDDMockito.*;
  */
 public class MessagingMessageListenerAdapterTests {
 
-	@Rule
-	public final ExpectedException thrown = ExpectedException.none();
-
 	private static final Destination sharedReplyDestination = mock(Destination.class);
 
 	private final DefaultMessageHandlerMethodFactory factory = new DefaultMessageHandlerMethodFactory();
@@ -149,9 +146,10 @@ public class MessagingMessageListenerAdapterTests {
 		MessagingMessageListenerAdapter listener = getSimpleInstance("simple", Message.class);
 		Message message = listener.toMessagingMessage(jmsMessage);
 
-		this.thrown.expect(IllegalArgumentException.class);
-		this.thrown.expectMessage("Header failure");
-		message.getHeaders(); // Triggers headers resolution
+		// Triggers headers resolution
+		assertThatIllegalArgumentException().isThrownBy(
+				message::getHeaders)
+			.withMessageContaining("Header failure");
 	}
 
 	@Test
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 61e0465e4f8..c6a9b102a95 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
@@ -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,12 +16,11 @@
 
 package org.springframework.jms.listener.endpoint;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.jms.support.QosSettings;
 
+import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
 import static org.junit.Assert.*;
 
 /**
@@ -29,9 +28,6 @@ import static org.junit.Assert.*;
  */
 public class JmsMessageEndpointManagerTests {
 
-	@Rule
-	public final ExpectedException thrown = ExpectedException.none();
-
 	@Test
 	public void isPubSubDomainWithQueue() {
 		JmsMessageEndpointManager endpoint = new JmsMessageEndpointManager();
@@ -79,25 +75,25 @@ public class JmsMessageEndpointManagerTests {
 	@Test
 	public void isPubSubDomainWithNoConfig() {
 		JmsMessageEndpointManager endpoint = new JmsMessageEndpointManager();
-
-		this.thrown.expect(IllegalStateException.class); // far from ideal
-		endpoint.isPubSubDomain();
+		// far from ideal
+		assertThatIllegalStateException().isThrownBy(
+				endpoint::isPubSubDomain);
 	}
 
 	@Test
 	public void isReplyPubSubDomainWithNoConfig() {
 		JmsMessageEndpointManager endpoint = new JmsMessageEndpointManager();
-
-		this.thrown.expect(IllegalStateException.class); // far from ideal
-		endpoint.isReplyPubSubDomain();
+		// far from ideal
+		assertThatIllegalStateException().isThrownBy(
+				endpoint::isReplyPubSubDomain);
 	}
 
 	@Test
 	public void getReplyQosSettingsWithNoConfig() {
 		JmsMessageEndpointManager endpoint = new JmsMessageEndpointManager();
-
-		this.thrown.expect(IllegalStateException.class); // far from ideal
-		endpoint.getReplyQosSettings();
+		// far from ideal
+		assertThatIllegalStateException().isThrownBy(
+				endpoint::getReplyQosSettings);
 	}
 
 	@Test
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 c4d9adae41b..4742c169854 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
@@ -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.
@@ -32,9 +32,7 @@ import javax.jms.QueueSession;
 import javax.jms.Session;
 
 import org.junit.Before;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.jms.support.converter.MessageConversionException;
 import org.springframework.jms.support.converter.SimpleMessageConverter;
@@ -42,6 +40,7 @@ import org.springframework.remoting.RemoteTimeoutException;
 import org.springframework.tests.sample.beans.ITestBean;
 import org.springframework.tests.sample.beans.TestBean;
 
+import static org.assertj.core.api.Assertions.*;
 import static org.junit.Assert.*;
 import static org.mockito.BDDMockito.*;
 
@@ -51,9 +50,6 @@ import static org.mockito.BDDMockito.*;
  */
 public class JmsInvokerTests {
 
-	@Rule
-	public final ExpectedException thrown = ExpectedException.none();
-
 	private QueueConnectionFactory mockConnectionFactory;
 
 	private QueueConnection mockConnection;
@@ -101,10 +97,10 @@ public class JmsInvokerTests {
 		pfb.afterPropertiesSet();
 		ITestBean proxy = (ITestBean) pfb.getObject();
 
-		thrown.expect(RemoteTimeoutException.class);
-		thrown.expectMessage("1500 ms");
-		thrown.expectMessage("getAge");
-		proxy.getAge();
+		assertThatExceptionOfType(RemoteTimeoutException.class).isThrownBy(() ->
+				proxy.getAge())
+			.withMessageContaining("1500 ms")
+			.withMessageContaining("getAge");
 	}
 
 	private void doTestJmsInvokerProxyFactoryBeanAndServiceExporter(boolean dynamicQueue) throws Throwable {
@@ -146,21 +142,10 @@ public class JmsInvokerTests {
 		assertEquals(50, proxy.getAge());
 		proxy.setStringArray(new String[] {"str1", "str2"});
 		assertTrue(Arrays.equals(new String[] {"str1", "str2"}, proxy.getStringArray()));
-
-		try {
-			proxy.exceptional(new IllegalStateException());
-			fail("Should have thrown IllegalStateException");
-		}
-		catch (IllegalStateException ex) {
-			// expected
-		}
-		try {
-			proxy.exceptional(new IllegalAccessException());
-			fail("Should have thrown IllegalAccessException");
-		}
-		catch (IllegalAccessException ex) {
-			// expected
-		}
+		assertThatIllegalStateException().isThrownBy(() ->
+			proxy.exceptional(new IllegalStateException()));
+		assertThatExceptionOfType(IllegalAccessException.class).isThrownBy(() ->
+				proxy.exceptional(new IllegalAccessException()));
 	}
 
 
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 98e7ba08bde..73e2d7806aa 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
@@ -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.
@@ -36,6 +36,7 @@ import org.springframework.jms.support.converter.MessageConversionException;
 import org.springframework.jms.support.converter.SimpleMessageConverter;
 
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.BDDMockito.*;
 
 /**
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 97e732827af..8800ef69479 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
@@ -29,15 +29,15 @@ import javax.jms.TextMessage;
 
 import com.fasterxml.jackson.annotation.JsonView;
 import org.junit.Before;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
 
 import org.springframework.core.MethodParameter;
 
+import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.BDDMockito.*;
 
 /**
@@ -47,9 +47,6 @@ import static org.mockito.BDDMockito.*;
  */
 public class MappingJackson2MessageConverterTests {
 
-	@Rule
-	public final ExpectedException thrown = ExpectedException.none();
-
 	private MappingJackson2MessageConverter converter;
 
 	private Session sessionMock;
@@ -206,8 +203,8 @@ public class MappingJackson2MessageConverterTests {
 		Method method = this.getClass().getDeclaredMethod("invalid");
 		MethodParameter returnType = new MethodParameter(method, -1);
 
-		thrown.expect(IllegalArgumentException.class);
-		testToTextMessageWithReturnType(returnType);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				testToTextMessageWithReturnType(returnType));
 	}
 
 	private void testToTextMessageWithReturnType(MethodParameter returnType) throws JMSException, NoSuchMethodException {
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 d659ab7c393..49026f81058 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
@@ -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.
@@ -29,6 +29,7 @@ import org.springframework.oxm.Marshaller;
 import org.springframework.oxm.Unmarshaller;
 
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.BDDMockito.*;
 
 /**
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 cc115c0bd75..00fb6e2ad5c 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
@@ -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.
@@ -22,14 +22,13 @@ import javax.jms.ObjectMessage;
 import javax.jms.Session;
 import javax.jms.TextMessage;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.jms.StubTextMessage;
 import org.springframework.messaging.Message;
 import org.springframework.messaging.support.MessageBuilder;
 
+import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
 import static org.junit.Assert.*;
 import static org.mockito.BDDMockito.*;
 
@@ -40,14 +39,11 @@ public class MessagingMessageConverterTests {
 
 	private final MessagingMessageConverter converter = new MessagingMessageConverter();
 
-	@Rule
-	public final ExpectedException thrown = ExpectedException.none();
-
 
 	@Test
 	public void onlyHandlesMessage() throws JMSException {
-		this.thrown.expect(IllegalArgumentException.class);
-		this.converter.toMessage(new Object(), mock(Session.class));
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				this.converter.toMessage(new Object(), mock(Session.class)));
 	}
 
 	@Test
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 25d3fc92423..c26bd28aa9c 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
@@ -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.
@@ -21,7 +21,7 @@ import javax.jms.ConnectionFactory;
 import org.junit.Test;
 
 import static org.junit.Assert.*;
-import static org.mockito.BDDMockito.*;
+import static org.mockito.Mockito.*;
 
 /**
  * @author Rick Evans
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 1ec7e5ed66c..4b6af923d5d 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
@@ -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,9 +18,7 @@ package org.springframework.messaging.converter;
 
 import java.util.Locale;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.core.convert.ConversionException;
 import org.springframework.core.convert.ConversionService;
@@ -28,7 +26,7 @@ import org.springframework.core.convert.support.DefaultConversionService;
 import org.springframework.messaging.Message;
 import org.springframework.messaging.support.MessageBuilder;
 
-import static org.hamcrest.Matchers.*;
+import static org.assertj.core.api.Assertions.*;
 import static org.junit.Assert.*;
 
 /**
@@ -37,9 +35,6 @@ import static org.junit.Assert.*;
  */
 public class GenericMessageConverterTests {
 
-	@Rule
-	public final ExpectedException thrown = ExpectedException.none();
-
 	private final ConversionService conversionService = new DefaultConversionService();
 	private final GenericMessageConverter converter = new GenericMessageConverter(conversionService);
 
@@ -58,8 +53,8 @@ public class GenericMessageConverterTests {
 	@Test
 	public void fromMessageWithFailedConversion() {
 		Message content = MessageBuilder.withPayload("test not a number").build();
-		thrown.expect(MessageConversionException.class);
-		thrown.expectCause(isA(ConversionException.class));
-		converter.fromMessage(content, Integer.class);
+		assertThatExceptionOfType(MessageConversionException.class).isThrownBy(() ->
+				converter.fromMessage(content, Integer.class))
+			.withCauseInstanceOf(ConversionException.class);
 	}
 }
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 b26637d19c1..2f67e5a88e1 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
@@ -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,15 +16,8 @@
 
 package org.springframework.messaging.converter;
 
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.*;
-import static org.xmlunit.diff.ComparisonType.*;
-import static org.xmlunit.diff.DifferenceEvaluators.*;
-import static org.xmlunit.matchers.CompareMatcher.*;
-
 import java.io.IOException;
 import java.nio.charset.StandardCharsets;
-
 import javax.xml.bind.annotation.XmlRootElement;
 
 import org.junit.Before;
@@ -35,6 +28,12 @@ import org.springframework.messaging.Message;
 import org.springframework.messaging.support.MessageBuilder;
 import org.springframework.oxm.jaxb.Jaxb2Marshaller;
 
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.*;
+import static org.xmlunit.diff.ComparisonType.*;
+import static org.xmlunit.diff.DifferenceEvaluators.*;
+import static org.xmlunit.matchers.CompareMatcher.*;
+
 /**
  * @author Arjen Poutsma
  */
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 63feb6ad06f..684d24c114d 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
@@ -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.
@@ -23,6 +23,7 @@ import java.util.concurrent.atomic.AtomicReference;
 
 import org.junit.Before;
 import org.junit.Test;
+
 import org.springframework.messaging.Message;
 import org.springframework.messaging.MessageChannel;
 import org.springframework.messaging.MessageDeliveryException;
@@ -38,6 +39,7 @@ import org.springframework.messaging.support.MessageHeaderAccessor;
 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
 
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.Mockito.*;
 
 /**
@@ -130,9 +132,7 @@ public class GenericMessagingTemplateTests {
 		SubscribableChannel channel = mock(SubscribableChannel.class);
 		MessageHandler handler = createLateReplier(latch, failure);
 		doAnswer(invocation -> {
-			this.executor.execute(() -> {
-				handler.handleMessage(invocation.getArgument(0));
-			});
+			this.executor.execute(() -> handler.handleMessage(invocation.getArgument(0)));
 			return true;
 		}).when(channel).send(any(Message.class), anyLong());
 
@@ -158,9 +158,7 @@ public class GenericMessagingTemplateTests {
 		SubscribableChannel channel = mock(SubscribableChannel.class);
 		MessageHandler handler = createLateReplier(latch, failure);
 		doAnswer(invocation -> {
-			this.executor.execute(() -> {
-				handler.handleMessage(invocation.getArgument(0));
-			});
+			this.executor.execute(() -> handler.handleMessage(invocation.getArgument(0)));
 			return true;
 		}).when(channel).send(any(Message.class), anyLong());
 
@@ -192,9 +190,7 @@ public class GenericMessagingTemplateTests {
 		SubscribableChannel channel = mock(SubscribableChannel.class);
 		MessageHandler handler = createLateReplier(latch, failure);
 		doAnswer(invocation -> {
-			this.executor.execute(() -> {
-				handler.handleMessage(invocation.getArgument(0));
-			});
+			this.executor.execute(() -> handler.handleMessage(invocation.getArgument(0)));
 			return true;
 		}).when(channel).send(any(Message.class), anyLong());
 
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 ae2363a7b6b..b8c4a5f0c7b 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
@@ -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.
@@ -19,9 +19,7 @@ package org.springframework.messaging.core;
 import java.io.Writer;
 
 import org.junit.Before;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.core.convert.ConversionFailedException;
 import org.springframework.messaging.Message;
@@ -29,7 +27,7 @@ import org.springframework.messaging.converter.GenericMessageConverter;
 import org.springframework.messaging.converter.MessageConversionException;
 import org.springframework.messaging.support.GenericMessage;
 
-import static org.hamcrest.CoreMatchers.*;
+import static org.assertj.core.api.Assertions.*;
 import static org.junit.Assert.*;
 
 /**
@@ -40,9 +38,6 @@ import static org.junit.Assert.*;
  */
 public class MessageReceivingTemplateTests {
 
-	@Rule
-	public final ExpectedException thrown = ExpectedException.none();
-
 	private TestMessagingTemplate template;
 
 
@@ -104,9 +99,9 @@ public class MessageReceivingTemplateTests {
 		this.template.setReceiveMessage(expected);
 		this.template.setMessageConverter(new GenericMessageConverter());
 
-		thrown.expect(MessageConversionException.class);
-		thrown.expectCause(isA(ConversionFailedException.class));
-		this.template.receiveAndConvert("somewhere", Integer.class);
+		assertThatExceptionOfType(MessageConversionException.class).isThrownBy(() ->
+				this.template.receiveAndConvert("somewhere", Integer.class))
+			.withCauseInstanceOf(ConversionFailedException.class);
 	}
 
 	@Test
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 e18e17f7d80..34ea9bf6258 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
@@ -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.
@@ -26,7 +26,6 @@ import java.util.Map;
 
 import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 import org.junit.rules.TestName;
 
 import org.springframework.beans.factory.support.StaticListableBeanFactory;
@@ -47,6 +46,7 @@ import org.springframework.validation.Errors;
 import org.springframework.validation.Validator;
 import org.springframework.validation.annotation.Validated;
 
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
 import static org.junit.Assert.*;
 
 /**
@@ -59,9 +59,6 @@ public class DefaultMessageHandlerMethodFactoryTests {
 	@Rule
 	public final TestName name = new TestName();
 
-	@Rule
-	public final ExpectedException thrown = ExpectedException.none();
-
 
 	@Test
 	public void customConversion() throws Exception {
@@ -95,8 +92,8 @@ public class DefaultMessageHandlerMethodFactoryTests {
 		InvocableHandlerMethod invocableHandlerMethod =
 				createInvocableHandlerMethod(instance, "simpleString", String.class);
 
-		thrown.expect(MessageConversionException.class);
-		invocableHandlerMethod.invoke(MessageBuilder.withPayload(123).build());
+		assertThatExceptionOfType(MessageConversionException.class).isThrownBy(() ->
+				invocableHandlerMethod.invoke(MessageBuilder.withPayload(123).build()));
 	}
 
 	@Test
@@ -109,8 +106,8 @@ public class DefaultMessageHandlerMethodFactoryTests {
 		InvocableHandlerMethod invocableHandlerMethod =
 				createInvocableHandlerMethod(instance, "simpleString", String.class);
 
-		thrown.expect(MessageConversionException.class);
-		invocableHandlerMethod.invoke(MessageBuilder.withPayload(123).build());
+		assertThatExceptionOfType(MessageConversionException.class).isThrownBy(() ->
+				invocableHandlerMethod.invoke(MessageBuilder.withPayload(123).build()));
 	}
 
 	@Test
@@ -148,9 +145,8 @@ public class DefaultMessageHandlerMethodFactoryTests {
 		InvocableHandlerMethod invocableHandlerMethod2 =
 				createInvocableHandlerMethod(instance, "simpleString", String.class);
 
-		thrown.expect(MethodArgumentResolutionException.class);
-		thrown.expectMessage("No suitable resolver");
-		invocableHandlerMethod2.invoke(message);
+		assertThatExceptionOfType(MethodArgumentResolutionException.class).isThrownBy(() ->
+				invocableHandlerMethod2.invoke(message)).withMessageContaining("No suitable resolver");
 	}
 
 	@Test
@@ -184,8 +180,8 @@ public class DefaultMessageHandlerMethodFactoryTests {
 
 		InvocableHandlerMethod invocableHandlerMethod =
 				createInvocableHandlerMethod(instance, "payloadValidation", String.class);
-		thrown.expect(MethodArgumentNotValidException.class);
-		invocableHandlerMethod.invoke(MessageBuilder.withPayload("failure").build());
+		assertThatExceptionOfType(MethodArgumentNotValidException.class).isThrownBy(() ->
+				invocableHandlerMethod.invoke(MessageBuilder.withPayload("failure").build()));
 	}
 
 
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 7910e59625d..63117ed5889 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
@@ -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.
@@ -20,9 +20,7 @@ import java.lang.reflect.Method;
 import java.util.Locale;
 
 import org.junit.Before;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.core.MethodParameter;
 import org.springframework.messaging.Message;
@@ -33,6 +31,7 @@ import org.springframework.messaging.support.ErrorMessage;
 import org.springframework.messaging.support.GenericMessage;
 import org.springframework.messaging.support.MessageBuilder;
 
+import static org.assertj.core.api.Assertions.*;
 import static org.junit.Assert.*;
 import static org.mockito.Mockito.*;
 
@@ -44,9 +43,6 @@ import static org.mockito.Mockito.*;
  */
 public class MessageMethodArgumentResolverTests {
 
-	@Rule
-	public final ExpectedException thrown = ExpectedException.none();
-
 	private MessageConverter converter;
 
 	private MessageMethodArgumentResolver resolver;
@@ -112,10 +108,10 @@ public class MessageMethodArgumentResolverTests {
 		MethodParameter parameter = new MethodParameter(this.method, 1);
 
 		assertTrue(this.resolver.supportsParameter(parameter));
-		thrown.expect(MessageConversionException.class);
-		thrown.expectMessage(Integer.class.getName());
-		thrown.expectMessage(String.class.getName());
-		this.resolver.resolveArgument(parameter, message);
+		assertThatExceptionOfType(MessageConversionException.class).isThrownBy(() ->
+				this.resolver.resolveArgument(parameter, message))
+			.withMessageContaining(Integer.class.getName())
+			.withMessageContaining(String.class.getName());
 	}
 
 	@Test
@@ -124,11 +120,11 @@ public class MessageMethodArgumentResolverTests {
 		MethodParameter parameter = new MethodParameter(this.method, 1);
 
 		assertTrue(this.resolver.supportsParameter(parameter));
-		thrown.expect(MessageConversionException.class);
-		thrown.expectMessage("payload is empty");
-		thrown.expectMessage(Integer.class.getName());
-		thrown.expectMessage(String.class.getName());
-		this.resolver.resolveArgument(parameter, message);
+		assertThatExceptionOfType(MessageConversionException.class).isThrownBy(() ->
+				this.resolver.resolveArgument(parameter, message))
+			.withMessageContaining("payload is empty")
+			.withMessageContaining(Integer.class.getName())
+			.withMessageContaining(String.class.getName());
 	}
 
 	@Test
@@ -146,10 +142,10 @@ public class MessageMethodArgumentResolverTests {
 		MethodParameter parameter = new MethodParameter(this.method, 3);
 
 		assertTrue(this.resolver.supportsParameter(parameter));
-		thrown.expect(MessageConversionException.class);
-		thrown.expectMessage(Number.class.getName());
-		thrown.expectMessage(Locale.class.getName());
-		this.resolver.resolveArgument(parameter, message);
+		assertThatExceptionOfType(MessageConversionException.class).isThrownBy(() ->
+				this.resolver.resolveArgument(parameter, message))
+			.withMessageContaining(Number.class.getName())
+			.withMessageContaining(Locale.class.getName());
 	}
 
 	@Test
@@ -177,10 +173,10 @@ public class MessageMethodArgumentResolverTests {
 		MethodParameter parameter = new MethodParameter(this.method, 4);
 
 		assertTrue(this.resolver.supportsParameter(parameter));
-		thrown.expect(MethodArgumentTypeMismatchException.class);
-		thrown.expectMessage(ErrorMessage.class.getName());
-		thrown.expectMessage(GenericMessage.class.getName());
-		assertSame(message, this.resolver.resolveArgument(parameter, message));
+		assertThatExceptionOfType(MethodArgumentTypeMismatchException.class).isThrownBy(() ->
+				this.resolver.resolveArgument(parameter, message))
+			.withMessageContaining(ErrorMessage.class.getName())
+			.withMessageContaining(GenericMessage.class.getName());
 	}
 
 	@Test
@@ -202,10 +198,10 @@ public class MessageMethodArgumentResolverTests {
 		MethodParameter parameter = new MethodParameter(this.method, 1);
 
 		assertTrue(this.resolver.supportsParameter(parameter));
-		thrown.expect(MessageConversionException.class);
-		thrown.expectMessage(Integer.class.getName());
-		thrown.expectMessage(String.class.getName());
-		this.resolver.resolveArgument(parameter, message);
+		assertThatExceptionOfType(MessageConversionException.class).isThrownBy(() ->
+				this.resolver.resolveArgument(parameter, message))
+			.withMessageContaining(Integer.class.getName())
+			.withMessageContaining(String.class.getName());
 	}
 
 	@Test
@@ -216,11 +212,11 @@ public class MessageMethodArgumentResolverTests {
 		MethodParameter parameter = new MethodParameter(this.method, 1);
 
 		assertTrue(this.resolver.supportsParameter(parameter));
-		thrown.expect(MessageConversionException.class);
-		thrown.expectMessage("payload is empty");
-		thrown.expectMessage(Integer.class.getName());
-		thrown.expectMessage(String.class.getName());
-		this.resolver.resolveArgument(parameter, message);
+		assertThatExceptionOfType(MessageConversionException.class).isThrownBy(() ->
+				this.resolver.resolveArgument(parameter, message))
+			.withMessageContaining("payload is empty")
+			.withMessageContaining(Integer.class.getName())
+			.withMessageContaining(String.class.getName());
 	}
 
 	@Test // SPR-16486
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 c3ffcb257bd..25c9b1ad720 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
@@ -24,9 +24,7 @@ import java.lang.reflect.Method;
 import java.util.Locale;
 
 import org.junit.Before;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.core.LocalVariableTableParameterNameDiscoverer;
 import org.springframework.core.MethodParameter;
@@ -40,6 +38,8 @@ import org.springframework.validation.Errors;
 import org.springframework.validation.Validator;
 import org.springframework.validation.annotation.Validated;
 
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
+import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
 import static org.junit.Assert.*;
 
 /**
@@ -68,10 +68,6 @@ public class PayloadMethodArgumentResolverTests {
 	private MethodParameter paramValidated;
 
 
-	@Rule
-	public final ExpectedException thrown = ExpectedException.none();
-
-
 	@Before
 	public void setup() throws Exception {
 		this.resolver = new PayloadMethodArgumentResolver(new StringMessageConverter(), testValidator());
@@ -113,17 +109,17 @@ public class PayloadMethodArgumentResolverTests {
 	@Test
 	public void resolveRequiredEmpty() throws Exception {
 		Message message = MessageBuilder.withPayload("").build();
-
-		thrown.expect(MethodArgumentNotValidException.class);  // required but empty
-		this.resolver.resolveArgument(paramAnnotated, message);
+		 // required but empty
+		assertThatExceptionOfType(MethodArgumentNotValidException.class).isThrownBy(() ->
+		this.resolver.resolveArgument(paramAnnotated, message));
 	}
 
 	@Test
 	public void resolveRequiredEmptyNonAnnotatedParameter() throws Exception {
 		Message message = MessageBuilder.withPayload("").build();
-
-		thrown.expect(MethodArgumentNotValidException.class);  // required but empty
-		this.resolver.resolveArgument(this.paramNotAnnotated, message);
+		// required but empty
+		assertThatExceptionOfType(MethodArgumentNotValidException.class).isThrownBy(() ->
+				this.resolver.resolveArgument(this.paramNotAnnotated, message));
 	}
 
 	@Test
@@ -142,17 +138,17 @@ public class PayloadMethodArgumentResolverTests {
 	public void resolveNonConvertibleParam() throws Exception {
 		Message notEmptyMessage = MessageBuilder.withPayload(123).build();
 
-		thrown.expect(MessageConversionException.class);
-		thrown.expectMessage("Cannot convert");
-		this.resolver.resolveArgument(this.paramAnnotatedRequired, notEmptyMessage);
+		assertThatExceptionOfType(MessageConversionException.class).isThrownBy(() ->
+				this.resolver.resolveArgument(this.paramAnnotatedRequired, notEmptyMessage))
+			.withMessageContaining("Cannot convert");
 	}
 
 	@Test
 	public void resolveSpelExpressionNotSupported() throws Exception {
 		Message message = MessageBuilder.withPayload("ABC".getBytes()).build();
 
-		thrown.expect(IllegalStateException.class);
-		this.resolver.resolveArgument(paramWithSpelExpression, message);
+		assertThatIllegalStateException().isThrownBy(() ->
+				this.resolver.resolveArgument(paramWithSpelExpression, message));
 	}
 
 	@Test
@@ -166,16 +162,16 @@ public class PayloadMethodArgumentResolverTests {
 		// See testValidator()
 		Message message = MessageBuilder.withPayload("invalidValue".getBytes()).build();
 
-		thrown.expect(MethodArgumentNotValidException.class);
-		this.resolver.resolveArgument(this.paramValidated, message);
+		assertThatExceptionOfType(MethodArgumentNotValidException.class).isThrownBy(() ->
+				this.resolver.resolveArgument(this.paramValidated, message));
 	}
 
 	@Test
 	public void resolveFailValidationNoConversionNecessary() throws Exception {
 		Message message = MessageBuilder.withPayload("invalidValue").build();
 
-		thrown.expect(MethodArgumentNotValidException.class);
-		this.resolver.resolveArgument(this.paramValidated, message);
+		assertThatExceptionOfType(MethodArgumentNotValidException.class).isThrownBy(() ->
+				this.resolver.resolveArgument(this.paramValidated, message));
 	}
 
 	@Test
@@ -184,8 +180,8 @@ public class PayloadMethodArgumentResolverTests {
 		assertEquals("ABC", this.resolver.resolveArgument(this.paramNotAnnotated, notEmptyMessage));
 
 		Message emptyStringMessage = MessageBuilder.withPayload("").build();
-		thrown.expect(MethodArgumentNotValidException.class);
-		this.resolver.resolveArgument(this.paramValidated, emptyStringMessage);
+		assertThatExceptionOfType(MethodArgumentNotValidException.class).isThrownBy(() ->
+				this.resolver.resolveArgument(this.paramValidated, emptyStringMessage));
 	}
 
 	@Test
@@ -193,9 +189,9 @@ public class PayloadMethodArgumentResolverTests {
 		// See testValidator()
 		Message message = MessageBuilder.withPayload("invalidValue".getBytes()).build();
 
-		thrown.expect(MethodArgumentNotValidException.class);
-		thrown.expectMessage("invalid value");
-		assertEquals("invalidValue", this.resolver.resolveArgument(this.paramValidatedNotAnnotated, message));
+		assertThatExceptionOfType(MethodArgumentNotValidException.class).isThrownBy(() ->
+				assertEquals("invalidValue", this.resolver.resolveArgument(this.paramValidatedNotAnnotated, message)))
+			.withMessageContaining("invalid value");
 	}
 
 
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 5031dc9a7c8..04fea70411f 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
@@ -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.
@@ -21,14 +21,13 @@ import java.util.concurrent.ConcurrentHashMap;
 
 import org.junit.After;
 import org.junit.Before;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.messaging.Message;
 import org.springframework.messaging.support.GenericMessage;
 import org.springframework.messaging.support.MessageBuilder;
 
+import static org.assertj.core.api.Assertions.*;
 import static org.hamcrest.MatcherAssert.*;
 import static org.hamcrest.Matchers.*;
 
@@ -43,9 +42,6 @@ public class SimpAttributesContextHolderTests {
 
 	private SimpAttributes simpAttributes;
 
-	@Rule
-	public ExpectedException thrown = ExpectedException.none();
-
 
 	@Before
 	public void setUp() {
@@ -108,19 +104,19 @@ public class SimpAttributesContextHolderTests {
 
 	@Test
 	public void setAttributesFromMessageWithMissingSessionId() {
-		this.thrown.expect(IllegalStateException.class);
-		this.thrown.expectMessage(startsWith("No session id in"));
-		SimpAttributesContextHolder.setAttributesFromMessage(new GenericMessage(""));
+		assertThatIllegalStateException().isThrownBy(() ->
+				SimpAttributesContextHolder.setAttributesFromMessage(new GenericMessage("")))
+			.withMessageStartingWith("No session id in");
 	}
 
 	@Test
 	public void setAttributesFromMessageWithMissingSessionAttributes() {
-		this.thrown.expect(IllegalStateException.class);
-		this.thrown.expectMessage(startsWith("No session attributes in"));
 		SimpMessageHeaderAccessor headerAccessor = SimpMessageHeaderAccessor.create();
 		headerAccessor.setSessionId("session1");
 		Message message = MessageBuilder.createMessage("", headerAccessor.getMessageHeaders());
-		SimpAttributesContextHolder.setAttributesFromMessage(message);
+		assertThatIllegalStateException().isThrownBy(() ->
+				SimpAttributesContextHolder.setAttributesFromMessage(message))
+			.withMessageStartingWith("No session attributes in");
 	}
 
 	@Test
@@ -131,9 +127,9 @@ public class SimpAttributesContextHolderTests {
 
 	@Test
 	public void currentAttributesNone() {
-		this.thrown.expect(IllegalStateException.class);
-		this.thrown.expectMessage(startsWith("No thread-bound SimpAttributes found"));
-		SimpAttributesContextHolder.currentAttributes();
+		assertThatIllegalStateException().isThrownBy(() ->
+				SimpAttributesContextHolder.currentAttributes())
+			.withMessageStartingWith("No thread-bound SimpAttributes found");
 	}
 
 }
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 126494116d5..1c88e5240e3 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
@@ -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.
@@ -20,12 +20,11 @@ import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
 import org.junit.Before;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 import org.mockito.Mockito;
 
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.assertj.core.api.Assertions.*;
+import static org.hamcrest.MatcherAssert.*;
 import static org.hamcrest.Matchers.*;
 import static org.mockito.Mockito.*;
 
@@ -42,9 +41,6 @@ public class SimpAttributesTests {
 
 	private Map map;
 
-	@Rule
-	public ExpectedException thrown = ExpectedException.none();
-
 
 	@Before
 	public void setup() {
@@ -82,9 +78,9 @@ public class SimpAttributesTests {
 	@Test
 	public void registerDestructionCallbackAfterSessionCompleted() {
 		this.simpAttributes.sessionCompleted();
-		this.thrown.expect(IllegalStateException.class);
-		this.thrown.expectMessage(containsString("already completed"));
-		this.simpAttributes.registerDestructionCallback("name1", Mockito.mock(Runnable.class));
+		assertThatIllegalStateException().isThrownBy(() ->
+				this.simpAttributes.registerDestructionCallback("name1", Mockito.mock(Runnable.class)))
+			.withMessageContaining("already completed");
 	}
 
 	@Test
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 4ec9bd53dd6..74df3bf2278 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
@@ -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.
@@ -25,7 +25,7 @@ import org.mockito.Mockito;
 
 import org.springframework.beans.factory.ObjectFactory;
 
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.MatcherAssert.*;
 import static org.hamcrest.Matchers.*;
 import static org.mockito.BDDMockito.*;
 
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 a9c506400fb..fdc55e06bea 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
@@ -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.
@@ -55,6 +55,7 @@ import org.springframework.messaging.support.MessageHeaderAccessor;
 import org.springframework.util.MimeType;
 
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.BDDMockito.*;
 
 /**
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 96d417d4ac8..ec8b3f806ac 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
@@ -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.
@@ -70,7 +70,7 @@ import org.springframework.validation.annotation.Validated;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.*;
 import static org.junit.Assert.*;
-import static org.mockito.BDDMockito.any;
+import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.BDDMockito.*;
 
 /**
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 60773537a4f..030b27d65e6 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
@@ -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.
@@ -46,6 +46,7 @@ import org.springframework.messaging.support.MessageHeaderAccessor;
 import org.springframework.util.MimeType;
 
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.BDDMockito.*;
 
 /**
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 58c7d98cf9b..c454fc2ebbb 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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.
@@ -30,8 +30,7 @@ import org.springframework.messaging.simp.SimpMessageType;
 import org.springframework.messaging.support.MessageBuilder;
 import org.springframework.util.MultiValueMap;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.*;
 
 /**
  * Test fixture for
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 f0edaab9249..93fec53ddb2 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
@@ -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.
@@ -39,6 +39,7 @@ import org.springframework.messaging.support.MessageBuilder;
 import org.springframework.scheduling.TaskScheduler;
 
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.Mockito.*;
 
 /**
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 dd7e0362101..218395a2ccf 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
@@ -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.
@@ -25,9 +25,7 @@ import org.junit.Test;
 
 import org.springframework.messaging.Message;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.*;
 
 /**
  * Unit tests for {@link BufferingStompDecoder}.
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 1e97424a676..f45933a025f 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
@@ -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.
@@ -22,11 +22,8 @@ import java.util.Map;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.atomic.AtomicReference;
 
-import org.hamcrest.Matchers;
 import org.junit.Before;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Captor;
 import org.mockito.Mock;
@@ -46,10 +43,12 @@ import org.springframework.util.MimeType;
 import org.springframework.util.MimeTypeUtils;
 import org.springframework.util.concurrent.SettableListenableFuture;
 
+import static org.assertj.core.api.Assertions.*;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.*;
 import static org.junit.Assert.*;
-import static org.mockito.Mockito.any;
+import static org.mockito.ArgumentMatchers.*;
+import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.*;
 
 /**
@@ -72,9 +71,6 @@ public class DefaultStompSessionTests {
 	@Captor
 	private ArgumentCaptor> messageCaptor;
 
-	@Rule
-	public ExpectedException expected = ExpectedException.none();
-
 
 	@Before
 	public void setUp() {
@@ -399,9 +395,8 @@ public class DefaultStompSessionTests {
 		stompHeaders.setContentType(MimeTypeUtils.APPLICATION_JSON);
 		String payload = "{'foo':'bar'}";
 
-		this.expected.expect(MessageConversionException.class);
-		this.session.send(stompHeaders, payload);
-		verifyNoMoreInteractions(this.connection);
+		assertThatExceptionOfType(MessageConversionException.class).isThrownBy(() ->
+				this.session.send(stompHeaders, payload));
 	}
 
 	@Test
@@ -414,12 +409,9 @@ public class DefaultStompSessionTests {
 		future.setException(exception);
 
 		when(this.connection.send(any())).thenReturn(future);
-		this.expected.expect(MessageDeliveryException.class);
-		this.expected.expectCause(Matchers.sameInstance(exception));
-
-		this.session.send("/topic/foo", "sample payload".getBytes(StandardCharsets.UTF_8));
-
-		verifyNoMoreInteractions(this.connection);
+		assertThatExceptionOfType(MessageDeliveryException.class).isThrownBy(() ->
+				this.session.send("/topic/foo", "sample payload".getBytes(StandardCharsets.UTF_8)))
+			.withCause(exception);
 	}
 
 	@Test
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 5109f9d4784..9481a5a071c 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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.
@@ -15,9 +15,6 @@
  */
 package org.springframework.messaging.simp.stomp;
 
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
-
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
@@ -44,6 +41,9 @@ import org.springframework.messaging.tcp.TcpOperations;
 import org.springframework.util.concurrent.ListenableFuture;
 import org.springframework.util.concurrent.ListenableFutureTask;
 
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
 /**
  * Unit tests for StompBrokerRelayMessageHandler.
  *
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 1562fcfb695..b6bcbcbbd3f 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
@@ -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.
@@ -26,8 +26,7 @@ import org.springframework.messaging.Message;
 import org.springframework.messaging.simp.SimpMessageType;
 import org.springframework.util.InvalidMimeTypeException;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.Assert.*;
 
 /**
  * Test fixture for {@link StompDecoder}.
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 000ce8daa61..a53962f2338 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
@@ -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.
@@ -21,8 +21,7 @@ import org.junit.Test;
 import org.springframework.messaging.Message;
 import org.springframework.messaging.support.MessageBuilder;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
 
 /**
  * Test fixture for {@link StompEncoder}.
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 31ffb835c30..f1b20b336fd 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
@@ -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,11 +16,6 @@
 
 package org.springframework.messaging.simp.user;
 
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.containsInAnyOrder;
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
-
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashSet;
@@ -35,6 +30,11 @@ import org.springframework.messaging.Message;
 import org.springframework.messaging.converter.MappingJackson2MessageConverter;
 import org.springframework.messaging.converter.MessageConverter;
 
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.*;
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
 /**
  * Unit tests for {@link MultiServerUserRegistry}.
  *
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 33929c3a716..f379296d30b 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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,9 +16,6 @@
 
 package org.springframework.messaging.simp.user;
 
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
-
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashSet;
@@ -41,6 +38,10 @@ import org.springframework.messaging.simp.SimpMessagingTemplate;
 import org.springframework.messaging.simp.broker.BrokerAvailabilityEvent;
 import org.springframework.scheduling.TaskScheduler;
 
+import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
+import static org.mockito.Mockito.*;
+
 /**
  * User tests for {@link UserRegistryMessageHandler}.
  * @author Rossen Stoyanchev
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 5ef79012b13..f1199f1febf 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
@@ -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.
@@ -19,7 +19,7 @@ package org.springframework.messaging.support;
 import org.junit.Test;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.MatcherAssert.*;
 
 /**
  * @author Gary Russell
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 23a08428dd7..577f1e4a853 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
@@ -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.
@@ -19,9 +19,7 @@ package org.springframework.messaging.support;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import org.junit.Before;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Captor;
 import org.mockito.Mock;
@@ -33,6 +31,7 @@ import org.springframework.messaging.MessageChannel;
 import org.springframework.messaging.MessageDeliveryException;
 import org.springframework.messaging.MessageHandler;
 
+import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.*;
 import static org.junit.Assert.*;
@@ -45,9 +44,6 @@ import static org.mockito.BDDMockito.*;
  */
 public class ExecutorSubscribableChannelTests {
 
-	@Rule
-	public ExpectedException thrown = ExpectedException.none();
-
 	private ExecutorSubscribableChannel channel = new ExecutorSubscribableChannel();
 
 	@Mock
@@ -69,9 +65,9 @@ public class ExecutorSubscribableChannelTests {
 
 	@Test
 	public void messageMustNotBeNull() {
-		thrown.expect(IllegalArgumentException.class);
-		thrown.expectMessage("Message must not be null");
-		this.channel.send(null);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				this.channel.send(null))
+			.withMessageContaining("Message must not be null");
 	}
 
 	@Test
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 1a2665b9f82..b37198db58c 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
@@ -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.
@@ -21,14 +21,13 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.UUID;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.messaging.Message;
 import org.springframework.messaging.MessageHeaders;
 import org.springframework.util.IdGenerator;
 
+import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
 import static org.junit.Assert.*;
 
 /**
@@ -37,10 +36,6 @@ import static org.junit.Assert.*;
  */
 public class MessageBuilderTests {
 
-	@Rule
-	public final ExpectedException thrown = ExpectedException.none();
-
-
 	@Test
 	public void testSimpleMessageCreation() {
 		Message message = MessageBuilder.withPayload("foo").build();
@@ -192,9 +187,9 @@ public class MessageBuilderTests {
 		MessageHeaders headers = accessor.getMessageHeaders();
 		Message message = MessageBuilder.createMessage("foo", headers);
 
-		this.thrown.expect(IllegalStateException.class);
-		this.thrown.expectMessage("Already immutable");
-		accessor.setHeader("foo", "bar");
+		assertThatIllegalStateException().isThrownBy(() ->
+				accessor.setHeader("foo", "bar"))
+			.withMessageContaining("Already immutable");
 
 		assertSame(accessor, MessageHeaderAccessor.getAccessor(message, MessageHeaderAccessor.class));
 	}
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 66ffa307e3c..429a3ecc627 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
@@ -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.
@@ -22,24 +22,17 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.UUID;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.messaging.Message;
 import org.springframework.messaging.MessageHeaders;
 import org.springframework.util.MimeTypeUtils;
 import org.springframework.util.SerializationTestUtils;
 
-import static org.hamcrest.CoreMatchers.startsWith;
+import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
+import static org.hamcrest.CoreMatchers.*;
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
 
 /**
  * Test fixture for {@link MessageHeaderAccessor}.
@@ -50,10 +43,6 @@ import static org.junit.Assert.assertTrue;
  */
 public class MessageHeaderAccessorTests {
 
-	@Rule
-	public final ExpectedException thrown = ExpectedException.none();
-
-
 	@Test
 	public void newEmptyHeaders() {
 		MessageHeaderAccessor accessor = new MessageHeaderAccessor();
@@ -217,13 +206,13 @@ public class MessageHeaderAccessorTests {
 		MessageHeaders headers = accessor.getMessageHeaders();
 		Message message = MessageBuilder.createMessage("payload", headers);
 
-		this.thrown.expect(IllegalStateException.class);
-		this.thrown.expectMessage("Already immutable");
-		accessor.setLeaveMutable(true);
+		assertThatIllegalStateException().isThrownBy(() ->
+				accessor.setLeaveMutable(true))
+			.withMessageContaining("Already immutable");
 
-		this.thrown.expect(IllegalStateException.class);
-		this.thrown.expectMessage("Already immutable");
-		accessor.setHeader("foo", "baz");
+		assertThatIllegalStateException().isThrownBy(() ->
+				accessor.setHeader("foo", "baz"))
+			.withMessageContaining("Already immutable");
 
 		assertEquals("bar", headers.get("foo"));
 		assertSame(accessor, MessageHeaderAccessor.getAccessor(message, MessageHeaderAccessor.class));
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 d0817aaba26..7f0347809fe 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
@@ -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.
@@ -22,14 +22,13 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.messaging.Message;
 import org.springframework.util.LinkedMultiValueMap;
 import org.springframework.util.MultiValueMap;
 
+import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
 import static org.junit.Assert.*;
 
 /**
@@ -39,10 +38,6 @@ import static org.junit.Assert.*;
  */
 public class NativeMessageHeaderAccessorTests {
 
-	@Rule
-	public final ExpectedException thrown = ExpectedException.none();
-
-
 	@Test
 	public void createFromNativeHeaderMap() {
 		MultiValueMap inputNativeHeaders = new LinkedMultiValueMap<>();
@@ -166,9 +161,9 @@ public class NativeMessageHeaderAccessorTests {
 		headerAccessor.setNativeHeader("foo", "bar");
 		headerAccessor.setImmutable();
 
-		this.thrown.expect(IllegalStateException.class);
-		this.thrown.expectMessage("Already immutable");
-		headerAccessor.setNativeHeader("foo", "baz");
+		assertThatIllegalStateException().isThrownBy(() ->
+				headerAccessor.setNativeHeader("foo", "baz"))
+			.withMessageContaining("Already immutable");
 	}
 
 	@Test
@@ -216,9 +211,9 @@ public class NativeMessageHeaderAccessorTests {
 		headerAccessor.addNativeHeader("foo", "bar");
 		headerAccessor.setImmutable();
 
-		this.thrown.expect(IllegalStateException.class);
-		this.thrown.expectMessage("Already immutable");
-		headerAccessor.addNativeHeader("foo", "baz");
+		assertThatIllegalStateException().isThrownBy(() ->
+				headerAccessor.addNativeHeader("foo", "baz"))
+			.withMessageContaining("Already immutable");
 	}
 
 	@Test
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 180f22b5f99..15accfa4679 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2013 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.
@@ -26,7 +26,7 @@ import org.junit.Before;
 import org.springframework.transaction.support.TransactionSynchronizationManager;
 
 import static org.junit.Assert.*;
-import static org.mockito.BDDMockito.*;
+import static org.mockito.Mockito.*;
 
 /**
  * Superclass for unit tests for EntityManagerFactory-creating beans.
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 8aa796b4f53..3c925994384 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2013 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.orm.jpa;
 
 import org.junit.Test;
 
-import static org.mockito.BDDMockito.*;
+import static org.mockito.Mockito.*;
 
 /**
  * @author Rod Johnson
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 140ba6cd331..c7b2a11f0d6 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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.
@@ -27,7 +27,7 @@ import org.junit.After;
 import org.junit.Test;
 
 import static org.junit.Assert.*;
-import static org.mockito.BDDMockito.*;
+import static org.mockito.Mockito.*;
 
 /**
  * @author Rod Johnson
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 d407924cf99..dadc7068b07 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
@@ -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.
@@ -31,10 +31,6 @@ import static org.hamcrest.CoreMatchers.*;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.Assert.*;
 import static org.mockito.BDDMockito.*;
-import static org.mockito.BDDMockito.verifyNoMoreInteractions;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.withSettings;
 
 /**
  * Unit tests for {@link SharedEntityManagerCreator}.
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 17b19f828ae..3b00f35a587 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
@@ -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.
@@ -23,7 +23,7 @@ import org.springframework.core.io.ClassPathResource;
 import org.springframework.core.io.DefaultResourceLoader;
 import org.springframework.orm.jpa.domain.Person;
 
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.MatcherAssert.*;
 import static org.hamcrest.Matchers.*;
 
 /**
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 ca7100a27e3..7614360cc6e 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
@@ -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.
@@ -49,6 +49,7 @@ import org.springframework.web.context.request.async.WebAsyncUtils;
 import org.springframework.web.context.support.StaticWebApplicationContext;
 
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.BDDMockito.*;
 
 /**
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 ae428902bb6..247474306ef 100644
--- a/spring-oxm/src/test/java/org/springframework/oxm/AbstractMarshallerTests.java
+++ b/spring-oxm/src/test/java/org/springframework/oxm/AbstractMarshallerTests.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.
@@ -16,15 +16,8 @@
 
 package org.springframework.oxm;
 
-import org.junit.Before;
-import org.junit.Test;
-import org.springframework.util.xml.StaxUtils;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Text;
-import org.xmlunit.matchers.CompareMatcher;
-
+import java.io.ByteArrayOutputStream;
+import java.io.StringWriter;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.stream.XMLEventWriter;
@@ -34,11 +27,19 @@ import javax.xml.transform.Result;
 import javax.xml.transform.dom.DOMResult;
 import javax.xml.transform.stax.StAXResult;
 import javax.xml.transform.stream.StreamResult;
-import java.io.ByteArrayOutputStream;
-import java.io.StringWriter;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Text;
+import org.xmlunit.matchers.CompareMatcher;
+
+import org.springframework.util.xml.StaxUtils;
 
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
 
 /**
  * @author Arjen Poutsma
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 6740032b255..5072a760bf6 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
@@ -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,26 +16,12 @@
 
 package org.springframework.oxm.jaxb;
 
-import org.junit.Test;
-import org.mockito.ArgumentCaptor;
-import org.mockito.InOrder;
-import org.springframework.core.io.ClassPathResource;
-import org.springframework.core.io.Resource;
-import org.springframework.oxm.AbstractMarshallerTests;
-import org.springframework.oxm.UncategorizedMappingException;
-import org.springframework.oxm.XmlMappingException;
-import org.springframework.oxm.jaxb.test.FlightType;
-import org.springframework.oxm.jaxb.test.Flights;
-import org.springframework.oxm.jaxb.test.ObjectFactory;
-import org.springframework.oxm.mime.MimeContainer;
-import org.springframework.util.FileCopyUtils;
-import org.springframework.util.ReflectionUtils;
-import org.xml.sax.Attributes;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.InputSource;
-import org.xml.sax.Locator;
-import org.xmlunit.diff.DifferenceEvaluator;
-
+import java.io.ByteArrayOutputStream;
+import java.io.StringWriter;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.util.Collections;
 import javax.activation.DataHandler;
 import javax.activation.FileDataSource;
 import javax.xml.bind.JAXBElement;
@@ -47,31 +33,35 @@ import javax.xml.transform.sax.SAXResult;
 import javax.xml.transform.sax.SAXSource;
 import javax.xml.transform.stream.StreamResult;
 import javax.xml.transform.stream.StreamSource;
-import java.io.ByteArrayOutputStream;
-import java.io.StringWriter;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Type;
-import java.util.Collections;
+
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.InOrder;
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.Locator;
+import org.xmlunit.diff.DifferenceEvaluator;
+
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.Resource;
+import org.springframework.oxm.AbstractMarshallerTests;
+import org.springframework.oxm.UncategorizedMappingException;
+import org.springframework.oxm.XmlMappingException;
+import org.springframework.oxm.jaxb.test.FlightType;
+import org.springframework.oxm.jaxb.test.Flights;
+import org.springframework.oxm.jaxb.test.ObjectFactory;
+import org.springframework.oxm.mime.MimeContainer;
+import org.springframework.util.FileCopyUtils;
+import org.springframework.util.ReflectionUtils;
 
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.mockito.BDDMockito.eq;
-import static org.mockito.BDDMockito.given;
-import static org.mockito.BDDMockito.inOrder;
-import static org.mockito.BDDMockito.isA;
-import static org.mockito.BDDMockito.mock;
-import static org.mockito.BDDMockito.reset;
-import static org.mockito.BDDMockito.times;
-import static org.mockito.BDDMockito.verify;
-import static org.xmlunit.diff.ComparisonType.XML_STANDALONE;
-import static org.xmlunit.diff.DifferenceEvaluators.Default;
-import static org.xmlunit.diff.DifferenceEvaluators.chain;
-import static org.xmlunit.diff.DifferenceEvaluators.downgradeDifferencesToEqual;
-import static org.xmlunit.matchers.CompareMatcher.isSimilarTo;
+import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
+import static org.mockito.BDDMockito.*;
+import static org.xmlunit.diff.ComparisonType.*;
+import static org.xmlunit.diff.DifferenceEvaluators.*;
+import static org.xmlunit.matchers.CompareMatcher.*;
 
 /**
  * @author Arjen Poutsma
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 513a4e24535..198eb1513da 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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.
@@ -19,7 +19,6 @@ package org.springframework.oxm.jaxb;
 import java.io.File;
 import java.io.IOException;
 import java.io.StringReader;
-
 import javax.activation.DataHandler;
 import javax.activation.FileDataSource;
 import javax.xml.bind.JAXBElement;
diff --git a/spring-oxm/src/test/java/org/springframework/oxm/jaxb/XmlRegObjectFactory.java b/spring-oxm/src/test/java/org/springframework/oxm/jaxb/XmlRegObjectFactory.java
index 13c24191836..458385eda86 100644
--- a/spring-oxm/src/test/java/org/springframework/oxm/jaxb/XmlRegObjectFactory.java
+++ b/spring-oxm/src/test/java/org/springframework/oxm/jaxb/XmlRegObjectFactory.java
@@ -1,6 +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.
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 33f79764e35..cf7732f5537 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
@@ -26,7 +26,7 @@ import org.junit.Test;
 import org.springframework.oxm.AbstractMarshallerTests;
 
 import static org.junit.Assert.*;
-import static org.xmlunit.matchers.CompareMatcher.isSimilarTo;
+import static org.xmlunit.matchers.CompareMatcher.*;
 
 /**
  * NOTE: These tests fail under Eclipse/IDEA because JiBX binding does not occur by
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 cfcfce7400b..fa18c87c966 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
@@ -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.
@@ -60,7 +60,8 @@ import org.springframework.util.xml.StaxUtils;
 
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.Assert.*;
-import static org.mockito.BDDMockito.*;
+import static org.mockito.ArgumentMatchers.*;
+import static org.mockito.Mockito.*;
 import static org.xmlunit.matchers.CompareMatcher.*;
 
 /**
diff --git a/spring-test/src/test/java/org/springframework/mock/http/server/reactive/MockServerHttpRequestTests.java b/spring-test/src/test/java/org/springframework/mock/http/server/reactive/MockServerHttpRequestTests.java
index ef339e02586..3e8907e518d 100644
--- a/spring-test/src/test/java/org/springframework/mock/http/server/reactive/MockServerHttpRequestTests.java
+++ b/spring-test/src/test/java/org/springframework/mock/http/server/reactive/MockServerHttpRequestTests.java
@@ -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.
@@ -22,7 +22,7 @@ import org.junit.Test;
 import org.springframework.http.HttpCookie;
 import org.springframework.http.HttpHeaders;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.*;
 
 /**
  * Unit tests for {@link MockServerHttpRequest}.
diff --git a/spring-test/src/test/java/org/springframework/mock/http/server/reactive/MockServerHttpResponseTests.java b/spring-test/src/test/java/org/springframework/mock/http/server/reactive/MockServerHttpResponseTests.java
index 84f3b0de027..f498fcbe9d8 100644
--- a/spring-test/src/test/java/org/springframework/mock/http/server/reactive/MockServerHttpResponseTests.java
+++ b/spring-test/src/test/java/org/springframework/mock/http/server/reactive/MockServerHttpResponseTests.java
@@ -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.
@@ -22,7 +22,7 @@ import org.junit.Test;
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.ResponseCookie;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.*;
 
 /**
  * Unit tests for {@link MockServerHttpResponse}.
diff --git a/spring-test/src/test/java/org/springframework/mock/web/MockCookieTests.java b/spring-test/src/test/java/org/springframework/mock/web/MockCookieTests.java
index 3180369f0a4..5f63e238602 100644
--- a/spring-test/src/test/java/org/springframework/mock/web/MockCookieTests.java
+++ b/spring-test/src/test/java/org/springframework/mock/web/MockCookieTests.java
@@ -16,10 +16,9 @@
 
 package org.springframework.mock.web;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
+import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
 import static org.junit.Assert.*;
 
 /**
@@ -31,9 +30,6 @@ import static org.junit.Assert.*;
  */
 public class MockCookieTests {
 
-	@Rule
-	public final ExpectedException exception = ExpectedException.none();
-
 
 	@Test
 	public void constructCookie() {
@@ -86,25 +82,25 @@ public class MockCookieTests {
 
 	@Test
 	public void parseNullHeader() {
-		exception.expect(IllegalArgumentException.class);
-		exception.expectMessage("Set-Cookie header must not be null");
-		MockCookie.parse(null);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				MockCookie.parse(null))
+			.withMessageContaining("Set-Cookie header must not be null");
 	}
 
 	@Test
 	public void parseInvalidHeader() {
-		exception.expect(IllegalArgumentException.class);
-		exception.expectMessage("Invalid Set-Cookie header 'BOOM'");
-		MockCookie.parse("BOOM");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				MockCookie.parse("BOOM"))
+			.withMessageContaining("Invalid Set-Cookie header 'BOOM'");
 	}
 
 	@Test
 	public void parseInvalidAttribute() {
 		String header = "SESSION=123; Path=";
 
-		exception.expect(IllegalArgumentException.class);
-		exception.expectMessage("No value in attribute 'Path' for Set-Cookie header '" + header + "'");
-		MockCookie.parse(header);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				MockCookie.parse(header))
+			.withMessageContaining("No value in attribute 'Path' for Set-Cookie header '" + header + "'");
 	}
 
 	@Test
diff --git a/spring-test/src/test/java/org/springframework/mock/web/MockFilterChainTests.java b/spring-test/src/test/java/org/springframework/mock/web/MockFilterChainTests.java
index 69e8c5e2853..d12a7f2ff55 100644
--- a/spring-test/src/test/java/org/springframework/mock/web/MockFilterChainTests.java
+++ b/spring-test/src/test/java/org/springframework/mock/web/MockFilterChainTests.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.
@@ -28,10 +28,10 @@ import javax.servlet.ServletResponse;
 import org.junit.Before;
 import org.junit.Test;
 
-import static org.hamcrest.Matchers.*;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.*;
 import static org.junit.Assert.*;
-import static org.mockito.BDDMockito.*;
+import static org.mockito.Mockito.*;
 
 /**
  * Test fixture for {@link MockFilterChain}.
diff --git a/spring-test/src/test/java/org/springframework/mock/web/MockHttpServletRequestTests.java b/spring-test/src/test/java/org/springframework/mock/web/MockHttpServletRequestTests.java
index c28b95b3786..3417462063a 100644
--- a/spring-test/src/test/java/org/springframework/mock/web/MockHttpServletRequestTests.java
+++ b/spring-test/src/test/java/org/springframework/mock/web/MockHttpServletRequestTests.java
@@ -29,14 +29,13 @@ import java.util.Locale;
 import java.util.Map;
 import javax.servlet.http.Cookie;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.http.HttpHeaders;
 import org.springframework.util.FileCopyUtils;
 import org.springframework.util.StreamUtils;
 
+import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
 import static org.junit.Assert.*;
 
 /**
@@ -56,9 +55,6 @@ public class MockHttpServletRequestTests {
 
 	private final MockHttpServletRequest request = new MockHttpServletRequest();
 
-	@Rule
-	public final ExpectedException exception = ExpectedException.none();
-
 
 	@Test
 	public void protocolAndScheme() {
@@ -104,9 +100,9 @@ public class MockHttpServletRequestTests {
 
 	@Test
 	public void getContentAsStringWithoutSettingCharacterEncoding() throws IOException {
-		exception.expect(IllegalStateException.class);
-		exception.expectMessage("Cannot get content as a String for a null character encoding");
-		request.getContentAsString();
+		assertThatIllegalStateException().isThrownBy(
+				request::getContentAsString)
+			.withMessageContaining("Cannot get content as a String for a null character encoding");
 	}
 
 	@Test
@@ -142,20 +138,18 @@ public class MockHttpServletRequestTests {
 
 	@Test  // SPR-16499
 	public void getReaderAfterGettingInputStream() throws IOException {
-		exception.expect(IllegalStateException.class);
-		exception.expectMessage(
-				"Cannot call getReader() after getInputStream() has already been called for the current request");
 		request.getInputStream();
-		request.getReader();
+		assertThatIllegalStateException().isThrownBy(
+				request::getReader)
+			.withMessageContaining("Cannot call getReader() after getInputStream() has already been called for the current request");
 	}
 
 	@Test  // SPR-16499
 	public void getInputStreamAfterGettingReader() throws IOException {
-		exception.expect(IllegalStateException.class);
-		exception.expectMessage(
-				"Cannot call getInputStream() after getReader() has already been called for the current request");
 		request.getReader();
-		request.getInputStream();
+		assertThatIllegalStateException().isThrownBy(
+				request::getInputStream)
+			.withMessageContaining("Cannot call getInputStream() after getReader() has already been called for the current request");
 	}
 
 	@Test
diff --git a/spring-test/src/test/java/org/springframework/mock/web/MockServletContextTests.java b/spring-test/src/test/java/org/springframework/mock/web/MockServletContextTests.java
index 9c80d40d764..87ed3271f79 100644
--- a/spring-test/src/test/java/org/springframework/mock/web/MockServletContextTests.java
+++ b/spring-test/src/test/java/org/springframework/mock/web/MockServletContextTests.java
@@ -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.
@@ -26,11 +26,7 @@ import org.junit.Test;
 
 import org.springframework.http.MediaType;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
 
 /**
  * @author Juergen Hoeller
diff --git a/spring-test/src/test/java/org/springframework/test/context/BootstrapUtilsTests.java b/spring-test/src/test/java/org/springframework/test/context/BootstrapUtilsTests.java
index b64ff3d6cd9..d8f7bf137e1 100644
--- a/spring-test/src/test/java/org/springframework/test/context/BootstrapUtilsTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/BootstrapUtilsTests.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.
@@ -19,18 +19,16 @@ package org.springframework.test.context;
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.test.context.support.DefaultTestContextBootstrapper;
 import org.springframework.test.context.web.WebAppConfiguration;
 import org.springframework.test.context.web.WebTestContextBootstrapper;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Mockito.mock;
-import static org.springframework.test.context.BootstrapUtils.resolveTestContextBootstrapper;
+import static org.assertj.core.api.Assertions.*;
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+import static org.springframework.test.context.BootstrapUtils.*;
 
 /**
  * Unit tests for {@link BootstrapUtils}.
@@ -43,30 +41,23 @@ public class BootstrapUtilsTests {
 
 	private final CacheAwareContextLoaderDelegate delegate = mock(CacheAwareContextLoaderDelegate.class);
 
-	@Rule
-	public final ExpectedException exception = ExpectedException.none();
-
 	@Test
 	public void resolveTestContextBootstrapperWithEmptyBootstrapWithAnnotation() {
 		BootstrapContext bootstrapContext = BootstrapTestUtils.buildBootstrapContext(EmptyBootstrapWithAnnotationClass.class, delegate);
-
-		exception.expect(IllegalStateException.class);
-		exception.expectMessage("Specify @BootstrapWith's 'value' attribute");
-
-		resolveTestContextBootstrapper(bootstrapContext);
+		assertThatIllegalStateException().isThrownBy(() ->
+				resolveTestContextBootstrapper(bootstrapContext))
+			.withMessageContaining("Specify @BootstrapWith's 'value' attribute");
 	}
 
 	@Test
 	public void resolveTestContextBootstrapperWithDoubleMetaBootstrapWithAnnotations() {
 		BootstrapContext bootstrapContext = BootstrapTestUtils.buildBootstrapContext(
 			DoubleMetaAnnotatedBootstrapWithAnnotationClass.class, delegate);
-
-		exception.expect(IllegalStateException.class);
-		exception.expectMessage("Configuration error: found multiple declarations of @BootstrapWith");
-		exception.expectMessage(FooBootstrapper.class.getName());
-		exception.expectMessage(BarBootstrapper.class.getName());
-
-		resolveTestContextBootstrapper(bootstrapContext);
+		assertThatIllegalStateException().isThrownBy(() ->
+				resolveTestContextBootstrapper(bootstrapContext))
+			.withMessageContaining("Configuration error: found multiple declarations of @BootstrapWith")
+			.withMessageContaining(FooBootstrapper.class.getName())
+			.withMessageContaining(BarBootstrapper.class.getName());
 	}
 
 	@Test
@@ -156,12 +147,12 @@ public class BootstrapUtilsTests {
 	@BootWithFoo
 	@BootWithFooAgain
 	static class DuplicateMetaAnnotatedBootstrapWithAnnotationClass {}
-	
+
 	@BootWithFoo
 	@BootWithBar
 	@BootstrapWith(EnigmaBootstrapper.class)
 	static class LocalDeclarationAndMetaAnnotatedBootstrapWithAnnotationClass {}
-	
+
 	@WebAppConfiguration
 	static class WebAppConfigurationAnnotatedClass {}
 
diff --git a/spring-test/src/test/java/org/springframework/test/context/TestContextConcurrencyTests.java b/spring-test/src/test/java/org/springframework/test/context/TestContextConcurrencyTests.java
index 3d08bcd401e..ba22c7729c6 100644
--- a/spring-test/src/test/java/org/springframework/test/context/TestContextConcurrencyTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/TestContextConcurrencyTests.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.
@@ -24,11 +24,11 @@ import java.util.stream.IntStream;
 
 import org.junit.Test;
 
-import static java.util.Arrays.stream;
-import static java.util.stream.Collectors.toCollection;
-import static org.hamcrest.CoreMatchers.equalTo;
+import static java.util.Arrays.*;
+import static java.util.stream.Collectors.*;
+import static org.hamcrest.CoreMatchers.*;
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.*;
 
 /**
  * Integration tests that verify proper concurrency support between a
diff --git a/spring-test/src/test/java/org/springframework/test/context/cache/ClassLevelDirtiesContextTestNGTests.java b/spring-test/src/test/java/org/springframework/test/context/cache/ClassLevelDirtiesContextTestNGTests.java
index 0dff41bc794..e1d165170b1 100644
--- a/spring-test/src/test/java/org/springframework/test/context/cache/ClassLevelDirtiesContextTestNGTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/cache/ClassLevelDirtiesContextTestNGTests.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.
@@ -23,6 +23,8 @@ import org.junit.BeforeClass;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.JUnit4;
+import org.testng.ITestNGListener;
+import org.testng.TestNG;
 
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.ApplicationContext;
@@ -36,9 +38,6 @@ import org.springframework.test.context.support.DirtiesContextTestExecutionListe
 import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
 import org.springframework.test.context.testng.TrackingTestNGTestListener;
 
-import org.testng.ITestNGListener;
-import org.testng.TestNG;
-
 import static org.junit.Assert.*;
 import static org.springframework.test.context.cache.ContextCacheTestUtils.*;
 
diff --git a/spring-test/src/test/java/org/springframework/test/context/cache/ContextCacheUtilsTests.java b/spring-test/src/test/java/org/springframework/test/context/cache/ContextCacheUtilsTests.java
index bd525d31bf8..c38445a22b6 100644
--- a/spring-test/src/test/java/org/springframework/test/context/cache/ContextCacheUtilsTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/cache/ContextCacheUtilsTests.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.
@@ -23,8 +23,8 @@ import org.junit.Test;
 import org.springframework.core.SpringProperties;
 
 import static org.junit.Assert.*;
-import static org.springframework.test.context.cache.ContextCacheUtils.*;
 import static org.springframework.test.context.cache.ContextCache.*;
+import static org.springframework.test.context.cache.ContextCacheUtils.*;
 
 /**
  * Unit tests for {@link ContextCacheUtils}.
diff --git a/spring-test/src/test/java/org/springframework/test/context/configuration/interfaces/TestPropertySourceInterfaceTests.java b/spring-test/src/test/java/org/springframework/test/context/configuration/interfaces/TestPropertySourceInterfaceTests.java
index 7b6b8c26b7a..e3f824fa08c 100644
--- a/spring-test/src/test/java/org/springframework/test/context/configuration/interfaces/TestPropertySourceInterfaceTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/configuration/interfaces/TestPropertySourceInterfaceTests.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.
@@ -25,7 +25,7 @@ import org.springframework.core.env.Environment;
 import org.springframework.test.context.junit4.SpringRunner;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.MatcherAssert.*;
 
 /**
  * @author Sam Brannen
diff --git a/spring-test/src/test/java/org/springframework/test/context/event/CustomTestEventTests.java b/spring-test/src/test/java/org/springframework/test/context/event/CustomTestEventTests.java
index 14c3a110328..58c9ea13751 100644
--- a/spring-test/src/test/java/org/springframework/test/context/event/CustomTestEventTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/event/CustomTestEventTests.java
@@ -33,8 +33,8 @@ import org.springframework.test.context.TestExecutionListeners;
 import org.springframework.test.context.event.CustomTestEventTests.CustomEventPublishingTestExecutionListener;
 import org.springframework.test.context.junit4.SpringRunner;
 
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.springframework.test.context.TestExecutionListeners.MergeMode.MERGE_WITH_DEFAULTS;
+import static org.assertj.core.api.Assertions.*;
+import static org.springframework.test.context.TestExecutionListeners.MergeMode.*;
 
 /**
  * Integration tests for custom event publication via
diff --git a/spring-test/src/test/java/org/springframework/test/context/event/EventPublishingTestExecutionListenerIntegrationTests.java b/spring-test/src/test/java/org/springframework/test/context/event/EventPublishingTestExecutionListenerIntegrationTests.java
index cc878fe13bd..74ef5f5a8f6 100644
--- a/spring-test/src/test/java/org/springframework/test/context/event/EventPublishingTestExecutionListenerIntegrationTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/event/EventPublishingTestExecutionListenerIntegrationTests.java
@@ -24,9 +24,7 @@ import java.util.concurrent.Executor;
 import java.util.concurrent.TimeUnit;
 
 import org.junit.After;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 import org.junit.runner.RunWith;
 
 import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
@@ -53,6 +51,7 @@ import org.springframework.util.ReflectionUtils;
 
 import static java.lang.annotation.ElementType.METHOD;
 import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static org.assertj.core.api.Assertions.*;
 import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.CoreMatchers.startsWith;
 import static org.hamcrest.MatcherAssert.assertThat;
@@ -85,9 +84,6 @@ public class EventPublishingTestExecutionListenerIntegrationTests {
 	private final Object testInstance = new ExampleTestCase();
 	private final Method traceableTestMethod = ReflectionUtils.findMethod(ExampleTestCase.class, "traceableTest");
 
-	@Rule
-	public final ExpectedException exception = ExpectedException.none();
-
 
 	@After
 	public void closeApplicationContext() {
@@ -132,16 +128,10 @@ public class EventPublishingTestExecutionListenerIntegrationTests {
 	@Test
 	public void beforeTestMethodAnnotationWithFailingEventListener() throws Exception {
 		Method method = ReflectionUtils.findMethod(ExampleTestCase.class, "testWithFailingEventListener");
-
-		exception.expect(RuntimeException.class);
-		exception.expectMessage("Boom!");
-
-		try {
-			testContextManager.beforeTestMethod(testInstance, method);
-		}
-		finally {
-			verify(listener, only()).beforeTestMethod(testContext);
-		}
+		assertThatExceptionOfType(RuntimeException.class).isThrownBy(() ->
+				testContextManager.beforeTestMethod(testInstance, method))
+			.withMessageContaining("Boom!");
+		verify(listener, only()).beforeTestMethod(testContext);
 	}
 
 	/**
diff --git a/spring-test/src/test/java/org/springframework/test/context/event/EventPublishingTestExecutionListenerTests.java b/spring-test/src/test/java/org/springframework/test/context/event/EventPublishingTestExecutionListenerTests.java
index 3f57d5e26cf..169a04113f1 100644
--- a/spring-test/src/test/java/org/springframework/test/context/event/EventPublishingTestExecutionListenerTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/event/EventPublishingTestExecutionListenerTests.java
@@ -33,15 +33,14 @@ import org.springframework.context.ApplicationContext;
 import org.springframework.context.ApplicationEvent;
 import org.springframework.test.context.TestContext;
 
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.MatcherAssert.*;
+import static org.hamcrest.Matchers.*;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.*;
 
 /**
  * Unit tests for {@link EventPublishingTestExecutionListener}.
- * 
+ *
  * @author Frank Scheffler
  * @author Sam Brannen
  * @since 5.2
diff --git a/spring-test/src/test/java/org/springframework/test/context/jdbc/SqlScriptsTestExecutionListenerTests.java b/spring-test/src/test/java/org/springframework/test/context/jdbc/SqlScriptsTestExecutionListenerTests.java
index 413ea844186..64c924fe1be 100644
--- a/spring-test/src/test/java/org/springframework/test/context/jdbc/SqlScriptsTestExecutionListenerTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/jdbc/SqlScriptsTestExecutionListenerTests.java
@@ -16,10 +16,7 @@
 
 package org.springframework.test.context.jdbc;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
-
 import org.mockito.BDDMockito;
 
 import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
@@ -29,8 +26,8 @@ import org.springframework.core.io.Resource;
 import org.springframework.test.context.TestContext;
 import org.springframework.test.context.jdbc.SqlConfig.TransactionMode;
 
-import static org.hamcrest.Matchers.*;
-import static org.junit.Assert.*;
+import static org.assertj.core.api.Assertions.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.BDDMockito.*;
 
 /**
@@ -45,9 +42,6 @@ public class SqlScriptsTestExecutionListenerTests {
 
 	private final TestContext testContext = mock(TestContext.class);
 
-	@Rule
-	public final ExpectedException exception = ExpectedException.none();
-
 
 	@Test
 	public void missingValueAndScriptsAndStatementsAtClassLevel() throws Exception {
@@ -73,15 +67,11 @@ public class SqlScriptsTestExecutionListenerTests {
 		BDDMockito.> given(testContext.getTestClass()).willReturn(clazz);
 		given(testContext.getTestMethod()).willReturn(clazz.getDeclaredMethod("foo"));
 
-		exception.expect(AnnotationConfigurationException.class);
-		exception.expectMessage(either(
-				containsString("attribute 'value' and its alias 'scripts'")).or(
-				containsString("attribute 'scripts' and its alias 'value'")));
-		exception.expectMessage(either(containsString("values of [{foo}] and [{bar}]")).or(
-				containsString("values of [{bar}] and [{foo}]")));
-		exception.expectMessage(either(containsString("but only one is permitted")).or(
-				containsString("Different @AliasFor mirror values")));
-		listener.beforeTestMethod(testContext);
+		assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() ->
+				listener.beforeTestMethod(testContext))
+			.withMessageContaining("Different @AliasFor mirror values")
+			.withMessageContaining("attribute 'scripts' and its alias 'value'")
+			.withMessageContaining("values of [{bar}] and [{foo}]");
 	}
 
 	@Test
@@ -113,14 +103,9 @@ public class SqlScriptsTestExecutionListenerTests {
 	}
 
 	private void assertExceptionContains(String msg) throws Exception {
-		try {
-			listener.beforeTestMethod(testContext);
-			fail("Should have thrown an IllegalStateException.");
-		}
-		catch (IllegalStateException e) {
-			// System.err.println(e.getMessage());
-			assertTrue("Exception message should contain: " + msg, e.getMessage().contains(msg));
-		}
+		assertThatIllegalStateException().isThrownBy(() ->
+				listener.beforeTestMethod(testContext))
+			.withMessageContaining(msg);
 	}
 
 
diff --git a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/DisabledIfConditionTests.java b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/DisabledIfConditionTests.java
index 5ff4d83c2d6..96cb44fc290 100644
--- a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/DisabledIfConditionTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/DisabledIfConditionTests.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.
@@ -20,7 +20,6 @@ import java.lang.reflect.Method;
 import java.util.Optional;
 
 import org.hamcrest.Matcher;
-
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ConditionEvaluationResult;
 import org.junit.jupiter.api.extension.ExtensionContext;
@@ -35,7 +34,7 @@ import static org.hamcrest.CoreMatchers.*;
 import static org.hamcrest.CoreMatchers.endsWith;
 import static org.hamcrest.MatcherAssert.*;
 import static org.junit.jupiter.api.Assertions.*;
-import static org.mockito.Mockito.any;
+import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.*;
 
 /**
diff --git a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/DisabledIfTests.java b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/DisabledIfTests.java
index 0d41d14f6f7..ed18a9ce451 100644
--- a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/DisabledIfTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/DisabledIfTests.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.
@@ -24,8 +24,7 @@ import org.springframework.context.annotation.Configuration;
 import org.springframework.test.context.TestPropertySource;
 import org.springframework.test.context.junit.SpringJUnitJupiterTestSuite;
 
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.fail;
+import static org.junit.jupiter.api.Assertions.*;
 
 /**
  * Integration tests which verify support for {@link DisabledIf @DisabledIf}
diff --git a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/EnabledIfTests.java b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/EnabledIfTests.java
index 658a1318389..d5e4166cdd1 100644
--- a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/EnabledIfTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/EnabledIfTests.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.
@@ -24,9 +24,7 @@ import org.springframework.context.annotation.Configuration;
 import org.springframework.test.context.TestPropertySource;
 import org.springframework.test.context.junit.SpringJUnitJupiterTestSuite;
 
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.fail;
+import static org.junit.jupiter.api.Assertions.*;
 
 /**
  * Integration tests which verify support for {@link EnabledIf @EnabledIf}
diff --git a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/FailingBeforeAndAfterMethodsSpringExtensionTests.java b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/FailingBeforeAndAfterMethodsSpringExtensionTests.java
index 2f357fbe84e..1103d27e4cb 100644
--- a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/FailingBeforeAndAfterMethodsSpringExtensionTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/FailingBeforeAndAfterMethodsSpringExtensionTests.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.
@@ -19,7 +19,6 @@ package org.springframework.test.context.junit.jupiter;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.stream.Stream;
-
 import javax.sql.DataSource;
 
 import org.junit.jupiter.api.DynamicTest;
@@ -32,7 +31,6 @@ import org.junit.platform.launcher.TestIdentifier;
 import org.junit.platform.launcher.core.LauncherFactory;
 import org.junit.platform.launcher.listeners.SummaryGeneratingListener;
 import org.junit.platform.launcher.listeners.TestExecutionSummary;
-
 import org.opentest4j.AssertionFailedError;
 
 import org.springframework.context.annotation.Bean;
diff --git a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/SpringManagedJupiterExtensionTests.java b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/SpringManagedJupiterExtensionTests.java
index dbb03be76cc..ecaa8df38d1 100644
--- a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/SpringManagedJupiterExtensionTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/SpringManagedJupiterExtensionTests.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.
@@ -30,6 +30,7 @@ import org.junit.jupiter.api.extension.ParameterResolver;
 import org.junit.jupiter.api.extension.RegisterExtension;
 import org.junit.jupiter.api.extension.TestTemplateInvocationContext;
 import org.junit.jupiter.api.extension.TestTemplateInvocationContextProvider;
+
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
diff --git a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/nested/NestedTestsWithSpringAndJUnitJupiterTests.java b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/nested/NestedTestsWithSpringAndJUnitJupiterTests.java
index 54197d6f278..34f1c251e1b 100644
--- a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/nested/NestedTestsWithSpringAndJUnitJupiterTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/nested/NestedTestsWithSpringAndJUnitJupiterTests.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.
@@ -27,7 +27,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
 import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
 import org.springframework.test.context.junit.jupiter.nested.NestedTestsWithSpringAndJUnitJupiterTests.TopLevelConfig;
 
-import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
 /**
  * Integration tests that verify support for {@code @Nested} test classes
diff --git a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/nested/NestedTestsWithSqlScriptsAndJUnitJupiterTests.java b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/nested/NestedTestsWithSqlScriptsAndJUnitJupiterTests.java
index dd2ee8f31dc..6b048981c5d 100644
--- a/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/nested/NestedTestsWithSqlScriptsAndJUnitJupiterTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/junit/jupiter/nested/NestedTestsWithSqlScriptsAndJUnitJupiterTests.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.
@@ -32,7 +32,7 @@ import org.springframework.test.context.transaction.BeforeTransaction;
 import org.springframework.test.jdbc.JdbcTestUtils;
 import org.springframework.transaction.annotation.Transactional;
 
-import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
 /**
  * Integration tests that verify support for {@link Nested @Nested} test classes in
diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/JUnitTestingUtils.java b/spring-test/src/test/java/org/springframework/test/context/junit4/JUnitTestingUtils.java
index 8baccc69ecd..764cdf20a6b 100644
--- a/spring-test/src/test/java/org/springframework/test/context/junit4/JUnitTestingUtils.java
+++ b/spring-test/src/test/java/org/springframework/test/context/junit4/JUnitTestingUtils.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.
@@ -28,8 +28,7 @@ import org.junit.runner.notification.RunNotifier;
 
 import org.springframework.beans.BeanUtils;
 
-import static org.junit.jupiter.api.Assertions.assertAll;
-import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
 /**
  * Collection of utilities for testing the execution of JUnit 4 based tests.
diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/MethodLevelTransactionalSpringRunnerTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/MethodLevelTransactionalSpringRunnerTests.java
index b0f8258afe5..9fff5502202 100644
--- a/spring-test/src/test/java/org/springframework/test/context/junit4/MethodLevelTransactionalSpringRunnerTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/junit4/MethodLevelTransactionalSpringRunnerTests.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.
@@ -21,6 +21,7 @@ import javax.sql.DataSource;
 import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.Test;
+
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.jdbc.core.JdbcTemplate;
diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/OptionalContextConfigurationSpringRunnerTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/OptionalContextConfigurationSpringRunnerTests.java
index 189a4e9db95..67669bca8ee 100644
--- a/spring-test/src/test/java/org/springframework/test/context/junit4/OptionalContextConfigurationSpringRunnerTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/junit4/OptionalContextConfigurationSpringRunnerTests.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.
@@ -23,11 +23,11 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.*;
 
 /**
- * JUnit 4 based integration test which verifies that {@link @ContextConfiguration}
- * is optional.
+ * JUnit 4 based integration test which verifies that
+ * {@link ContextConfiguration @ContextConfiguration} is optional.
  *
  * @author Phillip Webb
  * @author Sam Brannen
diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/SpringJUnit4TestSuite.java b/spring-test/src/test/java/org/springframework/test/context/junit4/SpringJUnit4TestSuite.java
index 994f349624e..b41b51d5979 100644
--- a/spring-test/src/test/java/org/springframework/test/context/junit4/SpringJUnit4TestSuite.java
+++ b/spring-test/src/test/java/org/springframework/test/context/junit4/SpringJUnit4TestSuite.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.
@@ -19,6 +19,7 @@ package org.springframework.test.context.junit4;
 import org.junit.runner.RunWith;
 import org.junit.runners.Suite;
 import org.junit.runners.Suite.SuiteClasses;
+
 import org.springframework.test.context.cache.ClassLevelDirtiesContextTests;
 import org.springframework.test.context.cache.SpringRunnerContextCacheTests;
 import org.springframework.test.context.jdbc.IsolatedTransactionModeSqlScriptsTests;
diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/aci/annotation/InitializerConfiguredViaMetaAnnotationTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/aci/annotation/InitializerConfiguredViaMetaAnnotationTests.java
index 32c9a5cef3e..868771e2f78 100644
--- a/spring-test/src/test/java/org/springframework/test/context/junit4/aci/annotation/InitializerConfiguredViaMetaAnnotationTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/junit4/aci/annotation/InitializerConfiguredViaMetaAnnotationTests.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.
@@ -24,6 +24,7 @@ import java.util.List;
 
 import org.junit.Test;
 import org.junit.runner.RunWith;
+
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.ApplicationContextInitializer;
 import org.springframework.context.annotation.AnnotatedBeanDefinitionReader;
@@ -34,7 +35,7 @@ import org.springframework.test.context.junit4.SpringRunner;
 import org.springframework.test.context.junit4.aci.annotation.InitializerConfiguredViaMetaAnnotationTests.ComposedContextConfiguration;
 import org.springframework.test.context.support.AnnotationConfigContextLoader;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.*;
 
 /**
  * Integration test that demonstrates how to register one or more {@code @Configuration}
diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/nested/NestedTestsWithSpringRulesTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/nested/NestedTestsWithSpringRulesTests.java
index 66d36cafc24..1004c0e7067 100644
--- a/spring-test/src/test/java/org/springframework/test/context/junit4/nested/NestedTestsWithSpringRulesTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/junit4/nested/NestedTestsWithSpringRulesTests.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,6 +16,7 @@
 
 package org.springframework.test.context.junit4.nested;
 
+import de.bechte.junit.runners.context.HierarchicalContextRunner;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
@@ -27,10 +28,7 @@ import org.springframework.test.context.junit4.nested.NestedTestsWithSpringRules
 import org.springframework.test.context.junit4.rules.SpringClassRule;
 import org.springframework.test.context.junit4.rules.SpringMethodRule;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-
-import de.bechte.junit.runners.context.HierarchicalContextRunner;
+import static org.junit.Assert.*;
 
 /**
  * JUnit 4 based integration tests for nested test classes that are
diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/profile/annotation/DevProfileAnnotationConfigTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/profile/annotation/DevProfileAnnotationConfigTests.java
index 470edbf2c26..59ce7b9e0dd 100644
--- a/spring-test/src/test/java/org/springframework/test/context/junit4/profile/annotation/DevProfileAnnotationConfigTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/junit4/profile/annotation/DevProfileAnnotationConfigTests.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 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.
diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/profile/xml/DevProfileXmlConfigTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/profile/xml/DevProfileXmlConfigTests.java
index 9e5d0306307..8cd54c3e360 100644
--- a/spring-test/src/test/java/org/springframework/test/context/junit4/profile/xml/DevProfileXmlConfigTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/junit4/profile/xml/DevProfileXmlConfigTests.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 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.
diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/spr3896/BeanOverridingDefaultLocationsInheritedTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/spr3896/BeanOverridingDefaultLocationsInheritedTests.java
index 97274401f0f..ff4ba40139f 100644
--- a/spring-test/src/test/java/org/springframework/test/context/junit4/spr3896/BeanOverridingDefaultLocationsInheritedTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/junit4/spr3896/BeanOverridingDefaultLocationsInheritedTests.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2007 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.
diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/spr3896/BeanOverridingExplicitLocationsInheritedTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/spr3896/BeanOverridingExplicitLocationsInheritedTests.java
index efd60eadbc3..f8a3b8125ea 100644
--- a/spring-test/src/test/java/org/springframework/test/context/junit4/spr3896/BeanOverridingExplicitLocationsInheritedTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/junit4/spr3896/BeanOverridingExplicitLocationsInheritedTests.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2007 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.
diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/spr6128/AutowiredQualifierTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/spr6128/AutowiredQualifierTests.java
index 1e7eced86c1..03a67200673 100644
--- a/spring-test/src/test/java/org/springframework/test/context/junit4/spr6128/AutowiredQualifierTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/junit4/spr6128/AutowiredQualifierTests.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2012 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.
@@ -24,7 +24,7 @@ import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.MatcherAssert.*;
 import static org.hamcrest.core.IsEqual.*;
 
 /**
diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/spr8849/TestClass1.java b/spring-test/src/test/java/org/springframework/test/context/junit4/spr8849/TestClass1.java
index 7a49d74a234..90288eb090c 100644
--- a/spring-test/src/test/java/org/springframework/test/context/junit4/spr8849/TestClass1.java
+++ b/spring-test/src/test/java/org/springframework/test/context/junit4/spr8849/TestClass1.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.
@@ -21,6 +21,7 @@ import javax.sql.DataSource;
 
 import org.junit.Test;
 import org.junit.runner.RunWith;
+
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.ImportResource;
 import org.springframework.test.context.ContextConfiguration;
diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/spr8849/TestClass2.java b/spring-test/src/test/java/org/springframework/test/context/junit4/spr8849/TestClass2.java
index b184d6549d1..6431bf8b489 100644
--- a/spring-test/src/test/java/org/springframework/test/context/junit4/spr8849/TestClass2.java
+++ b/spring-test/src/test/java/org/springframework/test/context/junit4/spr8849/TestClass2.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.
@@ -21,6 +21,7 @@ import javax.sql.DataSource;
 
 import org.junit.Test;
 import org.junit.runner.RunWith;
+
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.ImportResource;
 import org.springframework.test.context.ContextConfiguration;
diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/spr8849/TestClass3.java b/spring-test/src/test/java/org/springframework/test/context/junit4/spr8849/TestClass3.java
index c9b374635ca..a3622afcfd0 100644
--- a/spring-test/src/test/java/org/springframework/test/context/junit4/spr8849/TestClass3.java
+++ b/spring-test/src/test/java/org/springframework/test/context/junit4/spr8849/TestClass3.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.
@@ -21,6 +21,7 @@ import javax.sql.DataSource;
 
 import org.junit.Test;
 import org.junit.runner.RunWith;
+
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.ImportResource;
 import org.springframework.test.context.ContextConfiguration;
diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/spr8849/TestClass4.java b/spring-test/src/test/java/org/springframework/test/context/junit4/spr8849/TestClass4.java
index 7dc87487178..70909a27885 100644
--- a/spring-test/src/test/java/org/springframework/test/context/junit4/spr8849/TestClass4.java
+++ b/spring-test/src/test/java/org/springframework/test/context/junit4/spr8849/TestClass4.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.
@@ -21,6 +21,7 @@ import javax.sql.DataSource;
 
 import org.junit.Test;
 import org.junit.runner.RunWith;
+
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.ImportResource;
 import org.springframework.test.context.ContextConfiguration;
diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/statements/SpringFailOnTimeoutTests.java b/spring-test/src/test/java/org/springframework/test/context/junit4/statements/SpringFailOnTimeoutTests.java
index fd9d7bb452b..d02fb83203e 100644
--- a/spring-test/src/test/java/org/springframework/test/context/junit4/statements/SpringFailOnTimeoutTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/junit4/statements/SpringFailOnTimeoutTests.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.
@@ -19,14 +19,11 @@ package org.springframework.test.context.junit4.statements;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 import org.junit.runners.model.Statement;
 import org.mockito.stubbing.Answer;
 
-import org.springframework.test.context.junit4.statements.SpringFailOnTimeout;
-
+import static org.assertj.core.api.Assertions.*;
 import static org.mockito.Mockito.*;
 
 /**
@@ -40,28 +37,25 @@ public class SpringFailOnTimeoutTests {
 
 	private Statement statement = mock(Statement.class);
 
-	@Rule
-	public final ExpectedException exception = ExpectedException.none();
-
 
 	@Test
 	public void nullNextStatement() throws Throwable {
-		exception.expect(IllegalArgumentException.class);
-		new SpringFailOnTimeout(null, 1);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				new SpringFailOnTimeout(null, 1));
 	}
 
 	@Test
 	public void negativeTimeout() throws Throwable {
-		exception.expect(IllegalArgumentException.class);
-		new SpringFailOnTimeout(statement, -1);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				new SpringFailOnTimeout(statement, -1));
 	}
 
 	@Test
 	public void userExceptionPropagates() throws Throwable {
 		doThrow(new Boom()).when(statement).evaluate();
 
-		exception.expect(Boom.class);
-		new SpringFailOnTimeout(statement, 1).evaluate();
+		assertThatExceptionOfType(Boom.class).isThrownBy(() ->
+				new SpringFailOnTimeout(statement, 1).evaluate());
 	}
 
 	@Test
@@ -71,16 +65,13 @@ public class SpringFailOnTimeoutTests {
 			return null;
 		}).when(statement).evaluate();
 
-		exception.expect(TimeoutException.class);
-		new SpringFailOnTimeout(statement, 1).evaluate();
+		assertThatExceptionOfType(TimeoutException.class).isThrownBy(() ->
+		new SpringFailOnTimeout(statement, 1).evaluate());
 	}
 
 	@Test
 	public void noExceptionThrownIfNoUserExceptionAndTimeoutDoesNotOccur() throws Throwable {
-		doAnswer((Answer) invocation -> {
-			return null;
-		}).when(statement).evaluate();
-
+		doAnswer((Answer) invocation -> null).when(statement).evaluate();
 		new SpringFailOnTimeout(statement, 100).evaluate();
 	}
 
diff --git a/spring-test/src/test/java/org/springframework/test/context/support/AnnotationConfigContextLoaderTests.java b/spring-test/src/test/java/org/springframework/test/context/support/AnnotationConfigContextLoaderTests.java
index 158c3700ebe..f3867e22e55 100644
--- a/spring-test/src/test/java/org/springframework/test/context/support/AnnotationConfigContextLoaderTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/support/AnnotationConfigContextLoaderTests.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.
@@ -16,13 +16,11 @@
 
 package org.springframework.test.context.support;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.test.context.MergedContextConfiguration;
 
-import static org.hamcrest.CoreMatchers.*;
+import static org.assertj.core.api.Assertions.*;
 import static org.junit.Assert.*;
 
 /**
@@ -38,21 +36,17 @@ public class AnnotationConfigContextLoaderTests {
 	private static final String[] EMPTY_STRING_ARRAY = new String[0];
 	private static final Class[] EMPTY_CLASS_ARRAY = new Class[0];
 
-	@Rule
-	public ExpectedException expectedException = ExpectedException.none();
-
 
 	/**
 	 * @since 4.0.4
 	 */
 	@Test
 	public void configMustNotContainLocations() throws Exception {
-		expectedException.expect(IllegalStateException.class);
-		expectedException.expectMessage(containsString("does not support resource locations"));
-
 		MergedContextConfiguration mergedConfig = new MergedContextConfiguration(getClass(),
 			new String[] { "config.xml" }, EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, contextLoader);
-		contextLoader.loadContext(mergedConfig);
+		assertThatIllegalStateException().isThrownBy(() ->
+				contextLoader.loadContext(mergedConfig))
+			.withMessageContaining("does not support resource locations");
 	}
 
 	@Test
diff --git a/spring-test/src/test/java/org/springframework/test/context/support/AnnotationConfigContextLoaderUtilsTests.java b/spring-test/src/test/java/org/springframework/test/context/support/AnnotationConfigContextLoaderUtilsTests.java
index 286072aa537..8cf7440cb3b 100644
--- a/spring-test/src/test/java/org/springframework/test/context/support/AnnotationConfigContextLoaderUtilsTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/support/AnnotationConfigContextLoaderUtilsTests.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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.
@@ -22,6 +22,7 @@ import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
 
 import org.junit.Test;
+
 import org.springframework.context.annotation.Configuration;
 
 import static org.junit.Assert.*;
diff --git a/spring-test/src/test/java/org/springframework/test/context/support/BootstrapTestUtilsMergedConfigTests.java b/spring-test/src/test/java/org/springframework/test/context/support/BootstrapTestUtilsMergedConfigTests.java
index 248426df62c..0f6f8eeaf50 100644
--- a/spring-test/src/test/java/org/springframework/test/context/support/BootstrapTestUtilsMergedConfigTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/support/BootstrapTestUtilsMergedConfigTests.java
@@ -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.
@@ -21,9 +21,7 @@ import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.test.context.BootstrapTestUtils;
 import org.springframework.test.context.ContextConfiguration;
@@ -32,9 +30,8 @@ import org.springframework.test.context.MergedContextConfiguration;
 import org.springframework.test.context.web.WebDelegatingSmartContextLoader;
 import org.springframework.test.context.web.WebMergedContextConfiguration;
 
-import static org.hamcrest.CoreMatchers.startsWith;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
+import static org.assertj.core.api.Assertions.*;
+import static org.junit.Assert.*;
 
 /**
  * Unit tests for {@link BootstrapTestUtils} involving {@link MergedContextConfiguration}.
@@ -44,10 +41,6 @@ import static org.junit.Assert.assertNotEquals;
  */
 public class BootstrapTestUtilsMergedConfigTests extends AbstractContextConfigurationUtilsTests {
 
-	@Rule
-	public final ExpectedException exception = ExpectedException.none();
-
-
 	@Test
 	public void buildImplicitMergedConfigWithoutAnnotation() {
 		Class testClass = Enigma.class;
@@ -61,11 +54,10 @@ public class BootstrapTestUtilsMergedConfigTests extends AbstractContextConfigur
 	 */
 	@Test
 	public void buildMergedConfigWithContextConfigurationWithoutLocationsClassesOrInitializers() {
-		exception.expect(IllegalStateException.class);
-		exception.expectMessage(startsWith("DelegatingSmartContextLoader was unable to detect defaults, "
-				+ "and no ApplicationContextInitializers or ContextCustomizers were declared for context configuration attributes"));
-
-		buildMergedContextConfiguration(MissingContextAttributesTestCase.class);
+		assertThatIllegalStateException().isThrownBy(() ->
+				buildMergedContextConfiguration(MissingContextAttributesTestCase.class))
+			.withMessageStartingWith("DelegatingSmartContextLoader was unable to detect defaults, "
+					+ "and no ApplicationContextInitializers or ContextCustomizers were declared for context configuration attributes");
 	}
 
 	@Test
diff --git a/spring-test/src/test/java/org/springframework/test/context/support/ContextLoaderUtilsConfigurationAttributesTests.java b/spring-test/src/test/java/org/springframework/test/context/support/ContextLoaderUtilsConfigurationAttributesTests.java
index 55eee8a04db..f994d1c0c91 100644
--- a/spring-test/src/test/java/org/springframework/test/context/support/ContextLoaderUtilsConfigurationAttributesTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/support/ContextLoaderUtilsConfigurationAttributesTests.java
@@ -18,16 +18,14 @@ package org.springframework.test.context.support;
 
 import java.util.List;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.core.annotation.AnnotationConfigurationException;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.ContextConfigurationAttributes;
 import org.springframework.test.context.ContextLoader;
 
-import static org.hamcrest.Matchers.*;
+import static org.assertj.core.api.Assertions.*;
 import static org.junit.Assert.*;
 import static org.springframework.test.context.support.ContextLoaderUtils.*;
 
@@ -39,10 +37,6 @@ import static org.springframework.test.context.support.ContextLoaderUtils.*;
  */
 public class ContextLoaderUtilsConfigurationAttributesTests extends AbstractContextConfigurationUtilsTests {
 
-	@Rule
-	public final ExpectedException exception = ExpectedException.none();
-
-
 	private void assertLocationsFooAttributes(ContextConfigurationAttributes attributes) {
 		assertAttributes(attributes, LocationsFoo.class, new String[] { "/foo.xml" }, EMPTY_CLASS_ARRAY,
 				ContextLoader.class, false);
@@ -65,18 +59,12 @@ public class ContextLoaderUtilsConfigurationAttributesTests extends AbstractCont
 
 	@Test
 	public void resolveConfigAttributesWithConflictingLocations() {
-		exception.expect(AnnotationConfigurationException.class);
-		exception.expectMessage(containsString(ConflictingLocations.class.getName()));
-		exception.expectMessage(either(
-				containsString("attribute 'value' and its alias 'locations'")).or(
-				containsString("attribute 'locations' and its alias 'value'")));
-		exception.expectMessage(either(
-				containsString("values of [{x}] and [{y}]")).or(
-				containsString("values of [{y}] and [{x}]")));
-		exception.expectMessage(either(
-				containsString("Different @AliasFor mirror values")).or(
-				containsString("but only one is permitted")));
-		resolveContextConfigurationAttributes(ConflictingLocations.class);
+		assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() ->
+				resolveContextConfigurationAttributes(ConflictingLocations.class))
+			.withMessageStartingWith("Different @AliasFor mirror values")
+			.withMessageContaining(ConflictingLocations.class.getName())
+			.withMessageContaining("attribute 'locations' and its alias 'value'")
+			.withMessageContaining("values of [{y}] and [{x}]");
 	}
 
 	@Test
diff --git a/spring-test/src/test/java/org/springframework/test/context/support/DelegatingSmartContextLoaderTests.java b/spring-test/src/test/java/org/springframework/test/context/support/DelegatingSmartContextLoaderTests.java
index e05ace59fb7..04e6963d959 100644
--- a/spring-test/src/test/java/org/springframework/test/context/support/DelegatingSmartContextLoaderTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/support/DelegatingSmartContextLoaderTests.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.
@@ -16,9 +16,7 @@
 
 package org.springframework.test.context.support;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.ConfigurableApplicationContext;
@@ -29,7 +27,7 @@ import org.springframework.test.context.ContextLoader;
 import org.springframework.test.context.MergedContextConfiguration;
 import org.springframework.util.ObjectUtils;
 
-import static org.hamcrest.CoreMatchers.*;
+import static org.assertj.core.api.Assertions.*;
 import static org.junit.Assert.*;
 
 /**
@@ -45,9 +43,6 @@ public class DelegatingSmartContextLoaderTests {
 
 	private final DelegatingSmartContextLoader loader = new DelegatingSmartContextLoader();
 
-	@Rule
-	public ExpectedException expectedException = ExpectedException.none();
-
 
 	private static void assertEmpty(Object[] array) {
 		assertTrue(ObjectUtils.isEmpty(array));
@@ -75,13 +70,12 @@ public class DelegatingSmartContextLoaderTests {
 
 	@Test
 	public void processContextConfigurationWithDefaultXmlConfigAndConfigurationClassGeneration() {
-		expectedException.expect(IllegalStateException.class);
-		expectedException.expectMessage(containsString("both default locations AND default configuration classes were detected"));
-
 		ContextConfigurationAttributes configAttributes = new ContextConfigurationAttributes(
 				ImproperDuplicateDefaultXmlAndConfigClassTestCase.class, EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY,
 				true, null, true, ContextLoader.class);
-		loader.processContextConfiguration(configAttributes);
+		assertThatIllegalStateException().isThrownBy(() ->
+					loader.processContextConfiguration(configAttributes))
+			.withMessageContaining("both default locations AND default configuration classes were detected");
 	}
 
 	@Test
@@ -114,13 +108,12 @@ public class DelegatingSmartContextLoaderTests {
 
 	@Test
 	public void loadContextWithoutLocationsAndConfigurationClasses() throws Exception {
-		expectedException.expect(IllegalStateException.class);
-		expectedException.expectMessage(startsWith("Neither"));
-		expectedException.expectMessage(containsString("was able to load an ApplicationContext from"));
-
 		MergedContextConfiguration mergedConfig = new MergedContextConfiguration(
 				getClass(), EMPTY_STRING_ARRAY, EMPTY_CLASS_ARRAY, EMPTY_STRING_ARRAY, loader);
-		loader.loadContext(mergedConfig);
+		assertThatIllegalStateException().isThrownBy(() ->
+				loader.loadContext(mergedConfig))
+			.withMessageStartingWith("Neither")
+			.withMessageContaining("was able to load an ApplicationContext from");
 	}
 
 	/**
@@ -128,13 +121,12 @@ public class DelegatingSmartContextLoaderTests {
 	 */
 	@Test
 	public void loadContextWithLocationsAndConfigurationClasses() throws Exception {
-		expectedException.expect(IllegalStateException.class);
-		expectedException.expectMessage(startsWith("Neither"));
-		expectedException.expectMessage(endsWith("declare either 'locations' or 'classes' but not both."));
-
 		MergedContextConfiguration mergedConfig = new MergedContextConfiguration(getClass(),
 				new String[] {"test.xml"}, new Class[] {getClass()}, EMPTY_STRING_ARRAY, loader);
-		loader.loadContext(mergedConfig);
+		assertThatIllegalStateException().isThrownBy(() ->
+				loader.loadContext(mergedConfig))
+			.withMessageStartingWith("Neither")
+			.withMessageContaining("declare either 'locations' or 'classes' but not both.");
 	}
 
 	private void assertApplicationContextLoadsAndContainsFooString(MergedContextConfiguration mergedConfig)
diff --git a/spring-test/src/test/java/org/springframework/test/context/support/DirtiesContextTestExecutionListenerTests.java b/spring-test/src/test/java/org/springframework/test/context/support/DirtiesContextTestExecutionListenerTests.java
index c2ee97646fc..494ba23120a 100644
--- a/spring-test/src/test/java/org/springframework/test/context/support/DirtiesContextTestExecutionListenerTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/support/DirtiesContextTestExecutionListenerTests.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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.
@@ -20,7 +20,6 @@ import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 
 import org.junit.Test;
-
 import org.mockito.BDDMockito;
 
 import org.springframework.test.annotation.DirtiesContext;
@@ -29,6 +28,7 @@ import org.springframework.test.annotation.DirtiesContext.HierarchyMode;
 import org.springframework.test.context.TestContext;
 import org.springframework.test.context.TestExecutionListener;
 
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.BDDMockito.*;
 import static org.springframework.test.annotation.DirtiesContext.ClassMode.*;
 import static org.springframework.test.annotation.DirtiesContext.HierarchyMode.*;
diff --git a/spring-test/src/test/java/org/springframework/test/context/support/GenericPropertiesContextLoaderTests.java b/spring-test/src/test/java/org/springframework/test/context/support/GenericPropertiesContextLoaderTests.java
index d48a43614a2..81dde711fc1 100644
--- a/spring-test/src/test/java/org/springframework/test/context/support/GenericPropertiesContextLoaderTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/support/GenericPropertiesContextLoaderTests.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.
@@ -16,13 +16,11 @@
 
 package org.springframework.test.context.support;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.test.context.MergedContextConfiguration;
 
-import static org.hamcrest.CoreMatchers.*;
+import static org.assertj.core.api.Assertions.*;
 
 /**
  * Unit tests for {@link GenericPropertiesContextLoader}.
@@ -34,19 +32,15 @@ public class GenericPropertiesContextLoaderTests {
 
 	private static final String[] EMPTY_STRING_ARRAY = new String[0];
 
-	@Rule
-	public ExpectedException expectedException = ExpectedException.none();
-
 
 	@Test
 	public void configMustNotContainAnnotatedClasses() throws Exception {
-		expectedException.expect(IllegalStateException.class);
-		expectedException.expectMessage(containsString("does not support annotated classes"));
-
 		GenericPropertiesContextLoader loader = new GenericPropertiesContextLoader();
 		MergedContextConfiguration mergedConfig = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY,
 			new Class[] { getClass() }, EMPTY_STRING_ARRAY, loader);
-		loader.loadContext(mergedConfig);
+		assertThatIllegalStateException().isThrownBy(() ->
+				loader.loadContext(mergedConfig))
+			.withMessageContaining("does not support annotated classes");
 	}
 
 }
diff --git a/spring-test/src/test/java/org/springframework/test/context/support/GenericXmlContextLoaderResourceLocationsTests.java b/spring-test/src/test/java/org/springframework/test/context/support/GenericXmlContextLoaderResourceLocationsTests.java
index d36983847e4..90c5b336d5b 100644
--- a/spring-test/src/test/java/org/springframework/test/context/support/GenericXmlContextLoaderResourceLocationsTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/support/GenericXmlContextLoaderResourceLocationsTests.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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.
@@ -25,6 +25,7 @@ import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
 import org.junit.runners.Parameterized.Parameters;
+
 import org.springframework.core.annotation.AnnotationUtils;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.ContextLoader;
diff --git a/spring-test/src/test/java/org/springframework/test/context/support/GenericXmlContextLoaderTests.java b/spring-test/src/test/java/org/springframework/test/context/support/GenericXmlContextLoaderTests.java
index c8ae43f7309..770e9d74d01 100644
--- a/spring-test/src/test/java/org/springframework/test/context/support/GenericXmlContextLoaderTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/support/GenericXmlContextLoaderTests.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.
@@ -16,13 +16,11 @@
 
 package org.springframework.test.context.support;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.test.context.MergedContextConfiguration;
 
-import static org.hamcrest.CoreMatchers.*;
+import static org.assertj.core.api.Assertions.*;
 
 /**
  * Unit tests for {@link GenericXmlContextLoader}.
@@ -35,19 +33,15 @@ public class GenericXmlContextLoaderTests {
 
 	private static final String[] EMPTY_STRING_ARRAY = new String[0];
 
-	@Rule
-	public ExpectedException expectedException = ExpectedException.none();
-
 
 	@Test
 	public void configMustNotContainAnnotatedClasses() throws Exception {
-		expectedException.expect(IllegalStateException.class);
-		expectedException.expectMessage(containsString("does not support annotated classes"));
-
 		GenericXmlContextLoader loader = new GenericXmlContextLoader();
 		MergedContextConfiguration mergedConfig = new MergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY,
 			new Class[] { getClass() }, EMPTY_STRING_ARRAY, loader);
-		loader.loadContext(mergedConfig);
+		assertThatIllegalStateException().isThrownBy(() ->
+				loader.loadContext(mergedConfig))
+			.withMessageContaining("does not support annotated classes");
 	}
 
 }
diff --git a/spring-test/src/test/java/org/springframework/test/context/support/TestPropertySourceUtilsTests.java b/spring-test/src/test/java/org/springframework/test/context/support/TestPropertySourceUtilsTests.java
index f4febfee1c9..66b4efcf1f4 100644
--- a/spring-test/src/test/java/org/springframework/test/context/support/TestPropertySourceUtilsTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/support/TestPropertySourceUtilsTests.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.
@@ -18,9 +18,7 @@ package org.springframework.test.context.support;
 
 import java.util.Map;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.context.ConfigurableApplicationContext;
 import org.springframework.core.annotation.AnnotationConfigurationException;
@@ -32,9 +30,9 @@ import org.springframework.mock.env.MockEnvironment;
 import org.springframework.mock.env.MockPropertySource;
 import org.springframework.test.context.TestPropertySource;
 
-import static org.hamcrest.CoreMatchers.*;
-import static org.hamcrest.CoreMatchers.startsWith;
+import static org.assertj.core.api.Assertions.*;
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.Mockito.*;
 import static org.springframework.test.context.support.TestPropertySourceUtils.*;
 
@@ -53,24 +51,21 @@ public class TestPropertySourceUtilsTests {
 	private static final String[] FOO_LOCATIONS = new String[] {"classpath:/foo.properties"};
 
 
-	@Rule
-	public ExpectedException expectedException = ExpectedException.none();
-
 
 	@Test
 	public void emptyAnnotation() {
-		expectedException.expect(IllegalStateException.class);
-		expectedException.expectMessage(startsWith("Could not detect default properties file for test"));
-		expectedException.expectMessage(containsString("EmptyPropertySources.properties"));
-		buildMergedTestPropertySources(EmptyPropertySources.class);
+		assertThatIllegalStateException().isThrownBy(() ->
+				buildMergedTestPropertySources(EmptyPropertySources.class))
+			.withMessageStartingWith("Could not detect default properties file for test")
+			.withMessageContaining("EmptyPropertySources.properties");
 	}
 
 	@Test
 	public void extendedEmptyAnnotation() {
-		expectedException.expect(IllegalStateException.class);
-		expectedException.expectMessage(startsWith("Could not detect default properties file for test"));
-		expectedException.expectMessage(containsString("ExtendedEmptyPropertySources.properties"));
-		buildMergedTestPropertySources(ExtendedEmptyPropertySources.class);
+		assertThatIllegalStateException().isThrownBy(() ->
+				buildMergedTestPropertySources(ExtendedEmptyPropertySources.class))
+			.withMessageStartingWith("Could not detect default properties file for test")
+			.withMessageContaining("ExtendedEmptyPropertySources.properties");
 	}
 
 	@Test
@@ -81,8 +76,8 @@ public class TestPropertySourceUtilsTests {
 
 	@Test
 	public void locationsAndValueAttributes() {
-		expectedException.expect(AnnotationConfigurationException.class);
-		buildMergedTestPropertySources(LocationsAndValuePropertySources.class);
+		assertThatExceptionOfType(AnnotationConfigurationException.class).isThrownBy(() ->
+				buildMergedTestPropertySources(LocationsAndValuePropertySources.class));
 	}
 
 	@Test
@@ -125,30 +120,30 @@ public class TestPropertySourceUtilsTests {
 
 	@Test
 	public void addPropertiesFilesToEnvironmentWithNullContext() {
-		expectedException.expect(IllegalArgumentException.class);
-		expectedException.expectMessage("must not be null");
-		addPropertiesFilesToEnvironment((ConfigurableApplicationContext) null, FOO_LOCATIONS);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				addPropertiesFilesToEnvironment((ConfigurableApplicationContext) null, FOO_LOCATIONS))
+			.withMessageContaining("must not be null");
 	}
 
 	@Test
 	public void addPropertiesFilesToEnvironmentWithContextAndNullLocations() {
-		expectedException.expect(IllegalArgumentException.class);
-		expectedException.expectMessage("must not be null");
-		addPropertiesFilesToEnvironment(mock(ConfigurableApplicationContext.class), (String[]) null);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				addPropertiesFilesToEnvironment(mock(ConfigurableApplicationContext.class), (String[]) null))
+			.withMessageContaining("must not be null");
 	}
 
 	@Test
 	public void addPropertiesFilesToEnvironmentWithNullEnvironment() {
-		expectedException.expect(IllegalArgumentException.class);
-		expectedException.expectMessage("must not be null");
-		addPropertiesFilesToEnvironment((ConfigurableEnvironment) null, mock(ResourceLoader.class), FOO_LOCATIONS);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				addPropertiesFilesToEnvironment((ConfigurableEnvironment) null, mock(ResourceLoader.class), FOO_LOCATIONS))
+			.withMessageContaining("must not be null");
 	}
 
 	@Test
 	public void addPropertiesFilesToEnvironmentWithEnvironmentAndNullLocations() {
-		expectedException.expect(IllegalArgumentException.class);
-		expectedException.expectMessage("must not be null");
-		addPropertiesFilesToEnvironment(new MockEnvironment(), mock(ResourceLoader.class), (String[]) null);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				addPropertiesFilesToEnvironment(new MockEnvironment(), mock(ResourceLoader.class), (String[]) null))
+			.withMessageContaining("must not be null");
 	}
 
 	@Test
@@ -171,44 +166,44 @@ public class TestPropertySourceUtilsTests {
 
 	@Test
 	public void addInlinedPropertiesToEnvironmentWithNullContext() {
-		expectedException.expect(IllegalArgumentException.class);
-		expectedException.expectMessage("context");
-		addInlinedPropertiesToEnvironment((ConfigurableApplicationContext) null, KEY_VALUE_PAIR);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				addInlinedPropertiesToEnvironment((ConfigurableApplicationContext) null, KEY_VALUE_PAIR))
+			.withMessageContaining("context");
 	}
 
 	@Test
 	public void addInlinedPropertiesToEnvironmentWithContextAndNullInlinedProperties() {
-		expectedException.expect(IllegalArgumentException.class);
-		expectedException.expectMessage("inlined");
-		addInlinedPropertiesToEnvironment(mock(ConfigurableApplicationContext.class), (String[]) null);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				addInlinedPropertiesToEnvironment(mock(ConfigurableApplicationContext.class), (String[]) null))
+			.withMessageContaining("inlined");
 	}
 
 	@Test
 	public void addInlinedPropertiesToEnvironmentWithNullEnvironment() {
-		expectedException.expect(IllegalArgumentException.class);
-		expectedException.expectMessage("environment");
-		addInlinedPropertiesToEnvironment((ConfigurableEnvironment) null, KEY_VALUE_PAIR);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				addInlinedPropertiesToEnvironment((ConfigurableEnvironment) null, KEY_VALUE_PAIR))
+			.withMessageContaining("environment");
 	}
 
 	@Test
 	public void addInlinedPropertiesToEnvironmentWithEnvironmentAndNullInlinedProperties() {
-		expectedException.expect(IllegalArgumentException.class);
-		expectedException.expectMessage("inlined");
-		addInlinedPropertiesToEnvironment(new MockEnvironment(), (String[]) null);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				addInlinedPropertiesToEnvironment(new MockEnvironment(), (String[]) null))
+			.withMessageContaining("inlined");
 	}
 
 	@Test
 	public void addInlinedPropertiesToEnvironmentWithMalformedUnicodeInValue() {
-		expectedException.expect(IllegalStateException.class);
-		expectedException.expectMessage("Failed to load test environment property");
-		addInlinedPropertiesToEnvironment(new MockEnvironment(), asArray("key = \\uZZZZ"));
+		assertThatIllegalStateException().isThrownBy(() ->
+				addInlinedPropertiesToEnvironment(new MockEnvironment(), asArray("key = \\uZZZZ")))
+			.withMessageContaining("Failed to load test environment property");
 	}
 
 	@Test
 	public void addInlinedPropertiesToEnvironmentWithMultipleKeyValuePairsInSingleInlinedProperty() {
-		expectedException.expect(IllegalStateException.class);
-		expectedException.expectMessage("Failed to load exactly one test environment property");
-		addInlinedPropertiesToEnvironment(new MockEnvironment(), asArray("a=b\nx=y"));
+		assertThatIllegalStateException().isThrownBy(() ->
+				addInlinedPropertiesToEnvironment(new MockEnvironment(), asArray("a=b\nx=y")))
+			.withMessageContaining("Failed to load exactly one test environment property");
 	}
 
 	@Test
@@ -225,9 +220,9 @@ public class TestPropertySourceUtilsTests {
 
 	@Test
 	public void convertInlinedPropertiesToMapWithNullInlinedProperties() {
-		expectedException.expect(IllegalArgumentException.class);
-		expectedException.expectMessage("inlined");
-		convertInlinedPropertiesToMap((String[]) null);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				convertInlinedPropertiesToMap((String[]) null))
+			.withMessageContaining("inlined");
 	}
 
 
diff --git a/spring-test/src/test/java/org/springframework/test/context/testng/AnnotationConfigTestNGSpringContextTests.java b/spring-test/src/test/java/org/springframework/test/context/testng/AnnotationConfigTestNGSpringContextTests.java
index f04280d8644..31975ed14eb 100644
--- a/spring-test/src/test/java/org/springframework/test/context/testng/AnnotationConfigTestNGSpringContextTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/testng/AnnotationConfigTestNGSpringContextTests.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.
@@ -16,6 +16,8 @@
 
 package org.springframework.test.context.testng;
 
+import org.testng.annotations.Test;
+
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
@@ -23,8 +25,6 @@ import org.springframework.test.context.ContextConfiguration;
 import org.springframework.tests.sample.beans.Employee;
 import org.springframework.tests.sample.beans.Pet;
 
-import org.testng.annotations.Test;
-
 import static org.testng.Assert.*;
 
 /**
diff --git a/spring-test/src/test/java/org/springframework/test/context/testng/transaction/ejb/CommitForRequiredEjbTxDaoTestNGTests.java b/spring-test/src/test/java/org/springframework/test/context/testng/transaction/ejb/CommitForRequiredEjbTxDaoTestNGTests.java
index 8aea564adb0..4ca7ebea2b4 100644
--- a/spring-test/src/test/java/org/springframework/test/context/testng/transaction/ejb/CommitForRequiredEjbTxDaoTestNGTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/testng/transaction/ejb/CommitForRequiredEjbTxDaoTestNGTests.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.
@@ -16,13 +16,13 @@
 
 package org.springframework.test.context.testng.transaction.ejb;
 
+import org.testng.annotations.Test;
+
 import org.springframework.test.annotation.Commit;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.transaction.TransactionalTestExecutionListener;
 import org.springframework.test.context.transaction.ejb.dao.RequiredEjbTxTestEntityDao;
 
-import org.testng.annotations.Test;
-
 /**
  * Concrete subclass of {@link AbstractEjbTxDaoTestNGTests} which uses the
  * {@link RequiredEjbTxTestEntityDao} and sets the default rollback semantics
diff --git a/spring-test/src/test/java/org/springframework/test/context/testng/transaction/ejb/CommitForRequiresNewEjbTxDaoTestNGTests.java b/spring-test/src/test/java/org/springframework/test/context/testng/transaction/ejb/CommitForRequiresNewEjbTxDaoTestNGTests.java
index 5cf811184b8..c79df3dc56b 100644
--- a/spring-test/src/test/java/org/springframework/test/context/testng/transaction/ejb/CommitForRequiresNewEjbTxDaoTestNGTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/testng/transaction/ejb/CommitForRequiresNewEjbTxDaoTestNGTests.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.
@@ -16,13 +16,13 @@
 
 package org.springframework.test.context.testng.transaction.ejb;
 
+import org.testng.annotations.Test;
+
 import org.springframework.test.annotation.Commit;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.transaction.TransactionalTestExecutionListener;
 import org.springframework.test.context.transaction.ejb.dao.RequiresNewEjbTxTestEntityDao;
 
-import org.testng.annotations.Test;
-
 /**
  * Concrete subclass of {@link AbstractEjbTxDaoTestNGTests} which uses the
  * {@link RequiresNewEjbTxTestEntityDao} and sets the default rollback semantics
diff --git a/spring-test/src/test/java/org/springframework/test/context/testng/transaction/ejb/RollbackForRequiredEjbTxDaoTestNGTests.java b/spring-test/src/test/java/org/springframework/test/context/testng/transaction/ejb/RollbackForRequiredEjbTxDaoTestNGTests.java
index eda666379fa..66ecb632e41 100644
--- a/spring-test/src/test/java/org/springframework/test/context/testng/transaction/ejb/RollbackForRequiredEjbTxDaoTestNGTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/testng/transaction/ejb/RollbackForRequiredEjbTxDaoTestNGTests.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.
@@ -16,11 +16,11 @@
 
 package org.springframework.test.context.testng.transaction.ejb;
 
+import org.testng.annotations.Test;
+
 import org.springframework.test.annotation.Rollback;
 import org.springframework.test.context.transaction.TransactionalTestExecutionListener;
 
-import org.testng.annotations.Test;
-
 import static org.testng.AssertJUnit.*;
 
 /**
diff --git a/spring-test/src/test/java/org/springframework/test/context/testng/transaction/ejb/RollbackForRequiresNewEjbTxDaoTestNGTests.java b/spring-test/src/test/java/org/springframework/test/context/testng/transaction/ejb/RollbackForRequiresNewEjbTxDaoTestNGTests.java
index 84d312bfc31..b4063beee24 100644
--- a/spring-test/src/test/java/org/springframework/test/context/testng/transaction/ejb/RollbackForRequiresNewEjbTxDaoTestNGTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/testng/transaction/ejb/RollbackForRequiresNewEjbTxDaoTestNGTests.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.
@@ -16,11 +16,11 @@
 
 package org.springframework.test.context.testng.transaction.ejb;
 
+import org.testng.annotations.Test;
+
 import org.springframework.test.annotation.Rollback;
 import org.springframework.test.context.transaction.TransactionalTestExecutionListener;
 
-import org.testng.annotations.Test;
-
 /**
  * Extension of {@link CommitForRequiresNewEjbTxDaoTestNGTests} which sets the default
  * rollback semantics for the {@link TransactionalTestExecutionListener} to
diff --git a/spring-test/src/test/java/org/springframework/test/context/testng/transaction/programmatic/ProgrammaticTxMgmtTestNGTests.java b/spring-test/src/test/java/org/springframework/test/context/testng/transaction/programmatic/ProgrammaticTxMgmtTestNGTests.java
index 39f2b0b477f..be17477afc4 100644
--- a/spring-test/src/test/java/org/springframework/test/context/testng/transaction/programmatic/ProgrammaticTxMgmtTestNGTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/testng/transaction/programmatic/ProgrammaticTxMgmtTestNGTests.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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.
@@ -19,9 +19,12 @@ package org.springframework.test.context.testng.transaction.programmatic;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
-
 import javax.sql.DataSource;
 
+import org.testng.IHookCallBack;
+import org.testng.ITestResult;
+import org.testng.annotations.Test;
+
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.jdbc.datasource.DataSourceTransactionManager;
@@ -37,10 +40,6 @@ import org.springframework.transaction.PlatformTransactionManager;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 
-import org.testng.IHookCallBack;
-import org.testng.ITestResult;
-import org.testng.annotations.Test;
-
 import static org.junit.Assert.*;
 import static org.springframework.test.transaction.TransactionTestUtils.*;
 
diff --git a/spring-test/src/test/java/org/springframework/test/context/transaction/TransactionalTestExecutionListenerTests.java b/spring-test/src/test/java/org/springframework/test/context/transaction/TransactionalTestExecutionListenerTests.java
index 528d98cfa55..4cb323dd055 100644
--- a/spring-test/src/test/java/org/springframework/test/context/transaction/TransactionalTestExecutionListenerTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/transaction/TransactionalTestExecutionListenerTests.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.
@@ -20,9 +20,7 @@ import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 
 import org.junit.After;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 import org.mockito.BDDMockito;
 
 import org.springframework.beans.BeanUtils;
@@ -59,9 +57,6 @@ public class TransactionalTestExecutionListenerTests {
 
 	private final TestContext testContext = mock(TestContext.class);
 
-	@Rule
-	public ExpectedException exception = ExpectedException.none();
-
 
 	@After
 	public void cleanUpThreadLocalStateForSubsequentTestClassesInSuite() {
diff --git a/spring-test/src/test/java/org/springframework/test/context/transaction/programmatic/ProgrammaticTxMgmtTests.java b/spring-test/src/test/java/org/springframework/test/context/transaction/programmatic/ProgrammaticTxMgmtTests.java
index d1b99f9681f..4fde05320b5 100644
--- a/spring-test/src/test/java/org/springframework/test/context/transaction/programmatic/ProgrammaticTxMgmtTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/transaction/programmatic/ProgrammaticTxMgmtTests.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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.
@@ -19,7 +19,6 @@ package org.springframework.test.context.transaction.programmatic;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
-
 import javax.sql.DataSource;
 
 import org.junit.Rule;
diff --git a/spring-test/src/test/java/org/springframework/test/context/web/AnnotationConfigWebContextLoaderTests.java b/spring-test/src/test/java/org/springframework/test/context/web/AnnotationConfigWebContextLoaderTests.java
index 6a8a1d90197..f0d2ab67861 100644
--- a/spring-test/src/test/java/org/springframework/test/context/web/AnnotationConfigWebContextLoaderTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/web/AnnotationConfigWebContextLoaderTests.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,11 +16,9 @@
 
 package org.springframework.test.context.web;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
-import static org.hamcrest.CoreMatchers.*;
+import static org.assertj.core.api.Assertions.*;
 
 /**
  * Unit tests for {@link AnnotationConfigWebContextLoader}.
@@ -33,20 +31,16 @@ public class AnnotationConfigWebContextLoaderTests {
 	private static final String[] EMPTY_STRING_ARRAY = new String[0];
 	private static final Class[] EMPTY_CLASS_ARRAY = new Class[0];
 
-	@Rule
-	public ExpectedException expectedException = ExpectedException.none();
-
 
 	@Test
 	public void configMustNotContainLocations() throws Exception {
-		expectedException.expect(IllegalStateException.class);
-		expectedException.expectMessage(containsString("does not support resource locations"));
-
 		AnnotationConfigWebContextLoader loader = new AnnotationConfigWebContextLoader();
 		WebMergedContextConfiguration mergedConfig = new WebMergedContextConfiguration(getClass(),
 				new String[] { "config.xml" }, EMPTY_CLASS_ARRAY, null, EMPTY_STRING_ARRAY, EMPTY_STRING_ARRAY,
 				EMPTY_STRING_ARRAY, "resource/path", loader, null, null);
-		loader.loadContext(mergedConfig);
+		assertThatIllegalStateException().isThrownBy(() ->
+				loader.loadContext(mergedConfig))
+			.withMessageContaining("does not support resource locations");
 	}
 
 }
diff --git a/spring-test/src/test/java/org/springframework/test/context/web/GenericXmlWebContextLoaderTests.java b/spring-test/src/test/java/org/springframework/test/context/web/GenericXmlWebContextLoaderTests.java
index 30d320e11e0..2e10cac10b8 100644
--- a/spring-test/src/test/java/org/springframework/test/context/web/GenericXmlWebContextLoaderTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/web/GenericXmlWebContextLoaderTests.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,11 +16,9 @@
 
 package org.springframework.test.context.web;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
-import static org.hamcrest.CoreMatchers.*;
+import static org.assertj.core.api.Assertions.*;
 
 /**
  * Unit tests for {@link GenericXmlWebContextLoader}.
@@ -32,20 +30,16 @@ public class GenericXmlWebContextLoaderTests {
 
 	private static final String[] EMPTY_STRING_ARRAY = new String[0];
 
-	@Rule
-	public ExpectedException expectedException = ExpectedException.none();
-
 
 	@Test
 	public void configMustNotContainAnnotatedClasses() throws Exception {
-		expectedException.expect(IllegalStateException.class);
-		expectedException.expectMessage(containsString("does not support annotated classes"));
-
 		GenericXmlWebContextLoader loader = new GenericXmlWebContextLoader();
 		WebMergedContextConfiguration mergedConfig = new WebMergedContextConfiguration(getClass(), EMPTY_STRING_ARRAY,
 				new Class[] { getClass() }, null, EMPTY_STRING_ARRAY, EMPTY_STRING_ARRAY, EMPTY_STRING_ARRAY,
 				"resource/path", loader, null, null);
-		loader.loadContext(mergedConfig);
+		assertThatIllegalStateException().isThrownBy(() ->
+				loader.loadContext(mergedConfig))
+			.withMessageContaining("does not support annotated classes");
 	}
 
 }
diff --git a/spring-test/src/test/java/org/springframework/test/context/web/WebAppConfigurationBootstrapWithTests.java b/spring-test/src/test/java/org/springframework/test/context/web/WebAppConfigurationBootstrapWithTests.java
index e61aaa95886..531d6e24ffe 100644
--- a/spring-test/src/test/java/org/springframework/test/context/web/WebAppConfigurationBootstrapWithTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/web/WebAppConfigurationBootstrapWithTests.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.
@@ -29,8 +29,7 @@ import org.springframework.test.context.junit4.SpringRunner;
 import org.springframework.test.context.web.WebAppConfigurationBootstrapWithTests.CustomWebTestContextBootstrapper;
 import org.springframework.web.context.WebApplicationContext;
 
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
 
 /**
  * JUnit-based integration tests that verify support for loading a
diff --git a/spring-test/src/test/java/org/springframework/test/context/web/socket/WebSocketServletServerContainerFactoryBeanTests.java b/spring-test/src/test/java/org/springframework/test/context/web/socket/WebSocketServletServerContainerFactoryBeanTests.java
index 0dc43b20cf7..0ed0f65b61c 100644
--- a/spring-test/src/test/java/org/springframework/test/context/web/socket/WebSocketServletServerContainerFactoryBeanTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/web/socket/WebSocketServletServerContainerFactoryBeanTests.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.
@@ -20,6 +20,7 @@ import javax.websocket.server.ServerContainer;
 
 import org.junit.Test;
 import org.junit.runner.RunWith;
+
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
diff --git a/spring-test/src/test/java/org/springframework/test/jdbc/JdbcTestUtilsTests.java b/spring-test/src/test/java/org/springframework/test/jdbc/JdbcTestUtilsTests.java
index 3c32d77332f..fca02f325e6 100644
--- a/spring-test/src/test/java/org/springframework/test/jdbc/JdbcTestUtilsTests.java
+++ b/spring-test/src/test/java/org/springframework/test/jdbc/JdbcTestUtilsTests.java
@@ -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.
@@ -23,8 +23,8 @@ import org.mockito.junit.MockitoJUnitRunner;
 
 import org.springframework.jdbc.core.JdbcTemplate;
 
+import static org.hamcrest.MatcherAssert.*;
 import static org.hamcrest.Matchers.*;
-import static org.hamcrest.MatcherAssert.assertThat;
 import static org.mockito.BDDMockito.*;
 
 /**
diff --git a/spring-test/src/test/java/org/springframework/test/util/JsonPathExpectationsHelperTests.java b/spring-test/src/test/java/org/springframework/test/util/JsonPathExpectationsHelperTests.java
index 161b71f0592..76baeebf177 100644
--- a/spring-test/src/test/java/org/springframework/test/util/JsonPathExpectationsHelperTests.java
+++ b/spring-test/src/test/java/org/springframework/test/util/JsonPathExpectationsHelperTests.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2004-2016 the original author or authors.
+ * Copyright 2004-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,11 +16,10 @@
 
 package org.springframework.test.util;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
-import static org.hamcrest.core.Is.is;
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
+import static org.hamcrest.core.Is.*;
 
 /**
  * Unit tests for {@link JsonPathExpectationsHelper}.
@@ -51,9 +50,6 @@ public class JsonPathExpectationsHelperTests {
 			"{'name': 'Maggie'}  " + //
 	" ] }";
 
-	@Rule
-	public final ExpectedException exception = ExpectedException.none();
-
 
 	@Test
 	public void exists() throws Exception {
@@ -78,9 +74,9 @@ public class JsonPathExpectationsHelperTests {
 	@Test
 	public void existsForIndefinatePathWithEmptyResults() throws Exception {
 		String expression = "$.familyMembers[?(@.name == 'Dilbert')]";
-		exception.expect(AssertionError.class);
-		exception.expectMessage("No value at JSON path \"" + expression + "\"");
-		new JsonPathExpectationsHelper(expression).exists(SIMPSONS);
+		assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
+				new JsonPathExpectationsHelper(expression).exists(SIMPSONS))
+			.withMessageContaining("No value at JSON path \"" + expression + "\"");
 	}
 
 	@Test
@@ -91,26 +87,25 @@ public class JsonPathExpectationsHelperTests {
 	@Test
 	public void doesNotExistForAnEmptyArray() throws Exception {
 		String expression = "$.emptyArray";
-		exception.expect(AssertionError.class);
-		exception.expectMessage("Expected no value at JSON path \"" + expression + "\" but found: []");
-		new JsonPathExpectationsHelper(expression).doesNotExist(CONTENT);
+		assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
+				new JsonPathExpectationsHelper(expression).doesNotExist(CONTENT))
+			.withMessageContaining("Expected no value at JSON path \"" + expression + "\" but found: []");
 	}
 
 	@Test
 	public void doesNotExistForAnEmptyMap() throws Exception {
 		String expression = "$.emptyMap";
-		exception.expect(AssertionError.class);
-		exception.expectMessage("Expected no value at JSON path \"" + expression + "\" but found: {}");
-		new JsonPathExpectationsHelper(expression).doesNotExist(CONTENT);
+		assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
+				new JsonPathExpectationsHelper(expression).doesNotExist(CONTENT))
+			.withMessageContaining("Expected no value at JSON path \"" + expression + "\" but found: {}");
 	}
 
 	@Test
 	public void doesNotExistForIndefinatePathWithResults() throws Exception {
 		String expression = "$.familyMembers[?(@.name == 'Bart')]";
-		exception.expect(AssertionError.class);
-		exception.expectMessage("Expected no value at JSON path \"" + expression
-				+ "\" but found: [{\"name\":\"Bart\"}]");
-		new JsonPathExpectationsHelper(expression).doesNotExist(SIMPSONS);
+		assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
+				new JsonPathExpectationsHelper(expression).doesNotExist(SIMPSONS))
+			.withMessageContaining("Expected no value at JSON path \"" + expression + "\" but found: [{\"name\":\"Bart\"}]");
 	}
 
 	@Test
@@ -141,18 +136,17 @@ public class JsonPathExpectationsHelperTests {
 	@Test
 	public void assertValueIsEmptyForIndefinatePathWithResults() throws Exception {
 		String expression = "$.familyMembers[?(@.name == 'Bart')]";
-		exception.expect(AssertionError.class);
-		exception.expectMessage("Expected an empty value at JSON path \"" + expression
-				+ "\" but found: [{\"name\":\"Bart\"}]");
-		new JsonPathExpectationsHelper(expression).assertValueIsEmpty(SIMPSONS);
+		assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
+				new JsonPathExpectationsHelper(expression).assertValueIsEmpty(SIMPSONS))
+			.withMessageContaining("Expected an empty value at JSON path \"" + expression + "\" but found: [{\"name\":\"Bart\"}]");
 	}
 
 	@Test
 	public void assertValueIsEmptyForWhitespace() throws Exception {
 		String expression = "$.whitespace";
-		exception.expect(AssertionError.class);
-		exception.expectMessage("Expected an empty value at JSON path \"" + expression + "\" but found: '    '");
-		new JsonPathExpectationsHelper(expression).assertValueIsEmpty(CONTENT);
+		assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
+				new JsonPathExpectationsHelper(expression).assertValueIsEmpty(CONTENT))
+			.withMessageContaining("Expected an empty value at JSON path \"" + expression + "\" but found: '    '");
 	}
 
 	@Test
@@ -188,33 +182,33 @@ public class JsonPathExpectationsHelperTests {
 	@Test
 	public void assertValueIsNotEmptyForIndefinatePathWithEmptyResults() throws Exception {
 		String expression = "$.familyMembers[?(@.name == 'Dilbert')]";
-		exception.expect(AssertionError.class);
-		exception.expectMessage("Expected a non-empty value at JSON path \"" + expression + "\" but found: []");
-		new JsonPathExpectationsHelper(expression).assertValueIsNotEmpty(SIMPSONS);
+		assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
+				new JsonPathExpectationsHelper(expression).assertValueIsNotEmpty(SIMPSONS))
+			.withMessageContaining("Expected a non-empty value at JSON path \"" + expression + "\" but found: []");
 	}
 
 	@Test
 	public void assertValueIsNotEmptyForAnEmptyString() throws Exception {
 		String expression = "$.emptyString";
-		exception.expect(AssertionError.class);
-		exception.expectMessage("Expected a non-empty value at JSON path \"" + expression + "\" but found: ''");
-		new JsonPathExpectationsHelper(expression).assertValueIsNotEmpty(CONTENT);
+		assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
+				new JsonPathExpectationsHelper(expression).assertValueIsNotEmpty(CONTENT))
+			.withMessageContaining("Expected a non-empty value at JSON path \"" + expression + "\" but found: ''");
 	}
 
 	@Test
 	public void assertValueIsNotEmptyForAnEmptyArray() throws Exception {
 		String expression = "$.emptyArray";
-		exception.expect(AssertionError.class);
-		exception.expectMessage("Expected a non-empty value at JSON path \"" + expression + "\" but found: []");
-		new JsonPathExpectationsHelper(expression).assertValueIsNotEmpty(CONTENT);
+		assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
+				new JsonPathExpectationsHelper(expression).assertValueIsNotEmpty(CONTENT))
+			.withMessageContaining("Expected a non-empty value at JSON path \"" + expression + "\" but found: []");
 	}
 
 	@Test
 	public void assertValueIsNotEmptyForAnEmptyMap() throws Exception {
 		String expression = "$.emptyMap";
-		exception.expect(AssertionError.class);
-		exception.expectMessage("Expected a non-empty value at JSON path \"" + expression + "\" but found: {}");
-		new JsonPathExpectationsHelper(expression).assertValueIsNotEmpty(CONTENT);
+		assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
+				new JsonPathExpectationsHelper(expression).assertValueIsNotEmpty(CONTENT))
+			.withMessageContaining("Expected a non-empty value at JSON path \"" + expression + "\" but found: {}");
 	}
 
 	@Test
@@ -235,9 +229,9 @@ public class JsonPathExpectationsHelperTests {
 	@Test
 	public void hasJsonPathForIndefinatePathWithEmptyResults() {
 		String expression = "$.familyMembers[?(@.name == 'Dilbert')]";
-		exception.expect(AssertionError.class);
-		exception.expectMessage("No values for JSON path \"" + expression + "\"");
-		new JsonPathExpectationsHelper(expression).hasJsonPath(SIMPSONS);
+		assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
+				new JsonPathExpectationsHelper(expression).hasJsonPath(SIMPSONS))
+			.withMessageContaining("No values for JSON path \"" + expression + "\"");
 	}
 
 	@Test // SPR-16339
@@ -247,8 +241,8 @@ public class JsonPathExpectationsHelperTests {
 
 	@Test // SPR-16339
 	public void doesNotHaveJsonPathWithNull() {
-		exception.expect(AssertionError.class);
-		new JsonPathExpectationsHelper("$.abc").doesNotHaveJsonPath("{\"abc\": null}");
+		assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
+				new JsonPathExpectationsHelper("$.abc").doesNotHaveJsonPath("{\"abc\": null}"));
 	}
 
 	@Test
@@ -259,10 +253,9 @@ public class JsonPathExpectationsHelperTests {
 	@Test
 	public void doesNotHaveEmptyPathForIndefinatePathWithResults() {
 		String expression = "$.familyMembers[?(@.name == 'Bart')]";
-		exception.expect(AssertionError.class);
-		exception.expectMessage("Expected no values at JSON path \"" + expression + "\" " +
-				"but found: [{\"name\":\"Bart\"}]");
-		new JsonPathExpectationsHelper(expression).doesNotHaveJsonPath(SIMPSONS);
+		assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
+				new JsonPathExpectationsHelper(expression).doesNotHaveJsonPath(SIMPSONS))
+			.withMessageContaining("Expected no values at JSON path \"" + expression + "\" " + "but found: [{\"name\":\"Bart\"}]");
 	}
 
 	@Test
@@ -293,9 +286,9 @@ public class JsonPathExpectationsHelperTests {
 	@Test
 	public void assertValueIsStringForNonString() throws Exception {
 		String expression = "$.bool";
-		exception.expect(AssertionError.class);
-		exception.expectMessage("Expected a string at JSON path \"" + expression + "\" but found: true");
-		new JsonPathExpectationsHelper(expression).assertValueIsString(CONTENT);
+		assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
+				new JsonPathExpectationsHelper(expression).assertValueIsString(CONTENT))
+			.withMessageContaining("Expected a string at JSON path \"" + expression + "\" but found: true");
 	}
 
 	@Test
@@ -306,9 +299,9 @@ public class JsonPathExpectationsHelperTests {
 	@Test
 	public void assertValueIsNumberForNonNumber() throws Exception {
 		String expression = "$.bool";
-		exception.expect(AssertionError.class);
-		exception.expectMessage("Expected a number at JSON path \"" + expression + "\" but found: true");
-		new JsonPathExpectationsHelper(expression).assertValueIsNumber(CONTENT);
+		assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
+				new JsonPathExpectationsHelper(expression).assertValueIsNumber(CONTENT))
+			.withMessageContaining("Expected a number at JSON path \"" + expression + "\" but found: true");
 	}
 
 	@Test
@@ -319,9 +312,9 @@ public class JsonPathExpectationsHelperTests {
 	@Test
 	public void assertValueIsBooleanForNonBoolean() throws Exception {
 		String expression = "$.num";
-		exception.expect(AssertionError.class);
-		exception.expectMessage("Expected a boolean at JSON path \"" + expression + "\" but found: 5");
-		new JsonPathExpectationsHelper(expression).assertValueIsBoolean(CONTENT);
+		assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
+				new JsonPathExpectationsHelper(expression).assertValueIsBoolean(CONTENT))
+			.withMessageContaining("Expected a boolean at JSON path \"" + expression + "\" but found: 5");
 	}
 
 	@Test
@@ -337,9 +330,9 @@ public class JsonPathExpectationsHelperTests {
 	@Test
 	public void assertValueIsArrayForNonArray() throws Exception {
 		String expression = "$.str";
-		exception.expect(AssertionError.class);
-		exception.expectMessage("Expected an array at JSON path \"" + expression + "\" but found: 'foo'");
-		new JsonPathExpectationsHelper(expression).assertValueIsArray(CONTENT);
+		assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
+				new JsonPathExpectationsHelper(expression).assertValueIsArray(CONTENT))
+			.withMessageContaining("Expected an array at JSON path \"" + expression + "\" but found: 'foo'");
 	}
 
 	@Test
@@ -355,9 +348,9 @@ public class JsonPathExpectationsHelperTests {
 	@Test
 	public void assertValueIsMapForNonMap() throws Exception {
 		String expression = "$.str";
-		exception.expect(AssertionError.class);
-		exception.expectMessage("Expected a map at JSON path \"" + expression + "\" but found: 'foo'");
-		new JsonPathExpectationsHelper(expression).assertValueIsMap(CONTENT);
+		assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
+				new JsonPathExpectationsHelper(expression).assertValueIsMap(CONTENT))
+			.withMessageContaining("Expected a map at JSON path \"" + expression + "\" but found: 'foo'");
 	}
 
 }
diff --git a/spring-test/src/test/java/org/springframework/test/util/MetaAnnotationUtilsTests.java b/spring-test/src/test/java/org/springframework/test/util/MetaAnnotationUtilsTests.java
index 8a4853b64e5..e192d0ccfe5 100644
--- a/spring-test/src/test/java/org/springframework/test/util/MetaAnnotationUtilsTests.java
+++ b/spring-test/src/test/java/org/springframework/test/util/MetaAnnotationUtilsTests.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.
@@ -30,6 +30,8 @@ import org.springframework.core.annotation.Order;
 import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Service;
 import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.util.MetaAnnotationUtils.AnnotationDescriptor;
+import org.springframework.test.util.MetaAnnotationUtils.UntypedAnnotationDescriptor;
 import org.springframework.transaction.annotation.Transactional;
 
 import static org.junit.Assert.*;
diff --git a/spring-test/src/test/java/org/springframework/test/util/OverriddenMetaAnnotationAttributesTests.java b/spring-test/src/test/java/org/springframework/test/util/OverriddenMetaAnnotationAttributesTests.java
index 4765c1ed864..1e9c5150e49 100644
--- a/spring-test/src/test/java/org/springframework/test/util/OverriddenMetaAnnotationAttributesTests.java
+++ b/spring-test/src/test/java/org/springframework/test/util/OverriddenMetaAnnotationAttributesTests.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.
@@ -23,6 +23,7 @@ import org.junit.Test;
 
 import org.springframework.core.annotation.AnnotationAttributes;
 import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.util.MetaAnnotationUtils.AnnotationDescriptor;
 
 import static org.junit.Assert.*;
 import static org.springframework.test.util.MetaAnnotationUtils.*;
diff --git a/spring-test/src/test/java/org/springframework/test/util/ReflectionTestUtilsTests.java b/spring-test/src/test/java/org/springframework/test/util/ReflectionTestUtilsTests.java
index 82934530c5b..504c8b47efd 100644
--- a/spring-test/src/test/java/org/springframework/test/util/ReflectionTestUtilsTests.java
+++ b/spring-test/src/test/java/org/springframework/test/util/ReflectionTestUtilsTests.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,9 +18,7 @@ package org.springframework.test.util;
 
 import org.junit.Before;
 import org.junit.Ignore;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.aop.framework.ProxyFactory;
 import org.springframework.aop.support.AopUtils;
@@ -30,7 +28,7 @@ import org.springframework.test.util.subpackage.Person;
 import org.springframework.test.util.subpackage.PersonEntity;
 import org.springframework.test.util.subpackage.StaticFields;
 
-import static org.hamcrest.CoreMatchers.*;
+import static org.assertj.core.api.Assertions.*;
 import static org.junit.Assert.*;
 import static org.springframework.test.util.ReflectionTestUtils.*;
 
@@ -50,9 +48,6 @@ public class ReflectionTestUtilsTests {
 
 	private final LegacyEntity entity = new LegacyEntity();
 
-	@Rule
-	public final ExpectedException exception = ExpectedException.none();
-
 
 	@Before
 	public void resetStaticFields() {
@@ -61,51 +56,51 @@ public class ReflectionTestUtilsTests {
 
 	@Test
 	public void setFieldWithNullTargetObject() throws Exception {
-		exception.expect(IllegalArgumentException.class);
-		exception.expectMessage(startsWith("Either targetObject or targetClass"));
-		setField((Object) null, "id", Long.valueOf(99));
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				setField((Object) null, "id", Long.valueOf(99)))
+			.withMessageStartingWith("Either targetObject or targetClass");
 	}
 
 	@Test
 	public void getFieldWithNullTargetObject() throws Exception {
-		exception.expect(IllegalArgumentException.class);
-		exception.expectMessage(startsWith("Either targetObject or targetClass"));
-		getField((Object) null, "id");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				getField((Object) null, "id"))
+			.withMessageStartingWith("Either targetObject or targetClass");
 	}
 
 	@Test
 	public void setFieldWithNullTargetClass() throws Exception {
-		exception.expect(IllegalArgumentException.class);
-		exception.expectMessage(startsWith("Either targetObject or targetClass"));
-		setField((Class) null, "id", Long.valueOf(99));
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				setField((Class) null, "id", Long.valueOf(99)))
+			.withMessageStartingWith("Either targetObject or targetClass");
 	}
 
 	@Test
 	public void getFieldWithNullTargetClass() throws Exception {
-		exception.expect(IllegalArgumentException.class);
-		exception.expectMessage(startsWith("Either targetObject or targetClass"));
-		getField((Class) null, "id");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				getField((Class) null, "id"))
+			.withMessageStartingWith("Either targetObject or targetClass");
 	}
 
 	@Test
 	public void setFieldWithNullNameAndNullType() throws Exception {
-		exception.expect(IllegalArgumentException.class);
-		exception.expectMessage(startsWith("Either name or type"));
-		setField(person, null, Long.valueOf(99), null);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				setField(person, null, Long.valueOf(99), null))
+			.withMessageStartingWith("Either name or type");
 	}
 
 	@Test
 	public void setFieldWithBogusName() throws Exception {
-		exception.expect(IllegalArgumentException.class);
-		exception.expectMessage(startsWith("Could not find field 'bogus'"));
-		setField(person, "bogus", Long.valueOf(99), long.class);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				setField(person, "bogus", Long.valueOf(99), long.class))
+			.withMessageStartingWith("Could not find field 'bogus'");
 	}
 
 	@Test
 	public void setFieldWithWrongType() throws Exception {
-		exception.expect(IllegalArgumentException.class);
-		exception.expectMessage(startsWith("Could not find field"));
-		setField(person, "id", Long.valueOf(99), String.class);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				setField(person, "id", Long.valueOf(99), String.class))
+			.withMessageStartingWith("Could not find field");
 	}
 
 	@Test
@@ -363,30 +358,30 @@ public class ReflectionTestUtilsTests {
 
 	@Test
 	public void invokeInitMethodBeforeAutowiring() {
-		exception.expect(IllegalStateException.class);
-		exception.expectMessage(equalTo("number must not be null"));
-		invokeMethod(component, "init");
+		assertThatIllegalStateException().isThrownBy(() ->
+				invokeMethod(component, "init"))
+			.withMessageStartingWith("number must not be null");
 	}
 
 	@Test
 	public void invokeMethodWithIncompatibleArgumentTypes() {
-		exception.expect(IllegalStateException.class);
-		exception.expectMessage(startsWith("Method not found"));
-		invokeMethod(component, "subtract", "foo", 2.0);
+		assertThatIllegalStateException().isThrownBy(() ->
+				invokeMethod(component, "subtract", "foo", 2.0))
+		.withMessageStartingWith("Method not found");
 	}
 
 	@Test
 	public void invokeMethodWithTooFewArguments() {
-		exception.expect(IllegalStateException.class);
-		exception.expectMessage(startsWith("Method not found"));
-		invokeMethod(component, "configure", Integer.valueOf(42));
+		assertThatIllegalStateException().isThrownBy(() ->
+				invokeMethod(component, "configure", Integer.valueOf(42)))
+			.withMessageStartingWith("Method not found");
 	}
 
 	@Test
 	public void invokeMethodWithTooManyArguments() {
-		exception.expect(IllegalStateException.class);
-		exception.expectMessage(startsWith("Method not found"));
-		invokeMethod(component, "configure", Integer.valueOf(42), "enigma", "baz", "quux");
+		assertThatIllegalStateException().isThrownBy(() ->
+				invokeMethod(component, "configure", Integer.valueOf(42), "enigma", "baz", "quux"))
+			.withMessageStartingWith("Method not found");
 	}
 
 	@Test // SPR-14363
diff --git a/spring-test/src/test/java/org/springframework/test/util/XmlExpectationsHelperTests.java b/spring-test/src/test/java/org/springframework/test/util/XmlExpectationsHelperTests.java
index 8f4690edca7..e31d64a9cd5 100644
--- a/spring-test/src/test/java/org/springframework/test/util/XmlExpectationsHelperTests.java
+++ b/spring-test/src/test/java/org/springframework/test/util/XmlExpectationsHelperTests.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.
@@ -16,10 +16,9 @@
 
 package org.springframework.test.util;
 
-import org.hamcrest.Matchers;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
+
+import static org.assertj.core.api.Assertions.*;
 
 /**
  * Unit tests for {@link XmlExpectationsHelper}.
@@ -28,62 +27,52 @@ import org.junit.rules.ExpectedException;
  */
 public class XmlExpectationsHelperTests {
 
-	@Rule
-	public final ExpectedException exception = ExpectedException.none();
-
 
 	@Test
 	public void assertXmlEqualForEqual() throws Exception {
-		final String control = "f1f2";
-		final String test = "f1f2";
-
-		final XmlExpectationsHelper xmlHelper = new XmlExpectationsHelper();
+		String control = "f1f2";
+		String test = "f1f2";
+		XmlExpectationsHelper xmlHelper = new XmlExpectationsHelper();
 		xmlHelper.assertXmlEqual(control, test);
 	}
 
 	@Test
 	public void assertXmlEqualExceptionForIncorrectValue() throws Exception {
-		final String control = "f1f2";
-		final String test = "notf1f2";
-
-		exception.expect(AssertionError.class);
-		exception.expectMessage(Matchers.startsWith("Body content Expected child 'field1'"));
-
-		final XmlExpectationsHelper xmlHelper = new XmlExpectationsHelper();
-		xmlHelper.assertXmlEqual(control, test);
+		String control = "f1f2";
+		String test = "notf1f2";
+		XmlExpectationsHelper xmlHelper = new XmlExpectationsHelper();
+		assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
+				xmlHelper.assertXmlEqual(control, test))
+			.withMessageStartingWith("Body content Expected child 'field1'");
 	}
 
 	@Test
 	public void assertXmlEqualForOutOfOrder() throws Exception {
-		final String control = "f1f2";
-		final String test = "f2f1";
-
-		final XmlExpectationsHelper xmlHelper = new XmlExpectationsHelper();
+		String control = "f1f2";
+		String test = "f2f1";
+		XmlExpectationsHelper xmlHelper = new XmlExpectationsHelper();
 		xmlHelper.assertXmlEqual(control, test);
 	}
 
 	@Test
 	public void assertXmlEqualExceptionForMoreEntries() throws Exception {
-		final String control = "f1f2";
-		final String test = "f1f2f3";
+		String control = "f1f2";
+		String test = "f1f2f3";
+		XmlExpectationsHelper xmlHelper = new XmlExpectationsHelper();
+		assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
+				xmlHelper.assertXmlEqual(control, test))
+			.withMessageContaining("Expected child nodelist length '2' but was '3'");
 
-		exception.expect(AssertionError.class);
-		exception.expectMessage(Matchers.containsString("Expected child nodelist length '2' but was '3'"));
-
-		final XmlExpectationsHelper xmlHelper = new XmlExpectationsHelper();
-		xmlHelper.assertXmlEqual(control, test);
 	}
 
 	@Test
 	public void assertXmlEqualExceptionForLessEntries() throws Exception {
-		final String control = "f1f2f3";
-		final String test = "f1f2";
-
-		exception.expect(AssertionError.class);
-		exception.expectMessage(Matchers.containsString("Expected child nodelist length '3' but was '2'"));
-
-		final XmlExpectationsHelper xmlHelper = new XmlExpectationsHelper();
-		xmlHelper.assertXmlEqual(control, test);
+		String control = "f1f2f3";
+		String test = "f1f2";
+		XmlExpectationsHelper xmlHelper = new XmlExpectationsHelper();
+		assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
+				xmlHelper.assertXmlEqual(control, test))
+			.withMessageContaining("Expected child nodelist length '3' but was '2'");
 	}
 
 }
diff --git a/spring-test/src/test/java/org/springframework/test/web/client/DefaultRequestExpectationTests.java b/spring-test/src/test/java/org/springframework/test/web/client/DefaultRequestExpectationTests.java
index 002f31d4f5b..2de67c455f3 100644
--- a/spring-test/src/test/java/org/springframework/test/web/client/DefaultRequestExpectationTests.java
+++ b/spring-test/src/test/java/org/springframework/test/web/client/DefaultRequestExpectationTests.java
@@ -19,13 +19,12 @@ package org.springframework.test.web.client;
 import java.net.URI;
 import java.net.URISyntaxException;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.http.HttpMethod;
 import org.springframework.http.client.ClientHttpRequest;
 
+import static org.assertj.core.api.Assertions.*;
 import static org.junit.Assert.*;
 import static org.springframework.http.HttpMethod.*;
 import static org.springframework.test.web.client.ExpectedCount.*;
@@ -38,9 +37,6 @@ import static org.springframework.test.web.client.response.MockRestResponseCreat
  */
 public class DefaultRequestExpectationTests {
 
-	@Rule
-	public ExpectedException thrown = ExpectedException.none();
-
 
 	@Test
 	public void match() throws Exception {
@@ -52,9 +48,9 @@ public class DefaultRequestExpectationTests {
 	public void matchWithFailedExpectation() throws Exception {
 		RequestExpectation expectation = new DefaultRequestExpectation(once(), requestTo("/foo"));
 		expectation.andExpect(method(POST));
-
-		this.thrown.expectMessage("Unexpected HttpMethod expected: but was:");
-		expectation.match(createRequest(GET, "/foo"));
+		assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
+				expectation.match(createRequest(GET, "/foo")))
+			.withMessageContaining("Unexpected HttpMethod expected: but was:");
 	}
 
 	@Test
diff --git a/spring-test/src/test/java/org/springframework/test/web/client/SimpleRequestExpectationManagerTests.java b/spring-test/src/test/java/org/springframework/test/web/client/SimpleRequestExpectationManagerTests.java
index a27f42bc833..3caa68f50ea 100644
--- a/spring-test/src/test/java/org/springframework/test/web/client/SimpleRequestExpectationManagerTests.java
+++ b/spring-test/src/test/java/org/springframework/test/web/client/SimpleRequestExpectationManagerTests.java
@@ -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.
@@ -20,14 +20,13 @@ import java.net.SocketException;
 import java.net.URI;
 import java.net.URISyntaxException;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.http.HttpMethod;
 import org.springframework.http.client.ClientHttpRequest;
 import org.springframework.mock.http.client.MockClientHttpRequest;
 
+import static org.assertj.core.api.Assertions.*;
 import static org.junit.Assert.*;
 import static org.springframework.http.HttpMethod.*;
 import static org.springframework.test.web.client.ExpectedCount.*;
@@ -43,9 +42,6 @@ public class SimpleRequestExpectationManagerTests {
 
 	private final SimpleRequestExpectationManager manager = new SimpleRequestExpectationManager();
 
-	@Rule
-	public ExpectedException thrown = ExpectedException.none();
-
 
 	@Test
 	public void unexpectedRequest() throws Exception {
@@ -77,27 +73,25 @@ public class SimpleRequestExpectationManagerTests {
 	public void sequentialRequestsTooMany() throws Exception {
 		this.manager.expectRequest(max(1), requestTo("/foo")).andExpect(method(GET)).andRespond(withSuccess());
 		this.manager.expectRequest(max(1), requestTo("/bar")).andExpect(method(GET)).andRespond(withSuccess());
-
-		this.thrown.expectMessage("No further requests expected: HTTP GET /baz\n" +
-				"2 request(s) executed:\n" +
-				"GET /foo\n" +
-				"GET /bar\n");
-
 		this.manager.validateRequest(createRequest(GET, "/foo"));
 		this.manager.validateRequest(createRequest(GET, "/bar"));
-		this.manager.validateRequest(createRequest(GET, "/baz"));
+		assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
+				this.manager.validateRequest(createRequest(GET, "/baz")))
+			.withMessage("No further requests expected: HTTP GET /baz\n" +
+					"2 request(s) executed:\n" +
+					"GET /foo\n" +
+					"GET /bar\n");
 	}
 
 	@Test
 	public void sequentialRequestsTooFew() throws Exception {
 		this.manager.expectRequest(min(1), requestTo("/foo")).andExpect(method(GET)).andRespond(withSuccess());
 		this.manager.expectRequest(min(1), requestTo("/bar")).andExpect(method(GET)).andRespond(withSuccess());
-
-		this.thrown.expectMessage("Further request(s) expected leaving 1 unsatisfied expectation(s).\n" +
-				"1 request(s) executed:\nGET /foo\n");
-
 		this.manager.validateRequest(createRequest(GET, "/foo"));
-		this.manager.verify();
+		assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
+				this.manager.verify())
+			.withMessage("Further request(s) expected leaving 1 unsatisfied expectation(s).\n" +
+				"1 request(s) executed:\nGET /foo\n");
 	}
 
 	@Test
@@ -118,35 +112,33 @@ public class SimpleRequestExpectationManagerTests {
 	public void repeatedRequestsTooMany() throws Exception {
 		this.manager.expectRequest(max(2), requestTo("/foo")).andExpect(method(GET)).andRespond(withSuccess());
 		this.manager.expectRequest(max(2), requestTo("/bar")).andExpect(method(GET)).andRespond(withSuccess());
-
-		this.thrown.expectMessage("No further requests expected: HTTP GET /foo\n" +
-				"4 request(s) executed:\n" +
-				"GET /foo\n" +
-				"GET /bar\n" +
-				"GET /foo\n" +
-				"GET /bar\n");
-
 		this.manager.validateRequest(createRequest(GET, "/foo"));
 		this.manager.validateRequest(createRequest(GET, "/bar"));
 		this.manager.validateRequest(createRequest(GET, "/foo"));
 		this.manager.validateRequest(createRequest(GET, "/bar"));
-		this.manager.validateRequest(createRequest(GET, "/foo"));
+		assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
+				this.manager.validateRequest(createRequest(GET, "/foo")))
+			.withMessage("No further requests expected: HTTP GET /foo\n" +
+					"4 request(s) executed:\n" +
+					"GET /foo\n" +
+					"GET /bar\n" +
+					"GET /foo\n" +
+					"GET /bar\n");
 	}
 
 	@Test
 	public void repeatedRequestsTooFew() throws Exception {
 		this.manager.expectRequest(min(2), requestTo("/foo")).andExpect(method(GET)).andRespond(withSuccess());
 		this.manager.expectRequest(min(2), requestTo("/bar")).andExpect(method(GET)).andRespond(withSuccess());
-
-		this.thrown.expectMessage("3 request(s) executed:\n" +
-				"GET /foo\n" +
-				"GET /bar\n" +
-				"GET /foo\n");
-
 		this.manager.validateRequest(createRequest(GET, "/foo"));
 		this.manager.validateRequest(createRequest(GET, "/bar"));
 		this.manager.validateRequest(createRequest(GET, "/foo"));
-		this.manager.verify();
+		assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
+				this.manager.verify())
+			.withMessageContaining("3 request(s) executed:\n" +
+				"GET /foo\n" +
+				"GET /bar\n" +
+				"GET /foo\n");
 	}
 
 	@Test
@@ -154,9 +146,9 @@ public class SimpleRequestExpectationManagerTests {
 		this.manager.expectRequest(twice(), requestTo("/foo")).andExpect(method(GET)).andRespond(withSuccess());
 		this.manager.expectRequest(twice(), requestTo("/bar")).andExpect(method(GET)).andRespond(withSuccess());
 		this.manager.expectRequest(twice(), requestTo("/baz")).andExpect(method(GET)).andRespond(withSuccess());
-
-		this.thrown.expectMessage("Unexpected HttpMethod expected: but was:");
-		this.manager.validateRequest(createRequest(POST, "/foo"));
+		assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
+				this.manager.validateRequest(createRequest(POST, "/foo")))
+			.withMessage("Unexpected HttpMethod expected: but was:");
 	}
 
 	@Test  // SPR-15672
@@ -186,14 +178,8 @@ public class SimpleRequestExpectationManagerTests {
 				andExpect(method(GET)).andRespond(request -> { throw new SocketException("pseudo network error"); });
 		this.manager.expectRequest(once(), requestTo("/handle-error")).
 				andExpect(method(POST)).andRespond(withSuccess());
-
-		try {
-			this.manager.validateRequest(createRequest(GET, "/foo"));
-			fail("Expected SocketException");
-		}
-		catch (SocketException ex) {
-			// expected
-		}
+		assertThatExceptionOfType(SocketException.class).isThrownBy(() ->
+				this.manager.validateRequest(createRequest(GET, "/foo")));
 		this.manager.validateRequest(createRequest(POST, "/handle-error"));
 		this.manager.verify();
 	}
diff --git a/spring-test/src/test/java/org/springframework/test/web/client/UnorderedRequestExpectationManagerTests.java b/spring-test/src/test/java/org/springframework/test/web/client/UnorderedRequestExpectationManagerTests.java
index 60619db3917..661eff1b119 100644
--- a/spring-test/src/test/java/org/springframework/test/web/client/UnorderedRequestExpectationManagerTests.java
+++ b/spring-test/src/test/java/org/springframework/test/web/client/UnorderedRequestExpectationManagerTests.java
@@ -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.
@@ -19,13 +19,12 @@ package org.springframework.test.web.client;
 import java.net.URI;
 import java.net.URISyntaxException;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.http.HttpMethod;
 import org.springframework.http.client.ClientHttpRequest;
 
+import static org.assertj.core.api.Assertions.*;
 import static org.junit.Assert.*;
 import static org.springframework.http.HttpMethod.*;
 import static org.springframework.test.web.client.ExpectedCount.*;
@@ -41,9 +40,6 @@ public class UnorderedRequestExpectationManagerTests {
 
 	private UnorderedRequestExpectationManager manager = new UnorderedRequestExpectationManager();
 
-	@Rule
-	public ExpectedException thrown = ExpectedException.none();
-
 
 	@Test
 	public void unexpectedRequest() throws Exception {
@@ -87,35 +83,33 @@ public class UnorderedRequestExpectationManagerTests {
 	public void repeatedRequestsTooMany() throws Exception {
 		this.manager.expectRequest(max(2), requestTo("/foo")).andExpect(method(GET)).andRespond(withSuccess());
 		this.manager.expectRequest(max(2), requestTo("/bar")).andExpect(method(GET)).andRespond(withSuccess());
-
-		this.thrown.expectMessage("No further requests expected: HTTP GET /foo\n" +
+		this.manager.validateRequest(createRequest(GET, "/bar"));
+		this.manager.validateRequest(createRequest(GET, "/foo"));
+		this.manager.validateRequest(createRequest(GET, "/bar"));
+		this.manager.validateRequest(createRequest(GET, "/foo"));
+		assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
+				this.manager.validateRequest(createRequest(GET, "/foo")))
+			.withMessage("No further requests expected: HTTP GET /foo\n" +
 				"4 request(s) executed:\n" +
 				"GET /bar\n" +
 				"GET /foo\n" +
 				"GET /bar\n" +
 				"GET /foo\n");
-
-		this.manager.validateRequest(createRequest(GET, "/bar"));
-		this.manager.validateRequest(createRequest(GET, "/foo"));
-		this.manager.validateRequest(createRequest(GET, "/bar"));
-		this.manager.validateRequest(createRequest(GET, "/foo"));
-		this.manager.validateRequest(createRequest(GET, "/foo"));
 	}
 
 	@Test
 	public void repeatedRequestsTooFew() throws Exception {
 		this.manager.expectRequest(min(2), requestTo("/foo")).andExpect(method(GET)).andRespond(withSuccess());
 		this.manager.expectRequest(min(2), requestTo("/bar")).andExpect(method(GET)).andRespond(withSuccess());
-
-		this.thrown.expectMessage("3 request(s) executed:\n" +
-				"GET /bar\n" +
-				"GET /foo\n" +
-				"GET /foo\n");
-
 		this.manager.validateRequest(createRequest(GET, "/bar"));
 		this.manager.validateRequest(createRequest(GET, "/foo"));
 		this.manager.validateRequest(createRequest(GET, "/foo"));
-		this.manager.verify();
+		assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
+				this.manager.verify())
+			.withMessageContaining("3 request(s) executed:\n" +
+				"GET /bar\n" +
+				"GET /foo\n" +
+				"GET /foo\n");
 	}
 
 
diff --git a/spring-test/src/test/java/org/springframework/test/web/client/match/MockRestRequestMatchersTests.java b/spring-test/src/test/java/org/springframework/test/web/client/match/MockRestRequestMatchersTests.java
index 4f2d584f7b2..38532220e29 100644
--- a/spring-test/src/test/java/org/springframework/test/web/client/match/MockRestRequestMatchersTests.java
+++ b/spring-test/src/test/java/org/springframework/test/web/client/match/MockRestRequestMatchersTests.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.
@@ -25,9 +25,9 @@ import org.junit.Test;
 import org.springframework.http.HttpMethod;
 import org.springframework.mock.http.client.MockClientHttpRequest;
 
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.containsString;
-import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.hamcrest.MatcherAssert.*;
+import static org.hamcrest.Matchers.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 /**
  * Unit tests for {@link MockRestRequestMatchers}.
diff --git a/spring-test/src/test/java/org/springframework/test/web/client/samples/MockMvcClientHttpRequestFactoryTests.java b/spring-test/src/test/java/org/springframework/test/web/client/samples/MockMvcClientHttpRequestFactoryTests.java
index db2e299a2ae..011187a3856 100644
--- a/spring-test/src/test/java/org/springframework/test/web/client/samples/MockMvcClientHttpRequestFactoryTests.java
+++ b/spring-test/src/test/java/org/springframework/test/web/client/samples/MockMvcClientHttpRequestFactoryTests.java
@@ -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.
@@ -40,8 +40,8 @@ import org.springframework.web.context.WebApplicationContext;
 import org.springframework.web.servlet.config.annotation.EnableWebMvc;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 
-import static org.junit.Assert.assertEquals;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+import static org.junit.Assert.*;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
 
 /**
  * Tests that use a {@link RestTemplate} configured with a
diff --git a/spring-test/src/test/java/org/springframework/test/web/client/samples/SampleAsyncTests.java b/spring-test/src/test/java/org/springframework/test/web/client/samples/SampleAsyncTests.java
index 78c93cc1f9e..ffc3662a686 100644
--- a/spring-test/src/test/java/org/springframework/test/web/client/samples/SampleAsyncTests.java
+++ b/spring-test/src/test/java/org/springframework/test/web/client/samples/SampleAsyncTests.java
@@ -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.
@@ -28,7 +28,7 @@ import org.springframework.test.web.client.MockRestServiceServer;
 import org.springframework.util.concurrent.ListenableFuture;
 
 import static org.junit.Assert.*;
-import static org.springframework.test.web.client.ExpectedCount.manyTimes;
+import static org.springframework.test.web.client.ExpectedCount.*;
 import static org.springframework.test.web.client.match.MockRestRequestMatchers.*;
 import static org.springframework.test.web.client.response.MockRestResponseCreators.*;
 
diff --git a/spring-test/src/test/java/org/springframework/test/web/client/samples/SampleTests.java b/spring-test/src/test/java/org/springframework/test/web/client/samples/SampleTests.java
index 32d955eb9a4..feb5fe91955 100644
--- a/spring-test/src/test/java/org/springframework/test/web/client/samples/SampleTests.java
+++ b/spring-test/src/test/java/org/springframework/test/web/client/samples/SampleTests.java
@@ -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.
@@ -35,12 +35,9 @@ import org.springframework.util.FileCopyUtils;
 import org.springframework.web.client.RestTemplate;
 
 import static org.junit.Assert.*;
-import static org.springframework.test.web.client.ExpectedCount.manyTimes;
-import static org.springframework.test.web.client.ExpectedCount.never;
-import static org.springframework.test.web.client.ExpectedCount.once;
-import static org.springframework.test.web.client.match.MockRestRequestMatchers.method;
-import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
-import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess;
+import static org.springframework.test.web.client.ExpectedCount.*;
+import static org.springframework.test.web.client.match.MockRestRequestMatchers.*;
+import static org.springframework.test.web.client.response.MockRestResponseCreators.*;
 
 /**
  * Examples to demonstrate writing client-side REST tests with Spring MVC Test.
diff --git a/spring-test/src/test/java/org/springframework/test/web/reactive/server/HttpHandlerConnectorTests.java b/spring-test/src/test/java/org/springframework/test/web/reactive/server/HttpHandlerConnectorTests.java
index dd687157d4d..ca9846721c9 100644
--- a/spring-test/src/test/java/org/springframework/test/web/reactive/server/HttpHandlerConnectorTests.java
+++ b/spring-test/src/test/java/org/springframework/test/web/reactive/server/HttpHandlerConnectorTests.java
@@ -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.
@@ -40,8 +40,8 @@ import org.springframework.http.server.reactive.ServerHttpRequest;
 import org.springframework.http.server.reactive.ServerHttpResponse;
 import org.springframework.mock.http.server.reactive.MockServerHttpRequest;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
-import static org.junit.Assert.assertEquals;
+import static java.nio.charset.StandardCharsets.*;
+import static org.junit.Assert.*;
 
 /**
  * Unit tests for {@link HttpHandlerConnector}.
diff --git a/spring-test/src/test/java/org/springframework/test/web/reactive/server/WiretapConnectorTests.java b/spring-test/src/test/java/org/springframework/test/web/reactive/server/WiretapConnectorTests.java
index 5c84c1db87a..a50ff0785e4 100644
--- a/spring-test/src/test/java/org/springframework/test/web/reactive/server/WiretapConnectorTests.java
+++ b/spring-test/src/test/java/org/springframework/test/web/reactive/server/WiretapConnectorTests.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.
@@ -33,7 +33,7 @@ import org.springframework.web.reactive.function.client.ClientRequest;
 import org.springframework.web.reactive.function.client.ExchangeFunction;
 import org.springframework.web.reactive.function.client.ExchangeFunctions;
 
-import static java.time.Duration.ofMillis;
+import static java.time.Duration.*;
 import static org.junit.Assert.*;
 
 /**
diff --git a/spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/ResponseEntityTests.java b/spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/ResponseEntityTests.java
index 4744f8662eb..7e22090e899 100644
--- a/spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/ResponseEntityTests.java
+++ b/spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/ResponseEntityTests.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.
@@ -107,9 +107,9 @@ public class ResponseEntityTests {
 				.exchange()
 				.expectStatus().isOk()
 				.expectHeader().contentType(MediaType.APPLICATION_JSON)
-				.expectBodyList(Person.class).value(people -> {
-					MatcherAssert.assertThat(people, hasItem(new Person("Jason")));
-				});
+				.expectBodyList(Person.class).value(people ->
+					MatcherAssert.assertThat(people, hasItem(new Person("Jason")))
+				);
 	}
 
 	@Test
diff --git a/spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/XmlContentTests.java b/spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/XmlContentTests.java
index 11e30058308..4f0728eafd7 100644
--- a/spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/XmlContentTests.java
+++ b/spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/XmlContentTests.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.
@@ -167,4 +167,4 @@ public class XmlContentTests {
 		}
 	}
 
-}
\ No newline at end of file
+}
diff --git a/spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/bind/RouterFunctionTests.java b/spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/bind/RouterFunctionTests.java
index 32f4f1e770f..6b685617460 100644
--- a/spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/bind/RouterFunctionTests.java
+++ b/spring-test/src/test/java/org/springframework/test/web/reactive/server/samples/bind/RouterFunctionTests.java
@@ -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.
@@ -23,8 +23,8 @@ import org.springframework.test.web.reactive.server.WebTestClient;
 import org.springframework.web.reactive.function.server.RouterFunction;
 import org.springframework.web.reactive.function.server.ServerResponse;
 
-import static org.springframework.web.reactive.function.server.RequestPredicates.GET;
-import static org.springframework.web.reactive.function.server.RouterFunctions.route;
+import static org.springframework.web.reactive.function.server.RequestPredicates.*;
+import static org.springframework.web.reactive.function.server.RouterFunctions.*;
 
 /**
  * Sample tests demonstrating "mock" server tests binding to a RouterFunction.
diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/MockMvcReuseTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/MockMvcReuseTests.java
index 30d36f948dc..1f20c2f1f94 100644
--- a/spring-test/src/test/java/org/springframework/test/web/servlet/MockMvcReuseTests.java
+++ b/spring-test/src/test/java/org/springframework/test/web/servlet/MockMvcReuseTests.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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.
@@ -34,6 +34,7 @@ import org.springframework.web.servlet.config.annotation.EnableWebMvc;
 import static org.hamcrest.CoreMatchers.*;
 import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
 import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.request;
 import static org.springframework.test.web.servlet.setup.MockMvcBuilders.*;
 
 /**
diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/DelegatingWebConnectionTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/DelegatingWebConnectionTests.java
index 81ce961eb97..15f4ec82039 100644
--- a/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/DelegatingWebConnectionTests.java
+++ b/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/DelegatingWebConnectionTests.java
@@ -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.
@@ -41,7 +41,7 @@ import org.springframework.tests.TestGroup;
 
 import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.CoreMatchers.sameInstance;
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.MatcherAssert.*;
 import static org.hamcrest.Matchers.*;
 import static org.hamcrest.core.IsNot.not;
 import static org.mockito.Mockito.*;
diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/HtmlUnitRequestBuilderTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/HtmlUnitRequestBuilderTests.java
index d8441b9ac15..da23341bf5a 100644
--- a/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/HtmlUnitRequestBuilderTests.java
+++ b/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/HtmlUnitRequestBuilderTests.java
@@ -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.
@@ -45,16 +45,10 @@ import org.springframework.test.util.ReflectionTestUtils;
 import org.springframework.test.web.servlet.MockMvc;
 import org.springframework.test.web.servlet.setup.MockMvcBuilders;
 
-import static java.util.Arrays.asList;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.contains;
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.isEmptyString;
-import static org.hamcrest.Matchers.not;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.hamcrest.Matchers.nullValue;
-import static org.hamcrest.Matchers.sameInstance;
-import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
+import static java.util.Arrays.*;
+import static org.hamcrest.MatcherAssert.*;
+import static org.hamcrest.Matchers.*;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
 
 /**
  * Unit tests for {@link HtmlUnitRequestBuilder}.
diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/MockMvcConnectionBuilderSupportTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/MockMvcConnectionBuilderSupportTests.java
index b20b5231cf0..740af68f3cd 100644
--- a/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/MockMvcConnectionBuilderSupportTests.java
+++ b/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/MockMvcConnectionBuilderSupportTests.java
@@ -24,7 +24,6 @@ import com.gargoylesoftware.htmlunit.WebClient;
 import com.gargoylesoftware.htmlunit.WebConnection;
 import com.gargoylesoftware.htmlunit.WebRequest;
 import com.gargoylesoftware.htmlunit.WebResponse;
-
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -43,10 +42,9 @@ import org.springframework.web.servlet.config.annotation.EnableWebMvc;
 
 import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.CoreMatchers.nullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.MatcherAssert.*;
 import static org.hamcrest.Matchers.notNullValue;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.*;
 
 /**
  * Integration tests for {@link MockMvcWebConnectionBuilderSupport}.
diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/MockMvcWebClientBuilderTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/MockMvcWebClientBuilderTests.java
index 7360375b89e..b3c7896a0cd 100644
--- a/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/MockMvcWebClientBuilderTests.java
+++ b/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/MockMvcWebClientBuilderTests.java
@@ -49,7 +49,7 @@ import org.springframework.web.context.WebApplicationContext;
 import org.springframework.web.servlet.config.annotation.EnableWebMvc;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.MatcherAssert.*;
 
 /**
  * Integration tests for {@link MockMvcWebClientBuilder}.
diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/MockWebResponseBuilderTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/MockWebResponseBuilderTests.java
index 63eb0567154..231eaac696a 100644
--- a/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/MockWebResponseBuilderTests.java
+++ b/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/MockWebResponseBuilderTests.java
@@ -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.
@@ -30,7 +30,7 @@ import org.junit.Test;
 import org.springframework.mock.web.MockHttpServletResponse;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.MatcherAssert.*;
 
 /**
  * Tests for {@link MockWebResponseBuilder}.
diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/webdriver/WebConnectionHtmlUnitDriverTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/webdriver/WebConnectionHtmlUnitDriverTests.java
index c86bc86f99f..5875f014d02 100644
--- a/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/webdriver/WebConnectionHtmlUnitDriverTests.java
+++ b/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/webdriver/WebConnectionHtmlUnitDriverTests.java
@@ -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.
@@ -21,17 +21,18 @@ import java.io.IOException;
 import com.gargoylesoftware.htmlunit.WebConnection;
 import com.gargoylesoftware.htmlunit.WebRequest;
 import org.junit.Before;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.junit.MockitoJUnitRunner;
 import org.openqa.selenium.WebDriverException;
 
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
+import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
 import static org.hamcrest.CoreMatchers.equalTo;
 import static org.hamcrest.MatcherAssert.*;
 import static org.hamcrest.Matchers.notNullValue;
+import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.*;
 
 /**
@@ -49,9 +50,6 @@ public class WebConnectionHtmlUnitDriverTests {
 	@Mock
 	private WebConnection connection;
 
-	@Rule
-	public ExpectedException exception = ExpectedException.none();
-
 	@Before
 	public void setup() throws Exception {
 		when(this.connection.getResponse(any(WebRequest.class))).thenThrow(new IOException(""));
@@ -65,17 +63,16 @@ public class WebConnectionHtmlUnitDriverTests {
 
 	@Test
 	public void setWebConnectionToNull() {
-		this.exception.expect(IllegalArgumentException.class);
-		this.driver.setWebConnection(null);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				this.driver.setWebConnection(null));
 	}
 
 	@Test
 	public void setWebConnection() {
 		this.driver.setWebConnection(this.connection);
 		assertThat(this.driver.getWebConnection(), equalTo(this.connection));
-
-		this.exception.expect(WebDriverException.class);
-		this.driver.get("https://example.com");
+		assertThatExceptionOfType(WebDriverException.class).isThrownBy(() ->
+				this.driver.get("https://example.com"));
 	}
 
 }
diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/result/JsonPathResultMatchersTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/result/JsonPathResultMatchersTests.java
index b6f8c37e497..aa4f9150161 100644
--- a/spring-test/src/test/java/org/springframework/test/web/servlet/result/JsonPathResultMatchersTests.java
+++ b/spring-test/src/test/java/org/springframework/test/web/servlet/result/JsonPathResultMatchersTests.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.
@@ -17,7 +17,6 @@
 package org.springframework.test.web.servlet.result;
 
 import org.hamcrest.Matchers;
-
 import org.junit.Test;
 
 import org.springframework.mock.web.MockHttpServletResponse;
diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/context/AsyncControllerJavaConfigTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/context/AsyncControllerJavaConfigTests.java
index 98aae70d15c..211df77e455 100644
--- a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/context/AsyncControllerJavaConfigTests.java
+++ b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/context/AsyncControllerJavaConfigTests.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.
@@ -44,12 +44,10 @@ import org.springframework.web.servlet.config.annotation.AsyncSupportConfigurer;
 import org.springframework.web.servlet.config.annotation.EnableWebMvc;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 
-import static org.mockito.ArgumentMatchers.any;
-import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.asyncDispatch;
-import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
+import static org.mockito.ArgumentMatchers.*;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
 import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.request;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
 
 /**
  * Tests with Java configuration.
diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/context/JavaConfigTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/context/JavaConfigTests.java
index 90c016cf453..7b37d428ff9 100644
--- a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/context/JavaConfigTests.java
+++ b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/context/JavaConfigTests.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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.
@@ -46,15 +46,11 @@ import org.springframework.web.servlet.config.annotation.ViewResolverRegistry;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 import org.springframework.web.servlet.view.tiles3.TilesConfigurer;
 
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.BDDMockito.given;
-import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
-import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.forwardedUrl;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+import static org.junit.Assert.*;
+import static org.mockito.BDDMockito.*;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
+import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.*;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
 
 /**
  * Tests with Java configuration.
diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/context/WebAppResourceTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/context/WebAppResourceTests.java
index fbb1b1bc4f6..87354da764f 100644
--- a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/context/WebAppResourceTests.java
+++ b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/context/WebAppResourceTests.java
@@ -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.
@@ -30,12 +30,9 @@ import org.springframework.test.web.servlet.setup.MockMvcBuilders;
 import org.springframework.web.context.WebApplicationContext;
 import org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler;
 
-import static org.hamcrest.Matchers.containsString;
-import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.forwardedUrl;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.handler;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+import static org.hamcrest.Matchers.*;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
 
 /**
  * Tests dependent on access to resources under the web application root directory.
diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/spr/CustomRequestAttributesRequestContextHolderTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/spr/CustomRequestAttributesRequestContextHolderTests.java
index 6519ef6ce46..c7a880b9b0d 100644
--- a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/spr/CustomRequestAttributesRequestContextHolderTests.java
+++ b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/spr/CustomRequestAttributesRequestContextHolderTests.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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.
@@ -41,13 +41,11 @@ import org.springframework.web.context.support.GenericWebApplicationContext;
 import org.springframework.web.servlet.config.annotation.EnableWebMvc;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.nullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
-import static org.springframework.test.web.servlet.setup.MockMvcBuilders.webAppContextSetup;
+import static org.hamcrest.CoreMatchers.*;
+import static org.hamcrest.MatcherAssert.*;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
+import static org.springframework.test.web.servlet.setup.MockMvcBuilders.*;
 
 /**
  * Integration tests for SPR-13211 which verify that a custom mock request
diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/spr/EncodedUriTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/spr/EncodedUriTests.java
index 2059d3285fd..92918412211 100644
--- a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/spr/EncodedUriTests.java
+++ b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/spr/EncodedUriTests.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.
@@ -47,11 +47,10 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
 import org.springframework.web.util.UriComponentsBuilder;
 
-import static org.hamcrest.core.Is.is;
-import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.model;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
-import static org.springframework.test.web.servlet.setup.MockMvcBuilders.webAppContextSetup;
+import static org.hamcrest.core.Is.*;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
+import static org.springframework.test.web.servlet.setup.MockMvcBuilders.*;
 
 /**
  * Tests for SPR-11441 (MockMvc accepts an already encoded URI).
diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/spr/HttpOptionsTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/spr/HttpOptionsTests.java
index c4fef7c1de8..d2e8a2edced 100644
--- a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/spr/HttpOptionsTests.java
+++ b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/spr/HttpOptionsTests.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.
@@ -37,10 +37,10 @@ import org.springframework.web.context.WebApplicationContext;
 import org.springframework.web.servlet.config.annotation.EnableWebMvc;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 
-import static org.junit.Assert.assertEquals;
-import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.options;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
-import static org.springframework.test.web.servlet.setup.MockMvcBuilders.webAppContextSetup;
+import static org.junit.Assert.*;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
+import static org.springframework.test.web.servlet.setup.MockMvcBuilders.*;
 
 /**
  * Tests for SPR-10093 (support for OPTIONS requests).
diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/spr/MockMvcBuilderMethodChainTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/spr/MockMvcBuilderMethodChainTests.java
index d40ebaf7858..1a1dfb37af1 100644
--- a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/spr/MockMvcBuilderMethodChainTests.java
+++ b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/spr/MockMvcBuilderMethodChainTests.java
@@ -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.
@@ -30,7 +30,7 @@ import org.springframework.web.filter.CharacterEncodingFilter;
 import org.springframework.web.servlet.config.annotation.EnableWebMvc;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 
-import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
 
 /**
  * Test for SPR-10277 (multiple method chaining when building MockMvc).
diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/AsyncTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/AsyncTests.java
index 4eb0f31e515..bd21c5574cb 100644
--- a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/AsyncTests.java
+++ b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/AsyncTests.java
@@ -44,6 +44,7 @@ import static org.junit.Assert.*;
 import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
 import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.*;
 import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.request;
 import static org.springframework.test.web.servlet.setup.MockMvcBuilders.*;
 
 /**
diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/FilterTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/FilterTests.java
index cc0f2f5906b..63f203550d8 100644
--- a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/FilterTests.java
+++ b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/FilterTests.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.
@@ -49,17 +49,10 @@ import org.springframework.web.filter.ShallowEtagHeaderFilter;
 import org.springframework.web.servlet.ModelAndView;
 import org.springframework.web.servlet.mvc.support.RedirectAttributes;
 
-import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.asyncDispatch;
-import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
-import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.flash;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.model;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.redirectedUrl;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
 import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.request;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
-import static org.springframework.test.web.servlet.setup.MockMvcBuilders.standaloneSetup;
+import static org.springframework.test.web.servlet.setup.MockMvcBuilders.*;
 
 /**
  * Tests with {@link Filter}'s.
diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resulthandlers/PrintingResultHandlerSmokeTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resulthandlers/PrintingResultHandlerSmokeTests.java
index d70874cbd3d..134d9640098 100644
--- a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resulthandlers/PrintingResultHandlerSmokeTests.java
+++ b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resulthandlers/PrintingResultHandlerSmokeTests.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.
@@ -17,7 +17,6 @@
 package org.springframework.test.web.servlet.samples.standalone.resulthandlers;
 
 import java.io.StringWriter;
-
 import javax.servlet.http.Cookie;
 import javax.servlet.http.HttpServletResponse;
 
diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resultmatchers/HandlerAssertionTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resultmatchers/HandlerAssertionTests.java
index fb312376084..e5188ff973f 100644
--- a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resultmatchers/HandlerAssertionTests.java
+++ b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resultmatchers/HandlerAssertionTests.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.
@@ -18,9 +18,7 @@ package org.springframework.test.web.servlet.samples.standalone.resultmatchers;
 
 import java.lang.reflect.Method;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.http.ResponseEntity;
 import org.springframework.test.web.servlet.MockMvc;
@@ -28,14 +26,12 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.servlet.mvc.method.annotation.MvcUriComponentsBuilder;
 
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.not;
-import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.handler;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
-import static org.springframework.test.web.servlet.setup.MockMvcBuilders.standaloneSetup;
-import static org.springframework.web.servlet.mvc.method.annotation.MvcUriComponentsBuilder.on;
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
+import static org.hamcrest.Matchers.*;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
+import static org.springframework.test.web.servlet.setup.MockMvcBuilders.*;
+import static org.springframework.web.servlet.mvc.method.annotation.MvcUriComponentsBuilder.*;
 
 /**
  * Examples of expectations on the controller type and controller method.
@@ -47,9 +43,6 @@ public class HandlerAssertionTests {
 
 	private final MockMvc mockMvc = standaloneSetup(new SimpleController()).alwaysExpect(status().isOk()).build();
 
-	@Rule
-	public final ExpectedException exception = ExpectedException.none();
-
 
 	@Test
 	public void handlerType() throws Exception {
@@ -58,12 +51,11 @@ public class HandlerAssertionTests {
 
 	@Test
 	public void methodCallOnNonMock() throws Exception {
-		exception.expect(AssertionError.class);
-		exception.expectMessage("The supplied object [bogus] is not an instance of");
-		exception.expectMessage(MvcUriComponentsBuilder.MethodInvocationInfo.class.getName());
-		exception.expectMessage("Ensure that you invoke the handler method via MvcUriComponentsBuilder.on()");
-
-		this.mockMvc.perform(get("/")).andExpect(handler().methodCall("bogus"));
+		assertThatExceptionOfType(AssertionError.class).isThrownBy(() ->
+				this.mockMvc.perform(get("/")).andExpect(handler().methodCall("bogus")))
+			.withMessageContaining("The supplied object [bogus] is not an instance of")
+			.withMessageContaining(MvcUriComponentsBuilder.MethodInvocationInfo.class.getName())
+			.withMessageContaining("Ensure that you invoke the handler method via MvcUriComponentsBuilder.on()");
 	}
 
 	@Test
diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resultmatchers/SessionAttributeAssertionTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resultmatchers/SessionAttributeAssertionTests.java
index 291b2faa14e..6f7dee123c9 100644
--- a/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resultmatchers/SessionAttributeAssertionTests.java
+++ b/spring-test/src/test/java/org/springframework/test/web/servlet/samples/standalone/resultmatchers/SessionAttributeAssertionTests.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2012 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.
@@ -30,8 +30,8 @@ import org.springframework.web.bind.annotation.SessionAttributes;
 
 import static org.hamcrest.Matchers.*;
 import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.request;
 import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.request;
 import static org.springframework.test.web.servlet.setup.MockMvcBuilders.*;
 
 /**
diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/setup/DefaultMockMvcBuilderTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/setup/DefaultMockMvcBuilderTests.java
index 88f70e676d2..1b8d7577685 100644
--- a/spring-test/src/test/java/org/springframework/test/web/servlet/setup/DefaultMockMvcBuilderTests.java
+++ b/spring-test/src/test/java/org/springframework/test/web/servlet/setup/DefaultMockMvcBuilderTests.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,9 +16,7 @@
 
 package org.springframework.test.web.servlet.setup;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.beans.DirectFieldAccessor;
 import org.springframework.context.support.StaticApplicationContext;
@@ -29,7 +27,7 @@ import org.springframework.web.context.support.StaticWebApplicationContext;
 import org.springframework.web.context.support.WebApplicationContextUtils;
 import org.springframework.web.servlet.DispatcherServlet;
 
-import static org.hamcrest.CoreMatchers.*;
+import static org.assertj.core.api.Assertions.*;
 import static org.junit.Assert.*;
 import static org.springframework.test.web.servlet.setup.MockMvcBuilders.*;
 
@@ -45,22 +43,18 @@ public class DefaultMockMvcBuilderTests {
 
 	private final MockServletContext servletContext = new MockServletContext();
 
-	@Rule
-	public final ExpectedException exception = ExpectedException.none();
-
-
 	@Test
 	public void webAppContextSetupWithNullWac() {
-		exception.expect(IllegalArgumentException.class);
-		exception.expectMessage(equalTo("WebApplicationContext is required"));
-		webAppContextSetup(null);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				webAppContextSetup(null))
+			.withMessage("WebApplicationContext is required");
 	}
 
 	@Test
 	public void webAppContextSetupWithNullServletContext() {
-		exception.expect(IllegalArgumentException.class);
-		exception.expectMessage(equalTo("WebApplicationContext must have a ServletContext"));
-		webAppContextSetup(new StubWebApplicationContext(null));
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				webAppContextSetup(new StubWebApplicationContext(null)))
+			.withMessage("WebApplicationContext must have a ServletContext");
 	}
 
 	/**
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 10180b334aa..c99892b13b4 100644
--- a/spring-tx/src/test/java/org/springframework/transaction/TxNamespaceHandlerEventTests.java
+++ b/spring-tx/src/test/java/org/springframework/transaction/TxNamespaceHandlerEventTests.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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.
@@ -27,7 +27,7 @@ import org.springframework.core.io.ClassPathResource;
 import org.springframework.tests.beans.CollectingReaderEventListener;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.MatcherAssert.*;
 
 /**
  * @author Torsten Juergeleit
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 bd22c4cd248..c6a9faae814 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
@@ -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.
@@ -18,9 +18,7 @@ package org.springframework.transaction.event;
 
 import java.lang.reflect.Method;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.context.PayloadApplicationEvent;
 import org.springframework.context.event.ApplicationListenerMethodAdapter;
@@ -35,10 +33,6 @@ import static org.junit.Assert.*;
  */
 public class ApplicationListenerMethodTransactionalAdapterTests {
 
-	@Rule
-	public final ExpectedException thrown = ExpectedException.none();
-
-
 	@Test
 	public void defaultPhase() {
 		Method m = ReflectionUtils.findMethod(SampleEvents.class, "defaultPhase", String.class);
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 1529c7ebbd0..6e4941f2662 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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.
@@ -27,9 +27,7 @@ import java.util.List;
 import java.util.Map;
 
 import org.junit.After;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.ConfigurableApplicationContext;
@@ -66,9 +64,6 @@ public class TransactionalEventListenerTests {
 
 	private TransactionTemplate transactionTemplate = new TransactionTemplate(new CallCountingTransactionManager());
 
-	@Rule
-	public final ExpectedException thrown = ExpectedException.none();
-
 
 	@After
 	public void closeContext() {
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 507c9d4e941..2538f2a6ba6 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
@@ -240,7 +240,8 @@ public abstract class AbstractReactiveTransactionAspectTests {
 			else {
 				when(rtm.commit(status)).thenReturn(Mono.error(tex));
 			}
-		}else{
+		}
+		else {
 			when(rtm.commit(status)).thenReturn(Mono.empty());
 			when(rtm.rollback(status)).thenReturn(Mono.empty());
 		}
@@ -251,10 +252,10 @@ public abstract class AbstractReactiveTransactionAspectTests {
 		itb.exceptional(ex)
 				.as(StepVerifier::create)
 				.expectErrorSatisfies(actual -> {
-
 					if (rollbackException) {
 						assertThat(actual).isEqualTo(tex);
-					} else {
+					}
+					else {
 						assertThat(actual).isEqualTo(ex);
 					}
 				}).verify();
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 805bb3c0155..31c9a3bfcf2 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
@@ -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 @@ import org.springframework.transaction.TransactionException;
 import org.springframework.transaction.TransactionStatus;
 
 import static org.junit.Assert.*;
-import static org.mockito.BDDMockito.*;
+import static org.mockito.Mockito.*;
 
 /**
  * Test cases for AOP transaction management.
diff --git a/spring-tx/src/test/java/org/springframework/transaction/interceptor/ReactiveTransactionInterceptorTests.java b/spring-tx/src/test/java/org/springframework/transaction/interceptor/ReactiveTransactionInterceptorTests.java
index 6530ea39358..08f80611032 100644
--- a/spring-tx/src/test/java/org/springframework/transaction/interceptor/ReactiveTransactionInterceptorTests.java
+++ b/spring-tx/src/test/java/org/springframework/transaction/interceptor/ReactiveTransactionInterceptorTests.java
@@ -58,4 +58,4 @@ public class ReactiveTransactionInterceptorTests extends AbstractReactiveTransac
 		return pf.getProxy();
 	}
 
-}
\ No newline at end of file
+}
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 1279d6c4abd..7e8ac3e2f29 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
@@ -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.
@@ -19,9 +19,7 @@ package org.springframework.transaction.interceptor;
 import java.io.Serializable;
 import java.util.Properties;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.aop.framework.ProxyFactory;
 import org.springframework.beans.factory.BeanFactory;
@@ -33,6 +31,7 @@ import org.springframework.transaction.TransactionException;
 import org.springframework.transaction.TransactionStatus;
 import org.springframework.util.SerializationTestUtils;
 
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
 import static org.junit.Assert.*;
 import static org.mockito.BDDMockito.*;
 
@@ -44,10 +43,6 @@ import static org.mockito.BDDMockito.*;
  */
 public class TransactionInterceptorTests extends AbstractTransactionAspectTests {
 
-	@Rule
-	public final ExpectedException thrown = ExpectedException.none();
-
-
 	@Override
 	protected Object advised(Object target, PlatformTransactionManager ptm, TransactionAttributeSource[] tas) throws Exception {
 		TransactionInterceptor ti = new TransactionInterceptor();
@@ -154,9 +149,9 @@ public class TransactionInterceptorTests extends AbstractTransactionAspectTests
 		DefaultTransactionAttribute attribute = new DefaultTransactionAttribute();
 		attribute.setQualifier("fooTransactionManager");
 
-		thrown.expect(NoSuchBeanDefinitionException.class);
-		thrown.expectMessage("'fooTransactionManager'");
-		ti.determineTransactionManager(attribute);
+		assertThatExceptionOfType(NoSuchBeanDefinitionException.class).isThrownBy(() ->
+				ti.determineTransactionManager(attribute))
+			.withMessageContaining("'fooTransactionManager'");
 	}
 
 	@Test
diff --git a/spring-tx/src/test/java/org/springframework/transaction/jta/MockUOWManager.java b/spring-tx/src/test/java/org/springframework/transaction/jta/MockUOWManager.java
index 5dcb133bcf2..7d1e35bb200 100644
--- a/spring-tx/src/test/java/org/springframework/transaction/jta/MockUOWManager.java
+++ b/spring-tx/src/test/java/org/springframework/transaction/jta/MockUOWManager.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.
@@ -59,7 +59,8 @@ public class MockUOWManager implements UOWManager {
 		catch (Error | RuntimeException ex) {
 			this.status = UOW_STATUS_ROLLEDBACK;
 			throw ex;
-		} catch (Exception ex) {
+		}
+		catch (Exception ex) {
 			this.status = UOW_STATUS_ROLLEDBACK;
 			throw new UOWActionException(ex);
 		}
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 a28a9040988..8137f7b2cf2 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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.
@@ -20,6 +20,9 @@ import javax.transaction.RollbackException;
 import javax.transaction.Status;
 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.springframework.dao.OptimisticLockingFailureException;
@@ -33,10 +36,6 @@ import org.springframework.transaction.support.DefaultTransactionDefinition;
 import org.springframework.transaction.support.TransactionCallback;
 import org.springframework.transaction.support.TransactionSynchronizationManager;
 
-import com.ibm.wsspi.uow.UOWAction;
-import com.ibm.wsspi.uow.UOWException;
-import com.ibm.wsspi.uow.UOWManager;
-
 import static org.junit.Assert.*;
 import static org.mockito.BDDMockito.*;
 
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 703fcf5f98d..44bac1bdb92 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
@@ -22,8 +22,8 @@ import reactor.core.publisher.Mono;
 import reactor.test.StepVerifier;
 
 import org.springframework.transaction.IllegalTransactionStateException;
-import org.springframework.transaction.ReactiveTransactionManager;
 import org.springframework.transaction.ReactiveTransaction;
+import org.springframework.transaction.ReactiveTransactionManager;
 import org.springframework.transaction.TransactionDefinition;
 import org.springframework.transaction.support.DefaultTransactionDefinition;
 
@@ -42,9 +42,9 @@ public class ReactiveTransactionSupportTests {
 
 		tm.getReactiveTransaction(new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_SUPPORTS))
 				.subscriberContext(TransactionContextManager.createTransactionContext()).cast(GenericReactiveTransaction.class)
-				.as(StepVerifier::create).consumeNextWith(actual -> {
-					assertFalse(actual.hasTransaction());
-				}).verifyComplete();
+				.as(StepVerifier::create).consumeNextWith(actual ->
+					assertFalse(actual.hasTransaction())
+				).verifyComplete();
 
 		tm.getReactiveTransaction(new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_REQUIRED))
 				.cast(GenericReactiveTransaction.class).subscriberContext(TransactionContextManager.createTransactionContext())
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 8eab832c25f..e30075269a2 100644
--- a/spring-web/src/test/java/org/springframework/http/CacheControlTests.java
+++ b/spring-web/src/test/java/org/springframework/http/CacheControlTests.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,13 +16,13 @@
 
 package org.springframework.http;
 
-import org.hamcrest.Matchers;
-import org.junit.Test;
-
 import java.time.Duration;
 import java.util.concurrent.TimeUnit;
 
-import static org.hamcrest.MatcherAssert.assertThat;
+import org.hamcrest.Matchers;
+import org.junit.Test;
+
+import static org.hamcrest.MatcherAssert.*;
 
 /**
  * @author Brian Clozel
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 788a9c69fed..5a11a8ebef2 100644
--- a/spring-web/src/test/java/org/springframework/http/ContentDispositionTests.java
+++ b/spring-web/src/test/java/org/springframework/http/ContentDispositionTests.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.
@@ -22,11 +22,12 @@ import java.nio.charset.StandardCharsets;
 import java.time.ZonedDateTime;
 import java.time.format.DateTimeFormatter;
 
-import static org.junit.Assert.assertEquals;
 import org.junit.Test;
 
 import org.springframework.util.ReflectionUtils;
 
+import static org.junit.Assert.*;
+
 /**
  * Unit tests for {@link ContentDisposition}
  *
diff --git a/spring-web/src/test/java/org/springframework/http/MockHttpOutputMessage.java b/spring-web/src/test/java/org/springframework/http/MockHttpOutputMessage.java
index a30b8d3fcc6..81a2050e05a 100644
--- a/spring-web/src/test/java/org/springframework/http/MockHttpOutputMessage.java
+++ b/spring-web/src/test/java/org/springframework/http/MockHttpOutputMessage.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.
@@ -21,7 +21,7 @@ import java.io.IOException;
 import java.io.OutputStream;
 import java.nio.charset.Charset;
 
-import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.*;
 
 /**
  * @author Arjen Poutsma
diff --git a/spring-web/src/test/java/org/springframework/http/client/AbstractAsyncHttpRequestFactoryTestCase.java b/spring-web/src/test/java/org/springframework/http/client/AbstractAsyncHttpRequestFactoryTestCase.java
index 8ec3a06678e..8f5b40963fe 100644
--- a/spring-web/src/test/java/org/springframework/http/client/AbstractAsyncHttpRequestFactoryTestCase.java
+++ b/spring-web/src/test/java/org/springframework/http/client/AbstractAsyncHttpRequestFactoryTestCase.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,10 +16,6 @@
 
 package org.springframework.http.client;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
 import java.io.IOException;
 import java.net.URI;
 import java.util.Arrays;
@@ -29,6 +25,7 @@ import java.util.concurrent.Future;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
+
 import org.springframework.beans.factory.DisposableBean;
 import org.springframework.beans.factory.InitializingBean;
 import org.springframework.http.HttpMethod;
@@ -39,6 +36,8 @@ import org.springframework.util.StreamUtils;
 import org.springframework.util.concurrent.ListenableFuture;
 import org.springframework.util.concurrent.ListenableFutureCallback;
 
+import static org.junit.Assert.*;
+
 @SuppressWarnings("deprecation")
 public abstract class AbstractAsyncHttpRequestFactoryTestCase extends AbstractMockWebServerTestCase {
 
diff --git a/spring-web/src/test/java/org/springframework/http/client/AbstractMockWebServerTestCase.java b/spring-web/src/test/java/org/springframework/http/client/AbstractMockWebServerTestCase.java
index 0a496e871a7..97bb1b70f8e 100644
--- a/spring-web/src/test/java/org/springframework/http/client/AbstractMockWebServerTestCase.java
+++ b/spring-web/src/test/java/org/springframework/http/client/AbstractMockWebServerTestCase.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2002-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.springframework.http.client;
 
 import java.util.Collections;
@@ -13,7 +29,7 @@ import org.junit.Before;
 import org.springframework.http.MediaType;
 import org.springframework.util.StringUtils;
 
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.MatcherAssert.*;
 
 /**
  * @author Brian Clozel
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 749d1a0f6f5..ae02d6568d1 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
@@ -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.
@@ -27,6 +27,7 @@ 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.springframework.http.HttpMethod;
 
 import static org.junit.Assert.*;
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 622e36151db..05165e94e94 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
@@ -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.
@@ -29,7 +29,7 @@ import org.springframework.util.StreamUtils;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.*;
 import static org.junit.Assert.*;
-import static org.mockito.BDDMockito.any;
+import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.BDDMockito.*;
 
 /**
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 bee37740d63..78cee9efa6c 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
@@ -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.
@@ -18,9 +18,7 @@ package org.springframework.http.client.support;
 
 import java.net.URI;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.beans.DirectFieldAccessor;
 import org.springframework.http.HttpMethod;
@@ -28,6 +26,7 @@ import org.springframework.http.client.ClientHttpRequest;
 import org.springframework.http.client.ClientHttpRequestExecution;
 import org.springframework.http.client.SimpleClientHttpRequestFactory;
 
+import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
 import static org.junit.Assert.*;
 import static org.mockito.Mockito.*;
 
@@ -39,14 +38,11 @@ import static org.mockito.Mockito.*;
  */
 public class BasicAuthorizationInterceptorTests {
 
-	@Rule
-	public ExpectedException thrown = ExpectedException.none();
-
 	@Test
 	public void createWhenUsernameContainsColonShouldThrowException() {
-		this.thrown.expect(IllegalArgumentException.class);
-		this.thrown.expectMessage("Username must not contain a colon");
-		new BasicAuthorizationInterceptor("username:", "password");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				new BasicAuthorizationInterceptor("username:", "password"))
+			.withMessageContaining("Username must not contain a colon");
 	}
 
 	@Test
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 b554e638f9b..3955f52ba27 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
@@ -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.
@@ -29,7 +29,7 @@ import org.springframework.http.client.ClientHttpRequestExecution;
 import org.springframework.http.client.ClientHttpRequestInterceptor;
 import org.springframework.http.client.ClientHttpResponse;
 
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.MatcherAssert.*;
 
 /**
  * Tests for {@link InterceptingHttpAccessor}.
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 86966b8a7a1..a7e31c3a80b 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
@@ -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.
@@ -41,7 +41,7 @@ import org.springframework.util.MimeTypeUtils;
 
 import static java.nio.charset.StandardCharsets.*;
 import static org.junit.Assert.*;
-import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.Mockito.*;
 import static org.springframework.core.ResolvableType.*;
 import static org.springframework.http.MediaType.*;
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 2a9d10ee3c7..ab3cf318f22 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
@@ -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.
@@ -35,12 +35,10 @@ import org.springframework.util.MimeTypeUtils;
 import org.springframework.util.StringUtils;
 
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.containsInAnyOrder;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.startsWith;
-import static org.junit.Assert.assertArrayEquals;
-import static org.springframework.http.MediaType.TEXT_PLAIN;
-import static org.springframework.mock.http.server.reactive.test.MockServerHttpRequest.get;
+import static org.hamcrest.Matchers.*;
+import static org.junit.Assert.*;
+import static org.springframework.http.MediaType.*;
+import static org.springframework.mock.http.server.reactive.test.MockServerHttpRequest.*;
 
 /**
  * Unit tests for {@link ResourceHttpMessageWriter}.
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 04350796662..3967f843aec 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
@@ -31,10 +31,9 @@ import org.springframework.http.codec.Pojo;
 import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
 import org.springframework.util.MimeType;
 
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.springframework.core.ResolvableType.forClass;
-import static org.springframework.http.MediaType.APPLICATION_JSON;
+import static org.junit.Assert.*;
+import static org.springframework.core.ResolvableType.*;
+import static org.springframework.http.MediaType.*;
 
 /**
  * Unit tests for {@link Jackson2CborDecoder}.
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 2f9d8190f16..7ba50b16fb7 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
@@ -33,11 +33,9 @@ import org.springframework.http.codec.ServerSentEvent;
 import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
 import org.springframework.util.MimeType;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.springframework.core.io.buffer.DataBufferUtils.release;
-import static org.springframework.http.MediaType.APPLICATION_XML;
+import static org.junit.Assert.*;
+import static org.springframework.core.io.buffer.DataBufferUtils.*;
+import static org.springframework.http.MediaType.*;
 
 /**
  * Unit tests for {@link Jackson2CborEncoder}.
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 1f5d680871f..e9ac91c1930 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
@@ -40,6 +40,8 @@ import org.springframework.core.codec.DecodingException;
 import org.springframework.core.io.buffer.DataBuffer;
 import org.springframework.http.MediaType;
 import org.springframework.http.codec.Pojo;
+import org.springframework.http.codec.json.JacksonViewBean.MyJacksonView1;
+import org.springframework.http.codec.json.JacksonViewBean.MyJacksonView3;
 import org.springframework.util.MimeType;
 
 import static java.util.Arrays.*;
@@ -47,8 +49,7 @@ import static java.util.Collections.*;
 import static org.junit.Assert.*;
 import static org.springframework.core.ResolvableType.*;
 import static org.springframework.http.MediaType.*;
-import static org.springframework.http.codec.json.Jackson2JsonDecoder.*;
-import static org.springframework.http.codec.json.JacksonViewBean.*;
+import static org.springframework.http.codec.json.Jackson2CodecSupport.*;
 
 /**
  * Unit tests for {@link Jackson2JsonDecoder}.
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 b8a216b7817..10545d96936 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
@@ -38,18 +38,15 @@ import org.springframework.core.io.buffer.DataBufferUtils;
 import org.springframework.http.MediaType;
 import org.springframework.http.codec.Pojo;
 import org.springframework.http.codec.ServerSentEvent;
+import org.springframework.http.codec.json.JacksonViewBean.MyJacksonView1;
+import org.springframework.http.codec.json.JacksonViewBean.MyJacksonView3;
 import org.springframework.util.MimeType;
 import org.springframework.util.MimeTypeUtils;
 
-import static java.util.Collections.singletonMap;
+import static java.util.Collections.*;
 import static org.junit.Assert.*;
-import static org.springframework.http.MediaType.APPLICATION_JSON;
-import static org.springframework.http.MediaType.APPLICATION_OCTET_STREAM;
-import static org.springframework.http.MediaType.APPLICATION_STREAM_JSON;
-import static org.springframework.http.MediaType.APPLICATION_XML;
-import static org.springframework.http.codec.json.Jackson2JsonEncoder.JSON_VIEW_HINT;
-import static org.springframework.http.codec.json.JacksonViewBean.MyJacksonView1;
-import static org.springframework.http.codec.json.JacksonViewBean.MyJacksonView3;
+import static org.springframework.http.MediaType.*;
+import static org.springframework.http.codec.json.Jackson2CodecSupport.*;
 
 /**
  * @author Sebastien Deleuze
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 2fabea9319e..b71de700f5a 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
@@ -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.
@@ -32,8 +32,8 @@ import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
 import org.springframework.util.MimeType;
 
 import static org.junit.Assert.*;
-import static org.springframework.core.ResolvableType.forClass;
-import static org.springframework.http.MediaType.APPLICATION_JSON;
+import static org.springframework.core.ResolvableType.*;
+import static org.springframework.http.MediaType.*;
 
 /**
  * Unit tests for {@link Jackson2SmileDecoder}.
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 e6b3cba6fc0..2aacf505159 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
@@ -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.
@@ -37,8 +37,8 @@ import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
 import org.springframework.util.MimeType;
 
 import static org.junit.Assert.*;
-import static org.springframework.core.io.buffer.DataBufferUtils.release;
-import static org.springframework.http.MediaType.APPLICATION_XML;
+import static org.springframework.core.io.buffer.DataBufferUtils.*;
+import static org.springframework.http.MediaType.*;
 
 /**
  * Unit tests for {@link Jackson2SmileEncoder}.
diff --git a/spring-web/src/test/java/org/springframework/http/codec/multipart/DefaultMultipartMessageReaderTests.java b/spring-web/src/test/java/org/springframework/http/codec/multipart/DefaultMultipartMessageReaderTests.java
index 3eb4aa3a915..0da0407bb94 100644
--- a/spring-web/src/test/java/org/springframework/http/codec/multipart/DefaultMultipartMessageReaderTests.java
+++ b/spring-web/src/test/java/org/springframework/http/codec/multipart/DefaultMultipartMessageReaderTests.java
@@ -79,9 +79,9 @@ public class DefaultMultipartMessageReaderTests extends AbstractDataBufferAlloca
 		Flux result = this.reader.read(forClass(Part.class), request, emptyMap());
 
 		StepVerifier.create(result)
-				.consumeNextWith(part -> {
-					part.content().subscribe(DataBufferUtils::release);
-				})
+				.consumeNextWith(part ->
+					part.content().subscribe(DataBufferUtils::release)
+				)
 				.verifyComplete();
 	}
 
@@ -174,4 +174,4 @@ public class DefaultMultipartMessageReaderTests extends AbstractDataBufferAlloca
 		}
 	}
 
-}
\ No newline at end of file
+}
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 4c707a49825..fffda7870ef 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
@@ -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.
@@ -34,7 +34,7 @@ import org.springframework.protobuf.SecondMsg;
 import org.springframework.util.MimeType;
 
 import static org.junit.Assert.*;
-import static org.springframework.core.ResolvableType.forClass;
+import static org.springframework.core.ResolvableType.*;
 
 /**
  * Unit tests for {@link ProtobufEncoder}.
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 abc456fc211..59556427113 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
@@ -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.
@@ -33,11 +33,11 @@ import org.springframework.core.io.buffer.DataBuffer;
 import org.springframework.http.MediaType;
 import org.springframework.http.codec.Pojo;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static java.nio.charset.StandardCharsets.*;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.Assert.*;
-import static org.springframework.core.io.buffer.DataBufferUtils.release;
-import static org.xmlunit.matchers.CompareMatcher.isSimilarTo;
+import static org.springframework.core.io.buffer.DataBufferUtils.*;
+import static org.xmlunit.matchers.CompareMatcher.*;
 
 /**
  * @author Sebastien Deleuze
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 e3623277fb4..23276a0ee64 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
@@ -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.
@@ -24,9 +24,7 @@ import org.springframework.http.HttpInputMessage;
 import org.springframework.http.HttpOutputMessage;
 import org.springframework.http.MediaType;
 
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.*;
 
 /**
  * Test-case for AbstractHttpMessageConverter.
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 6c7b499cb0a..57612ae9107 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
@@ -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.
@@ -21,9 +21,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.util.Arrays;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.core.io.ByteArrayResource;
 import org.springframework.core.io.ClassPathResource;
@@ -35,11 +33,12 @@ import org.springframework.http.MockHttpInputMessage;
 import org.springframework.http.MockHttpOutputMessage;
 import org.springframework.util.FileCopyUtils;
 
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.core.Is.*;
 import static org.hamcrest.core.IsInstanceOf.*;
-import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.Assert.*;
-import static org.mockito.BDDMockito.any;
+import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.BDDMockito.*;
 
 /**
@@ -51,9 +50,6 @@ public class ResourceHttpMessageConverterTests {
 
 	private final ResourceHttpMessageConverter converter = new ResourceHttpMessageConverter();
 
-	@Rule
-	public ExpectedException thrown = ExpectedException.none();
-
 
 	@Test
 	public void canReadResource() {
@@ -96,10 +92,10 @@ public class ResourceHttpMessageConverterTests {
 	public void shouldNotReadInputStreamResource() throws IOException {
 		ResourceHttpMessageConverter noStreamConverter = new ResourceHttpMessageConverter(false);
 		try (InputStream body = getClass().getResourceAsStream("logo.jpg") ) {
-			this.thrown.expect(HttpMessageNotReadableException.class);
 			MockHttpInputMessage inputMessage = new MockHttpInputMessage(body);
 			inputMessage.getHeaders().setContentType(MediaType.IMAGE_JPEG);
-			noStreamConverter.read(InputStreamResource.class, inputMessage);
+			assertThatExceptionOfType(HttpMessageNotReadableException.class).isThrownBy(() ->
+					noStreamConverter.read(InputStreamResource.class, inputMessage));
 		}
 	}
 
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 fd8b89b7d35..2db4c9bcedf 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
@@ -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.
@@ -39,9 +39,8 @@ import org.springframework.http.MockHttpOutputMessage;
 import org.springframework.util.StringUtils;
 
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.hamcrest.Matchers.*;
+import static org.junit.Assert.*;
 
 /**
  * Test cases for {@link ResourceRegionHttpMessageConverter} class.
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 d1c8fda1d2b..8c1a5cc6483 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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.
@@ -20,7 +20,6 @@ import java.util.Calendar;
 import java.util.Date;
 
 import com.google.gson.Gson;
-
 import org.junit.Test;
 
 import static org.junit.Assert.*;
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 09c1b65729f..cf081f895de 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
@@ -667,7 +667,8 @@ public class Jackson2ObjectMapperBuilderTests {
 			try {
 				return OffsetDateTime.parse(value);
 
-			} catch (DateTimeParseException exception) {
+			}
+			catch (DateTimeParseException exception) {
 				return OffsetDateTime.parse(value + CURRENT_ZONE_OFFSET);
 			}
 		}
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 cb047610a47..d46ae037334 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
@@ -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.
@@ -28,14 +28,6 @@ import java.util.Locale;
 import java.util.Map;
 import java.util.TimeZone;
 
-import com.fasterxml.jackson.dataformat.smile.SmileFactory;
-import org.joda.time.DateTime;
-import org.joda.time.DateTimeZone;
-
-import org.junit.Test;
-
-import org.springframework.beans.FatalBeanException;
-
 import com.fasterxml.jackson.annotation.JsonFilter;
 import com.fasterxml.jackson.annotation.JsonInclude.Include;
 import com.fasterxml.jackson.core.JsonGenerator;
@@ -64,7 +56,13 @@ import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider;
 import com.fasterxml.jackson.databind.ser.std.ClassSerializer;
 import com.fasterxml.jackson.databind.ser.std.NumberSerializer;
 import com.fasterxml.jackson.databind.type.SimpleType;
+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.springframework.beans.FatalBeanException;
 
 import static org.hamcrest.Matchers.*;
 import static org.junit.Assert.*;
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 7820c5de4ba..92616f95ba6 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
@@ -32,6 +32,7 @@ import org.springframework.protobuf.Msg;
 import org.springframework.protobuf.SecondMsg;
 
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.Mockito.*;
 
 /**
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 9272b97fa54..6f87acdfe0b 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
@@ -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.
@@ -31,6 +31,7 @@ import org.springframework.protobuf.Msg;
 import org.springframework.protobuf.SecondMsg;
 
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.Mockito.*;
 
 /**
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 8a8c5973698..1582a4bb027 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,15 +20,14 @@ import java.io.IOException;
 
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.dataformat.smile.SmileFactory;
-import static org.junit.Assert.*;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.http.MediaType;
 import org.springframework.http.MockHttpInputMessage;
 import org.springframework.http.MockHttpOutputMessage;
 
+import static org.junit.Assert.*;
+
 /**
  * Jackson 2.x Smile converter tests.
  *
@@ -39,9 +38,6 @@ public class MappingJackson2SmileHttpMessageConverterTests {
 	private final MappingJackson2SmileHttpMessageConverter converter = new MappingJackson2SmileHttpMessageConverter();
 	private final ObjectMapper mapper = new ObjectMapper(new SmileFactory());
 
-	@Rule
-	public ExpectedException thrown = ExpectedException.none();
-
 
 	@Test
 	public void canRead() {
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 91ecf13b508..0cbc717152e 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
@@ -1,11 +1,11 @@
 /*
- * 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.
  * You may obtain a copy of the License at
  *
- *     https://www.apache.org/licenses/LICENSE-2.0
+ *      https://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -27,9 +27,7 @@ import javax.xml.bind.annotation.XmlType;
 import javax.xml.stream.XMLInputFactory;
 
 import org.junit.Before;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.core.ParameterizedTypeReference;
 import org.springframework.core.io.ClassPathResource;
@@ -37,6 +35,7 @@ import org.springframework.core.io.Resource;
 import org.springframework.http.MockHttpInputMessage;
 import org.springframework.http.converter.HttpMessageNotReadableException;
 
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
 import static org.junit.Assert.*;
 
 /**
@@ -57,9 +56,6 @@ public class Jaxb2CollectionHttpMessageConverterTests {
 
 	private Type typeSetType;
 
-	@Rule
-	public ExpectedException thrown = ExpectedException.none();
-
 
 	@Before
 	public void setup() {
@@ -199,9 +195,9 @@ public class Jaxb2CollectionHttpMessageConverterTests {
 				"]>\n" +
 				"&lol9;";
 		MockHttpInputMessage inputMessage = new MockHttpInputMessage(content.getBytes("UTF-8"));
-		this.thrown.expect(HttpMessageNotReadableException.class);
-		this.thrown.expectMessage("\"lol9\"");
-		this.converter.read(this.rootElementListType, null, inputMessage);
+		assertThatExceptionOfType(HttpMessageNotReadableException.class).isThrownBy(() ->
+				this.converter.read(this.rootElementListType, null, inputMessage))
+			.withMessageContaining("\"lol9\"");
 	}
 
 
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 b4ea4ad097f..be381183541 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
@@ -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.
@@ -27,9 +27,7 @@ import javax.xml.bind.annotation.adapters.XmlAdapter;
 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
 
 import org.junit.Before;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 import org.xmlunit.diff.DifferenceEvaluator;
 
 import org.springframework.aop.framework.AdvisedSupport;
@@ -42,6 +40,7 @@ import org.springframework.http.MockHttpInputMessage;
 import org.springframework.http.MockHttpOutputMessage;
 import org.springframework.http.converter.HttpMessageNotReadableException;
 
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.Assert.*;
 import static org.xmlunit.diff.ComparisonType.*;
@@ -63,9 +62,6 @@ public class Jaxb2RootElementHttpMessageConverterTests {
 
 	private RootElement rootElementCglib;
 
-	@Rule
-	public ExpectedException thrown = ExpectedException.none();
-
 
 	@Before
 	public void setup() {
@@ -171,9 +167,9 @@ public class Jaxb2RootElementHttpMessageConverterTests {
 				"]>\n" +
 				"&lol9;";
 		MockHttpInputMessage inputMessage = new MockHttpInputMessage(content.getBytes("UTF-8"));
-		this.thrown.expect(HttpMessageNotReadableException.class);
-		this.thrown.expectMessage("DOCTYPE");
-		this.converter.read(RootElement.class, inputMessage);
+		assertThatExceptionOfType(HttpMessageNotReadableException.class).isThrownBy(() ->
+				this.converter.read(RootElement.class, inputMessage))
+			.withMessageContaining("DOCTYPE");
 	}
 
 	@Test
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 07bec4add92..7341ad25ec9 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
@@ -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.
@@ -21,9 +21,7 @@ import java.nio.charset.StandardCharsets;
 
 import com.fasterxml.jackson.annotation.JsonView;
 import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.core.io.ClassPathResource;
 import org.springframework.http.MediaType;
@@ -32,6 +30,7 @@ import org.springframework.http.MockHttpOutputMessage;
 import org.springframework.http.converter.HttpMessageNotReadableException;
 import org.springframework.http.converter.json.MappingJacksonValue;
 
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
 import static org.hamcrest.CoreMatchers.*;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.Assert.*;
@@ -46,9 +45,6 @@ public class MappingJackson2XmlHttpMessageConverterTests {
 
 	private final MappingJackson2XmlHttpMessageConverter converter = new MappingJackson2XmlHttpMessageConverter();
 
-	@Rule
-	public ExpectedException thrown = ExpectedException.none();
-
 
 	@Test
 	public void canRead() {
@@ -112,8 +108,8 @@ public class MappingJackson2XmlHttpMessageConverterTests {
 		String body = "FooBar";
 		MockHttpInputMessage inputMessage = new MockHttpInputMessage(body.getBytes("UTF-8"));
 		inputMessage.getHeaders().setContentType(new MediaType("application", "xml"));
-		this.thrown.expect(HttpMessageNotReadableException.class);
-		converter.read(MyBean.class, inputMessage);
+		assertThatExceptionOfType(HttpMessageNotReadableException.class).isThrownBy(() ->
+				converter.read(MyBean.class, inputMessage));
 	}
 
 	@Test
@@ -160,8 +156,8 @@ public class MappingJackson2XmlHttpMessageConverterTests {
 		MockHttpInputMessage inputMessage = new MockHttpInputMessage(body.getBytes("UTF-8"));
 		inputMessage.getHeaders().setContentType(new MediaType("application", "xml"));
 
-		this.thrown.expect(HttpMessageNotReadableException.class);
-		this.converter.read(MyBean.class, inputMessage);
+		assertThatExceptionOfType(HttpMessageNotReadableException.class).isThrownBy(() ->
+				this.converter.read(MyBean.class, inputMessage));
 	}
 
 	@Test
@@ -187,8 +183,8 @@ public class MappingJackson2XmlHttpMessageConverterTests {
 		MockHttpInputMessage inputMessage = new MockHttpInputMessage(body.getBytes("UTF-8"));
 		inputMessage.getHeaders().setContentType(new MediaType("application", "xml"));
 
-		this.thrown.expect(HttpMessageNotReadableException.class);
-		this.converter.read(MyBean.class, inputMessage);
+		assertThatExceptionOfType(HttpMessageNotReadableException.class).isThrownBy(() ->
+				this.converter.read(MyBean.class, inputMessage));
 	}
 
 
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 e9b3e592555..39136c652c1 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
@@ -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.
@@ -33,6 +33,7 @@ import org.springframework.oxm.Unmarshaller;
 import org.springframework.oxm.UnmarshallingFailureException;
 
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.BDDMockito.*;
 
 /**
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 d464d563b5e..9564a8e9281 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
@@ -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.
@@ -30,9 +30,7 @@ import javax.xml.transform.stax.StAXSource;
 import javax.xml.transform.stream.StreamSource;
 
 import org.junit.Before;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.xml.sax.InputSource;
@@ -48,6 +46,7 @@ import org.springframework.http.MockHttpOutputMessage;
 import org.springframework.http.converter.HttpMessageNotReadableException;
 import org.springframework.util.FileCopyUtils;
 
+import static org.assertj.core.api.Assertions.*;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.Assert.*;
 import static org.xmlunit.matchers.CompareMatcher.*;
@@ -64,9 +63,6 @@ public class SourceHttpMessageConverterTests {
 
 	private String bodyExternal;
 
-	@Rule
-	public ExpectedException thrown = ExpectedException.none();
-
 
 	@Before
 	public void setup() throws IOException {
@@ -133,10 +129,9 @@ public class SourceHttpMessageConverterTests {
 				"&lol9;";
 		MockHttpInputMessage inputMessage = new MockHttpInputMessage(content.getBytes("UTF-8"));
 
-		this.thrown.expect(HttpMessageNotReadableException.class);
-		this.thrown.expectMessage("DOCTYPE");
-
-		this.converter.read(DOMSource.class, inputMessage);
+		assertThatExceptionOfType(HttpMessageNotReadableException.class).isThrownBy(() ->
+				this.converter.read(DOMSource.class, inputMessage))
+			.withMessageContaining("DOCTYPE");
 	}
 
 	@Test
@@ -190,12 +185,11 @@ public class SourceHttpMessageConverterTests {
 		MockHttpInputMessage inputMessage = new MockHttpInputMessage(content.getBytes("UTF-8"));
 		SAXSource result = (SAXSource) this.converter.read(SAXSource.class, inputMessage);
 
-		this.thrown.expect(SAXException.class);
-		this.thrown.expectMessage("DOCTYPE");
-
 		InputSource inputSource = result.getInputSource();
 		XMLReader reader = result.getXMLReader();
-		reader.parse(inputSource);
+		assertThatExceptionOfType(SAXException.class).isThrownBy(() ->
+				reader.parse(inputSource))
+			.withMessageContaining("DOCTYPE");
 	}
 
 	@Test
@@ -263,9 +257,9 @@ public class SourceHttpMessageConverterTests {
 		streamReader.next();
 		String s = streamReader.getLocalName();
 		assertEquals("root", s);
-
-		this.thrown.expectMessage("\"lol9\"");
-		s = streamReader.getElementText();
+		assertThatExceptionOfType(XMLStreamException.class).isThrownBy(() ->
+				streamReader.getElementText())
+			.withMessageContaining("\"lol9\"");
 	}
 
 	@Test
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 d039458be2a..5cf4eef030f 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
@@ -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.
@@ -26,8 +26,7 @@ import org.springframework.http.server.PathContainer.PathSegment;
 import org.springframework.util.LinkedMultiValueMap;
 import org.springframework.util.MultiValueMap;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
+import static org.junit.Assert.*;
 
 /**
  * Unit tests for {@link DefaultPathContainer}.
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 30a88935b62..b1c8f0bdcaf 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
@@ -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.
@@ -19,7 +19,7 @@ import java.net.URI;
 
 import org.junit.Test;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.*;
 
 /**
  * Unit tests for {@link DefaultRequestPath}.
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 3caf9da9215..81925bbdae4 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
@@ -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.
@@ -105,7 +105,7 @@ public class ServletServerHttpRequestTests {
 		mockRequest.setRequestURI(uri.getRawPath());
 		mockRequest.setQueryString(uri.getRawQuery());
 		assertEquals(uri, request.getURI());
-    }
+	}
 
 	@Test
 	public void getHeaders() {
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 46828f79e53..086fccfd0c1 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
@@ -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.
@@ -33,7 +33,7 @@ import org.springframework.http.RequestEntity;
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.client.RestTemplate;
 
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.MatcherAssert.*;
 
 /**
  * @author Stephane Maldini
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 e97182745c6..28c4227dc05 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
@@ -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.
@@ -32,9 +32,7 @@ import org.springframework.util.CollectionUtils;
 import org.springframework.util.LinkedCaseInsensitiveMap;
 import org.springframework.util.MultiValueMap;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
 
 /**
  * Unit tests for {@code HeadersAdapters} {@code MultiValueMap} implementations.
@@ -111,4 +109,4 @@ public class HeadersAdaptersTests {
 		assertEquals(1, this.headers.get("TestHeader").size());
 	}
 
-}
\ No newline at end of file
+}
diff --git a/spring-web/src/test/java/org/springframework/mock/http/server/reactive/test/package-info.java b/spring-web/src/test/java/org/springframework/mock/http/server/reactive/test/package-info.java
index 92e8462a0c8..03e7701a7bd 100644
--- a/spring-web/src/test/java/org/springframework/mock/http/server/reactive/test/package-info.java
+++ b/spring-web/src/test/java/org/springframework/mock/http/server/reactive/test/package-info.java
@@ -1,6 +1,6 @@
-
-// For @NonNull annotations on implementation classes
-
+/**
+ * For @NonNull annotations on implementation classes
+ */
 @NonNullApi
 @NonNullFields
 package org.springframework.mock.http.server.reactive.test;
diff --git a/spring-web/src/test/java/org/springframework/mock/web/test/server/package-info.java b/spring-web/src/test/java/org/springframework/mock/web/test/server/package-info.java
index 1567f1fca26..d1986319e44 100644
--- a/spring-web/src/test/java/org/springframework/mock/web/test/server/package-info.java
+++ b/spring-web/src/test/java/org/springframework/mock/web/test/server/package-info.java
@@ -1,6 +1,6 @@
-
-// For @NonNull annotations on implementation classes
-
+/**
+ * For @NonNull annotations on implementation classes
+ */
 @NonNullApi
 @NonNullFields
 package org.springframework.mock.web.test.server;
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 fc41bc95a5d..63787249562 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
@@ -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.
@@ -21,9 +21,7 @@ import java.net.InetSocketAddress;
 
 import com.caucho.hessian.client.HessianProxyFactory;
 import com.sun.net.httpserver.HttpServer;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.aop.framework.ProxyFactory;
 import org.springframework.remoting.RemoteAccessException;
@@ -31,6 +29,7 @@ import org.springframework.tests.sample.beans.ITestBean;
 import org.springframework.tests.sample.beans.TestBean;
 import org.springframework.util.SocketUtils;
 
+import static org.assertj.core.api.Assertions.*;
 import static org.junit.Assert.*;
 
 /**
@@ -40,15 +39,11 @@ import static org.junit.Assert.*;
  */
 public class CauchoRemotingTests {
 
-	@Rule
-	public final ExpectedException exception = ExpectedException.none();
-
-
 	@Test
 	public void hessianProxyFactoryBeanWithClassInsteadOfInterface() throws Exception {
 		HessianProxyFactoryBean factory = new HessianProxyFactoryBean();
-		exception.expect(IllegalArgumentException.class);
-		factory.setServiceInterface(TestBean.class);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				factory.setServiceInterface(TestBean.class));
 	}
 
 	@Test
@@ -62,8 +57,8 @@ public class CauchoRemotingTests {
 		assertTrue(factory.getObject() instanceof ITestBean);
 		ITestBean bean = (ITestBean) factory.getObject();
 
-		exception.expect(RemoteAccessException.class);
-		bean.setName("test");
+		assertThatExceptionOfType(RemoteAccessException.class).isThrownBy(() ->
+				bean.setName("test"));
 	}
 
 	@Test
@@ -80,8 +75,8 @@ public class CauchoRemotingTests {
 		assertTrue(factory.getObject() instanceof ITestBean);
 		ITestBean bean = (ITestBean) factory.getObject();
 
-		exception.expect(RemoteAccessException.class);
-		bean.setName("test");
+		assertThatExceptionOfType(RemoteAccessException.class).isThrownBy(() ->
+				bean.setName("test"));
 	}
 
 	@Test
@@ -103,8 +98,8 @@ public class CauchoRemotingTests {
 		assertEquals("bean", proxyFactory.password);
 		assertTrue(proxyFactory.overloadEnabled);
 
-		exception.expect(RemoteAccessException.class);
-		bean.setName("test");
+		assertThatExceptionOfType(RemoteAccessException.class).isThrownBy(() ->
+				bean.setName("test"));
 	}
 
 	@Test
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 5531272fb0c..0769cf539e4 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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.
@@ -33,7 +33,6 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import org.aopalliance.intercept.MethodInvocation;
-
 import org.junit.Test;
 
 import org.springframework.beans.factory.BeanClassLoaderAware;
diff --git a/spring-web/src/test/java/org/springframework/remoting/jaxws/OrderNotFoundException.java b/spring-web/src/test/java/org/springframework/remoting/jaxws/OrderNotFoundException.java
index add5efc0977..58cc650d103 100644
--- a/spring-web/src/test/java/org/springframework/remoting/jaxws/OrderNotFoundException.java
+++ b/spring-web/src/test/java/org/springframework/remoting/jaxws/OrderNotFoundException.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2012 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.
@@ -25,10 +25,11 @@ import javax.xml.ws.WebFault;
 @SuppressWarnings("serial")
 public class OrderNotFoundException extends Exception {
 
-	private String faultInfo;
+	private final String faultInfo;
 
 	public OrderNotFoundException(String message) {
 		super(message);
+		this.faultInfo = null;
 	}
 
 	public OrderNotFoundException(String message, String faultInfo) {
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 dd386e20585..af007925e92 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
@@ -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.
@@ -42,12 +42,11 @@ import org.springframework.util.MultiValueMap;
 import org.springframework.web.server.ServerWebExchange;
 
 import static junit.framework.TestCase.assertFalse;
-import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.*;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
-import static org.springframework.core.ResolvableType.forClass;
-import static org.springframework.core.ResolvableType.forClassWithGenerics;
+import static org.springframework.core.ResolvableType.*;
 
 /**
  * Unit tests for {@link WebExchangeDataBinder}.
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 87c311d230d..2fc36e5df3f 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
@@ -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.
@@ -112,7 +112,7 @@ public class AsyncRestTemplateIntegrationTests extends AbstractMockWebServerTest
 	public void getEntityCallbackWithLambdas() throws Exception {
 		ListenableFuture> futureEntity =
 				template.getForEntity(baseUrl + "/{method}", String.class, "get");
-		futureEntity.addCallback((entity) -> {
+		futureEntity.addCallback(entity -> {
 			assertEquals("Invalid content", helloWorld, entity.getBody());
 			assertFalse("No headers", entity.getHeaders().isEmpty());
 			assertEquals("Invalid content-type", textContentType, entity.getHeaders().getContentType());
@@ -620,6 +620,12 @@ public class AsyncRestTemplateIntegrationTests extends AbstractMockWebServerTest
 
 	private void waitTillDone(ListenableFuture future) {
 		while (!future.isDone()) {
+			try {
+				Thread.sleep(5);
+			}
+			catch (InterruptedException ex) {
+				Thread.currentThread().interrupt();
+			}
 		}
 	}
 
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 2b472cbfcb1..2c06ea8e5ce 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,10 +22,7 @@ import java.lang.reflect.Type;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.hamcrest.Matchers;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.core.ParameterizedTypeReference;
 import org.springframework.http.HttpHeaders;
@@ -37,7 +34,9 @@ import org.springframework.http.converter.GenericHttpMessageConverter;
 import org.springframework.http.converter.HttpMessageConverter;
 import org.springframework.http.converter.HttpMessageNotReadableException;
 
+import static org.assertj.core.api.Assertions.*;
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.BDDMockito.*;
 
 /**
@@ -52,9 +51,6 @@ public class HttpMessageConverterExtractorTests {
 
 	private final ClientHttpResponse response = mock(ClientHttpResponse.class);
 
-	@Rule
-	public final ExpectedException exception = ExpectedException.none();
-
 
 	@Test
 	public void noContent() throws IOException {
@@ -158,9 +154,8 @@ public class HttpMessageConverterExtractorTests {
 		given(response.getHeaders()).willReturn(responseHeaders);
 		given(response.getBody()).willReturn(new ByteArrayInputStream("Foobar".getBytes()));
 		given(converter.canRead(String.class, contentType)).willReturn(false);
-		exception.expect(RestClientException.class);
-
-		extractor.extractData(response);
+		assertThatExceptionOfType(RestClientException.class).isThrownBy(() ->
+				extractor.extractData(response));
 	}
 
 	@Test
@@ -197,12 +192,10 @@ public class HttpMessageConverterExtractorTests {
 		given(response.getBody()).willReturn(new ByteArrayInputStream("Foobar".getBytes()));
 		given(converter.canRead(String.class, contentType)).willReturn(true);
 		given(converter.read(eq(String.class), any(HttpInputMessage.class))).willThrow(IOException.class);
-		exception.expect(RestClientException.class);
-		exception.expectMessage("Error while extracting response for type " +
-				"[class java.lang.String] and content type [text/plain]");
-		exception.expectCause(Matchers.instanceOf(IOException.class));
-
-		extractor.extractData(response);
+		assertThatExceptionOfType(RestClientException.class).isThrownBy(() ->
+				extractor.extractData(response))
+			.withMessageContaining("Error while extracting response for type [class java.lang.String] and content type [text/plain]")
+			.withCauseInstanceOf(IOException.class);
 	}
 
 	@Test  // SPR-13592
@@ -217,12 +210,11 @@ public class HttpMessageConverterExtractorTests {
 		given(response.getHeaders()).willReturn(responseHeaders);
 		given(response.getBody()).willReturn(new ByteArrayInputStream("Foobar".getBytes()));
 		given(converter.canRead(String.class, contentType)).willThrow(HttpMessageNotReadableException.class);
-		exception.expect(RestClientException.class);
-		exception.expectMessage("Error while extracting response for type " +
-				"[class java.lang.String] and content type [text/plain]");
-		exception.expectCause(Matchers.instanceOf(HttpMessageNotReadableException.class));
+		assertThatExceptionOfType(RestClientException.class).isThrownBy(() ->
+				extractor.extractData(response))
+			.withMessageContaining("Error while extracting response for type [class java.lang.String] and content type [text/plain]")
+			.withCauseInstanceOf(HttpMessageNotReadableException.class);
 
-		extractor.extractData(response);
 	}
 
 	private List> createConverterList(HttpMessageConverter converter) {
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 ef6dce419c1..a35e035c3cc 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
@@ -27,7 +27,7 @@ import org.junit.Test;
 
 import org.springframework.http.HttpStatus;
 
-import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.*;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.Assert.*;
 
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 297d801e0f1..aae99d99306 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
@@ -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.
@@ -56,8 +56,8 @@ import org.springframework.util.LinkedMultiValueMap;
 import org.springframework.util.MultiValueMap;
 
 import static org.junit.Assert.*;
-import static org.junit.Assume.assumeFalse;
-import static org.springframework.http.HttpMethod.POST;
+import static org.junit.Assume.*;
+import static org.springframework.http.HttpMethod.*;
 
 /**
  * @author Arjen Poutsma
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 27134f9f3f3..871088814e6 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
@@ -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.
@@ -49,25 +49,11 @@ import org.springframework.web.util.DefaultUriBuilderFactory;
 
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.collection.IsIterableContainingInOrder.contains;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.fail;
-import static org.mockito.BDDMockito.any;
-import static org.mockito.BDDMockito.eq;
-import static org.mockito.BDDMockito.given;
-import static org.mockito.BDDMockito.mock;
-import static org.mockito.BDDMockito.verify;
-import static org.mockito.BDDMockito.willThrow;
-import static org.springframework.http.HttpMethod.DELETE;
-import static org.springframework.http.HttpMethod.GET;
-import static org.springframework.http.HttpMethod.HEAD;
-import static org.springframework.http.HttpMethod.OPTIONS;
-import static org.springframework.http.HttpMethod.PATCH;
-import static org.springframework.http.HttpMethod.POST;
-import static org.springframework.http.HttpMethod.PUT;
-import static org.springframework.http.MediaType.parseMediaType;
+import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
+import static org.mockito.BDDMockito.*;
+import static org.springframework.http.HttpMethod.*;
+import static org.springframework.http.MediaType.*;
 
 /**
  * @author Arjen Poutsma
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 270a91e0670..dd796208b58 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
@@ -1,11 +1,11 @@
 /*
- * Copyright 2002-2012 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.
  * You may obtain a copy of the License at
  *
- *     https://www.apache.org/licenses/LICENSE-2.0
+ *      https://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
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 f8052bb74ca..5e1244c1c03 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
@@ -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.
@@ -27,6 +27,7 @@ import org.springframework.mock.web.test.MockHttpServletRequest;
 import org.springframework.mock.web.test.MockHttpSession;
 
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.BDDMockito.*;
 
 /**
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 342d5de076e..6b9df168104 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
@@ -1,11 +1,11 @@
 /*
- * 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.
  * You may obtain a copy of the License at
  *
- * https://www.apache.org/licenses/LICENSE-2.0
+ *      https://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
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 00f970e55ea..53ea1bf6bcb 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
@@ -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,6 @@
 package org.springframework.web.context.request.async;
 
 import java.util.function.Consumer;
-
 import javax.servlet.AsyncEvent;
 
 import org.junit.Before;
@@ -28,15 +27,9 @@ import org.springframework.mock.web.test.MockHttpServletRequest;
 import org.springframework.mock.web.test.MockHttpServletResponse;
 
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.containsString;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.mockito.BDDMockito.mock;
-import static org.mockito.BDDMockito.verify;
+import static org.hamcrest.Matchers.*;
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
 
 /**
  * A test fixture with a {@link StandardServletAsyncWebRequest}.
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 efef26865b1..3887d261ef9 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
@@ -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.
@@ -29,12 +29,9 @@ import org.springframework.mock.web.test.MockHttpServletRequest;
 import org.springframework.mock.web.test.MockHttpServletResponse;
 import org.springframework.web.context.request.NativeWebRequest;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.BDDMockito.given;
-import static org.mockito.BDDMockito.mock;
-import static org.mockito.BDDMockito.verify;
-import static org.springframework.web.context.request.async.CallableProcessingInterceptor.RESULT_NONE;
+import static org.junit.Assert.*;
+import static org.mockito.BDDMockito.*;
+import static org.springframework.web.context.request.async.CallableProcessingInterceptor.*;
 
 /**
  * {@link WebAsyncManager} tests where container-triggered error/completion
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 c168f5571f9..c9d0e182450 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
@@ -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,7 +18,6 @@ package org.springframework.web.context.request.async;
 
 import java.util.concurrent.Callable;
 import java.util.function.Consumer;
-
 import javax.servlet.http.HttpServletRequest;
 
 import org.junit.Before;
@@ -29,6 +28,7 @@ import org.springframework.core.task.SimpleAsyncTaskExecutor;
 import org.springframework.mock.web.test.MockHttpServletRequest;
 
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.BDDMockito.*;
 
 /**
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 3927da1aeb2..e2b6c6c9344 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
@@ -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.
@@ -29,15 +29,10 @@ import org.springframework.mock.web.test.MockHttpServletRequest;
 import org.springframework.mock.web.test.MockHttpServletResponse;
 import org.springframework.web.context.request.NativeWebRequest;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.BDDMockito.given;
-import static org.mockito.BDDMockito.mock;
-import static org.mockito.BDDMockito.verify;
-import static org.mockito.Mockito.verifyNoMoreInteractions;
-import static org.mockito.Mockito.when;
-import static org.springframework.web.context.request.async.CallableProcessingInterceptor.RESULT_NONE;
+import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
+import static org.mockito.BDDMockito.*;
+import static org.springframework.web.context.request.async.CallableProcessingInterceptor.*;
 
 /**
  * {@link WebAsyncManager} tests where container-triggered timeout/completion
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 abd3bf9964d..53a1afeb8c9 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
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2002-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.springframework.web.context.support;
 
 import java.io.IOException;
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 c0639291b53..6671163988c 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2011 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.
@@ -25,7 +25,7 @@ import org.springframework.core.env.StandardEnvironment;
 import org.springframework.tests.mock.jndi.SimpleNamingContextBuilder;
 
 import static org.hamcrest.CoreMatchers.*;
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.MatcherAssert.*;
 
 /**
  * Unit tests for {@link StandardServletEnvironment}.
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 61f0b330fc0..97e34618439 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,14 +16,14 @@
 
 package org.springframework.web.cors;
 
-import static org.junit.Assert.*;
-
 import org.junit.Test;
 
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.HttpMethod;
 import org.springframework.mock.web.test.MockHttpServletRequest;
 
+import static org.junit.Assert.*;
+
 /**
  * Test case for {@link CorsUtils}.
  *
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 910dd8dec63..5f452145251 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
@@ -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.
@@ -27,7 +27,7 @@ import org.springframework.mock.web.test.MockHttpServletRequest;
 import org.springframework.mock.web.test.MockHttpServletResponse;
 
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.contains;
+import static org.hamcrest.Matchers.*;
 import static org.junit.Assert.*;
 
 /**
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 6c8c91bb90c..e441e8dfef2 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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,12 +16,13 @@
 
 package org.springframework.web.cors;
 
-import static org.junit.Assert.*;
 import org.junit.Test;
 
 import org.springframework.http.HttpMethod;
 import org.springframework.mock.web.test.MockHttpServletRequest;
 
+import static org.junit.Assert.*;
+
 /**
  * Unit tests for {@link UrlBasedCorsConfigurationSource}.
  * @author Sebastien Deleuze
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 d212e05d9b2..c7cb91ca2a0 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
@@ -31,16 +31,8 @@ import org.springframework.mock.web.test.server.MockServerWebExchange;
 import org.springframework.web.cors.CorsConfiguration;
 import org.springframework.web.server.WebFilterChain;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.springframework.http.HttpHeaders.ACCESS_CONTROL_ALLOW_HEADERS;
-import static org.springframework.http.HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN;
-import static org.springframework.http.HttpHeaders.ACCESS_CONTROL_EXPOSE_HEADERS;
-import static org.springframework.http.HttpHeaders.ACCESS_CONTROL_MAX_AGE;
-import static org.springframework.http.HttpHeaders.ACCESS_CONTROL_REQUEST_HEADERS;
-import static org.springframework.http.HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD;
-import static org.springframework.http.HttpHeaders.HOST;
-import static org.springframework.http.HttpHeaders.ORIGIN;
+import static org.junit.Assert.*;
+import static org.springframework.http.HttpHeaders.*;
 
 /**
  * Unit tests for {@link CorsWebFilter}.
@@ -65,12 +57,13 @@ public class CorsWebFilterTests {
 
 	@Test
 	public void nonCorsRequest() {
-		WebFilterChain filterChain = (filterExchange) -> {
+		WebFilterChain filterChain = filterExchange -> {
 			try {
 				HttpHeaders headers = filterExchange.getResponse().getHeaders();
 				assertNull(headers.getFirst(ACCESS_CONTROL_ALLOW_ORIGIN));
 				assertNull(headers.getFirst(ACCESS_CONTROL_EXPOSE_HEADERS));
-			} catch (AssertionError ex) {
+			}
+			catch (AssertionError ex) {
 				return Mono.error(ex);
 			}
 			return Mono.empty();
@@ -85,12 +78,13 @@ public class CorsWebFilterTests {
 
 	@Test
 	public void sameOriginRequest() {
-		WebFilterChain filterChain = (filterExchange) -> {
+		WebFilterChain filterChain = filterExchange -> {
 			try {
 				HttpHeaders headers = filterExchange.getResponse().getHeaders();
 				assertNull(headers.getFirst(ACCESS_CONTROL_ALLOW_ORIGIN));
 				assertNull(headers.getFirst(ACCESS_CONTROL_EXPOSE_HEADERS));
-			} catch (AssertionError ex) {
+			}
+			catch (AssertionError ex) {
 				return Mono.error(ex);
 			}
 			return Mono.empty();
@@ -105,12 +99,13 @@ public class CorsWebFilterTests {
 
 	@Test
 	public void validActualRequest() {
-		WebFilterChain filterChain = (filterExchange) -> {
+		WebFilterChain filterChain = filterExchange -> {
 			try {
 				HttpHeaders headers = filterExchange.getResponse().getHeaders();
 				assertEquals("https://domain2.com", headers.getFirst(ACCESS_CONTROL_ALLOW_ORIGIN));
 				assertEquals("header3, header4", headers.getFirst(ACCESS_CONTROL_EXPOSE_HEADERS));
-			} catch (AssertionError ex) {
+			}
+			catch (AssertionError ex) {
 				return Mono.error(ex);
 			}
 			return Mono.empty();
@@ -134,7 +129,7 @@ public class CorsWebFilterTests {
 						.header(ORIGIN, "https://domain2.com")
 						.header("header2", "foo"));
 
-		WebFilterChain filterChain = (filterExchange) -> Mono.error(
+		WebFilterChain filterChain = filterExchange -> Mono.error(
 				new AssertionError("Invalid requests must not be forwarded to the filter chain"));
 		filter.filter(exchange, filterChain).block();
 		assertNull(exchange.getResponse().getHeaders().getFirst(ACCESS_CONTROL_ALLOW_ORIGIN));
@@ -152,7 +147,7 @@ public class CorsWebFilterTests {
 						.header(ACCESS_CONTROL_REQUEST_HEADERS, "header1, header2")
 		);
 
-		WebFilterChain filterChain = (filterExchange) -> Mono.error(
+		WebFilterChain filterChain = filterExchange -> Mono.error(
 				new AssertionError("Preflight requests must not be forwarded to the filter chain"));
 		filter.filter(exchange, filterChain).block();
 
@@ -174,7 +169,7 @@ public class CorsWebFilterTests {
 						.header(ACCESS_CONTROL_REQUEST_METHOD, HttpMethod.DELETE.name())
 						.header(ACCESS_CONTROL_REQUEST_HEADERS, "header1, header2"));
 
-		WebFilterChain filterChain = (filterExchange) -> Mono.error(
+		WebFilterChain filterChain = filterExchange -> Mono.error(
 				new AssertionError("Preflight requests must not be forwarded to the filter chain"));
 
 		filter.filter(exchange, filterChain).block();
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 d6c869ae402..48a5de16176 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
@@ -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.
@@ -29,17 +29,9 @@ import org.springframework.web.cors.CorsConfiguration;
 import org.springframework.web.server.ServerWebExchange;
 
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.contains;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.springframework.http.HttpHeaders.ACCESS_CONTROL_ALLOW_HEADERS;
-import static org.springframework.http.HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN;
-import static org.springframework.http.HttpHeaders.ACCESS_CONTROL_REQUEST_HEADERS;
-import static org.springframework.http.HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD;
-import static org.springframework.http.HttpHeaders.ORIGIN;
-import static org.springframework.http.HttpHeaders.VARY;
+import static org.hamcrest.Matchers.*;
+import static org.junit.Assert.*;
+import static org.springframework.http.HttpHeaders.*;
 
 /**
  * {@link DefaultCorsProcessor} tests with simple or pre-flight CORS request.
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 1894608d550..85ab739a486 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
@@ -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.
@@ -22,8 +22,7 @@ import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest;
 import org.springframework.mock.web.test.server.MockServerWebExchange;
 import org.springframework.web.cors.CorsConfiguration;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.Assert.*;
 
 /**
  * Unit tests for {@link UrlBasedCorsConfigurationSource}.
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 d2bc3f471b8..6d6e14105e5 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,7 +21,6 @@ import java.util.Arrays;
 import javax.servlet.FilterChain;
 import javax.servlet.ServletException;
 
-import static org.junit.Assert.*;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -31,6 +30,8 @@ import org.springframework.mock.web.test.MockHttpServletRequest;
 import org.springframework.mock.web.test.MockHttpServletResponse;
 import org.springframework.web.cors.CorsConfiguration;
 
+import static org.junit.Assert.*;
+
 /**
  * Unit tests for {@link CorsFilter}.
  * @author Sebastien Deleuze
@@ -105,9 +106,8 @@ public class CorsFilterTests {
 		request.addHeader("header2", "foo");
 		MockHttpServletResponse response = new MockHttpServletResponse();
 
-		FilterChain filterChain = (filterRequest, filterResponse) -> {
+		FilterChain filterChain = (filterRequest, filterResponse) ->
 			fail("Invalid requests must not be forwarded to the filter chain");
-		};
 		filter.doFilter(request, response, filterChain);
 		assertNull(response.getHeader(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN));
 	}
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 076a06c1a1e..cc2f8575c37 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
@@ -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,6 @@
 package org.springframework.web.filter;
 
 import java.io.IOException;
-
 import javax.servlet.FilterChain;
 import javax.servlet.ServletException;
 import javax.servlet.ServletRequest;
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 6d13344452e..c35220097c6 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
@@ -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.
@@ -32,7 +32,7 @@ import org.springframework.web.server.ServerWebExchange;
 import org.springframework.web.server.WebFilterChain;
 
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.*;
 
 /**
  * Tests for {@link HiddenHttpMethodFilter}.
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 f858f90d242..70fef6d7bec 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2012 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.
@@ -36,10 +36,7 @@ import org.springframework.web.context.request.ServletWebRequest;
 import org.springframework.web.method.support.HandlerMethodArgumentResolverComposite;
 import org.springframework.web.method.support.InvocableHandlerMethod;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
+import static org.junit.Assert.*;
 
 /**
  * Test fixture with {@link InitBinderDataBinderFactory}.
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 13ce6ae9155..2467e8a7d9f 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
@@ -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.
@@ -43,6 +43,7 @@ import org.springframework.web.method.support.ModelAndViewContainer;
 import static java.lang.annotation.ElementType.*;
 import static java.lang.annotation.RetentionPolicy.*;
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.BDDMockito.*;
 
 /**
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 340908b49d6..cd7d8b1dea7 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
@@ -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.
@@ -41,13 +41,8 @@ import org.springframework.web.method.support.HandlerMethodArgumentResolverCompo
 import org.springframework.web.method.support.InvocableHandlerMethod;
 import org.springframework.web.method.support.ModelAndViewContainer;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.mockito.BDDMockito.given;
-import static org.mockito.BDDMockito.mock;
+import static org.junit.Assert.*;
+import static org.mockito.BDDMockito.*;
 
 /**
  * Text fixture for {@link ModelFactory} tests.
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 413d11da1d8..16611d1383d 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
@@ -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.
@@ -30,12 +30,8 @@ import org.springframework.web.bind.support.SessionAttributeStore;
 import org.springframework.web.context.request.NativeWebRequest;
 import org.springframework.web.context.request.ServletWebRequest;
 
-import static java.util.Arrays.asList;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static java.util.Arrays.*;
+import static org.junit.Assert.*;
 
 /**
  * Test fixture with {@link SessionAttributesHandler}.
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 68af7e9e489..c7b2cbd7015 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
@@ -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.
@@ -21,12 +21,8 @@ import org.junit.Test;
 
 import org.springframework.core.MethodParameter;
 
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoMoreInteractions;
-import static org.mockito.Mockito.when;
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
 
 /**
  * Test fixture with {@link HandlerMethodReturnValueHandlerComposite}.
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 5c003639354..06b3621c752 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
@@ -1,11 +1,11 @@
 /*
- * 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.
  * You may obtain a copy of the License at
  *
- * https://www.apache.org/licenses/LICENSE-2.0
+ *      https://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -36,11 +36,8 @@ import org.springframework.http.HttpStatus;
 import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest;
 import org.springframework.mock.web.test.server.MockServerWebExchange;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.springframework.mock.http.server.reactive.test.MockServerHttpRequest.get;
+import static org.junit.Assert.*;
+import static org.springframework.mock.http.server.reactive.test.MockServerHttpRequest.*;
 
 /**
  * "checkNotModified" unit tests for {@link DefaultServerWebExchange}.
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 04522b0cda0..3efa73a46c8 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
@@ -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.
@@ -30,8 +30,7 @@ import org.springframework.web.server.WebExceptionHandler;
 import org.springframework.web.server.WebHandler;
 import org.springframework.web.server.adapter.HttpWebHandlerAdapter;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.Assert.*;
 
 /**
  * Unit tests for {@link ExceptionHandlingWebHandler}.
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 337f12585f1..d40ce7fe1a6 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
@@ -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.
@@ -36,10 +36,7 @@ import org.springframework.web.server.WebFilterChain;
 import org.springframework.web.server.WebHandler;
 import org.springframework.web.server.adapter.WebHttpHandlerBuilder;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
 
 /**
  * Unit tests for {@link FilteringWebHandler}.
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 61e0a0abf88..7a1d84844fa 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
@@ -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.
@@ -22,8 +22,7 @@ import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest;
 import org.springframework.mock.web.test.server.MockServerWebExchange;
 import org.springframework.util.MultiValueMap;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.*;
 
 /**
  * Unit tests for {@link CookieWebSessionIdResolver}.
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 1330820613c..b9ce3d71a40 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
@@ -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.
@@ -35,8 +35,7 @@ import org.springframework.web.server.adapter.DefaultServerWebExchange;
 import org.springframework.web.server.i18n.AcceptHeaderLocaleContextResolver;
 
 import static org.junit.Assert.*;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.Mockito.*;
 
 /**
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 431a113a1fc..cf1bd6fdea5 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
@@ -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.
@@ -15,17 +15,17 @@
  */
 package org.springframework.web.server.session;
 
+import java.util.Arrays;
+import java.util.List;
+
 import org.junit.Before;
 import org.junit.Test;
+
 import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest;
 import org.springframework.mock.web.test.server.MockServerWebExchange;
 import org.springframework.web.server.ServerWebExchange;
 
-import java.util.Arrays;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
 
 /**
  * Tests using {@link HeaderWebSessionIdResolver}.
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 26e0e1b48ff..8cc2440ef33 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
@@ -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.
@@ -23,8 +23,8 @@ import org.junit.Test;
 
 import org.springframework.web.util.DefaultUriBuilderFactory.EncodingMode;
 
-import static java.util.Collections.singletonMap;
-import static junit.framework.TestCase.assertEquals;
+import static java.util.Collections.*;
+import static junit.framework.TestCase.*;
 
 /**
  * Unit tests for {@link DefaultUriBuilderFactory}.
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 62b24815490..1883ba1164f 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
@@ -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.
@@ -12,7 +12,9 @@
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
- */package org.springframework.web.util;
+ */
+
+package org.springframework.web.util;
 
 import org.junit.Test;
 
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 30b2a710b79..b9636276a7a 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
@@ -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.
@@ -25,11 +25,7 @@ import org.junit.Test;
 import org.springframework.http.server.PathContainer;
 import org.springframework.web.util.pattern.PatternParseException.PatternMessage;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.*;
 
 /**
  * Exercise the {@link PathPatternParser}.
@@ -186,7 +182,7 @@ public class PathPatternParserTests {
 		checkStructure("/{f}/");
 		checkStructure("/{foo}/{bar}/{wibble}");
 	}
-	
+
 	@Test
 	public void noEncoding() {
 		// Check no encoding of expressions or constraints
@@ -195,7 +191,7 @@ public class PathPatternParserTests {
 
 		pp = parse("/{var:f o}_");
 		assertEquals("Separator(/) Regex({var:f o}_)",pp.toChainString());
-		
+
 		pp = parse("{foo:f o}_ _{bar:b\\|o}");
 		assertEquals("Regex({foo:f o}_ _{bar:b\\|o})",pp.toChainString());
 	}
@@ -473,7 +469,7 @@ public class PathPatternParserTests {
 	private void assertNoMatch(PathPattern pp, String path) {
 		assertFalse(pp.matches(PathPatternTests.toPathContainer(path)));
 	}
-	
+
 	private PathPattern.PathMatchInfo matchAndExtract(PathPattern pp, String path) {
 		return pp.matchAndExtract(PathPatternTests.toPathContainer(path));
 	}
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 873bede4485..c77b4c10280 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
@@ -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.
@@ -24,23 +24,16 @@ import java.util.List;
 import java.util.Map;
 
 import org.hamcrest.Matchers;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.http.server.PathContainer;
 import org.springframework.http.server.PathContainer.Element;
 import org.springframework.util.AntPathMatcher;
 import org.springframework.web.util.pattern.PathPattern.PathRemainingMatchInfo;
 
-import static org.hamcrest.CoreMatchers.containsString;
+import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.*;
 
 /**
  * Exercise matching of {@link PathPattern} objects.
@@ -842,14 +835,11 @@ public class PathPatternTests {
 	public void extractUriTemplateVarsRegexCapturingGroups() {
 		PathPatternParser ppp = new PathPatternParser();
 		PathPattern pathPattern = ppp.parse("/web/{id:foo(bar)?}_{goo}");
-		exception.expect(IllegalArgumentException.class);
-		exception.expectMessage(containsString("The number of capturing groups in the pattern"));
-		matchAndExtract(pathPattern,"/web/foobar_goo");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				matchAndExtract(pathPattern,"/web/foobar_goo"))
+			.withMessageContaining("The number of capturing groups in the pattern");
 	}
 
-	@Rule
-	public final ExpectedException exception = ExpectedException.none();
-
 	@Test
 	public void combine() {
 		TestPathCombiner pathMatcher = new TestPathCombiner();
@@ -893,8 +883,8 @@ public class PathPatternTests {
 	@Test
 	public void combineWithTwoFileExtensionPatterns() {
 		TestPathCombiner pathMatcher = new TestPathCombiner();
-		exception.expect(IllegalArgumentException.class);
-		pathMatcher.combine("/*.html", "/*.txt");
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				pathMatcher.combine("/*.html", "/*.txt"));
 	}
 
 	@Test
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 5c8e79b4aa8..afd4da29dae 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
@@ -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.
@@ -25,7 +25,7 @@ import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest;
 import org.springframework.mock.web.test.server.MockServerWebExchange;
 import org.springframework.web.server.NotAcceptableStatusException;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.*;
 
 /**
  * Unit tests for {@link HeaderContentTypeResolver}.
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 c6709608b5a..d7f71fa47d0 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
@@ -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.
@@ -27,7 +27,7 @@ import org.springframework.mock.web.test.server.MockServerWebExchange;
 import org.springframework.web.server.NotAcceptableStatusException;
 import org.springframework.web.server.ServerWebExchange;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.*;
 
 /**
  * Unit tests for {@link ParameterContentTypeResolver}.
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 f035f580b09..2fc33922832 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
@@ -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.
@@ -24,7 +24,7 @@ import org.springframework.http.MediaType;
 import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest;
 import org.springframework.mock.web.test.server.MockServerWebExchange;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.*;
 
 /**
  * Unit tests for {@link RequestedContentTypeResolverBuilder}.
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 bac0c180f59..b2d29355494 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
@@ -38,6 +38,7 @@ import org.springframework.web.bind.support.ConfigurableWebBindingInitializer;
 import org.springframework.web.reactive.accept.RequestedContentTypeResolverBuilder;
 
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.BDDMockito.*;
 
 /**
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 71d75952215..d270575c0f1 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
@@ -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.
@@ -50,10 +50,7 @@ import org.springframework.web.reactive.resource.VersionResourceResolver;
 import org.springframework.web.reactive.resource.WebJarsResourceResolver;
 
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
 
 /**
  * Unit tests for {@link ResourceHandlerRegistry}.
@@ -126,7 +123,7 @@ public class ResourceHandlerRegistryTests {
 		this.registry.setResourceUrlProvider(resourceUrlProvider);
 		ResourceResolver mockResolver = Mockito.mock(ResourceResolver.class);
 		ResourceTransformerSupport mockTransformer = Mockito.mock(ResourceTransformerSupport.class);
-		
+
 		this.registration.resourceChain(true).addResolver(mockResolver).addTransformer(mockTransformer);
 
 		ResourceWebHandler handler = getHandler("/resources/**");
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 188a87638e1..f163bf53d30 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
@@ -78,15 +78,9 @@ import org.springframework.web.util.pattern.PathPatternParser;
 
 import static org.junit.Assert.*;
 import static org.mockito.Mockito.*;
-import static org.springframework.core.ResolvableType.forClass;
-import static org.springframework.core.ResolvableType.forClassWithGenerics;
-import static org.springframework.http.MediaType.APPLICATION_FORM_URLENCODED;
-import static org.springframework.http.MediaType.APPLICATION_JSON;
-import static org.springframework.http.MediaType.APPLICATION_OCTET_STREAM;
-import static org.springframework.http.MediaType.APPLICATION_XML;
-import static org.springframework.http.MediaType.IMAGE_PNG;
-import static org.springframework.http.MediaType.TEXT_PLAIN;
-import static org.springframework.mock.http.server.reactive.test.MockServerHttpRequest.get;
+import static org.springframework.core.ResolvableType.*;
+import static org.springframework.http.MediaType.*;
+import static org.springframework.mock.http.server.reactive.test.MockServerHttpRequest.*;
 
 /**
  * Unit tests for {@link WebFluxConfigurationSupport}.
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 fca84021a9f..6ef7a0ab05a 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
@@ -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.
@@ -435,8 +435,8 @@ public class BodyExtractorsTests {
 					try {
 						buffer.release();
 						Assert.fail("releasing the buffer should have failed");
-					} catch (IllegalReferenceCountException exc) {
-
+					}
+					catch (IllegalReferenceCountException exc) {
 					}
 					body.assertCancelled();
 				}).verify();
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 7965b7ab943..924471712e4 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
@@ -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.
@@ -46,12 +46,9 @@ import org.springframework.http.codec.HttpMessageReader;
 import org.springframework.util.LinkedMultiValueMap;
 import org.springframework.util.MultiValueMap;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.fail;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-import static org.springframework.web.reactive.function.BodyExtractors.toMono;
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+import static org.springframework.web.reactive.function.BodyExtractors.*;
 
 /**
  * @author Arjen Poutsma
@@ -250,7 +247,8 @@ public class DefaultClientResponseTests {
 		try {
 			result.getStatusCode();
 			fail("Expected IllegalArgumentException");
-		} catch (IllegalArgumentException ex) {
+		}
+		catch (IllegalArgumentException ex) {
 			// do nothing
 		}
 		assertEquals(999, result.getStatusCodeValue());
@@ -320,7 +318,8 @@ public class DefaultClientResponseTests {
 		try {
 			result.getStatusCode();
 			fail("Expected IllegalArgumentException");
-		} catch (IllegalArgumentException ex) {
+		}
+		catch (IllegalArgumentException ex) {
 			// do nothing
 		}
 		assertEquals(999, result.getStatusCodeValue());
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 70c38eee1d4..2a2cfe8286a 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
@@ -35,6 +35,7 @@ import org.springframework.http.HttpHeaders;
 import org.springframework.http.MediaType;
 
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.Mockito.*;
 
 /**
@@ -287,12 +288,12 @@ public class DefaultWebClientTests {
 	@Test
 	public void shouldApplyFiltersAtSubscription() {
 		WebClient client = this.builder
-				.filter((request, next) -> {
-					return next.exchange(ClientRequest
+				.filter((request, next) ->
+					next.exchange(ClientRequest
 							.from(request)
 							.header("Custom", "value")
-							.build());
-				})
+							.build())
+				)
 				.build();
 		Mono exchange = client.get().uri("/path").exchange();
 		verifyZeroInteractions(this.exchangeFunction);
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 74f93f667a2..659162863c3 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
@@ -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.
@@ -730,9 +730,9 @@ public class WebClientIntegrationTests {
 				.exchange()
 				.flatMap(response -> response.toEntity(Void.class));
 
-		StepVerifier.create(result).assertNext(r -> {
-			assertTrue(r.getStatusCode().is2xxSuccessful());
-		}).verifyComplete();
+		StepVerifier.create(result).assertNext(r ->
+			assertTrue(r.getStatusCode().is2xxSuccessful())
+		).verifyComplete();
 	}
 
 	@Test  // SPR-15782
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 f989e69b8b2..0a7611fd0f3 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
@@ -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.
@@ -46,6 +46,7 @@ import org.springframework.web.reactive.result.view.ViewResolverSupport;
 import org.springframework.web.server.ServerWebExchange;
 
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.Mockito.*;
 
 /**
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 71152e8dac3..21f66babfeb 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
@@ -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.
@@ -30,12 +30,8 @@ import org.springframework.web.client.RestTemplate;
 import org.springframework.web.util.pattern.PathPattern;
 
 import static org.junit.Assert.*;
-import static org.springframework.web.reactive.function.server.RequestPredicates.GET;
-import static org.springframework.web.reactive.function.server.RequestPredicates.all;
-import static org.springframework.web.reactive.function.server.RequestPredicates.method;
-import static org.springframework.web.reactive.function.server.RequestPredicates.path;
-import static org.springframework.web.reactive.function.server.RouterFunctions.nest;
-import static org.springframework.web.reactive.function.server.RouterFunctions.route;
+import static org.springframework.web.reactive.function.server.RequestPredicates.*;
+import static org.springframework.web.reactive.function.server.RouterFunctions.*;
 
 /**
  * @author Arjen Poutsma
@@ -141,7 +137,8 @@ public class NestedRouteIntegrationTests extends AbstractRouterFunctionIntegrati
 			Flux responseBody;
 			if (!pattern.isEmpty()) {
 				responseBody = Flux.just(pattern, "\n", pathVariables.toString());
-			} else {
+			}
+			else {
 				responseBody = Flux.just(pathVariables.toString());
 			}
 			return ServerResponse.ok().body(responseBody, String.class);
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 26d71d693cf..4171477e0db 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
@@ -203,9 +203,9 @@ public class RouterFunctionBuilderTests {
 
 
 		StepVerifier.create(fooResponseMono)
-				.consumeNextWith(serverResponse -> {
-					assertEquals(4, filterCount.get());
-				})
+				.consumeNextWith(serverResponse ->
+					assertEquals(4, filterCount.get())
+				)
 				.verifyComplete();
 
 		filterCount.set(0);
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 54403e2fad7..45e5bc24ec2 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
@@ -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.
@@ -109,12 +109,12 @@ public class RouterFunctionTests {
 
 		StepVerifier.create(responseMono)
 				.consumeNextWith(
-						serverResponse -> {
+						serverResponse ->
 							StepVerifier.create(serverResponse.entity())
 									.expectNext(42)
 									.expectComplete()
-									.verify();
-						})
+									.verify()
+						)
 				.expectComplete()
 				.verify();
 	}
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 bcd7e0ab877..93b38ecfa71 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
@@ -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.
@@ -23,15 +23,8 @@ import org.springframework.http.HttpMethod;
 import org.springframework.http.MediaType;
 
 import static org.junit.Assert.*;
-import static org.springframework.web.reactive.function.server.RequestPredicates.GET;
-import static org.springframework.web.reactive.function.server.RequestPredicates.accept;
-import static org.springframework.web.reactive.function.server.RequestPredicates.contentType;
-import static org.springframework.web.reactive.function.server.RequestPredicates.method;
-import static org.springframework.web.reactive.function.server.RequestPredicates.methods;
-import static org.springframework.web.reactive.function.server.RequestPredicates.path;
-import static org.springframework.web.reactive.function.server.RequestPredicates.pathExtension;
-import static org.springframework.web.reactive.function.server.RequestPredicates.queryParam;
-import static org.springframework.web.reactive.function.server.RouterFunctions.route;
+import static org.springframework.web.reactive.function.server.RequestPredicates.*;
+import static org.springframework.web.reactive.function.server.RouterFunctions.*;
 
 /**
  * @author Arjen Poutsma
@@ -42,11 +35,11 @@ public class ToStringVisitorTests {
 	public void nested() {
 		HandlerFunction handler = new SimpleHandlerFunction();
 		RouterFunction routerFunction = route()
-				.path("/foo", builder -> {
+				.path("/foo", builder ->
 					builder.path("/bar", () -> route()
 							.GET("/baz", handler)
-							.build());
-				})
+							.build())
+				)
 				.build();
 
 		ToStringVisitor visitor = new ToStringVisitor();
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 ca03dd92441..c50d40134b3 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
@@ -28,10 +28,7 @@ import org.springframework.web.cors.CorsConfiguration;
 import org.springframework.web.cors.reactive.CorsConfigurationSource;
 import org.springframework.web.server.ServerWebExchange;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertSame;
+import static org.junit.Assert.*;
 
 /**
  * Unit tests for CORS support at {@link AbstractUrlHandlerMapping} level.
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 a33f174fa1c..e522c93a09b 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
@@ -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.
@@ -31,11 +31,8 @@ import org.springframework.mock.web.test.server.MockServerWebExchange;
 import org.springframework.web.reactive.HandlerMapping;
 import org.springframework.web.server.ServerWebExchange;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.springframework.web.reactive.HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE;
+import static org.junit.Assert.*;
+import static org.springframework.web.reactive.HandlerMapping.*;
 
 /**
  * Unit tests for {@link SimpleUrlHandlerMapping}.
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 c849748d8ba..b2bf63a9ea8 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
@@ -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.
@@ -22,7 +22,6 @@ import org.junit.Test;
 
 import org.springframework.http.HttpStatus;
 import org.springframework.web.bind.annotation.ResponseStatus;
-import org.springframework.web.reactive.handler.WebFluxResponseStatusExceptionHandler;
 import org.springframework.web.server.handler.ResponseStatusExceptionHandler;
 import org.springframework.web.server.handler.ResponseStatusExceptionHandlerTests;
 
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 4b32ce15259..8c65d727b4c 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
@@ -1,11 +1,11 @@
 /*
- * 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.
  * You may obtain a copy of the License at
  *
- *  https://www.apache.org/licenses/LICENSE-2.0
+ *      https://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -43,7 +43,7 @@ public class AppCacheManifestTransformerTests {
 
 	private static final Duration TIMEOUT = Duration.ofSeconds(5);
 
-	
+
 	private AppCacheManifestTransformer transformer;
 
 	private ResourceTransformerChain chain;
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 a3a6bd29230..34b83c6eb88 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
@@ -1,11 +1,11 @@
 /*
- * 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.
  * You may obtain a copy of the License at
  *
- *  https://www.apache.org/licenses/LICENSE-2.0
+ *      https://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -13,6 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package org.springframework.web.reactive.resource;
 
 import java.util.Collections;
@@ -25,8 +26,7 @@ import org.springframework.core.io.Resource;
 import org.springframework.util.DigestUtils;
 import org.springframework.util.FileCopyUtils;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.Assert.*;
 
 /**
  * Unit tests for {@link ContentVersionStrategy}.
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 4afd4c07659..f650896d2ae 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
@@ -26,12 +26,8 @@ import org.springframework.core.io.FileUrlResource;
 import org.springframework.core.io.Resource;
 import org.springframework.core.io.UrlResource;
 
-import static java.util.Collections.singletonList;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static java.util.Collections.*;
+import static org.junit.Assert.*;
 
 /**
  * Unit tests for {@link PathResourceResolver}.
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 83ab2ad0cca..1da689a3f46 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
@@ -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.
@@ -29,14 +29,9 @@ import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest;
 import org.springframework.mock.web.test.server.MockServerWebExchange;
 import org.springframework.web.server.ServerWebExchange;
 
-import static java.util.Collections.singletonList;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.mockito.BDDMockito.given;
-import static org.mockito.BDDMockito.mock;
-import static org.mockito.BDDMockito.never;
-import static org.mockito.BDDMockito.times;
-import static org.mockito.BDDMockito.verify;
+import static java.util.Collections.*;
+import static org.junit.Assert.*;
+import static org.mockito.BDDMockito.*;
 
 /**
  * Unit tests for {@link WebJarsResourceResolver}.
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 efcf8c8c085..91178261f29 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
@@ -31,14 +31,8 @@ import org.springframework.web.reactive.accept.FixedContentTypeResolver;
 import org.springframework.web.reactive.accept.HeaderContentTypeResolver;
 import org.springframework.web.reactive.accept.RequestedContentTypeResolver;
 
-import static org.junit.Assert.assertEquals;
-import static org.springframework.http.MediaType.ALL;
-import static org.springframework.http.MediaType.APPLICATION_JSON;
-import static org.springframework.http.MediaType.APPLICATION_OCTET_STREAM;
-import static org.springframework.http.MediaType.IMAGE_GIF;
-import static org.springframework.http.MediaType.IMAGE_JPEG;
-import static org.springframework.http.MediaType.IMAGE_PNG;
-import static org.springframework.http.MediaType.TEXT_PLAIN;
+import static org.junit.Assert.*;
+import static org.springframework.http.MediaType.*;
 
 /**
  * Unit tests for {@link HandlerResultHandlerSupport}.
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 58772060b7f..b9bdccfbfae 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
@@ -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.
@@ -23,9 +23,7 @@ import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest;
 import org.springframework.mock.web.test.server.MockServerWebExchange;
 import org.springframework.web.bind.annotation.RequestMethod;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
+import static org.junit.Assert.*;
 
 /**
  * Unit tests for {@link CompositeRequestCondition}.
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 ff6264646b3..516caa62937 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
@@ -26,11 +26,7 @@ import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest;
 import org.springframework.mock.web.test.server.MockServerWebExchange;
 import org.springframework.web.reactive.result.condition.ConsumesRequestCondition.ConsumeMediaTypeExpression;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.*;
 
 /**
  * @author Arjen Poutsma
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 be8d74f3539..e90046bae63 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
@@ -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.
@@ -27,10 +27,8 @@ import org.springframework.web.server.ServerWebExchange;
 import org.springframework.web.util.pattern.PathPattern;
 import org.springframework.web.util.pattern.PathPatternParser;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.springframework.mock.http.server.reactive.test.MockServerHttpRequest.get;
+import static org.junit.Assert.*;
+import static org.springframework.mock.http.server.reactive.test.MockServerHttpRequest.*;
 
 /**
  * Unit tests for {@link PatternsRequestCondition}.
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 9726613e71d..7fcd9ce69cb 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
@@ -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.
@@ -22,10 +22,7 @@ import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest;
 import org.springframework.mock.web.test.server.MockServerWebExchange;
 import org.springframework.web.bind.annotation.RequestMethod;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
+import static org.junit.Assert.*;
 
 /**
  * Unit tests for {@link RequestConditionHolder}.
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 3131c23eeff..dccad8e5166 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
@@ -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.
@@ -22,9 +22,7 @@ import java.util.Comparator;
 import java.util.List;
 
 import org.junit.Ignore;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.MediaType;
@@ -37,13 +35,10 @@ import org.springframework.web.util.pattern.PathPattern;
 import org.springframework.web.util.pattern.PathPatternParser;
 import org.springframework.web.util.pattern.PatternParseException;
 
-import static java.util.Arrays.asList;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.springframework.web.reactive.result.method.RequestMappingInfo.paths;
+import static java.util.Arrays.*;
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
+import static org.junit.Assert.*;
+import static org.springframework.web.reactive.result.method.RequestMappingInfo.*;
 
 /**
  * Unit tests for {@link RequestMappingInfo}.
@@ -52,9 +47,6 @@ import static org.springframework.web.reactive.result.method.RequestMappingInfo.
  */
 public class RequestMappingInfoTests {
 
-	@Rule
-	public ExpectedException thrown = ExpectedException.none();
-
 	// TODO: CORS pre-flight (see @Ignore)
 
 
@@ -74,9 +66,9 @@ public class RequestMappingInfoTests {
 
 	@Test
 	public void throwWhenInvalidPattern() {
-		this.thrown.expect(PatternParseException.class);
-		this.thrown.expectMessage("Expected close capture character after variable name }");
-		paths("/{foo").build();
+		assertThatExceptionOfType(PatternParseException.class).isThrownBy(() ->
+				paths("/{foo").build())
+			.withMessageContaining("Expected close capture character after variable name }");
 	}
 
 	@Test
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 8d3afff3990..2aba9c9daba 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
@@ -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.
@@ -45,7 +45,7 @@ import org.springframework.web.server.UnsupportedMediaTypeStatusException;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.*;
 import static org.junit.Assert.*;
-import static org.mockito.Mockito.any;
+import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.*;
 import static org.springframework.mock.http.server.reactive.test.MockServerHttpRequest.*;
 
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 58ed270bf7f..a8f9809507d 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
@@ -50,7 +50,7 @@ import org.springframework.web.method.HandlerMethod;
 import org.springframework.web.reactive.BindingContext;
 import org.springframework.web.reactive.HandlerMapping;
 import org.springframework.web.reactive.HandlerResult;
-import org.springframework.web.reactive.result.method.RequestMappingInfo.*;
+import org.springframework.web.reactive.result.method.RequestMappingInfo.BuilderConfiguration;
 import org.springframework.web.server.MethodNotAllowedException;
 import org.springframework.web.server.NotAcceptableStatusException;
 import org.springframework.web.server.ServerWebExchange;
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 34440e853ec..f01c9342f33 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-201 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,6 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package org.springframework.web.reactive.result.method.annotation;
 
 import java.lang.reflect.Method;
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 c79a59affc5..a2619632113 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
@@ -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,9 +18,7 @@ package org.springframework.web.reactive.result.method.annotation;
 
 import java.time.Duration;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 import reactor.core.publisher.Mono;
 import reactor.core.publisher.MonoProcessor;
 
@@ -36,6 +34,7 @@ import org.springframework.web.bind.annotation.ModelAttribute;
 import org.springframework.web.method.ResolvableMethod;
 import org.springframework.web.reactive.BindingContext;
 
+import static org.assertj.core.api.Assertions.*;
 import static org.junit.Assert.*;
 
 /**
@@ -55,9 +54,6 @@ public class ErrorsMethodArgumentResolverTests {
 
 	private final ResolvableMethod testMethod = ResolvableMethod.on(getClass()).named("handle").build();
 
-	@Rule
-	public final ExpectedException expectedException = ExpectedException.none();
-
 
 	@Test
 	public void supports() {
@@ -107,22 +103,22 @@ public class ErrorsMethodArgumentResolverTests {
 
 	@Test
 	public void resolveWithMonoOnBindingResultAndModelAttribute() {
-		this.expectedException.expectMessage("An @ModelAttribute and an Errors/BindingResult argument " +
-				"cannot both be declared with an async type wrapper.");
-
 		MethodParameter parameter = this.testMethod.arg(BindingResult.class);
-		this.resolver.resolveArgument(parameter, this.bindingContext, this.exchange)
-				.block(Duration.ofMillis(5000));
+		assertThatIllegalStateException().isThrownBy(() ->
+				this.resolver.resolveArgument(parameter, this.bindingContext, this.exchange)
+						.block(Duration.ofMillis(5000)))
+			.withMessageContaining("An @ModelAttribute and an Errors/BindingResult argument " +
+					"cannot both be declared with an async type wrapper.");
 	}
 
 	@Test  // SPR-16187
 	public void resolveWithBindingResultNotFound() {
-		this.expectedException.expectMessage("An Errors/BindingResult argument is expected " +
-				"immediately after the @ModelAttribute argument");
-
 		MethodParameter parameter = this.testMethod.arg(Errors.class);
-		this.resolver.resolveArgument(parameter, this.bindingContext, this.exchange)
-				.block(Duration.ofMillis(5000));
+		assertThatIllegalStateException().isThrownBy(() ->
+				this.resolver.resolveArgument(parameter, this.bindingContext, this.exchange)
+						.block(Duration.ofMillis(5000)))
+			.withMessageContaining("An Errors/BindingResult argument is expected " +
+					"immediately after the @ModelAttribute argument");
 	}
 
 
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 2f6519091a0..049a686644a 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
@@ -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.
@@ -33,9 +33,7 @@ import org.springframework.mock.web.test.server.MockServerWebExchange;
 import org.springframework.tests.sample.beans.TestBean;
 import org.springframework.web.server.ServerWebExchange;
 
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.Assert.*;
 
 /**
  * Unit tests for {@link AbstractView}.
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 057fd03a455..a74ae10b299 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
@@ -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.
@@ -30,9 +30,7 @@ import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest;
 import org.springframework.mock.web.test.server.MockServerWebExchange;
 import org.springframework.web.reactive.HandlerMapping;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
 
 /**
  * Tests for redirect view, and query string construction.
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 8f19cef730a..eb69399e26c 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
@@ -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.
@@ -26,7 +26,7 @@ import org.springframework.context.support.GenericApplicationContext;
 import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest;
 import org.springframework.mock.web.test.server.MockServerWebExchange;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.*;
 
 /**
  * Unit tests for {@link RequestContext}.
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 831407ce1c3..554646e0683 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
@@ -23,9 +23,7 @@ import java.util.Locale;
 
 import freemarker.template.Configuration;
 import org.junit.Before;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 import reactor.test.StepVerifier;
 
 import org.springframework.context.ApplicationContextException;
@@ -42,6 +40,7 @@ import org.springframework.web.server.adapter.DefaultServerWebExchange;
 import org.springframework.web.server.i18n.AcceptHeaderLocaleContextResolver;
 import org.springframework.web.server.session.DefaultWebSessionManager;
 
+import static org.assertj.core.api.Assertions.*;
 import static org.junit.Assert.*;
 
 /**
@@ -60,9 +59,6 @@ public class FreeMarkerViewTests {
 
 	private Configuration freeMarkerConfig;
 
-	@Rule
-	public final ExpectedException exception = ExpectedException.none();
-
 
 	@Before
 	public void setup() throws Exception {
@@ -79,22 +75,20 @@ public class FreeMarkerViewTests {
 
 	@Test
 	public void noFreeMarkerConfig() throws Exception {
-		this.exception.expect(ApplicationContextException.class);
-		this.exception.expectMessage("Must define a single FreeMarkerConfig bean");
-
 		FreeMarkerView view = new FreeMarkerView();
 		view.setApplicationContext(this.context);
 		view.setUrl("anythingButNull");
-		view.afterPropertiesSet();
+		assertThatExceptionOfType(ApplicationContextException.class).isThrownBy(
+				view::afterPropertiesSet)
+			.withMessageContaining("Must define a single FreeMarkerConfig bean");
 	}
 
 	@Test
 	public void noTemplateName() throws Exception {
-		this.exception.expect(IllegalArgumentException.class);
-		this.exception.expectMessage("Property 'url' is required");
-
 		FreeMarkerView freeMarkerView = new FreeMarkerView();
-		freeMarkerView.afterPropertiesSet();
+		assertThatIllegalArgumentException().isThrownBy(
+				freeMarkerView::afterPropertiesSet)
+			.withMessageContaining("Property 'url' is required");
 	}
 
 	@Test
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 75d09ac3c2b..d0231d5d763 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
@@ -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.
@@ -30,7 +30,7 @@ import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest;
 import org.springframework.mock.http.server.reactive.test.MockServerHttpResponse;
 import org.springframework.mock.web.test.server.MockServerWebExchange;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.*;
 
 /**
  * Unit tests for ERB templates running on JRuby.
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 da5203bb7ef..0b3a53e7a85 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
@@ -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.
@@ -29,7 +29,7 @@ import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest;
 import org.springframework.mock.http.server.reactive.test.MockServerHttpResponse;
 import org.springframework.mock.web.test.server.MockServerWebExchange;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.*;
 
 /**
  * Unit tests for String templates running on Jython.
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 ef0a5c6e607..e5a6f3e0456 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
@@ -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.
@@ -32,7 +32,7 @@ import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest;
 import org.springframework.mock.http.server.reactive.test.MockServerHttpResponse;
 import org.springframework.mock.web.test.server.MockServerWebExchange;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.*;
 
 /**
  * Unit tests for Kotlin script templates running on Kotlin JSR-223 support.
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 bf23b96ceb8..090d49c6335 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
@@ -35,7 +35,7 @@ import org.springframework.web.server.adapter.DefaultServerWebExchange;
 import org.springframework.web.server.i18n.AcceptHeaderLocaleContextResolver;
 import org.springframework.web.server.session.DefaultWebSessionManager;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.*;
 
 /**
  * Unit tests for pure JavaScript templates running on Nashorn engine.
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 26c00c75766..1102a8dfa26 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
@@ -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.
@@ -26,17 +26,17 @@ import java.util.concurrent.Future;
 import javax.script.Invocable;
 import javax.script.ScriptEngine;
 
-import static org.junit.Assert.*;
 import org.junit.Before;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import static org.mockito.BDDMockito.*;
 
 import org.springframework.beans.DirectFieldAccessor;
 import org.springframework.context.ApplicationContextException;
 import org.springframework.context.support.StaticApplicationContext;
 
+import static org.assertj.core.api.Assertions.*;
+import static org.junit.Assert.*;
+import static org.mockito.BDDMockito.*;
+
 /**
  * Unit tests for {@link ScriptTemplateView}.
  *
@@ -50,9 +50,6 @@ public class ScriptTemplateViewTests {
 
 	private StaticApplicationContext context;
 
-	@Rule
-	public ExpectedException expectedException = ExpectedException.none();
-
 
 	@Before
 	public void setup() {
@@ -76,9 +73,9 @@ public class ScriptTemplateViewTests {
 
 	@Test
 	public void missingScriptTemplateConfig() throws Exception {
-		this.expectedException.expect(ApplicationContextException.class);
-		this.view.setApplicationContext(new StaticApplicationContext());
-		this.expectedException.expectMessage(contains("ScriptTemplateConfig"));
+		assertThatExceptionOfType(ApplicationContextException.class).isThrownBy(() ->
+				this.view.setApplicationContext(new StaticApplicationContext()))
+			.withMessageContaining("ScriptTemplateConfig");
 	}
 
 	@Test
@@ -159,8 +156,8 @@ public class ScriptTemplateViewTests {
 	public void nonInvocableScriptEngineWithRenderFunction() throws Exception {
 		this.view.setEngine(mock(ScriptEngine.class));
 		this.view.setRenderFunction("render");
-		this.expectedException.expect(IllegalArgumentException.class);
-		this.view.setApplicationContext(this.context);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				this.view.setApplicationContext(this.context));
 	}
 
 	@Test
@@ -168,9 +165,9 @@ public class ScriptTemplateViewTests {
 		this.view.setEngine(mock(InvocableScriptEngine.class));
 		this.view.setEngineName("test");
 		this.view.setRenderFunction("render");
-		this.expectedException.expect(IllegalArgumentException.class);
-		this.view.setApplicationContext(this.context);
-		this.expectedException.expectMessage(contains("'engine' or 'engineName'"));
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				this.view.setApplicationContext(this.context))
+			.withMessageContaining("'engine' or 'engineName'");
 	}
 
 	@Test
@@ -178,9 +175,9 @@ public class ScriptTemplateViewTests {
 		this.view.setEngine(mock(InvocableScriptEngine.class));
 		this.view.setRenderFunction("render");
 		this.view.setSharedEngine(false);
-		this.expectedException.expect(IllegalArgumentException.class);
-		this.view.setApplicationContext(this.context);
-		this.expectedException.expectMessage(contains("sharedEngine"));
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				this.view.setApplicationContext(this.context))
+			.withMessageContaining("sharedEngine");
 	}
 
 	private interface InvocableScriptEngine extends ScriptEngine, Invocable {
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 4d57b35b078..dac86988272 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
@@ -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.
@@ -129,9 +129,9 @@ public class WebSocketIntegrationTests extends AbstractWebSocketIntegrationTests
 					return session.receive()
 							.doOnNext(s -> logger.debug("inbound " + s))
 							.then()
-							.doFinally(signalType -> {
-								logger.debug("Completed with: " + signalType);
-							});
+							.doFinally(signalType ->
+								logger.debug("Completed with: " + signalType)
+							);
 				})
 				.block(TIMEOUT);
 	}
diff --git a/spring-webmvc/src/test/java/org/springframework/context/TestListener.java b/spring-webmvc/src/test/java/org/springframework/context/TestListener.java
index 056ce147b98..242d60ac635 100644
--- a/spring-webmvc/src/test/java/org/springframework/context/TestListener.java
+++ b/spring-webmvc/src/test/java/org/springframework/context/TestListener.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2002-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.springframework.context;
 
 /**
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 fedce2e0c09..3a71fe471dc 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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,6 @@
 package org.springframework.web.context;
 
 import java.util.Locale;
-
 import javax.servlet.ServletException;
 
 import org.junit.Test;
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 9a416003712..02d7c275133 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
@@ -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.
@@ -61,6 +61,7 @@ import org.springframework.web.util.WebUtils;
 import static org.hamcrest.CoreMatchers.*;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.Mockito.*;
 
 /**
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 c8b061acee6..4a142fe2ced 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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.
@@ -19,13 +19,13 @@ package org.springframework.web.servlet.config.annotation;
 import java.util.Arrays;
 import java.util.Map;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
 import org.junit.Before;
 import org.junit.Test;
 
 import org.springframework.web.cors.CorsConfiguration;
 
+import static org.junit.Assert.*;
+
 /**
  * Test fixture with a {@link CorsRegistry}.
  *
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 bb15ba6afa2..6f0ea63500d 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
@@ -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.
@@ -45,13 +45,8 @@ import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandl
 import org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver;
 import org.springframework.web.util.UrlPathHelper;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.BDDMockito.given;
-import static org.mockito.BDDMockito.mock;
-import static org.mockito.BDDMockito.verify;
+import static org.junit.Assert.*;
+import static org.mockito.BDDMockito.*;
 
 /**
  * A test fixture for {@link DelegatingWebMvcConfiguration} tests.
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 653fe82245a..264042a9424 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
@@ -40,10 +40,7 @@ import org.springframework.web.servlet.handler.WebRequestHandlerInterceptorAdapt
 import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
 import org.springframework.web.servlet.theme.ThemeChangeInterceptor;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.*;
 
 /**
  * Test fixture with a {@link InterceptorRegistry}, two {@link HandlerInterceptor}s and two
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 a56b0149c41..272c53a5b5c 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
@@ -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.
@@ -50,11 +50,7 @@ import org.springframework.web.servlet.resource.WebJarsResourceResolver;
 import org.springframework.web.util.UrlPathHelper;
 
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
 
 /**
  * Unit tests for {@link ResourceHandlerRegistry}.
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 112fd661947..12ef4600c1b 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
@@ -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.
@@ -19,9 +19,7 @@ package org.springframework.web.servlet.config.annotation;
 import java.io.IOException;
 import javax.servlet.ServletException;
 
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
@@ -40,7 +38,8 @@ import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver;
 import org.springframework.web.servlet.view.groovy.GroovyMarkupConfigurer;
 import org.springframework.web.servlet.view.tiles3.TilesConfigurer;
 
-import static org.junit.Assert.assertEquals;
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
+import static org.junit.Assert.*;
 
 /**
  * Integration tests for view resolution with {@code @EnableWebMvc}.
@@ -50,10 +49,6 @@ import static org.junit.Assert.assertEquals;
  */
 public class ViewResolutionIntegrationTests {
 
-	@Rule
-	public final ExpectedException thrown = ExpectedException.none();
-
-
 	@Test
 	public void freemarker() throws Exception {
 		MockHttpServletResponse response = runTest(FreeMarkerWebConfig.class);
@@ -74,20 +69,23 @@ public class ViewResolutionIntegrationTests {
 
 	@Test
 	public void freemarkerInvalidConfig() throws Exception {
-		this.thrown.expectMessage("In addition to a FreeMarker view resolver ");
-		runTest(InvalidFreeMarkerWebConfig.class);
+		assertThatExceptionOfType(RuntimeException.class).isThrownBy(() ->
+				runTest(InvalidFreeMarkerWebConfig.class))
+			.withMessageContaining("In addition to a FreeMarker view resolver ");
 	}
 
 	@Test
 	public void tilesInvalidConfig() throws Exception {
-		this.thrown.expectMessage("In addition to a Tiles view resolver ");
-		runTest(InvalidTilesWebConfig.class);
+		assertThatExceptionOfType(RuntimeException.class).isThrownBy(() ->
+				runTest(InvalidTilesWebConfig.class))
+			.withMessageContaining("In addition to a Tiles view resolver ");
 	}
 
 	@Test
 	public void groovyMarkupInvalidConfig() throws Exception {
-		this.thrown.expectMessage("In addition to a Groovy markup view resolver ");
-		runTest(InvalidGroovyMarkupWebConfig.class);
+		assertThatExceptionOfType(RuntimeException.class).isThrownBy(() ->
+				runTest(InvalidGroovyMarkupWebConfig.class))
+			.withMessageContaining("In addition to a Groovy markup view resolver ");
 	}
 
 	// SPR-12013
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 40041183adb..0ba46d077c4 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
@@ -72,5 +72,4 @@ public class DefaultServerRequestBuilderTests {
 		assertEquals("baz", body);
 	}
 
-
-}
\ No newline at end of file
+}
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 9c36d878bf0..5c825acf1ed 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
@@ -43,7 +43,7 @@ import org.springframework.util.LinkedMultiValueMap;
 import org.springframework.util.MultiValueMap;
 import org.springframework.web.HttpMediaTypeNotSupportedException;
 
-import static java.nio.charset.StandardCharsets.UTF_8;
+import static java.nio.charset.StandardCharsets.*;
 import static org.junit.Assert.*;
 
 /**
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 676b74a00f7..78988252b6c 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
@@ -26,9 +26,9 @@ import org.springframework.http.MediaType;
 import org.springframework.mock.web.test.MockHttpServletRequest;
 import org.springframework.web.util.pattern.PathPatternParser;
 
-import static java.util.Collections.emptyList;
+import static java.util.Collections.*;
 import static org.junit.Assert.*;
-import static org.springframework.http.MediaType.TEXT_XML_VALUE;
+import static org.springframework.http.MediaType.*;
 
 /**
  * @author Arjen Poutsma
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 8fc95397a0d..c59c9f79ac7 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
@@ -27,7 +27,7 @@ import org.springframework.http.HttpStatus;
 import org.springframework.http.MediaType;
 import org.springframework.mock.web.test.MockHttpServletRequest;
 
-import static java.util.Collections.emptyList;
+import static java.util.Collections.*;
 import static org.junit.Assert.*;
 import static org.springframework.web.servlet.function.RequestPredicates.HEAD;
 
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 76717405e41..3c5360a0863 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
@@ -22,7 +22,7 @@ import org.junit.Test;
 
 import org.springframework.mock.web.test.MockHttpServletRequest;
 
-import static java.util.Collections.emptyList;
+import static java.util.Collections.*;
 import static org.junit.Assert.*;
 
 /**
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 6d23c74dbff..763ea7020fb 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
@@ -22,15 +22,8 @@ import org.springframework.http.HttpMethod;
 import org.springframework.http.MediaType;
 
 import static org.junit.Assert.*;
-import static org.springframework.web.servlet.function.RequestPredicates.GET;
-import static org.springframework.web.servlet.function.RequestPredicates.accept;
-import static org.springframework.web.servlet.function.RequestPredicates.contentType;
-import static org.springframework.web.servlet.function.RequestPredicates.method;
-import static org.springframework.web.servlet.function.RequestPredicates.methods;
-import static org.springframework.web.servlet.function.RequestPredicates.param;
-import static org.springframework.web.servlet.function.RequestPredicates.path;
-import static org.springframework.web.servlet.function.RequestPredicates.pathExtension;
-import static org.springframework.web.servlet.function.RouterFunctions.route;
+import static org.springframework.web.servlet.function.RequestPredicates.*;
+import static org.springframework.web.servlet.function.RouterFunctions.*;
 
 /**
  * @author Arjen Poutsma
@@ -41,11 +34,11 @@ public class ToStringVisitorTests {
 	public void nested() {
 		HandlerFunction handler = new SimpleHandlerFunction();
 		RouterFunction routerFunction = route()
-				.path("/foo", builder -> {
+				.path("/foo", builder ->
 					builder.path("/bar", () -> route()
 							.GET("/baz", handler)
-							.build());
-				})
+							.build())
+				)
 				.build();
 
 		ToStringVisitor visitor = new ToStringVisitor();
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 6fcf9382dea..f42e77056f7 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
@@ -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.
@@ -39,10 +39,8 @@ import org.springframework.web.servlet.HandlerExecutionChain;
 import org.springframework.web.servlet.HandlerMapping;
 import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.springframework.web.servlet.HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE;
+import static org.junit.Assert.*;
+import static org.springframework.web.servlet.HandlerMapping.*;
 
 /**
  * Unit tests for {@link HandlerMappingIntrospector}.
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 4412d6ce26b..53b058e79bf 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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,6 @@
 package org.springframework.web.servlet.handler;
 
 import java.io.IOException;
-
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -35,7 +34,7 @@ import org.springframework.web.servlet.HandlerExecutionChain;
 import org.springframework.web.servlet.HandlerInterceptor;
 import org.springframework.web.servlet.support.WebContentGenerator;
 
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.MatcherAssert.*;
 
 /**
  * Unit tests for
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 7503f30cf2b..50966e1ee2d 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
@@ -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.
@@ -21,7 +21,6 @@ import java.util.Collections;
 import java.util.Comparator;
 import java.util.List;
 import java.util.Set;
-
 import javax.servlet.http.HttpServletRequest;
 
 import org.junit.Before;
@@ -39,9 +38,7 @@ import org.springframework.web.method.HandlerMethod;
 import org.springframework.web.servlet.HandlerMapping;
 import org.springframework.web.util.UrlPathHelper;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.Assert.*;
 
 
 /**
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 36f67059210..3d60ec0dde9 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2012 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.
@@ -30,6 +30,7 @@ import org.springframework.web.servlet.ModelAndView;
 import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
 
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.BDDMockito.*;
 
 /**
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 f5f339734d1..0bf385898b8 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2012 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.
@@ -27,9 +27,7 @@ import org.springframework.web.servlet.DispatcherServlet;
 import org.springframework.web.servlet.HandlerMapping;
 import org.springframework.web.servlet.ModelAndView;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
 
 /**
  * @author Juergen Hoeller
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 cb943001ae7..8bdec03e8d8 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
@@ -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.
@@ -24,7 +24,7 @@ import org.junit.Test;
 import org.springframework.mock.web.test.MockHttpServletRequest;
 import org.springframework.mock.web.test.MockHttpServletResponse;
 
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.MatcherAssert.*;
 import static org.hamcrest.Matchers.*;
 
 /**
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 678fe4a7533..c1fa3ac2661 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
@@ -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.
@@ -23,11 +23,7 @@ import org.junit.Test;
 import org.springframework.mock.web.test.MockHttpServletRequest;
 import org.springframework.web.servlet.mvc.condition.ParamsRequestCondition.ParamExpression;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
 
 /**
  * Unit tests for {@link ParamsRequestCondition}.
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 ce1c1e206c4..0ae700442a1 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
@@ -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.
@@ -27,15 +27,10 @@ import org.springframework.http.HttpHeaders;
 import org.springframework.mock.web.test.MockHttpServletRequest;
 import org.springframework.web.bind.annotation.RequestMethod;
 
-import static java.util.Arrays.asList;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.springframework.web.bind.annotation.RequestMethod.GET;
-import static org.springframework.web.bind.annotation.RequestMethod.HEAD;
-import static org.springframework.web.servlet.mvc.method.RequestMappingInfo.paths;
+import static java.util.Arrays.*;
+import static org.junit.Assert.*;
+import static org.springframework.web.bind.annotation.RequestMethod.*;
+import static org.springframework.web.servlet.mvc.method.RequestMappingInfo.*;
 
 /**
  * Test fixture for {@link RequestMappingInfo} tests.
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 f7702405acc..8c3b356f995 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
@@ -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.
@@ -25,9 +25,7 @@ import java.util.Arrays;
 import java.util.Properties;
 
 import org.junit.Before;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.beans.DirectFieldAccessor;
 import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
@@ -55,7 +53,7 @@ import org.springframework.web.servlet.mvc.condition.ProducesRequestCondition;
 import org.springframework.web.servlet.mvc.condition.RequestMethodsRequestCondition;
 import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
 
-import static org.hamcrest.CoreMatchers.*;
+import static org.assertj.core.api.Assertions.*;
 import static org.junit.Assert.*;
 
 /**
@@ -71,9 +69,6 @@ public class CrossOriginTests {
 
 	private final MockHttpServletRequest request = new MockHttpServletRequest();
 
-	@Rule
-	public ExpectedException exception = ExpectedException.none();
-
 
 	@Before
 	@SuppressWarnings("resource")
@@ -172,10 +167,10 @@ public class CrossOriginTests {
 
 	@Test
 	public void bogusAllowCredentialsValue() throws Exception {
-		exception.expect(IllegalStateException.class);
-		exception.expectMessage(containsString("@CrossOrigin's allowCredentials"));
-		exception.expectMessage(containsString("current value is [bogus]"));
-		this.handlerMapping.registerHandler(new MethodLevelControllerWithBogusAllowCredentialsValue());
+		assertThatIllegalStateException().isThrownBy(() ->
+				this.handlerMapping.registerHandler(new MethodLevelControllerWithBogusAllowCredentialsValue()))
+			.withMessageContaining("@CrossOrigin's allowCredentials")
+			.withMessageContaining("current value is [bogus]");
 	}
 
 	@Test
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 ff922625c50..91252674e18 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
@@ -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.
@@ -31,9 +31,7 @@ import java.util.Date;
 
 import org.hamcrest.Matchers;
 import org.junit.Before;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 import org.mockito.ArgumentCaptor;
 
 import org.springframework.core.MethodParameter;
@@ -60,8 +58,10 @@ import org.springframework.web.method.support.ModelAndViewContainer;
 
 import static java.time.Instant.*;
 import static java.time.format.DateTimeFormatter.*;
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.BDDMockito.*;
 import static org.springframework.http.MediaType.*;
 import static org.springframework.web.servlet.HandlerMapping.*;
@@ -81,9 +81,6 @@ public class HttpEntityMethodProcessorMockTests {
 	private static final ZoneId GMT = ZoneId.of("GMT");
 
 
-	@Rule
-	public ExpectedException thrown = ExpectedException.none();
-
 	private HttpEntityMethodProcessor processor;
 
 	private HttpMessageConverter stringHttpMessageConverter;
@@ -233,16 +230,16 @@ public class HttpEntityMethodProcessorMockTests {
 		given(stringHttpMessageConverter.getSupportedMediaTypes()).willReturn(Collections.singletonList(contentType));
 		given(stringHttpMessageConverter.canRead(String.class, contentType)).willReturn(false);
 
-		this.thrown.expect(HttpMediaTypeNotSupportedException.class);
-		processor.resolveArgument(paramHttpEntity, mavContainer, webRequest, null);
+		assertThatExceptionOfType(HttpMediaTypeNotSupportedException.class).isThrownBy(() ->
+				processor.resolveArgument(paramHttpEntity, mavContainer, webRequest, null));
 	}
 
 	@Test
 	public void shouldFailResolvingWhenContentTypeNotSupported() throws Exception {
 		servletRequest.setMethod("POST");
 		servletRequest.setContent("some content".getBytes(StandardCharsets.UTF_8));
-		this.thrown.expect(HttpMediaTypeNotSupportedException.class);
-		processor.resolveArgument(paramHttpEntity, mavContainer, webRequest, null);
+		assertThatExceptionOfType(HttpMediaTypeNotSupportedException.class).isThrownBy(() ->
+				processor.resolveArgument(paramHttpEntity, mavContainer, webRequest, null));
 	}
 
 	@Test
@@ -306,8 +303,8 @@ public class HttpEntityMethodProcessorMockTests {
 		given(stringHttpMessageConverter.getSupportedMediaTypes())
 				.willReturn(Collections.singletonList(TEXT_PLAIN));
 
-		this.thrown.expect(HttpMediaTypeNotAcceptableException.class);
-		processor.handleReturnValue(returnValue, returnTypeResponseEntity, mavContainer, webRequest);
+		assertThatExceptionOfType(HttpMediaTypeNotAcceptableException.class).isThrownBy(() ->
+				processor.handleReturnValue(returnValue, returnTypeResponseEntity, mavContainer, webRequest));
 	}
 
 	@Test
@@ -322,8 +319,8 @@ public class HttpEntityMethodProcessorMockTests {
 				.willReturn(Collections.singletonList(TEXT_PLAIN));
 		given(stringHttpMessageConverter.canWrite(String.class, accepted)).willReturn(false);
 
-		this.thrown.expect(HttpMediaTypeNotAcceptableException.class);
-		processor.handleReturnValue(returnValue, returnTypeResponseEntityProduces, mavContainer, webRequest);
+		assertThatExceptionOfType(HttpMediaTypeNotAcceptableException.class).isThrownBy(() ->
+				processor.handleReturnValue(returnValue, returnTypeResponseEntityProduces, mavContainer, webRequest));
 	}
 
 	@Test  // SPR-9142
@@ -331,8 +328,8 @@ public class HttpEntityMethodProcessorMockTests {
 		ResponseEntity returnValue = new ResponseEntity<>("Body", HttpStatus.ACCEPTED);
 		servletRequest.addHeader("Accept", "01");
 
-		this.thrown.expect(HttpMediaTypeNotAcceptableException.class);
-		processor.handleReturnValue(returnValue, returnTypeResponseEntity, mavContainer, webRequest);
+		assertThatExceptionOfType(HttpMediaTypeNotAcceptableException.class).isThrownBy(() ->
+				processor.handleReturnValue(returnValue, returnTypeResponseEntity, mavContainer, webRequest));
 	}
 
 	@Test
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 4cba186b457..9e68d199789 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
@@ -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.
@@ -35,10 +35,8 @@ import org.springframework.web.method.ResolvableMethod;
 import org.springframework.web.method.support.ModelAndViewContainer;
 import org.springframework.web.servlet.HandlerMapping;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.springframework.web.method.MvcAnnotationPredicates.matrixAttribute;
+import static org.junit.Assert.*;
+import static org.springframework.web.method.MvcAnnotationPredicates.*;
 
 /**
  * Test fixture with {@link MatrixVariableMethodArgumentResolver}.
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 5937c5e366d..a1240acf039 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
@@ -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.
@@ -36,10 +36,8 @@ import org.springframework.web.method.ResolvableMethod;
 import org.springframework.web.method.support.ModelAndViewContainer;
 import org.springframework.web.servlet.HandlerMapping;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.springframework.web.method.MvcAnnotationPredicates.matrixAttribute;
+import static org.junit.Assert.*;
+import static org.springframework.web.method.MvcAnnotationPredicates.*;
 
 /**
  * Test fixture with {@link MatrixVariableMethodArgumentResolver}.
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 2849bf33e1a..884dbdee10c 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
@@ -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.
@@ -58,8 +58,8 @@ import static junit.framework.TestCase.assertNull;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
-import static org.springframework.core.ResolvableType.forClass;
-import static org.springframework.web.method.ResolvableMethod.on;
+import static org.springframework.core.ResolvableType.*;
+import static org.springframework.web.method.ResolvableMethod.*;
 
 /**
  * Unit tests for {@link ReactiveTypeHandler}.
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 8564c30cf67..b7da379c331 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
@@ -46,7 +46,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.context.support.StaticWebApplicationContext;
-import org.springframework.web.method.HandlerMethod;
 import org.springframework.web.method.HandlerTypePredicate;
 import org.springframework.web.servlet.mvc.condition.ConsumesRequestCondition;
 import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
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 e8be018838e..bf2b0eb3bd9 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
@@ -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.
@@ -67,8 +67,8 @@ import org.springframework.web.servlet.DispatcherServlet;
 import org.springframework.web.servlet.config.annotation.EnableWebMvc;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 
-import static org.junit.Assert.assertEquals;
-import static org.springframework.web.bind.annotation.RequestMethod.POST;
+import static org.junit.Assert.*;
+import static org.springframework.web.bind.annotation.RequestMethod.*;
 
 /**
  * Test access to parts of a multipart request with {@link RequestPart}.
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 a44be3b0e42..da3f1ace54f 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
@@ -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.
@@ -56,6 +56,7 @@ import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.support.MissingServletRequestPartException;
 
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.BDDMockito.*;
 
 /**
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 5ab42eb8f95..cf8b3258f3b 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
@@ -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,6 +43,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
 import org.springframework.web.method.ControllerAdviceBean;
 
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.BDDMockito.*;
 
 /**
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 60a4b4c809e..d4e0ddb8593 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
@@ -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.
@@ -22,7 +22,6 @@ import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 import java.util.Optional;
-
 import javax.validation.Valid;
 import javax.validation.constraints.NotNull;
 
@@ -55,6 +54,7 @@ import org.springframework.web.method.support.ModelAndViewContainer;
 import org.springframework.web.servlet.HandlerMapping;
 
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.BDDMockito.*;
 
 /**
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 01a2131fd2a..1270a10197d 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
@@ -45,6 +45,7 @@ import org.springframework.web.context.request.async.WebAsyncUtils;
 import org.springframework.web.method.support.ModelAndViewContainer;
 
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.Mockito.*;
 import static org.springframework.core.ResolvableType.*;
 import static org.springframework.web.method.ResolvableMethod.*;
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 f6f316c9ef6..b7c3e9c5f86 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
@@ -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.
@@ -27,6 +27,7 @@ import org.mockito.MockitoAnnotations;
 import org.springframework.http.MediaType;
 
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.Mockito.*;
 
 /**
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 a471ed5b4e1..f322685e426 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
@@ -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.
@@ -52,10 +52,7 @@ import org.springframework.web.method.support.HandlerMethodReturnValueHandlerCom
 import org.springframework.web.method.support.ModelAndViewContainer;
 import org.springframework.web.servlet.view.RedirectView;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.*;
 
 /**
  * Test fixture with {@link ServletInvocableHandlerMethod}.
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 b53a3bae20a..29a75fb7955 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
@@ -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.
@@ -25,9 +25,8 @@ import org.junit.Test;
 
 import org.springframework.http.MediaType;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.springframework.web.servlet.mvc.method.annotation.SseEmitter.event;
+import static org.junit.Assert.*;
+import static org.springframework.web.servlet.mvc.method.annotation.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 ac270f7429a..47e33f10d60 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
@@ -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.
@@ -37,9 +37,7 @@ import org.springframework.web.context.request.async.StandardServletAsyncWebRequ
 import org.springframework.web.context.request.async.WebAsyncUtils;
 import org.springframework.web.method.support.ModelAndViewContainer;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
 
 
 /**
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 f94b19c2fda..86011ea7b2f 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
@@ -1,11 +1,11 @@
 /*
- * 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.
  * You may obtain a copy of the License at
  *
- *  https://www.apache.org/licenses/LICENSE-2.0
+ *      https://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
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 4a7ac26f35a..d31171fc2aa 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
@@ -1,11 +1,11 @@
 /*
- * 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.
  * You may obtain a copy of the License at
  *
- *  https://www.apache.org/licenses/LICENSE-2.0
+ *      https://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -13,6 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package org.springframework.web.servlet.resource;
 
 import java.io.IOException;
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 d4a58d91e8e..7230c0f1023 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
@@ -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,6 +43,7 @@ import org.springframework.web.accept.ContentNegotiationManagerFactoryBean;
 import org.springframework.web.servlet.HandlerMapping;
 
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.Mockito.*;
 
 /**
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 cf6fb920d4f..81330de0bca 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
@@ -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.
@@ -36,9 +36,8 @@ import org.springframework.web.servlet.handler.SimpleUrlHandlerMapping;
 
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.Assert.*;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
+import static org.mockito.ArgumentMatchers.*;
+import static org.mockito.Mockito.*;
 
 /**
  * Unit tests for {@link ResourceUrlProvider}.
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 e0b135e1fd7..f6f27fc41e9 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
@@ -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,15 +16,12 @@
 
 package org.springframework.web.servlet.support;
 
-import static org.junit.Assert.*;
-
 import java.net.URLEncoder;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 import java.util.concurrent.CopyOnWriteArrayList;
-
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
@@ -36,6 +33,8 @@ import org.springframework.mock.web.test.MockHttpServletResponse;
 import org.springframework.web.servlet.FlashMap;
 import org.springframework.web.util.WebUtils;
 
+import static org.junit.Assert.*;
+
 
 /**
  * Test fixture for testing {@link AbstractFlashMapManager} methods.
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 d8fc64fb494..5f19a72af0b 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
@@ -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.
@@ -21,8 +21,7 @@ import org.junit.Test;
 
 import org.springframework.mock.web.test.MockHttpServletResponse;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.Assert.*;
 
 /**
  * Unit tests for {@link WebContentGenerator}.
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 dabc5f8f4cc..56736648612 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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,6 @@
 package org.springframework.web.servlet.tags.form;
 
 import java.io.Writer;
-
 import javax.servlet.jsp.tagext.Tag;
 
 import org.junit.Test;
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 fcf12bba1f6..714cfc19f5a 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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.
@@ -30,7 +30,6 @@ 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.springframework.beans.propertyeditors.StringTrimmerEditor;
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 359fb847742..aa6080ebfe2 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
@@ -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.
@@ -34,7 +34,6 @@ 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.springframework.beans.propertyeditors.StringTrimmerEditor;
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 a516636328f..c2a95526a15 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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.
@@ -20,6 +20,7 @@ import javax.servlet.jsp.tagext.BodyTag;
 import javax.servlet.jsp.tagext.Tag;
 
 import org.junit.Test;
+
 import org.springframework.tests.sample.beans.CustomEnum;
 import org.springframework.tests.sample.beans.GenericBean;
 import org.springframework.web.servlet.support.BindStatus;
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 335cd358758..736d067554e 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
@@ -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.
@@ -31,7 +31,6 @@ import org.dom4j.Document;
 import org.dom4j.Element;
 import org.dom4j.Node;
 import org.dom4j.io.SAXReader;
-
 import org.junit.Test;
 
 import org.springframework.mock.web.test.MockHttpServletRequest;
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 d667be41ed2..c4b3ce9d7ed 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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.
@@ -25,7 +25,6 @@ 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.springframework.tests.sample.beans.Pet;
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 9bb8d39c004..59cec311a43 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
@@ -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.
@@ -33,7 +33,6 @@ import org.dom4j.Document;
 import org.dom4j.Element;
 import org.dom4j.Node;
 import org.dom4j.io.SAXReader;
-
 import org.junit.Test;
 
 import org.springframework.beans.propertyeditors.StringTrimmerEditor;
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 7bd7b6fcb78..cba0c6d1af7 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
@@ -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.
@@ -37,7 +37,6 @@ import org.dom4j.Document;
 import org.dom4j.DocumentException;
 import org.dom4j.Element;
 import org.dom4j.io.SAXReader;
-
 import org.junit.Test;
 
 import org.springframework.beans.propertyeditors.CustomCollectionEditor;
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 85296e0b44c..53f84a761ca 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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,6 @@
 package org.springframework.web.servlet.tags.form;
 
 import java.util.stream.IntStream;
-
 import javax.servlet.jsp.PageContext;
 
 import org.junit.Test;
diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/TestTypes.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/TestTypes.java
index 41500679e8f..3f1dd3830f3 100644
--- a/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/TestTypes.java
+++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/TestTypes.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2002-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.springframework.web.servlet.tags.form;
 
 /**
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 697ad5ee61f..f496a9914ae 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
@@ -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.
@@ -20,7 +20,6 @@ import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Properties;
-
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
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 8d73228fc3c..a6bf44187ef 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
@@ -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.
@@ -42,12 +42,8 @@ import org.springframework.web.servlet.support.RequestDataValueProcessorWrapper;
 import org.springframework.web.servlet.support.SessionFlashMapManager;
 import org.springframework.web.util.WebUtils;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.BDDMockito.given;
-import static org.mockito.BDDMockito.mock;
-import static org.mockito.BDDMockito.verify;
+import static org.junit.Assert.*;
+import static org.mockito.BDDMockito.*;
 
 /**
  * Tests for redirect view, and query string construction.
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 e06e3c43856..b1f9bd6df7c 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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.
@@ -19,7 +19,6 @@ package org.springframework.web.servlet.view;
 import java.util.Locale;
 import java.util.Map;
 import java.util.MissingResourceException;
-
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
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 66dfca1d09d..1652ed54168 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
@@ -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,23 +16,24 @@
 
 package org.springframework.web.servlet.view.feed;
 
-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.springframework.mock.web.test.MockHttpServletRequest;
-import org.springframework.mock.web.test.MockHttpServletResponse;
-import org.xmlunit.matchers.CompareMatcher;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
 import java.util.ArrayList;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import javax.servlet.http.HttpServletRequest;
+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.xmlunit.matchers.CompareMatcher;
+
+import org.springframework.mock.web.test.MockHttpServletRequest;
+import org.springframework.mock.web.test.MockHttpServletResponse;
 
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.*;
 
 /**
  * @author Arjen Poutsma
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 26f1fd638c4..5010237e8af 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
@@ -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,25 +16,24 @@
 
 package org.springframework.web.servlet.view.feed;
 
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import javax.servlet.http.HttpServletRequest;
+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.springframework.mock.web.test.MockHttpServletRequest;
 import org.springframework.mock.web.test.MockHttpServletResponse;
 
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.xmlunit.matchers.CompareMatcher.isSimilarTo;
+import static org.junit.Assert.*;
+import static org.xmlunit.matchers.CompareMatcher.*;
 
 /**
  * @author Arjen Poutsma
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 f648514c24c..5e1055182b8 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
@@ -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.
@@ -29,9 +29,7 @@ import freemarker.ext.servlet.AllHttpScopesHashModel;
 import freemarker.template.Configuration;
 import freemarker.template.Template;
 import freemarker.template.TemplateException;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.context.ApplicationContextException;
 import org.springframework.mock.web.test.MockHttpServletRequest;
@@ -46,7 +44,7 @@ import org.springframework.web.servlet.view.AbstractView;
 import org.springframework.web.servlet.view.InternalResourceView;
 import org.springframework.web.servlet.view.RedirectView;
 
-import static org.hamcrest.CoreMatchers.*;
+import static org.assertj.core.api.Assertions.*;
 import static org.junit.Assert.*;
 import static org.mockito.BDDMockito.*;
 
@@ -57,10 +55,6 @@ import static org.mockito.BDDMockito.*;
  */
 public class FreeMarkerViewTests {
 
-	@Rule
-	public final ExpectedException exception = ExpectedException.none();
-
-
 	@Test
 	public void noFreeMarkerConfig() throws Exception {
 		FreeMarkerView fv = new FreeMarkerView();
@@ -71,18 +65,18 @@ public class FreeMarkerViewTests {
 
 		fv.setUrl("anythingButNull");
 
-		exception.expect(ApplicationContextException.class);
-		exception.expectMessage(containsString("FreeMarkerConfig"));
-		fv.setApplicationContext(wac);
+		assertThatExceptionOfType(ApplicationContextException.class).isThrownBy(() ->
+				fv.setApplicationContext(wac))
+			.withMessageContaining("FreeMarkerConfig");
 	}
 
 	@Test
 	public void noTemplateName() throws Exception {
 		FreeMarkerView fv = new FreeMarkerView();
 
-		exception.expect(IllegalArgumentException.class);
-		exception.expectMessage(containsString("url"));
-		fv.afterPropertiesSet();
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				fv.afterPropertiesSet())
+			.withMessageContaining("url");
 	}
 
 	@Test
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 1121560eaa4..c5b7f1cd8c9 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
@@ -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.
@@ -23,21 +23,6 @@ import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 
-import org.junit.Before;
-import org.junit.Test;
-
-import org.mozilla.javascript.Context;
-import org.mozilla.javascript.ContextFactory;
-import org.mozilla.javascript.ScriptableObject;
-
-import org.springframework.beans.DirectFieldAccessor;
-import org.springframework.http.MediaType;
-import org.springframework.mock.web.test.MockHttpServletRequest;
-import org.springframework.mock.web.test.MockHttpServletResponse;
-import org.springframework.ui.ModelMap;
-import org.springframework.validation.BindingResult;
-import org.springframework.web.servlet.View;
-
 import com.fasterxml.jackson.annotation.JsonFilter;
 import com.fasterxml.jackson.annotation.JsonView;
 import com.fasterxml.jackson.core.JsonGenerator;
@@ -53,6 +38,19 @@ 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.mozilla.javascript.Context;
+import org.mozilla.javascript.ContextFactory;
+import org.mozilla.javascript.ScriptableObject;
+
+import org.springframework.beans.DirectFieldAccessor;
+import org.springframework.http.MediaType;
+import org.springframework.mock.web.test.MockHttpServletRequest;
+import org.springframework.mock.web.test.MockHttpServletResponse;
+import org.springframework.ui.ModelMap;
+import org.springframework.validation.BindingResult;
+import org.springframework.web.servlet.View;
 
 import static org.hamcrest.CoreMatchers.*;
 import static org.hamcrest.MatcherAssert.assertThat;
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 85f9812cc82..f026226a5b4 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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.
@@ -20,10 +20,8 @@ import java.util.HashMap;
 import java.util.Map;
 import javax.servlet.ServletContext;
 
-import static org.junit.Assert.assertEquals;
 import org.junit.Before;
 import org.junit.Test;
-import static org.mockito.Mockito.mock;
 
 import org.springframework.context.annotation.AnnotationConfigApplicationContext;
 import org.springframework.context.annotation.Bean;
@@ -33,6 +31,9 @@ import org.springframework.mock.web.test.MockHttpServletResponse;
 import org.springframework.mock.web.test.MockServletContext;
 import org.springframework.web.context.WebApplicationContext;
 
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
 /**
  * Unit tests for String templates running on Jython.
  *
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 6d6c3ef3b5f..caeafcf7c39 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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.
@@ -20,10 +20,8 @@ import java.util.HashMap;
 import java.util.Map;
 import javax.servlet.ServletContext;
 
-import static org.junit.Assert.assertEquals;
 import org.junit.Before;
 import org.junit.Test;
-import static org.mockito.Mockito.mock;
 
 import org.springframework.context.annotation.AnnotationConfigApplicationContext;
 import org.springframework.context.annotation.Bean;
@@ -33,6 +31,9 @@ import org.springframework.mock.web.test.MockHttpServletResponse;
 import org.springframework.mock.web.test.MockServletContext;
 import org.springframework.web.context.WebApplicationContext;
 
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
 /**
  * Unit tests for pure Javascript templates running on Nashorn engine.
  *
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 9fdac551241..36fbf39bf44 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
@@ -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.
@@ -29,9 +29,7 @@ import javax.script.Invocable;
 import javax.script.ScriptEngine;
 
 import org.junit.Before;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.beans.DirectFieldAccessor;
 import org.springframework.context.ApplicationContextException;
@@ -44,7 +42,9 @@ import org.springframework.mock.web.test.MockServletContext;
 import org.springframework.web.context.support.StaticWebApplicationContext;
 import org.springframework.web.servlet.DispatcherServlet;
 
+import static org.assertj.core.api.Assertions.*;
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.BDDMockito.*;
 
 /**
@@ -60,9 +60,6 @@ public class ScriptTemplateViewTests {
 
 	private StaticWebApplicationContext wac;
 
-	@Rule
-	public ExpectedException expectedException = ExpectedException.none();
-
 
 	@Before
 	public void setup() {
@@ -88,9 +85,9 @@ public class ScriptTemplateViewTests {
 
 	@Test
 	public void missingScriptTemplateConfig() throws Exception {
-		this.expectedException.expect(ApplicationContextException.class);
-		this.view.setApplicationContext(new StaticApplicationContext());
-		this.expectedException.expectMessage(contains("ScriptTemplateConfig"));
+		assertThatExceptionOfType(ApplicationContextException.class).isThrownBy(() ->
+				this.view.setApplicationContext(new StaticApplicationContext()))
+			.withMessageContaining("ScriptTemplateConfig");
 	}
 
 	@Test
@@ -174,8 +171,8 @@ public class ScriptTemplateViewTests {
 	public void nonInvocableScriptEngineWithRenderFunction() throws Exception {
 		this.view.setEngine(mock(ScriptEngine.class));
 		this.view.setRenderFunction("render");
-		this.expectedException.expect(IllegalArgumentException.class);
-		this.view.setApplicationContext(this.wac);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				this.view.setApplicationContext(this.wac));
 	}
 
 	@Test
@@ -183,9 +180,9 @@ public class ScriptTemplateViewTests {
 		this.view.setEngine(mock(InvocableScriptEngine.class));
 		this.view.setEngineName("test");
 		this.view.setRenderFunction("render");
-		this.expectedException.expect(IllegalArgumentException.class);
-		this.view.setApplicationContext(this.wac);
-		this.expectedException.expectMessage(contains("'engine' or 'engineName'"));
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				this.view.setApplicationContext(this.wac))
+			.withMessageContaining("'engine' or 'engineName'");
 	}
 
 	@Test
@@ -193,9 +190,9 @@ public class ScriptTemplateViewTests {
 		this.view.setEngine(mock(InvocableScriptEngine.class));
 		this.view.setRenderFunction("render");
 		this.view.setSharedEngine(false);
-		this.expectedException.expect(IllegalArgumentException.class);
-		this.view.setApplicationContext(this.wac);
-		this.expectedException.expectMessage(contains("sharedEngine"));
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				this.view.setApplicationContext(this.wac))
+			.withMessageContaining("sharedEngine");
 	}
 
 	@Test // SPR-14210
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 2b4218fc2c2..55000c28ffa 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2013 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.
@@ -26,6 +26,7 @@ import org.springframework.mock.web.test.MockServletContext;
 import org.springframework.web.context.support.StaticWebApplicationContext;
 
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.BDDMockito.*;
 
 /**
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 28626b041e5..1f4b416ff81 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
@@ -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.
@@ -31,7 +31,8 @@ import org.springframework.web.context.support.StaticWebApplicationContext;
 import org.springframework.web.servlet.DispatcherServlet;
 
 import static org.junit.Assert.*;
-import static org.mockito.BDDMockito.*;
+import static org.mockito.ArgumentMatchers.*;
+import static org.mockito.Mockito.*;
 
 /**
  * Test fixture for {@link TilesView}.
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 06572fc633b..e28c860ec10 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
@@ -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.
@@ -33,6 +33,7 @@ import org.springframework.validation.BeanPropertyBindingResult;
 import org.springframework.validation.BindingResult;
 
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.BDDMockito.*;
 
 /**
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 4abc0ececd5..bf8c71703ea 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2006 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,15 +16,15 @@
 
 package org.springframework.web.servlet.view.xslt;
 
-import org.junit.Test;
-
 import java.util.Locale;
 
-import static org.junit.Assert.*;
+import org.junit.Test;
 
 import org.springframework.context.support.StaticApplicationContext;
 import org.springframework.util.ClassUtils;
 
+import static org.junit.Assert.*;
+
 /**
  * @author Rob Harrop
  * @since 2.0
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 837253ae9aa..c4179152e54 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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.
@@ -31,8 +31,8 @@ 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.xml.sax.SAXException;
 
 import org.springframework.context.support.StaticApplicationContext;
 import org.springframework.core.io.ClassPathResource;
@@ -40,8 +40,6 @@ import org.springframework.core.io.Resource;
 import org.springframework.mock.web.test.MockHttpServletRequest;
 import org.springframework.mock.web.test.MockHttpServletResponse;
 
-import org.xml.sax.SAXException;
-
 import static java.util.Collections.*;
 import static org.junit.Assert.*;
 
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 db3027ab6bd..b102dd21afc 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
@@ -1,3 +1,19 @@
+/*
+ * Copyright 2002-2019 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.springframework.web.util;
 
 import org.junit.Test;
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 826a5551a82..a407c6bfc2e 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
@@ -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.
@@ -19,7 +19,7 @@ package org.springframework.web.socket;
 import org.hamcrest.Matchers;
 import org.junit.Test;
 
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.MatcherAssert.*;
 
 /**
  * Test fixture for {@link TextMessage}.
diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/UndertowTestServer.java b/spring-websocket/src/test/java/org/springframework/web/socket/UndertowTestServer.java
index 503af90a7f7..b44cf36ad0c 100644
--- a/spring-websocket/src/test/java/org/springframework/web/socket/UndertowTestServer.java
+++ b/spring-websocket/src/test/java/org/springframework/web/socket/UndertowTestServer.java
@@ -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.
@@ -39,9 +39,7 @@ import org.xnio.Xnio;
 import org.springframework.web.context.WebApplicationContext;
 import org.springframework.web.servlet.DispatcherServlet;
 
-import static io.undertow.servlet.Servlets.defaultContainer;
-import static io.undertow.servlet.Servlets.deployment;
-import static io.undertow.servlet.Servlets.servlet;
+import static io.undertow.servlet.Servlets.*;
 
 /**
  * Undertow-based {@link WebSocketTestServer}.
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 2508e73f7f0..3a3fc2bc671 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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.
@@ -22,9 +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.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 c40863135fc..5cb7e40e9e1 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2013 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.
@@ -24,9 +24,7 @@ import javax.websocket.Encoder;
 
 import org.junit.After;
 import org.junit.Before;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Bean;
@@ -40,7 +38,8 @@ import org.springframework.web.context.WebApplicationContext;
 import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
 import org.springframework.web.socket.ContextLoaderTestUtils;
 
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.assertj.core.api.Assertions.*;
+import static org.hamcrest.MatcherAssert.*;
 import static org.hamcrest.Matchers.*;
 
 /**
@@ -55,9 +54,6 @@ public class ConvertingEncoderDecoderSupportTests {
 	private static final ByteBuffer CONVERTED_BYTES = ByteBuffer.wrap("~test".getBytes());
 
 
-	@Rule
-	public ExpectedException thown = ExpectedException.none();
-
 	private WebApplicationContext applicationContext;
 
 	private MyType myType = new MyType("test");
@@ -89,9 +85,9 @@ public class ConvertingEncoderDecoderSupportTests {
 	@Test
 	public void encodeToTextCannotConvert() throws Exception {
 		setup(NoConvertersConfig.class);
-		thown.expect(EncodeException.class);
-		thown.expectCause(isA(ConverterNotFoundException.class));
-		new MyTextEncoder().encode(myType);
+		assertThatExceptionOfType(EncodeException.class).isThrownBy(() ->
+				new MyTextEncoder().encode(myType))
+			.withCauseInstanceOf(ConverterNotFoundException.class);
 	}
 
 	@Test
@@ -103,9 +99,9 @@ public class ConvertingEncoderDecoderSupportTests {
 	@Test
 	public void encodeToBinaryCannotConvert() throws Exception {
 		setup(NoConvertersConfig.class);
-		thown.expect(EncodeException.class);
-		thown.expectCause(isA(ConverterNotFoundException.class));
-		new MyBinaryEncoder().encode(myType);
+		assertThatExceptionOfType(EncodeException.class).isThrownBy(() ->
+				new MyBinaryEncoder().encode(myType))
+			.withCauseInstanceOf(ConverterNotFoundException.class);
 	}
 
 	@Test
@@ -120,9 +116,9 @@ public class ConvertingEncoderDecoderSupportTests {
 		setup(NoConvertersConfig.class);
 		Decoder.Text decoder = new MyTextDecoder();
 		assertThat(decoder.willDecode(CONVERTED_TEXT), is(false));
-		thown.expect(DecodeException.class);
-		thown.expectCause(isA(ConverterNotFoundException.class));
-		decoder.decode(CONVERTED_TEXT);
+		assertThatExceptionOfType(DecodeException.class).isThrownBy(() ->
+				decoder.decode(CONVERTED_TEXT))
+			.withCauseInstanceOf(ConverterNotFoundException.class);
 	}
 
 	@Test
@@ -137,9 +133,9 @@ public class ConvertingEncoderDecoderSupportTests {
 		setup(NoConvertersConfig.class);
 		Decoder.Binary decoder = new MyBinaryDecoder();
 		assertThat(decoder.willDecode(CONVERTED_BYTES), is(false));
-		thown.expect(DecodeException.class);
-		thown.expectCause(isA(ConverterNotFoundException.class));
-		decoder.decode(CONVERTED_BYTES);
+		assertThatExceptionOfType(DecodeException.class).isThrownBy(() ->
+				decoder.decode(CONVERTED_BYTES))
+			.withCauseInstanceOf(ConverterNotFoundException.class);
 	}
 
 	@Test
@@ -168,9 +164,9 @@ public class ConvertingEncoderDecoderSupportTests {
 		ContextLoaderTestUtils.setCurrentWebApplicationContext(null);
 		WithAutowire encoder = new WithAutowire();
 		encoder.init(null);
-		thown.expect(IllegalStateException.class);
-		thown.expectMessage("Unable to locate the Spring ApplicationContext");
-		encoder.encode(myType);
+		assertThatIllegalStateException().isThrownBy(() ->
+				encoder.encode(myType))
+			.withMessageContaining("Unable to locate the Spring ApplicationContext");
 	}
 
 	@Test
@@ -178,9 +174,9 @@ public class ConvertingEncoderDecoderSupportTests {
 		setup(NoConfig.class);
 		MyBinaryEncoder encoder = new MyBinaryEncoder();
 		encoder.init(null);
-		thown.expect(IllegalStateException.class);
-		thown.expectMessage("Unable to find ConversionService");
-		encoder.encode(myType);
+		assertThatIllegalStateException().isThrownBy(() ->
+				encoder.encode(myType))
+			.withMessageContaining("Unable to find ConversionService");
 	}
 
 	@Configuration
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 e88937c933a..da545c8da9f 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
@@ -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.
@@ -29,6 +29,7 @@ import org.springframework.web.socket.CloseStatus;
 import org.springframework.web.socket.WebSocketHandler;
 
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.BDDMockito.*;
 
 /**
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 c165510f4be..234598b0761 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
@@ -1,4 +1,5 @@
-/* Copyright 2002-2015 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.
@@ -20,7 +21,6 @@ import java.util.Map;
 import javax.websocket.Session;
 
 import org.junit.Test;
-
 import org.mockito.Mockito;
 
 import org.springframework.http.HttpHeaders;
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 c87e68d8a7f..fd14ec615d7 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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,15 +16,11 @@
 
 package org.springframework.web.socket.client.standard;
 
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
-
 import java.net.URI;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-
 import javax.websocket.ClientEndpointConfig;
 import javax.websocket.Endpoint;
 import javax.websocket.WebSocketContainer;
@@ -39,6 +35,10 @@ import org.springframework.web.socket.WebSocketHttpHeaders;
 import org.springframework.web.socket.WebSocketSession;
 import org.springframework.web.socket.handler.AbstractWebSocketHandler;
 
+import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
+import static org.mockito.Mockito.*;
+
 /**
  * Test fixture for {@link StandardWebSocketClient}.
  *
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 836dbe47015..e88bf032358 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
@@ -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,9 +16,6 @@
 
 package org.springframework.web.socket.config.annotation;
 
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
-
 import java.util.Map;
 
 import org.junit.Before;
@@ -33,6 +30,9 @@ import org.springframework.web.socket.messaging.SubProtocolHandler;
 import org.springframework.web.socket.messaging.SubProtocolWebSocketHandler;
 import org.springframework.web.util.UrlPathHelper;
 
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
 /**
  * Test fixture for
  * {@link org.springframework.web.socket.config.annotation.WebMvcStompEndpointRegistry}.
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 d78038cc4d5..29e3ecddb53 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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.
@@ -36,10 +36,7 @@ import org.springframework.web.socket.sockjs.transport.TransportType;
 import org.springframework.web.socket.sockjs.transport.handler.DefaultSockJsService;
 import org.springframework.web.socket.sockjs.transport.handler.WebSocketTransportHandler;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
 
 /**
  * Test fixture for
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 b7c86fc3e9d..15b842fb2b9 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
@@ -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.
@@ -26,7 +26,7 @@ import org.junit.Test;
 import org.springframework.web.socket.WebSocketExtension;
 import org.springframework.web.socket.WebSocketHttpHeaders;
 
-import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.MatcherAssert.*;
 
 /**
  * Unit tests for WebSocketHttpHeaders.
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 429369c6409..407240f3699 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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.
@@ -15,8 +15,6 @@
  */
 package org.springframework.web.socket.messaging;
 
-import static org.junit.Assert.*;
-
 import org.junit.Before;
 import org.junit.Test;
 
@@ -27,6 +25,8 @@ import org.springframework.messaging.simp.stomp.StompHeaderAccessor;
 import org.springframework.messaging.support.MessageBuilder;
 import org.springframework.messaging.support.MessageHeaderAccessor;
 
+import static org.junit.Assert.*;
+
 /**
  * Unit tests for {@link StompSubProtocolErrorHandler}.
  * @author Rossen Stoyanchev
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 eb72ec2c6b8..217353ec584 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
@@ -62,7 +62,7 @@ import org.springframework.web.socket.sockjs.transport.SockJsSession;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.*;
 import static org.junit.Assert.*;
-import static org.mockito.Mockito.any;
+import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.*;
 
 /**
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 10ada547b00..f5c1e461660 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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.
@@ -9,7 +9,7 @@
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIOsNS OF ANY KIND, either express or implied.
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
@@ -23,6 +23,7 @@ import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
+
 import org.springframework.beans.DirectFieldAccessor;
 import org.springframework.messaging.MessageChannel;
 import org.springframework.messaging.SubscribableChannel;
@@ -32,6 +33,7 @@ import org.springframework.web.socket.handler.ConcurrentWebSocketSessionDecorato
 import org.springframework.web.socket.handler.TestWebSocketSession;
 
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.BDDMockito.*;
 
 /**
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 05d1277fe35..92a973b8175 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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.
@@ -20,7 +20,6 @@ import java.util.concurrent.ConcurrentHashMap;
 
 import org.junit.Before;
 import org.junit.Test;
-
 import org.mockito.Mockito;
 
 import org.springframework.context.support.StaticApplicationContext;
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 cf98cf0f0b1..b869b234219 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
@@ -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.
@@ -47,6 +47,7 @@ import org.springframework.web.socket.WebSocketSession;
 import org.springframework.web.socket.client.WebSocketClient;
 
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.Mockito.*;
 
 /**
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 5cf1bdc7686..7d42d0ee817 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,6 @@ import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ConcurrentSkipListSet;
 
-import static org.junit.Assert.*;
 import org.junit.Test;
 import org.mockito.Mockito;
 
@@ -33,6 +32,8 @@ import org.springframework.http.HttpStatus;
 import org.springframework.web.socket.AbstractHttpRequestTests;
 import org.springframework.web.socket.WebSocketHandler;
 
+import static org.junit.Assert.*;
+
 /**
  * Test fixture for {@link OriginHandshakeInterceptor}.
  *
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 0147f5ac3dd..bd86dcba89d 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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.
@@ -68,10 +68,7 @@ import org.springframework.web.socket.server.HandshakeHandler;
 import org.springframework.web.socket.server.RequestUpgradeStrategy;
 import org.springframework.web.socket.server.support.DefaultHandshakeHandler;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.*;
 
 /**
  * Abstract base class for integration tests using the
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 e6a71d68706..f2b2dadc8cc 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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.
@@ -22,9 +22,7 @@ import java.net.URI;
 import java.util.List;
 
 import org.junit.Before;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 
 import org.springframework.util.concurrent.SettableListenableFuture;
 import org.springframework.web.socket.CloseStatus;
@@ -36,6 +34,7 @@ import org.springframework.web.socket.sockjs.frame.Jackson2SockJsMessageCodec;
 import org.springframework.web.socket.sockjs.frame.SockJsFrame;
 import org.springframework.web.socket.sockjs.transport.TransportType;
 
+import static org.assertj.core.api.Assertions.*;
 import static org.hamcrest.CoreMatchers.*;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.Assert.*;
@@ -57,9 +56,6 @@ public class ClientSockJsSessionTests {
 
 	private SettableListenableFuture connectFuture;
 
-	@Rule
-	public final ExpectedException thrown = ExpectedException.none();
-
 
 	@Before
 	public void setup() throws Exception {
@@ -190,17 +186,17 @@ public class ClientSockJsSessionTests {
 	@Test
 	public void closeWithNullStatus() throws Exception {
 		this.session.handleFrame(SockJsFrame.openFrame().getContent());
-		this.thrown.expect(IllegalArgumentException.class);
-		this.thrown.expectMessage("Invalid close status");
-		this.session.close(null);
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				this.session.close(null))
+			.withMessageContaining("Invalid close status");
 	}
 
 	@Test
 	public void closeWithStatusOutOfRange() throws Exception {
 		this.session.handleFrame(SockJsFrame.openFrame().getContent());
-		this.thrown.expect(IllegalArgumentException.class);
-		this.thrown.expectMessage("Invalid close status");
-		this.session.close(new CloseStatus(2999, "reason"));
+		assertThatIllegalArgumentException().isThrownBy(() ->
+				this.session.close(new CloseStatus(2999, "reason")))
+			.withMessageContaining("Invalid close status");
 	}
 
 	@Test
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 b6af54dbce1..579ec557b8f 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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.
@@ -22,9 +22,7 @@ import java.util.Date;
 import java.util.concurrent.ExecutionException;
 
 import org.junit.Before;
-import org.junit.Rule;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
 import org.mockito.ArgumentCaptor;
 
 import org.springframework.http.HttpHeaders;
@@ -35,7 +33,9 @@ import org.springframework.web.socket.WebSocketSession;
 import org.springframework.web.socket.sockjs.frame.Jackson2SockJsMessageCodec;
 import org.springframework.web.socket.sockjs.transport.TransportType;
 
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.Mockito.*;
 
 /**
@@ -57,10 +57,6 @@ public class DefaultTransportRequestTests {
 	private TestTransport xhrTransport;
 
 
-	@Rule
-	public final ExpectedException thrown = ExpectedException.none();
-
-
 	@SuppressWarnings("unchecked")
 	@Before
 	public void setup() throws Exception {
@@ -96,9 +92,9 @@ public class DefaultTransportRequestTests {
 		// Transport error => no more fallback
 		this.xhrTransport.getConnectCallback().onFailure(new IOException("Fake exception 2"));
 		assertTrue(this.connectFuture.isDone());
-		this.thrown.expect(ExecutionException.class);
-		this.thrown.expectMessage("Fake exception 2");
-		this.connectFuture.get();
+		assertThatExceptionOfType(ExecutionException.class).isThrownBy(
+				this.connectFuture::get)
+			.withMessageContaining("Fake exception 2");
 	}
 
 	@Test
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 34d8d65a18d..821f4d20f80 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
@@ -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.
@@ -56,6 +56,7 @@ import org.springframework.web.socket.sockjs.frame.Jackson2SockJsMessageCodec;
 import org.springframework.web.socket.sockjs.frame.SockJsFrame;
 import org.springframework.web.socket.sockjs.transport.TransportType;
 
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.BDDMockito.*;
 
 /**
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 defdb431e4d..79a004d55d7 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
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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.
@@ -34,16 +34,9 @@ import org.springframework.web.socket.WebSocketHttpHeaders;
 import org.springframework.web.socket.WebSocketSession;
 import org.springframework.web.socket.sockjs.client.TestTransport.XhrTestTransport;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.BDDMockito.any;
-import static org.mockito.BDDMockito.given;
-import static org.mockito.BDDMockito.mock;
-import static org.mockito.BDDMockito.times;
-import static org.mockito.BDDMockito.verify;
-import static org.mockito.BDDMockito.verifyNoMoreInteractions;
-import static org.mockito.BDDMockito.when;
+import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
+import static org.mockito.BDDMockito.*;
 
 /**
  * Unit tests for {@link org.springframework.web.socket.sockjs.client.SockJsClient}.
diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/TestTransport.java b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/TestTransport.java
index 77dc3fe2090..4fdea96b4a4 100644
--- a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/TestTransport.java
+++ b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/TestTransport.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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.
@@ -31,8 +31,7 @@ import org.springframework.web.socket.WebSocketHandler;
 import org.springframework.web.socket.WebSocketSession;
 import org.springframework.web.socket.sockjs.transport.TransportType;
 
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.*;
 
 /**
  * Test SockJS Transport.
diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/UndertowSockJsIntegrationTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/UndertowSockJsIntegrationTests.java
index 3ef0fdfe94e..c707f9faa67 100644
--- a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/UndertowSockJsIntegrationTests.java
+++ b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/client/UndertowSockJsIntegrationTests.java
@@ -1,11 +1,11 @@
 /*
- * 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.
  * You may obtain a copy of the License at
  *
- *  https://www.apache.org/licenses/LICENSE-2.0
+ *      https://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
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 b532d85eb65..d6a8e51b20d 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
@@ -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.
@@ -41,6 +41,7 @@ import org.springframework.web.socket.sockjs.transport.session.StubSockJsService
 import org.springframework.web.socket.sockjs.transport.session.TestSockJsSession;
 
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.BDDMockito.*;
 
 /**
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 1413fd53e7e..87a52c6debb 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
@@ -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.
@@ -31,6 +31,7 @@ import org.springframework.web.socket.sockjs.transport.session.StreamingSockJsSe
 import org.springframework.web.socket.sockjs.transport.session.StubSockJsServiceConfig;
 
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.Mockito.*;
 
 /**
diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/transport/session/SockJsSessionTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/transport/session/SockJsSessionTests.java
index f670b8b156e..2dc9404fb33 100644
--- a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/transport/session/SockJsSessionTests.java
+++ b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/transport/session/SockJsSessionTests.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.
@@ -31,17 +31,9 @@ import org.springframework.web.socket.sockjs.SockJsMessageDeliveryException;
 import org.springframework.web.socket.sockjs.SockJsTransportFailureException;
 import org.springframework.web.socket.sockjs.frame.SockJsFrame;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.mockito.BDDMockito.any;
-import static org.mockito.BDDMockito.given;
-import static org.mockito.BDDMockito.mock;
-import static org.mockito.BDDMockito.verify;
-import static org.mockito.BDDMockito.verifyNoMoreInteractions;
-import static org.mockito.BDDMockito.willReturn;
-import static org.mockito.BDDMockito.willThrow;
+import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
+import static org.mockito.BDDMockito.*;
 
 /**
  * Test fixture for {@link AbstractSockJsSession}.
diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/transport/session/WebSocketServerSockJsSessionTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/transport/session/WebSocketServerSockJsSessionTests.java
index 29efadf4e6b..0cb83e2205c 100644
--- a/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/transport/session/WebSocketServerSockJsSessionTests.java
+++ b/spring-websocket/src/test/java/org/springframework/web/socket/sockjs/transport/session/WebSocketServerSockJsSessionTests.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2015 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.
@@ -36,6 +36,7 @@ import org.springframework.web.socket.sockjs.transport.SockJsServiceConfig;
 import org.springframework.web.socket.sockjs.transport.session.WebSocketServerSockJsSessionTests.TestWebSocketServerSockJsSession;
 
 import static org.junit.Assert.*;
+import static org.mockito.ArgumentMatchers.*;
 import static org.mockito.Mockito.*;
 
 /**
diff --git a/src/checkstyle/checkstyle-suppressions.xml b/src/checkstyle/checkstyle-suppressions.xml
index c3cb44210ad..97b0fa28095 100644
--- a/src/checkstyle/checkstyle-suppressions.xml
+++ b/src/checkstyle/checkstyle-suppressions.xml
@@ -3,8 +3,7 @@
 
 
 	
-	
-	
+	
 
 	
 	
@@ -25,9 +24,10 @@
 	
 	
 	
+	
 
 	
-	
+	
 
 	
 	
@@ -45,6 +45,7 @@
 	
 	
 	
+	
 
 	
 	
@@ -62,16 +63,21 @@
 	
 	
 	
+	
 	
 	
 
 	
 	
+	
+	
+	
 
 	
 	
 	
 	
 	
+	
 
 
diff --git a/src/checkstyle/checkstyle.xml b/src/checkstyle/checkstyle.xml
index 62847e72ffe..45a1dea9886 100644
--- a/src/checkstyle/checkstyle.xml
+++ b/src/checkstyle/checkstyle.xml
@@ -94,6 +94,11 @@
 			
 			
 		
+		
+			
+			
+		
 
 		
 		
@@ -145,6 +150,15 @@
 			
 			
 		
+		
+			
+			
+			
+			
+		
 
 		
 		
diff --git a/src/test/java/com/foo/ComponentBeanDefinitionParserTests.java b/src/test/java/com/foo/ComponentBeanDefinitionParserTests.java
index 4fc5d1dc05f..b4b32bfb3d3 100644
--- a/src/test/java/com/foo/ComponentBeanDefinitionParserTests.java
+++ b/src/test/java/com/foo/ComponentBeanDefinitionParserTests.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2013 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,18 +16,20 @@
 
 package com.foo;
 
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.MatcherAssert.assertThat;
 
 import java.util.List;
 
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
+
 import org.springframework.beans.factory.support.DefaultListableBeanFactory;
 import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
 import org.springframework.core.io.ClassPathResource;
 
+import static org.hamcrest.CoreMatchers.*;
+import static org.hamcrest.MatcherAssert.*;
+
 /**
  * @author Costin Leau
  */
diff --git a/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests.java b/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests.java
index 03adc019240..292f56bb04f 100644
--- a/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests.java
+++ b/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorIntegrationTests.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2013 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,17 +16,13 @@
 
 package org.springframework.aop.framework.autoproxy;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
 import java.io.IOException;
 import java.lang.reflect.Method;
 import java.util.List;
-
 import javax.servlet.ServletException;
 
 import org.junit.Test;
+
 import org.springframework.aop.support.AopUtils;
 import org.springframework.aop.support.StaticMethodMatcherPointcutAdvisor;
 import org.springframework.beans.factory.BeanFactory;
@@ -41,6 +37,8 @@ import org.springframework.tests.transaction.CallCountingTransactionManager;
 import org.springframework.transaction.NoTransactionException;
 import org.springframework.transaction.interceptor.TransactionInterceptor;
 
+import static org.junit.Assert.*;
+
 /**
  * Integration tests for auto proxy creation by advisor recognition working in
  * conjunction with transaction management resources.
@@ -290,7 +288,6 @@ class Rollback {
 	/**
 	 * Inherits transaction attribute.
 	 * Illustrates programmatic rollback.
-	 * @param rollbackOnly
 	 */
 	public void rollbackOnly(boolean rollbackOnly) {
 		if (rollbackOnly) {
@@ -311,8 +308,9 @@ class Rollback {
 	 * @org.springframework.transaction.interceptor.NoRollbackRule ( "ServletException" )
 	 */
 	public void echoException(Exception ex) throws Exception {
-		if (ex != null)
+		if (ex != null) {
 			throw ex;
+		}
 	}
 
 }
diff --git a/src/test/java/org/springframework/context/annotation/jsr330/ClassPathBeanDefinitionScannerJsr330ScopeIntegrationTests.java b/src/test/java/org/springframework/context/annotation/jsr330/ClassPathBeanDefinitionScannerJsr330ScopeIntegrationTests.java
index 33fd9c4fa6d..529de624df3 100644
--- a/src/test/java/org/springframework/context/annotation/jsr330/ClassPathBeanDefinitionScannerJsr330ScopeIntegrationTests.java
+++ b/src/test/java/org/springframework/context/annotation/jsr330/ClassPathBeanDefinitionScannerJsr330ScopeIntegrationTests.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.
@@ -24,7 +24,6 @@ import javax.inject.Named;
 import javax.inject.Singleton;
 
 import org.junit.After;
-import static org.junit.Assert.*;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -42,6 +41,8 @@ import org.springframework.web.context.request.RequestContextHolder;
 import org.springframework.web.context.request.ServletRequestAttributes;
 import org.springframework.web.context.support.GenericWebApplicationContext;
 
+import static org.junit.Assert.*;
+
 /**
  * @author Mark Fisher
  * @author Juergen Hoeller
diff --git a/src/test/java/org/springframework/core/env/EnvironmentSystemIntegrationTests.java b/src/test/java/org/springframework/core/env/EnvironmentSystemIntegrationTests.java
index 35f2ec00b89..87ef82d8862 100644
--- a/src/test/java/org/springframework/core/env/EnvironmentSystemIntegrationTests.java
+++ b/src/test/java/org/springframework/core/env/EnvironmentSystemIntegrationTests.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.
@@ -57,8 +57,8 @@ import org.springframework.web.context.support.StandardServletEnvironment;
 import org.springframework.web.context.support.StaticWebApplicationContext;
 import org.springframework.web.context.support.XmlWebApplicationContext;
 
-import static org.hamcrest.Matchers.*;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.*;
 import static org.junit.Assert.*;
 import static org.springframework.beans.factory.support.BeanDefinitionBuilder.*;
 import static org.springframework.context.ConfigurableApplicationContext.*;
diff --git a/src/test/java/org/springframework/core/env/PropertyPlaceholderConfigurerEnvironmentIntegrationTests.java b/src/test/java/org/springframework/core/env/PropertyPlaceholderConfigurerEnvironmentIntegrationTests.java
index ca21643a70f..a037a1f1920 100644
--- a/src/test/java/org/springframework/core/env/PropertyPlaceholderConfigurerEnvironmentIntegrationTests.java
+++ b/src/test/java/org/springframework/core/env/PropertyPlaceholderConfigurerEnvironmentIntegrationTests.java
@@ -16,11 +16,12 @@
 
 package org.springframework.core.env;
 
-import static org.springframework.beans.factory.support.BeanDefinitionBuilder.rootBeanDefinition;
-
 import org.junit.Test;
+
 import org.springframework.context.support.GenericApplicationContext;
 
+import static org.springframework.beans.factory.support.BeanDefinitionBuilder.*;
+
 public class PropertyPlaceholderConfigurerEnvironmentIntegrationTests {
 
 	@Test
diff --git a/src/test/java/org/springframework/core/env/scan1/ProdConfig.java b/src/test/java/org/springframework/core/env/scan1/ProdConfig.java
index 896e2ea626e..eaf7c9a551a 100644
--- a/src/test/java/org/springframework/core/env/scan1/ProdConfig.java
+++ b/src/test/java/org/springframework/core/env/scan1/ProdConfig.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2010 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.
@@ -14,7 +14,6 @@
  * limitations under the License.
  */
 
-
 package org.springframework.core.env.scan1;
 
 import org.springframework.context.annotation.Bean;
diff --git a/src/test/java/org/springframework/core/env/scan2/ProdBean.java b/src/test/java/org/springframework/core/env/scan2/ProdBean.java
index 91af26d789a..75ee9d53c1b 100644
--- a/src/test/java/org/springframework/core/env/scan2/ProdBean.java
+++ b/src/test/java/org/springframework/core/env/scan2/ProdBean.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2010 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.
@@ -14,7 +14,6 @@
  * limitations under the License.
  */
 
-
 package org.springframework.core.env.scan2;
 
 import org.springframework.context.annotation.Profile;
diff --git a/src/test/java/org/springframework/expression/spel/support/Spr7538Tests.java b/src/test/java/org/springframework/expression/spel/support/Spr7538Tests.java
index c60637a7097..3a7f3dcbe17 100644
--- a/src/test/java/org/springframework/expression/spel/support/Spr7538Tests.java
+++ b/src/test/java/org/springframework/expression/spel/support/Spr7538Tests.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.
@@ -22,6 +22,7 @@ import java.util.List;
 
 import org.junit.Ignore;
 import org.junit.Test;
+
 import org.springframework.core.MethodParameter;
 import org.springframework.core.convert.TypeDescriptor;
 import org.springframework.expression.MethodExecutor;
diff --git a/src/test/java/org/springframework/scheduling/annotation/ScheduledAndTransactionalAnnotationIntegrationTests.java b/src/test/java/org/springframework/scheduling/annotation/ScheduledAndTransactionalAnnotationIntegrationTests.java
index cc5a0f60277..0017b43f498 100644
--- a/src/test/java/org/springframework/scheduling/annotation/ScheduledAndTransactionalAnnotationIntegrationTests.java
+++ b/src/test/java/org/springframework/scheduling/annotation/ScheduledAndTransactionalAnnotationIntegrationTests.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.
@@ -39,10 +39,10 @@ import org.springframework.transaction.PlatformTransactionManager;
 import org.springframework.transaction.annotation.EnableTransactionManagement;
 import org.springframework.transaction.annotation.Transactional;
 
-import static org.hamcrest.Matchers.*;
 import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.*;
 import static org.junit.Assert.*;
-import static org.mockito.BDDMockito.*;
+import static org.mockito.Mockito.*;
 
 /**
  * Integration tests cornering bug SPR-8651, which revealed that @Scheduled methods may
diff --git a/src/test/java/org/springframework/transaction/annotation/ProxyAnnotationDiscoveryTests.java b/src/test/java/org/springframework/transaction/annotation/ProxyAnnotationDiscoveryTests.java
index b9ba6957252..3e6c985cec7 100644
--- a/src/test/java/org/springframework/transaction/annotation/ProxyAnnotationDiscoveryTests.java
+++ b/src/test/java/org/springframework/transaction/annotation/ProxyAnnotationDiscoveryTests.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.
@@ -16,16 +16,16 @@
 
 package org.springframework.transaction.annotation;
 
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.CoreMatchers.not;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertTrue;
-
 import org.junit.Test;
+
 import org.springframework.aop.support.AopUtils;
 import org.springframework.context.annotation.AnnotationConfigApplicationContext;
 import org.springframework.context.annotation.Configuration;
 
+import static org.hamcrest.CoreMatchers.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.*;
+
 /**
  * Tests proving that regardless the proxy strategy used (JDK interface-based vs. CGLIB
  * subclass-based), discovery of advice-oriented annotations is consistent.