Migrate away from ExpectedException (#22922)
* Add limited checkstyles to test code Add a limited set of checkstyle rules to the test codebase to improve code consistency. * Fix checksyle violations in test code * Organize imports to fix checkstyle for test code * Migrate to assertThatExceptionOfType Migrate aware from ExpectedException rules to AssertJ exception assertions. Also include a checkstyle rules to ensure that the the ExpectedException is not accidentally used in the future. See gh-22894
This commit is contained in:
parent
7e6e3d7027
commit
d7320de871
|
|
@ -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.*;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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()");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.*;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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.*;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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.*;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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.*;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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.*;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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.*;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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}.
|
||||
|
|
|
|||
|
|
@ -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.*;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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}.
|
||||
|
|
|
|||
|
|
@ -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.*;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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 <beans> 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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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.*;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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.*;
|
||||
|
||||
|
|
|
|||
|
|
@ -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.*;
|
||||
|
||||
|
|
|
|||
|
|
@ -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}.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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<CachePut
|
|||
CacheMethodDetails<CachePut> 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<CachePut
|
|||
CacheMethodDetails<CachePut> 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
|
||||
|
|
|
|||
|
|
@ -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<? extends Annotation> context, String cacheName) {
|
||||
|
|
|
|||
|
|
@ -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<Cache
|
|||
SampleObject.class, "anotherSimpleGet", String.class, Long.class);
|
||||
CacheResultOperation operation = createDefaultOperation(methodDetails);
|
||||
|
||||
thrown.expect(IllegalStateException.class);
|
||||
operation.getAllParameters("bar"); // missing one argument
|
||||
// missing one argument
|
||||
assertThatIllegalStateException().isThrownBy(() ->
|
||||
operation.getAllParameters("bar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -91,8 +93,9 @@ public class CacheResultOperationTests extends AbstractCacheOperationTests<Cache
|
|||
SampleObject.class, "anotherSimpleGet", String.class, Long.class);
|
||||
CacheResultOperation operation = createDefaultOperation(methodDetails);
|
||||
|
||||
thrown.expect(IllegalStateException.class);
|
||||
operation.getKeyParameters("bar"); // missing one argument
|
||||
// missing one argument
|
||||
assertThatIllegalStateException().isThrownBy(() ->
|
||||
operation.getKeyParameters("bar"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -519,7 +519,8 @@ public class SpringValidatorAdapterTests {
|
|||
.addPropertyNode(f.getName())
|
||||
.addConstraintViolation();
|
||||
}
|
||||
} catch (IllegalAccessException ex) {
|
||||
}
|
||||
catch (IllegalAccessException ex) {
|
||||
throw new IllegalStateException(ex);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -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<T extends Cache> {
|
||||
|
||||
@Rule
|
||||
public final ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
protected final static String CACHE_NAME = "testCache";
|
||||
|
||||
protected abstract T getCache();
|
||||
|
|
|
|||
|
|
@ -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<T extends AbstractValueAdaptingCache>
|
||||
extends AbstractCacheTests<T> {
|
||||
|
||||
@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<T extends AbstractValueAda
|
|||
public void testCachePutNullValueAllowNullFalse() {
|
||||
T cache = getCache(false);
|
||||
String key = createRandomKey();
|
||||
|
||||
this.thrown.expect(IllegalArgumentException.class);
|
||||
this.thrown.expectMessage(CACHE_NAME_NO_NULL);
|
||||
this.thrown.expectMessage(
|
||||
"is configured to not allow null values but null was provided");
|
||||
cache.put(key, null);
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
cache.put(key, null))
|
||||
.withMessageContaining(CACHE_NAME_NO_NULL)
|
||||
.withMessageContaining("is configured to not allow null values but null was provided");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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.*;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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.*;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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.*;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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.*;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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<BeanDefinition> candidates,
|
||||
Class<? extends BeanDefinition> expectedType) {
|
||||
candidates.forEach(c -> {
|
||||
assertThat(c, is(instanceOf(expectedType)));
|
||||
});
|
||||
candidates.forEach(c ->
|
||||
assertThat(c, is(instanceOf(expectedType)))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 <component-scan> 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 <component-scan> tag")
|
||||
.withMessageContaining("Offending resource: class path resource [org/springframework/context/annotation/scopedProxyInvalidConfigTests.xml]");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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.*;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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}.
|
||||
|
|
|
|||
|
|
@ -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<String, List<String>> 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<Entry> instanceImports = new ArrayList<>();
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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.*;
|
||||
|
||||
/**
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue