Use Gradle test fixture support for spring-beans and spring-context

See gh-23550
This commit is contained in:
Sam Brannen 2019-12-28 17:13:39 +01:00
parent 5718bf424b
commit 61d4ee594d
585 changed files with 2270 additions and 1618 deletions

View File

@ -59,7 +59,7 @@ public class TestSourcesPlugin implements Plugin<Project> {
* Projects which will not be automatically added as a test dependency.
* <p>This is used to assist with the migration to Gradle test fixtures.
*/
private static final List<String> excludedProjects = Arrays.asList("spring-core");
private static final List<String> excludedProjects = Arrays.asList("spring-beans", "spring-core", "spring-context");
@Override

View File

@ -7,6 +7,7 @@ dependencies {
testCompile(project(":spring-beans"))
testCompile(project(":spring-context"))
testCompile(project(":spring-core"))
testCompile(testFixtures(project(":spring-beans")))
testCompile(testFixtures(project(":spring-core")))
testCompile(project(":spring-expression"))
testCompile(project(":spring-jdbc"))

View File

@ -21,12 +21,12 @@ import org.junit.jupiter.api.Test;
import org.springframework.aop.framework.Advised;
import org.springframework.aop.support.AopUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.test.fixtures.beans.ITestBean;
import org.springframework.beans.test.fixtures.beans.TestBean;
import org.springframework.core.test.fixtures.io.SerializationTestUtils;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpSession;
import org.springframework.test.context.junit.jupiter.web.SpringJUnitWebConfig;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

View File

@ -28,12 +28,12 @@ import org.springframework.aop.support.AopUtils;
import org.springframework.aop.support.StaticMethodMatcherPointcutAdvisor;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.test.fixtures.beans.ITestBean;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.lang.Nullable;
import org.springframework.tests.aop.advice.CountingBeforeAdvice;
import org.springframework.tests.aop.advice.MethodCounter;
import org.springframework.tests.aop.interceptor.NopInterceptor;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.transaction.CallCountingTransactionManager;
import org.springframework.transaction.NoTransactionException;
import org.springframework.transaction.interceptor.TransactionInterceptor;

View File

@ -11,19 +11,19 @@
<bean id="advice" class="org.springframework.aop.interceptor.DebugInterceptor"/>
<bean id="testBean" class="org.springframework.tests.sample.beans.TestBean"/>
<bean id="testBean" class="org.springframework.beans.test.fixtures.beans.TestBean"/>
<bean id="singletonScoped" class="org.springframework.tests.sample.beans.TestBean">
<bean id="singletonScoped" class="org.springframework.beans.test.fixtures.beans.TestBean">
<aop:scoped-proxy/>
<property name="name" value="Rob Harrop"/>
</bean>
<bean id="requestScoped" class="org.springframework.tests.sample.beans.TestBean" scope="request">
<bean id="requestScoped" class="org.springframework.beans.test.fixtures.beans.TestBean" scope="request">
<aop:scoped-proxy/>
<property name="name" value="Rob Harrop"/>
</bean>
<bean id="sessionScoped" name="sessionScopedAlias" class="org.springframework.tests.sample.beans.TestBean" scope="session">
<bean id="sessionScoped" name="sessionScopedAlias" class="org.springframework.beans.test.fixtures.beans.TestBean" scope="session">
<aop:scoped-proxy proxy-target-class="false"/>
<property name="name" value="Rob Harrop"/>
</bean>

View File

@ -74,20 +74,20 @@
<!-- These two beans would otherwise be eligible for autoproxying -->
<bean id="singletonDependency" class="org.springframework.tests.sample.beans.TestBean" scope="singleton"/>
<bean id="singletonDependency" class="org.springframework.beans.test.fixtures.beans.TestBean" scope="singleton"/>
<bean id="prototypeDependency" class="org.springframework.tests.sample.beans.TestBean" scope="prototype"/>
<bean id="prototypeDependency" class="org.springframework.beans.test.fixtures.beans.TestBean" scope="prototype"/>
<!-- ====== End test for prototype definitions to try to provoke circular references ========================= -->
<bean class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
<property name="advice"><ref bean="countingAdvice"/></property>
<property name="pattern"><value>org.springframework.tests.sample.beans.ITestBean.getName</value></property>
<property name="pattern"><value>org.springframework.beans.test.fixtures.beans.ITestBean.getName</value></property>
</bean>
<bean id="countingAdvice" class="org.springframework.tests.aop.advice.CountingAfterReturningAdvice"/>
<bean id="test" class="org.springframework.tests.sample.beans.TestBean">
<bean id="test" class="org.springframework.beans.test.fixtures.beans.TestBean">
<property name="age"><value>4</value></property>
</bean>
@ -97,7 +97,7 @@
<!-- The following beans test whether auto-proxying falls over for a null value -->
<bean id="tb" class="org.springframework.tests.sample.beans.TestBean"/>
<bean id="tb" class="org.springframework.beans.test.fixtures.beans.TestBean"/>
<bean id="nullValueReturned" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetObject" ref="tb"/>

View File

@ -6,5 +6,6 @@ dependencies {
optional("org.aspectj:aspectjweaver")
optional("org.apache.commons:commons-pool2")
optional("com.jamonapi:jamon")
testCompile(testFixtures(project(":spring-beans")))
testCompile(testFixtures(project(":spring-core")))
}

View File

@ -31,10 +31,10 @@ import org.springframework.aop.MethodMatcher;
import org.springframework.aop.Pointcut;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.aop.support.DefaultPointcutAdvisor;
import org.springframework.tests.sample.beans.IOther;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.tests.sample.beans.subpkg.DeepBean;
import org.springframework.beans.test.fixtures.beans.IOther;
import org.springframework.beans.test.fixtures.beans.ITestBean;
import org.springframework.beans.test.fixtures.beans.TestBean;
import org.springframework.beans.test.fixtures.beans.subpkg.DeepBean;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
@ -67,7 +67,7 @@ public class AspectJExpressionPointcutTests {
@Test
public void testMatchExplicit() {
String expression = "execution(int org.springframework.tests.sample.beans.TestBean.getAge())";
String expression = "execution(int org.springframework.beans.test.fixtures.beans.TestBean.getAge())";
Pointcut pointcut = getPointcut(expression);
ClassFilter classFilter = pointcut.getClassFilter();
@ -117,8 +117,8 @@ public class AspectJExpressionPointcutTests {
* @param which this or target
*/
private void testThisOrTarget(String which) throws SecurityException, NoSuchMethodException {
String matchesTestBean = which + "(org.springframework.tests.sample.beans.TestBean)";
String matchesIOther = which + "(org.springframework.tests.sample.beans.IOther)";
String matchesTestBean = which + "(org.springframework.beans.test.fixtures.beans.TestBean)";
String matchesIOther = which + "(org.springframework.beans.test.fixtures.beans.IOther)";
AspectJExpressionPointcut testBeanPc = new AspectJExpressionPointcut();
testBeanPc.setExpression(matchesTestBean);
@ -142,7 +142,7 @@ public class AspectJExpressionPointcutTests {
}
private void testWithinPackage(boolean matchSubpackages) throws SecurityException, NoSuchMethodException {
String withinBeansPackage = "within(org.springframework.tests.sample.beans.";
String withinBeansPackage = "within(org.springframework.beans.test.fixtures.beans.";
// Subpackages are matched by **
if (matchSubpackages) {
withinBeansPackage += ".";
@ -187,7 +187,7 @@ public class AspectJExpressionPointcutTests {
@Test
public void testMatchWithArgs() throws Exception {
String expression = "execution(void org.springframework.tests.sample.beans.TestBean.setSomeNumber(Number)) && args(Double)";
String expression = "execution(void org.springframework.beans.test.fixtures.beans.TestBean.setSomeNumber(Number)) && args(Double)";
Pointcut pointcut = getPointcut(expression);
ClassFilter classFilter = pointcut.getClassFilter();
@ -206,7 +206,7 @@ public class AspectJExpressionPointcutTests {
@Test
public void testSimpleAdvice() {
String expression = "execution(int org.springframework.tests.sample.beans.TestBean.getAge())";
String expression = "execution(int org.springframework.beans.test.fixtures.beans.TestBean.getAge())";
CallCountingInterceptor interceptor = new CallCountingInterceptor();
TestBean testBean = getAdvisedProxy(expression, interceptor);
@ -219,7 +219,7 @@ public class AspectJExpressionPointcutTests {
@Test
public void testDynamicMatchingProxy() {
String expression = "execution(void org.springframework.tests.sample.beans.TestBean.setSomeNumber(Number)) && args(Double)";
String expression = "execution(void org.springframework.beans.test.fixtures.beans.TestBean.setSomeNumber(Number)) && args(Double)";
CallCountingInterceptor interceptor = new CallCountingInterceptor();
TestBean testBean = getAdvisedProxy(expression, interceptor);
@ -233,7 +233,7 @@ public class AspectJExpressionPointcutTests {
@Test
public void testInvalidExpression() {
String expression = "execution(void org.springframework.tests.sample.beans.TestBean.setSomeNumber(Number) && args(Double)";
String expression = "execution(void org.springframework.beans.test.fixtures.beans.TestBean.setSomeNumber(Number) && args(Double)";
assertThatIllegalArgumentException().isThrownBy(
getPointcut(expression)::getClassFilter); // call to getClassFilter forces resolution
}
@ -264,7 +264,7 @@ public class AspectJExpressionPointcutTests {
@Test
public void testWithUnsupportedPointcutPrimitive() {
String expression = "call(int org.springframework.tests.sample.beans.TestBean.getAge())";
String expression = "call(int org.springframework.beans.test.fixtures.beans.TestBean.getAge())";
assertThatExceptionOfType(UnsupportedPointcutPrimitiveException.class).isThrownBy(() ->
getPointcut(expression).getClassFilter()) // call to getClassFilter forces resolution...
.satisfies(ex -> assertThat(ex.getUnsupportedPrimitive()).isEqualTo(PointcutPrimitive.CALL));

View File

@ -18,7 +18,7 @@ package org.springframework.aop.aspectj;
import org.junit.jupiter.api.Test;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.beans.test.fixtures.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;

View File

@ -33,8 +33,8 @@ import org.springframework.aop.framework.AopContext;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.aop.interceptor.ExposeInvocationInterceptor;
import org.springframework.aop.support.AopUtils;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.beans.test.fixtures.beans.ITestBean;
import org.springframework.beans.test.fixtures.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

View File

@ -27,7 +27,7 @@ import test.annotation.EmptySpringAnnotation;
import test.annotation.transaction.Tx;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.beans.test.fixtures.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;
@ -56,7 +56,7 @@ public class TigerAspectJExpressionPointcutTests {
@Test
public void testMatchGenericArgument() {
String expression = "execution(* set*(java.util.List<org.springframework.tests.sample.beans.TestBean>) )";
String expression = "execution(* set*(java.util.List<org.springframework.beans.test.fixtures.beans.TestBean>) )";
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
ajexp.setExpression(expression);

View File

@ -20,11 +20,11 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.tests.sample.beans.CountingTestBean;
import org.springframework.tests.sample.beans.IOther;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.tests.sample.beans.subpkg.DeepBean;
import org.springframework.beans.test.fixtures.beans.CountingTestBean;
import org.springframework.beans.test.fixtures.beans.IOther;
import org.springframework.beans.test.fixtures.beans.ITestBean;
import org.springframework.beans.test.fixtures.beans.TestBean;
import org.springframework.beans.test.fixtures.beans.subpkg.DeepBean;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
@ -57,7 +57,7 @@ class TypePatternClassFilterTests {
@Test
void validPatternMatching() {
TypePatternClassFilter tpcf = new TypePatternClassFilter("org.springframework.tests.sample.beans.*");
TypePatternClassFilter tpcf = new TypePatternClassFilter("org.springframework.beans.test.fixtures.beans.*");
assertThat(tpcf.matches(TestBean.class)).as("Must match: in package").isTrue();
assertThat(tpcf.matches(ITestBean.class)).as("Must match: in package").isTrue();
@ -70,7 +70,7 @@ class TypePatternClassFilterTests {
@Test
void subclassMatching() {
TypePatternClassFilter tpcf = new TypePatternClassFilter("org.springframework.tests.sample.beans.ITestBean+");
TypePatternClassFilter tpcf = new TypePatternClassFilter("org.springframework.beans.test.fixtures.beans.ITestBean+");
assertThat(tpcf.matches(TestBean.class)).as("Must match: in package").isTrue();
assertThat(tpcf.matches(ITestBean.class)).as("Must match: in package").isTrue();
@ -98,8 +98,8 @@ class TypePatternClassFilterTests {
@Test
void testEquals() {
TypePatternClassFilter filter1 = new TypePatternClassFilter("org.springframework.tests.sample.beans.*");
TypePatternClassFilter filter2 = new TypePatternClassFilter("org.springframework.tests.sample.beans.*");
TypePatternClassFilter filter1 = new TypePatternClassFilter("org.springframework.beans.test.fixtures.beans.*");
TypePatternClassFilter filter2 = new TypePatternClassFilter("org.springframework.beans.test.fixtures.beans.*");
TypePatternClassFilter filter3 = new TypePatternClassFilter("org.springframework.tests.*");
assertThat(filter1).isEqualTo(filter2);
@ -108,8 +108,8 @@ class TypePatternClassFilterTests {
@Test
void testHashCode() {
TypePatternClassFilter filter1 = new TypePatternClassFilter("org.springframework.tests.sample.beans.*");
TypePatternClassFilter filter2 = new TypePatternClassFilter("org.springframework.tests.sample.beans.*");
TypePatternClassFilter filter1 = new TypePatternClassFilter("org.springframework.beans.test.fixtures.beans.*");
TypePatternClassFilter filter2 = new TypePatternClassFilter("org.springframework.beans.test.fixtures.beans.*");
TypePatternClassFilter filter3 = new TypePatternClassFilter("org.springframework.tests.*");
assertThat(filter1.hashCode()).isEqualTo(filter2.hashCode());
@ -118,11 +118,11 @@ class TypePatternClassFilterTests {
@Test
void testToString() {
TypePatternClassFilter filter1 = new TypePatternClassFilter("org.springframework.tests.sample.beans.*");
TypePatternClassFilter filter2 = new TypePatternClassFilter("org.springframework.tests.sample.beans.*");
TypePatternClassFilter filter1 = new TypePatternClassFilter("org.springframework.beans.test.fixtures.beans.*");
TypePatternClassFilter filter2 = new TypePatternClassFilter("org.springframework.beans.test.fixtures.beans.*");
assertThat(filter1.toString())
.isEqualTo("org.springframework.aop.aspectj.TypePatternClassFilter: org.springframework.tests.sample.beans.*");
.isEqualTo("org.springframework.aop.aspectj.TypePatternClassFilter: org.springframework.beans.test.fixtures.beans.*");
assertThat(filter1.toString()).isEqualTo(filter2.toString());
}

View File

@ -50,11 +50,11 @@ import org.springframework.aop.framework.AopConfigException;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.aop.interceptor.ExposeInvocationInterceptor;
import org.springframework.aop.support.AopUtils;
import org.springframework.beans.test.fixtures.beans.ITestBean;
import org.springframework.beans.test.fixtures.beans.TestBean;
import org.springframework.core.OrderComparator;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.util.ObjectUtils;
import static org.assertj.core.api.Assertions.assertThat;
@ -590,7 +590,7 @@ public abstract class AbstractAspectJAdvisorFactoryTests {
}
@Aspect("pertypewithin(org.springframework.tests.sample.beans.IOther+)")
@Aspect("pertypewithin(org.springframework.beans.test.fixtures.beans.IOther+)")
public static class PerTypeWithinAspect {
public int count;
@ -931,7 +931,7 @@ abstract class AbstractMakeModifiable {
@Aspect
class MakeITestBeanModifiable extends AbstractMakeModifiable {
@DeclareParents(value = "org.springframework.tests.sample.beans.ITestBean+",
@DeclareParents(value = "org.springframework.beans.test.fixtures.beans.ITestBean+",
defaultImpl=ModifiableImpl.class)
public static MutableModifiable mixin;

View File

@ -27,8 +27,8 @@ import org.aspectj.lang.annotation.Pointcut;
import org.junit.jupiter.api.Test;
import org.springframework.aop.aspectj.AspectJAdviceParameterNameDiscoverer;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.beans.test.fixtures.beans.ITestBean;
import org.springframework.beans.test.fixtures.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;

View File

@ -23,7 +23,7 @@ import org.springframework.aop.Pointcut;
import org.springframework.aop.aspectj.AspectJExpressionPointcut;
import org.springframework.aop.aspectj.AspectJExpressionPointcutTests;
import org.springframework.aop.framework.AopConfigException;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.beans.test.fixtures.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

View File

@ -29,7 +29,7 @@ import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.beans.factory.xml.XmlReaderContext;
import org.springframework.tests.beans.CollectingReaderEventListener;
import org.springframework.beans.test.fixtures.beans.CollectingReaderEventListener;
import static org.assertj.core.api.Assertions.assertThat;

View File

@ -29,8 +29,8 @@ import org.springframework.beans.factory.parsing.ComponentDefinition;
import org.springframework.beans.factory.parsing.CompositeComponentDefinition;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.beans.test.fixtures.beans.CollectingReaderEventListener;
import org.springframework.core.io.Resource;
import org.springframework.tests.beans.CollectingReaderEventListener;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource;

View File

@ -23,8 +23,8 @@ import java.util.List;
import org.junit.jupiter.api.Test;
import org.springframework.aop.SpringProxy;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.beans.test.fixtures.beans.ITestBean;
import org.springframework.beans.test.fixtures.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;

View File

@ -19,8 +19,8 @@ package org.springframework.aop.framework;
import org.junit.jupiter.api.Test;
import org.springframework.aop.support.DelegatingIntroductionInterceptor;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.beans.test.fixtures.beans.ITestBean;
import org.springframework.beans.test.fixtures.beans.TestBean;
import org.springframework.util.StopWatch;
/**

View File

@ -23,7 +23,7 @@ import java.util.List;
import org.aopalliance.intercept.MethodInterceptor;
import org.junit.jupiter.api.Test;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.beans.test.fixtures.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;

View File

@ -34,14 +34,14 @@ import org.springframework.aop.support.AopUtils;
import org.springframework.aop.support.DefaultIntroductionAdvisor;
import org.springframework.aop.support.DefaultPointcutAdvisor;
import org.springframework.aop.support.DelegatingIntroductionInterceptor;
import org.springframework.beans.test.fixtures.beans.IOther;
import org.springframework.beans.test.fixtures.beans.ITestBean;
import org.springframework.beans.test.fixtures.beans.TestBean;
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
import org.springframework.core.annotation.Order;
import org.springframework.core.test.fixtures.TimeStamped;
import org.springframework.tests.aop.advice.CountingBeforeAdvice;
import org.springframework.tests.aop.interceptor.NopInterceptor;
import org.springframework.tests.sample.beans.IOther;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

View File

@ -22,10 +22,10 @@ import org.junit.jupiter.api.Test;
import org.springframework.aop.framework.Advised;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.beans.test.fixtures.beans.DerivedTestBean;
import org.springframework.beans.test.fixtures.beans.ITestBean;
import org.springframework.beans.test.fixtures.beans.TestBean;
import org.springframework.core.test.fixtures.io.SerializationTestUtils;
import org.springframework.tests.sample.beans.DerivedTestBean;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;

View File

@ -20,8 +20,8 @@ import org.junit.jupiter.api.Test;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.beans.factory.NamedBean;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.beans.test.fixtures.beans.ITestBean;
import org.springframework.beans.test.fixtures.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;

View File

@ -21,8 +21,8 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.beans.test.fixtures.beans.ITestBean;
import org.springframework.beans.test.fixtures.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource;

View File

@ -21,8 +21,8 @@ import java.io.IOException;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.test.fixtures.beans.TestBean;
import org.springframework.core.test.fixtures.io.SerializationTestUtils;
import org.springframework.tests.sample.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;

View File

@ -25,10 +25,10 @@ import org.springframework.aop.MethodMatcher;
import org.springframework.aop.Pointcut;
import org.springframework.aop.interceptor.ExposeInvocationInterceptor;
import org.springframework.aop.target.EmptyTargetSource;
import org.springframework.beans.test.fixtures.beans.TestBean;
import org.springframework.core.test.fixtures.io.SerializationTestUtils;
import org.springframework.lang.Nullable;
import org.springframework.tests.aop.interceptor.NopInterceptor;
import org.springframework.tests.sample.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;

View File

@ -19,9 +19,9 @@ package org.springframework.aop.support;
import org.junit.jupiter.api.Test;
import org.springframework.aop.ClassFilter;
import org.springframework.beans.test.fixtures.beans.ITestBean;
import org.springframework.beans.test.fixtures.beans.TestBean;
import org.springframework.core.NestedRuntimeException;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;

View File

@ -18,7 +18,7 @@ package org.springframework.aop.support;
import org.junit.jupiter.api.Test;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.beans.test.fixtures.beans.TestBean;
import org.springframework.util.ClassUtils;
import static org.assertj.core.api.Assertions.assertThat;

View File

@ -23,9 +23,9 @@ import org.junit.jupiter.api.Test;
import org.springframework.aop.ClassFilter;
import org.springframework.aop.MethodMatcher;
import org.springframework.aop.Pointcut;
import org.springframework.beans.test.fixtures.beans.TestBean;
import org.springframework.core.NestedRuntimeException;
import org.springframework.lang.Nullable;
import org.springframework.tests.sample.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;

View File

@ -20,9 +20,9 @@ import org.junit.jupiter.api.Test;
import org.springframework.aop.Pointcut;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.beans.test.fixtures.beans.ITestBean;
import org.springframework.beans.test.fixtures.beans.TestBean;
import org.springframework.tests.aop.interceptor.NopInterceptor;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;

View File

@ -24,15 +24,15 @@ import org.junit.jupiter.api.Test;
import org.springframework.aop.IntroductionAdvisor;
import org.springframework.aop.IntroductionInterceptor;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.beans.test.fixtures.beans.INestedTestBean;
import org.springframework.beans.test.fixtures.beans.ITestBean;
import org.springframework.beans.test.fixtures.beans.NestedTestBean;
import org.springframework.beans.test.fixtures.beans.Person;
import org.springframework.beans.test.fixtures.beans.SerializablePerson;
import org.springframework.beans.test.fixtures.beans.TestBean;
import org.springframework.core.test.fixtures.TimeStamped;
import org.springframework.core.test.fixtures.io.SerializationTestUtils;
import org.springframework.tests.aop.interceptor.SerializableNopInterceptor;
import org.springframework.tests.sample.beans.INestedTestBean;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.NestedTestBean;
import org.springframework.tests.sample.beans.Person;
import org.springframework.tests.sample.beans.SerializablePerson;
import org.springframework.tests.sample.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;

View File

@ -21,11 +21,11 @@ import java.lang.reflect.Method;
import org.junit.jupiter.api.Test;
import org.springframework.aop.MethodMatcher;
import org.springframework.beans.test.fixtures.beans.IOther;
import org.springframework.beans.test.fixtures.beans.ITestBean;
import org.springframework.beans.test.fixtures.beans.TestBean;
import org.springframework.core.test.fixtures.io.SerializationTestUtils;
import org.springframework.lang.Nullable;
import org.springframework.tests.sample.beans.IOther;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;

View File

@ -21,11 +21,11 @@ import org.junit.jupiter.api.Test;
import org.springframework.aop.framework.Advised;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.beans.test.fixtures.beans.Person;
import org.springframework.beans.test.fixtures.beans.SerializablePerson;
import org.springframework.core.test.fixtures.io.SerializationTestUtils;
import org.springframework.tests.aop.interceptor.NopInterceptor;
import org.springframework.tests.aop.interceptor.SerializableNopInterceptor;
import org.springframework.tests.sample.beans.Person;
import org.springframework.tests.sample.beans.SerializablePerson;
import static org.assertj.core.api.Assertions.assertThat;

View File

@ -22,8 +22,8 @@ import org.junit.jupiter.api.Test;
import org.springframework.aop.ClassFilter;
import org.springframework.aop.Pointcut;
import org.springframework.beans.test.fixtures.beans.TestBean;
import org.springframework.lang.Nullable;
import org.springframework.tests.sample.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;

View File

@ -21,13 +21,13 @@ import org.junit.jupiter.api.Test;
import org.springframework.aop.framework.Advised;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.beans.test.fixtures.beans.ITestBean;
import org.springframework.beans.test.fixtures.beans.Person;
import org.springframework.beans.test.fixtures.beans.TestBean;
import org.springframework.core.io.Resource;
import org.springframework.core.test.fixtures.io.SerializationTestUtils;
import org.springframework.tests.aop.interceptor.NopInterceptor;
import org.springframework.tests.aop.interceptor.SerializableNopInterceptor;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.Person;
import org.springframework.tests.sample.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource;

View File

@ -19,7 +19,7 @@ package org.springframework.aop.support;
import org.junit.jupiter.api.Test;
import org.springframework.aop.ClassFilter;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.beans.test.fixtures.beans.ITestBean;
import static org.assertj.core.api.Assertions.assertThat;

View File

@ -21,8 +21,8 @@ import org.junit.jupiter.api.Test;
import org.springframework.aop.support.AopUtils;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.beans.test.fixtures.beans.ITestBean;
import org.springframework.core.io.Resource;
import org.springframework.tests.sample.beans.ITestBean;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource;

View File

@ -25,11 +25,11 @@ import org.springframework.aop.framework.ProxyFactory;
import org.springframework.aop.support.DefaultPointcutAdvisor;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.beans.test.fixtures.beans.Person;
import org.springframework.beans.test.fixtures.beans.SerializablePerson;
import org.springframework.beans.test.fixtures.beans.SideEffectBean;
import org.springframework.core.test.fixtures.io.SerializationTestUtils;
import org.springframework.tests.aop.interceptor.SerializableNopInterceptor;
import org.springframework.tests.sample.beans.Person;
import org.springframework.tests.sample.beans.SerializablePerson;
import org.springframework.tests.sample.beans.SideEffectBean;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;

View File

@ -22,8 +22,8 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.beans.test.fixtures.beans.ITestBean;
import org.springframework.core.io.Resource;
import org.springframework.tests.sample.beans.ITestBean;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource;

View File

@ -23,9 +23,9 @@ import org.springframework.beans.MutablePropertyValues;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.beans.test.fixtures.beans.SerializablePerson;
import org.springframework.beans.test.fixtures.beans.TestBean;
import org.springframework.core.test.fixtures.io.SerializationTestUtils;
import org.springframework.tests.sample.beans.SerializablePerson;
import org.springframework.tests.sample.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;

View File

@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.tests.sample.beans.SideEffectBean;
import org.springframework.beans.test.fixtures.beans.SideEffectBean;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource;

View File

@ -21,8 +21,8 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.SideEffectBean;
import org.springframework.beans.test.fixtures.beans.ITestBean;
import org.springframework.beans.test.fixtures.beans.SideEffectBean;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource;

View File

@ -20,7 +20,7 @@
<bean id="getAgeCounter" class="org.springframework.aop.framework.CountingBeforeAdvice"/>
<bean id="testBean" class="org.springframework.tests.sample.beans.TestBean"/>
<bean id="testBean" class="org.springframework.beans.test.fixtures.beans.TestBean"/>
<bean id="countingAdvice" class="org.springframework.aop.config.CountingAspectJAdvice"/>

View File

@ -14,7 +14,7 @@
<bean id="getAgeCounter" class="org.springframework.aop.framework.CountingBeforeAdvice"/>
<bean id="testBean" class="org.springframework.tests.sample.beans.TestBean"/>
<bean id="testBean" class="org.springframework.beans.test.fixtures.beans.TestBean"/>
<bean id="countingAdvice" class="org.springframework.aop.config.CountingAspectJAdvice"/>

View File

@ -14,7 +14,7 @@
<bean id="getAgeCounter" class="org.springframework.aop.framework.CountingBeforeAdvice"/>
<bean id="testBean" class="org.springframework.tests.sample.beans.TestBean"/>
<bean id="testBean" class="org.springframework.beans.test.fixtures.beans.TestBean"/>
<bean id="countingAdvice" class="org.springframework.aop.config.CountingAspectJAdvice"/>

View File

@ -4,7 +4,7 @@
<beans>
<!-- Simple target -->
<bean id="test" class="org.springframework.tests.sample.beans.TestBean">
<bean id="test" class="org.springframework.beans.test.fixtures.beans.TestBean">
<property name="name"><value>custom</value></property>
<property name="age"><value>666</value></property>
</bean>
@ -21,15 +21,15 @@
</bean>
<bean id="settersAdvised" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="proxyInterfaces"><value>org.springframework.tests.sample.beans.ITestBean</value></property>
<property name="proxyInterfaces"><value>org.springframework.beans.test.fixtures.beans.ITestBean</value></property>
<property name="target"><ref bean="test"/></property>
<property name="interceptorNames"><value>settersAdvisor</value></property>
</bean>
<bean id="serializableSettersAdvised" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="proxyInterfaces"><value>org.springframework.tests.sample.beans.Person</value></property>
<property name="proxyInterfaces"><value>org.springframework.beans.test.fixtures.beans.Person</value></property>
<property name="target">
<bean class="org.springframework.tests.sample.beans.SerializablePerson">
<bean class="org.springframework.beans.test.fixtures.beans.SerializablePerson">
<property name="name"><value>serializableSettersAdvised</value></property>
</bean>
</property>
@ -48,7 +48,7 @@
</bean>
<bean id="settersAndAbsquatulateAdvised" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="proxyInterfaces"><value>org.springframework.tests.sample.beans.ITestBean</value></property>
<property name="proxyInterfaces"><value>org.springframework.beans.test.fixtures.beans.ITestBean</value></property>
<!-- Force CGLIB so we can cast to TestBean -->
<property name="proxyTargetClass"><value>true</value></property>
<property name="target"><ref bean="test"/></property>

View File

@ -3,7 +3,7 @@
<beans>
<bean id="testBeanTarget" class="org.springframework.tests.sample.beans.TestBean" scope="prototype"/>
<bean id="testBeanTarget" class="org.springframework.beans.test.fixtures.beans.TestBean" scope="prototype"/>
<bean id="targetSource" class="org.springframework.aop.target.CommonsPool2TargetSource">
<property name="targetBeanName" value="testBeanTarget"/>

View File

@ -4,11 +4,11 @@
<beans>
<!-- Simple target -->
<bean id="target1" class="org.springframework.tests.sample.beans.SideEffectBean">
<bean id="target1" class="org.springframework.beans.test.fixtures.beans.SideEffectBean">
<property name="count"><value>10</value></property>
</bean>
<bean id="target2" class="org.springframework.tests.sample.beans.SideEffectBean" scope="singleton">
<bean id="target2" class="org.springframework.beans.test.fixtures.beans.SideEffectBean" scope="singleton">
<property name="count"><value>20</value></property>
</bean>

View File

@ -3,7 +3,7 @@
<beans>
<bean id="target" class="org.springframework.tests.sample.beans.TestBean" lazy-init="true">
<bean id="target" class="org.springframework.beans.test.fixtures.beans.TestBean" lazy-init="true">
<property name="age"><value>10</value></property>
</bean>

View File

@ -3,7 +3,7 @@
<beans>
<bean id="target" class="org.springframework.tests.sample.beans.TestBean" lazy-init="true">
<bean id="target" class="org.springframework.beans.test.fixtures.beans.TestBean" lazy-init="true">
<property name="age"><value>10</value></property>
</bean>

View File

@ -4,11 +4,11 @@
<beans>
<!-- Simple target -->
<bean id="test" class="org.springframework.tests.sample.beans.SideEffectBean">
<bean id="test" class="org.springframework.beans.test.fixtures.beans.SideEffectBean">
<property name="count"><value>10</value></property>
</bean>
<bean id="prototypeTest" class="org.springframework.tests.sample.beans.SideEffectBean" scope="prototype">
<bean id="prototypeTest" class="org.springframework.beans.test.fixtures.beans.SideEffectBean" scope="prototype">
<property name="count"><value>10</value></property>
</bean>

View File

@ -3,7 +3,7 @@
<beans>
<bean id="prototypeTest" class="org.springframework.tests.sample.beans.SideEffectBean" scope="prototype">
<bean id="prototypeTest" class="org.springframework.beans.test.fixtures.beans.SideEffectBean" scope="prototype">
<property name="count"><value>10</value></property>
</bean>
@ -34,12 +34,12 @@
<!-- ================ Definitions for second ThreadLocalTargetSource ====== -->
<bean id="test" class="org.springframework.tests.sample.beans.TestBean" scope="prototype">
<bean id="test" class="org.springframework.beans.test.fixtures.beans.TestBean" scope="prototype">
<property name="name"><value>Rod</value></property>
<property name="spouse"><ref bean="wife"/></property>
</bean>
<bean id="wife" class="org.springframework.tests.sample.beans.TestBean">
<bean id="wife" class="org.springframework.beans.test.fixtures.beans.TestBean">
<property name="name"><value>Kerry</value></property>
</bean>

View File

@ -24,6 +24,7 @@ dependencies {
optional("javax.transaction:javax.transaction-api") // for @javax.transaction.Transactional support
testCompile(project(":spring-core")) // for CodeStyleAspect
testCompile(project(":spring-test"))
testCompile(testFixtures(project(":spring-context")))
testCompile(testFixtures(project(":spring-core")))
testCompile("javax.mail:javax.mail-api")
testCompileOnly("org.aspectj:aspectjrt")

View File

@ -0,0 +1,882 @@
/*
* Copyright 2002-2019 the original author 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.aspectj;
import java.util.Collection;
import java.util.UUID;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.aop.framework.AopProxyUtils;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.cache.config.AnnotatedClassCacheableService;
import org.springframework.cache.config.CacheableService;
import org.springframework.cache.config.TestEntity;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.test.fixtures.cache.SomeCustomKeyGenerator;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.assertThatIOException;
/**
* Copy of the shared {@code AbstractCacheAnnotationTests}: necessary
* due to issues with Gradle test fixtures and AspectJ configuration
* in the Gradle build.
*
* <p>Abstract cache annotation tests (containing several reusable methods).
*
* @author Costin Leau
* @author Chris Beams
* @author Phillip Webb
* @author Stephane Nicoll
*/
public abstract class AbstractCacheAnnotationTests {
protected ConfigurableApplicationContext ctx;
protected CacheableService<?> cs;
protected CacheableService<?> ccs;
protected CacheManager cm;
/**
* @return a refreshed application context
*/
protected abstract ConfigurableApplicationContext getApplicationContext();
@BeforeEach
public void setup() {
this.ctx = getApplicationContext();
this.cs = ctx.getBean("service", CacheableService.class);
this.ccs = ctx.getBean("classService", CacheableService.class);
this.cm = ctx.getBean("cacheManager", CacheManager.class);
Collection<String> cn = this.cm.getCacheNames();
assertThat(cn).containsOnly("testCache", "secondary", "primary");
}
@AfterEach
public void close() {
if (this.ctx != null) {
this.ctx.close();
}
}
protected void testCacheable(CacheableService<?> service) {
Object o1 = new Object();
Object r1 = service.cache(o1);
Object r2 = service.cache(o1);
Object r3 = service.cache(o1);
assertThat(r2).isSameAs(r1);
assertThat(r3).isSameAs(r1);
}
protected void testCacheableNull(CacheableService<?> service) {
Object o1 = new Object();
assertThat(this.cm.getCache("testCache").get(o1)).isNull();
Object r1 = service.cacheNull(o1);
Object r2 = service.cacheNull(o1);
Object r3 = service.cacheNull(o1);
assertThat(r2).isSameAs(r1);
assertThat(r3).isSameAs(r1);
assertThat(this.cm.getCache("testCache")).as("testCache").isNotNull();
assertThat(this.cm.getCache("testCache").get(o1)).as("cached object").isNotNull();
assertThat(this.cm.getCache("testCache").get(o1).get()).isEqualTo(r3);
assertThat(r3).as("Cached value should be null").isNull();
}
protected void testCacheableSync(CacheableService<?> service) {
Object o1 = new Object();
Object r1 = service.cacheSync(o1);
Object r2 = service.cacheSync(o1);
Object r3 = service.cacheSync(o1);
assertThat(r2).isSameAs(r1);
assertThat(r3).isSameAs(r1);
}
protected void testCacheableSyncNull(CacheableService<?> service) {
Object o1 = new Object();
assertThat(this.cm.getCache("testCache").get(o1)).isNull();
Object r1 = service.cacheSyncNull(o1);
Object r2 = service.cacheSyncNull(o1);
Object r3 = service.cacheSyncNull(o1);
assertThat(r2).isSameAs(r1);
assertThat(r3).isSameAs(r1);
assertThat(this.cm.getCache("testCache").get(o1).get()).isEqualTo(r3);
assertThat(r3).as("Cached value should be null").isNull();
}
protected void testEvict(CacheableService<?> service, boolean successExpected) {
Cache cache = this.cm.getCache("testCache");
Object o1 = new Object();
cache.putIfAbsent(o1, -1L);
Object r1 = service.cache(o1);
service.evict(o1, null);
if (successExpected) {
assertThat(cache.get(o1)).isNull();
}
else {
assertThat(cache.get(o1)).isNotNull();
}
Object r2 = service.cache(o1);
if (successExpected) {
assertThat(r2).isNotSameAs(r1);
}
else {
assertThat(r2).isSameAs(r1);
}
}
protected void testEvictEarly(CacheableService<?> service) {
Cache cache = this.cm.getCache("testCache");
Object o1 = new Object();
cache.putIfAbsent(o1, -1L);
Object r1 = service.cache(o1);
try {
service.evictEarly(o1);
}
catch (RuntimeException ex) {
// expected
}
assertThat(cache.get(o1)).isNull();
Object r2 = service.cache(o1);
assertThat(r2).isNotSameAs(r1);
}
protected void testEvictException(CacheableService<?> service) {
Object o1 = new Object();
Object r1 = service.cache(o1);
try {
service.evictWithException(o1);
}
catch (RuntimeException ex) {
// expected
}
// exception occurred, eviction skipped, data should still be in the cache
Object r2 = service.cache(o1);
assertThat(r2).isSameAs(r1);
}
protected void testEvictWithKey(CacheableService<?> service) {
Object o1 = new Object();
Object r1 = service.cache(o1);
service.evict(o1, null);
Object r2 = service.cache(o1);
assertThat(r2).isNotSameAs(r1);
}
protected void testEvictWithKeyEarly(CacheableService<?> service) {
Object o1 = new Object();
Object r1 = service.cache(o1);
try {
service.evictEarly(o1);
}
catch (Exception ex) {
// expected
}
Object r2 = service.cache(o1);
assertThat(r2).isNotSameAs(r1);
}
protected void testEvictAll(CacheableService<?> service, boolean successExpected) {
Cache cache = this.cm.getCache("testCache");
Object o1 = new Object();
Object o2 = new Object();
cache.putIfAbsent(o1, -1L);
cache.putIfAbsent(o2, -2L);
Object r1 = service.cache(o1);
Object r2 = service.cache(o2);
assertThat(r2).isNotSameAs(r1);
service.evictAll(new Object());
if (successExpected) {
assertThat(cache.get(o1)).isNull();
assertThat(cache.get(o2)).isNull();
}
else {
assertThat(cache.get(o1)).isNotNull();
assertThat(cache.get(o2)).isNotNull();
}
Object r3 = service.cache(o1);
Object r4 = service.cache(o2);
if (successExpected) {
assertThat(r3).isNotSameAs(r1);
assertThat(r4).isNotSameAs(r2);
}
else {
assertThat(r3).isSameAs(r1);
assertThat(r4).isSameAs(r2);
}
}
protected void testEvictAllEarly(CacheableService<?> service) {
Cache cache = this.cm.getCache("testCache");
Object o1 = new Object();
Object o2 = new Object();
cache.putIfAbsent(o1, -1L);
cache.putIfAbsent(o2, -2L);
Object r1 = service.cache(o1);
Object r2 = service.cache(o2);
assertThat(r2).isNotSameAs(r1);
try {
service.evictAllEarly(new Object());
}
catch (Exception ex) {
// expected
}
assertThat(cache.get(o1)).isNull();
assertThat(cache.get(o2)).isNull();
Object r3 = service.cache(o1);
Object r4 = service.cache(o2);
assertThat(r3).isNotSameAs(r1);
assertThat(r4).isNotSameAs(r2);
}
protected void testConditionalExpression(CacheableService<?> service) {
Object r1 = service.conditional(4);
Object r2 = service.conditional(4);
assertThat(r2).isNotSameAs(r1);
Object r3 = service.conditional(3);
Object r4 = service.conditional(3);
assertThat(r4).isSameAs(r3);
}
protected void testConditionalExpressionSync(CacheableService<?> service) {
Object r1 = service.conditionalSync(4);
Object r2 = service.conditionalSync(4);
assertThat(r2).isNotSameAs(r1);
Object r3 = service.conditionalSync(3);
Object r4 = service.conditionalSync(3);
assertThat(r4).isSameAs(r3);
}
protected void testUnlessExpression(CacheableService<?> service) {
Cache cache = this.cm.getCache("testCache");
cache.clear();
service.unless(10);
service.unless(11);
assertThat(cache.get(10).get()).isEqualTo(10L);
assertThat(cache.get(11)).isNull();
}
protected void testKeyExpression(CacheableService<?> service) {
Object r1 = service.key(5, 1);
Object r2 = service.key(5, 2);
assertThat(r2).isSameAs(r1);
Object r3 = service.key(1, 5);
Object r4 = service.key(2, 5);
assertThat(r4).isNotSameAs(r3);
}
protected void testVarArgsKey(CacheableService<?> service) {
Object r1 = service.varArgsKey(1, 2, 3);
Object r2 = service.varArgsKey(1, 2, 3);
assertThat(r2).isSameAs(r1);
Object r3 = service.varArgsKey(1, 2, 3);
Object r4 = service.varArgsKey(1, 2);
assertThat(r4).isNotSameAs(r3);
}
protected void testNullValue(CacheableService<?> service) {
Object key = new Object();
assertThat(service.nullValue(key)).isNull();
int nr = service.nullInvocations().intValue();
assertThat(service.nullValue(key)).isNull();
assertThat(service.nullInvocations().intValue()).isEqualTo(nr);
assertThat(service.nullValue(new Object())).isNull();
assertThat(service.nullInvocations().intValue()).isEqualTo(nr + 1);
}
protected void testMethodName(CacheableService<?> service, String keyName) {
Object key = new Object();
Object r1 = service.name(key);
assertThat(service.name(key)).isSameAs(r1);
Cache cache = this.cm.getCache("testCache");
// assert the method name is used
assertThat(cache.get(keyName)).isNotNull();
}
protected void testRootVars(CacheableService<?> service) {
Object key = new Object();
Object r1 = service.rootVars(key);
assertThat(service.rootVars(key)).isSameAs(r1);
Cache cache = this.cm.getCache("testCache");
// assert the method name is used
String expectedKey = "rootVarsrootVars" + AopProxyUtils.ultimateTargetClass(service) + service;
assertThat(cache.get(expectedKey)).isNotNull();
}
protected void testCheckedThrowable(CacheableService<?> service) {
String arg = UUID.randomUUID().toString();
assertThatIOException().isThrownBy(() ->
service.throwChecked(arg))
.withMessage(arg);
}
protected void testUncheckedThrowable(CacheableService<?> service) {
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() ->
service.throwUnchecked(1L))
.withMessage("1");
}
protected void testCheckedThrowableSync(CacheableService<?> service) {
String arg = UUID.randomUUID().toString();
assertThatIOException().isThrownBy(() ->
service.throwCheckedSync(arg))
.withMessage(arg);
}
protected void testUncheckedThrowableSync(CacheableService<?> service) {
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(() ->
service.throwUncheckedSync(1L))
.withMessage("1");
}
protected void testNullArg(CacheableService<?> service) {
Object r1 = service.cache(null);
assertThat(service.cache(null)).isSameAs(r1);
}
protected void testCacheUpdate(CacheableService<?> service) {
Object o = new Object();
Cache cache = this.cm.getCache("testCache");
assertThat(cache.get(o)).isNull();
Object r1 = service.update(o);
assertThat(cache.get(o).get()).isSameAs(r1);
o = new Object();
assertThat(cache.get(o)).isNull();
Object r2 = service.update(o);
assertThat(cache.get(o).get()).isSameAs(r2);
}
protected void testConditionalCacheUpdate(CacheableService<?> service) {
Integer one = 1;
Integer three = 3;
Cache cache = this.cm.getCache("testCache");
assertThat((int) Integer.valueOf(service.conditionalUpdate(one).toString())).isEqualTo((int) one);
assertThat(cache.get(one)).isNull();
assertThat((int) Integer.valueOf(service.conditionalUpdate(three).toString())).isEqualTo((int) three);
assertThat((int) Integer.valueOf(cache.get(three).get().toString())).isEqualTo((int) three);
}
protected void testMultiCache(CacheableService<?> service) {
Object o1 = new Object();
Object o2 = new Object();
Cache primary = this.cm.getCache("primary");
Cache secondary = this.cm.getCache("secondary");
assertThat(primary.get(o1)).isNull();
assertThat(secondary.get(o1)).isNull();
Object r1 = service.multiCache(o1);
assertThat(primary.get(o1).get()).isSameAs(r1);
assertThat(secondary.get(o1).get()).isSameAs(r1);
Object r2 = service.multiCache(o1);
Object r3 = service.multiCache(o1);
assertThat(r2).isSameAs(r1);
assertThat(r3).isSameAs(r1);
assertThat(primary.get(o2)).isNull();
assertThat(secondary.get(o2)).isNull();
Object r4 = service.multiCache(o2);
assertThat(primary.get(o2).get()).isSameAs(r4);
assertThat(secondary.get(o2).get()).isSameAs(r4);
}
protected void testMultiEvict(CacheableService<?> service) {
Object o1 = new Object();
Object o2 = o1.toString() + "A";
Object r1 = service.multiCache(o1);
Object r2 = service.multiCache(o1);
Cache primary = this.cm.getCache("primary");
Cache secondary = this.cm.getCache("secondary");
primary.put(o2, o2);
assertThat(r2).isSameAs(r1);
assertThat(primary.get(o1).get()).isSameAs(r1);
assertThat(secondary.get(o1).get()).isSameAs(r1);
service.multiEvict(o1);
assertThat(primary.get(o1)).isNull();
assertThat(secondary.get(o1)).isNull();
assertThat(primary.get(o2)).isNull();
Object r3 = service.multiCache(o1);
Object r4 = service.multiCache(o1);
assertThat(r3).isNotSameAs(r1);
assertThat(r4).isSameAs(r3);
assertThat(primary.get(o1).get()).isSameAs(r3);
assertThat(secondary.get(o1).get()).isSameAs(r4);
}
protected void testMultiPut(CacheableService<?> service) {
Object o = 1;
Cache primary = this.cm.getCache("primary");
Cache secondary = this.cm.getCache("secondary");
assertThat(primary.get(o)).isNull();
assertThat(secondary.get(o)).isNull();
Object r1 = service.multiUpdate(o);
assertThat(primary.get(o).get()).isSameAs(r1);
assertThat(secondary.get(o).get()).isSameAs(r1);
o = 2;
assertThat(primary.get(o)).isNull();
assertThat(secondary.get(o)).isNull();
Object r2 = service.multiUpdate(o);
assertThat(primary.get(o).get()).isSameAs(r2);
assertThat(secondary.get(o).get()).isSameAs(r2);
}
protected void testPutRefersToResult(CacheableService<?> service) {
Long id = Long.MIN_VALUE;
TestEntity entity = new TestEntity();
Cache primary = this.cm.getCache("primary");
assertThat(primary.get(id)).isNull();
assertThat(entity.getId()).isNull();
service.putRefersToResult(entity);
assertThat(primary.get(id).get()).isSameAs(entity);
}
protected void testMultiCacheAndEvict(CacheableService<?> service) {
String methodName = "multiCacheAndEvict";
Cache primary = this.cm.getCache("primary");
Cache secondary = this.cm.getCache("secondary");
Object key = 1;
secondary.put(key, key);
assertThat(secondary.get(methodName)).isNull();
assertThat(secondary.get(key).get()).isSameAs(key);
Object r1 = service.multiCacheAndEvict(key);
assertThat(service.multiCacheAndEvict(key)).isSameAs(r1);
// assert the method name is used
assertThat(primary.get(methodName).get()).isSameAs(r1);
assertThat(secondary.get(methodName)).isNull();
assertThat(secondary.get(key)).isNull();
}
protected void testMultiConditionalCacheAndEvict(CacheableService<?> service) {
Cache primary = this.cm.getCache("primary");
Cache secondary = this.cm.getCache("secondary");
Object key = 1;
secondary.put(key, key);
assertThat(primary.get(key)).isNull();
assertThat(secondary.get(key).get()).isSameAs(key);
Object r1 = service.multiConditionalCacheAndEvict(key);
Object r3 = service.multiConditionalCacheAndEvict(key);
assertThat(!r1.equals(r3)).isTrue();
assertThat(primary.get(key)).isNull();
Object key2 = 3;
Object r2 = service.multiConditionalCacheAndEvict(key2);
assertThat(service.multiConditionalCacheAndEvict(key2)).isSameAs(r2);
// assert the method name is used
assertThat(primary.get(key2).get()).isSameAs(r2);
assertThat(secondary.get(key2)).isNull();
}
@Test
public void testCacheable() {
testCacheable(this.cs);
}
@Test
public void testCacheableNull() {
testCacheableNull(this.cs);
}
@Test
public void testCacheableSync() {
testCacheableSync(this.cs);
}
@Test
public void testCacheableSyncNull() {
testCacheableSyncNull(this.cs);
}
@Test
public void testEvict() {
testEvict(this.cs, true);
}
@Test
public void testEvictEarly() {
testEvictEarly(this.cs);
}
@Test
public void testEvictWithException() {
testEvictException(this.cs);
}
@Test
public void testEvictAll() {
testEvictAll(this.cs, true);
}
@Test
public void testEvictAllEarly() {
testEvictAllEarly(this.cs);
}
@Test
public void testEvictWithKey() {
testEvictWithKey(this.cs);
}
@Test
public void testEvictWithKeyEarly() {
testEvictWithKeyEarly(this.cs);
}
@Test
public void testConditionalExpression() {
testConditionalExpression(this.cs);
}
@Test
public void testConditionalExpressionSync() {
testConditionalExpressionSync(this.cs);
}
@Test
public void testUnlessExpression() {
testUnlessExpression(this.cs);
}
@Test
public void testClassCacheUnlessExpression() {
testUnlessExpression(this.cs);
}
@Test
public void testKeyExpression() {
testKeyExpression(this.cs);
}
@Test
public void testVarArgsKey() {
testVarArgsKey(this.cs);
}
@Test
public void testClassCacheCacheable() {
testCacheable(this.ccs);
}
@Test
public void testClassCacheEvict() {
testEvict(this.ccs, true);
}
@Test
public void testClassEvictEarly() {
testEvictEarly(this.ccs);
}
@Test
public void testClassEvictAll() {
testEvictAll(this.ccs, true);
}
@Test
public void testClassEvictWithException() {
testEvictException(this.ccs);
}
@Test
public void testClassCacheEvictWithWKey() {
testEvictWithKey(this.ccs);
}
@Test
public void testClassEvictWithKeyEarly() {
testEvictWithKeyEarly(this.ccs);
}
@Test
public void testNullValue() {
testNullValue(this.cs);
}
@Test
public void testClassNullValue() {
Object key = new Object();
assertThat(this.ccs.nullValue(key)).isNull();
int nr = this.ccs.nullInvocations().intValue();
assertThat(this.ccs.nullValue(key)).isNull();
assertThat(this.ccs.nullInvocations().intValue()).isEqualTo(nr);
assertThat(this.ccs.nullValue(new Object())).isNull();
// the check method is also cached
assertThat(this.ccs.nullInvocations().intValue()).isEqualTo(nr);
assertThat(AnnotatedClassCacheableService.nullInvocations.intValue()).isEqualTo(nr + 1);
}
@Test
public void testMethodName() {
testMethodName(this.cs, "name");
}
@Test
public void testClassMethodName() {
testMethodName(this.ccs, "nametestCache");
}
@Test
public void testRootVars() {
testRootVars(this.cs);
}
@Test
public void testClassRootVars() {
testRootVars(this.ccs);
}
@Test
public void testCustomKeyGenerator() {
Object param = new Object();
Object r1 = this.cs.customKeyGenerator(param);
assertThat(this.cs.customKeyGenerator(param)).isSameAs(r1);
Cache cache = this.cm.getCache("testCache");
// Checks that the custom keyGenerator was used
Object expectedKey = SomeCustomKeyGenerator.generateKey("customKeyGenerator", param);
assertThat(cache.get(expectedKey)).isNotNull();
}
@Test
public void testUnknownCustomKeyGenerator() {
Object param = new Object();
assertThatExceptionOfType(NoSuchBeanDefinitionException.class).isThrownBy(() ->
this.cs.unknownCustomKeyGenerator(param));
}
@Test
public void testCustomCacheManager() {
CacheManager customCm = this.ctx.getBean("customCacheManager", CacheManager.class);
Object key = new Object();
Object r1 = this.cs.customCacheManager(key);
assertThat(this.cs.customCacheManager(key)).isSameAs(r1);
Cache cache = customCm.getCache("testCache");
assertThat(cache.get(key)).isNotNull();
}
@Test
public void testUnknownCustomCacheManager() {
Object param = new Object();
assertThatExceptionOfType(NoSuchBeanDefinitionException.class).isThrownBy(() ->
this.cs.unknownCustomCacheManager(param));
}
@Test
public void testNullArg() {
testNullArg(this.cs);
}
@Test
public void testClassNullArg() {
testNullArg(this.ccs);
}
@Test
public void testCheckedException() {
testCheckedThrowable(this.cs);
}
@Test
public void testClassCheckedException() {
testCheckedThrowable(this.ccs);
}
@Test
public void testCheckedExceptionSync() {
testCheckedThrowableSync(this.cs);
}
@Test
public void testClassCheckedExceptionSync() {
testCheckedThrowableSync(this.ccs);
}
@Test
public void testUncheckedException() {
testUncheckedThrowable(this.cs);
}
@Test
public void testClassUncheckedException() {
testUncheckedThrowable(this.ccs);
}
@Test
public void testUncheckedExceptionSync() {
testUncheckedThrowableSync(this.cs);
}
@Test
public void testClassUncheckedExceptionSync() {
testUncheckedThrowableSync(this.ccs);
}
@Test
public void testUpdate() {
testCacheUpdate(this.cs);
}
@Test
public void testClassUpdate() {
testCacheUpdate(this.ccs);
}
@Test
public void testConditionalUpdate() {
testConditionalCacheUpdate(this.cs);
}
@Test
public void testClassConditionalUpdate() {
testConditionalCacheUpdate(this.ccs);
}
@Test
public void testMultiCache() {
testMultiCache(this.cs);
}
@Test
public void testClassMultiCache() {
testMultiCache(this.ccs);
}
@Test
public void testMultiEvict() {
testMultiEvict(this.cs);
}
@Test
public void testClassMultiEvict() {
testMultiEvict(this.ccs);
}
@Test
public void testMultiPut() {
testMultiPut(this.cs);
}
@Test
public void testClassMultiPut() {
testMultiPut(this.ccs);
}
@Test
public void testPutRefersToResult() {
testPutRefersToResult(this.cs);
}
@Test
public void testClassPutRefersToResult() {
testPutRefersToResult(this.ccs);
}
@Test
public void testMultiCacheAndEvict() {
testMultiCacheAndEvict(this.cs);
}
@Test
public void testClassMultiCacheAndEvict() {
testMultiCacheAndEvict(this.ccs);
}
@Test
public void testMultiConditionalCacheAndEvict() {
testMultiConditionalCacheAndEvict(this.cs);
}
@Test
public void testClassMultiConditionalCacheAndEvict() {
testMultiConditionalCacheAndEvict(this.ccs);
}
}

View File

@ -19,7 +19,6 @@ package org.springframework.cache.aspectj;
import org.junit.jupiter.api.Test;
import org.springframework.cache.Cache;
import org.springframework.cache.config.AbstractCacheAnnotationTests;
import org.springframework.cache.config.CacheableService;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.GenericXmlApplicationContext;

View File

@ -22,14 +22,8 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.cache.CacheManager;
import org.springframework.cache.CacheTestUtils;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.config.AnnotatedClassCacheableService;
import org.springframework.cache.config.CacheableService;
import org.springframework.cache.config.DefaultCacheableService;
import org.springframework.cache.config.SomeCustomKeyGenerator;
import org.springframework.cache.config.SomeKeyGenerator;
import org.springframework.cache.interceptor.CacheErrorHandler;
import org.springframework.cache.interceptor.CacheResolver;
import org.springframework.cache.interceptor.KeyGenerator;
@ -42,6 +36,12 @@ import org.springframework.context.annotation.AdviceMode;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.test.fixtures.cache.CacheTestUtils;
import org.springframework.context.test.fixtures.cache.SomeCustomKeyGenerator;
import org.springframework.context.test.fixtures.cache.SomeKeyGenerator;
import org.springframework.context.test.fixtures.cache.beans.AnnotatedClassCacheableService;
import org.springframework.context.test.fixtures.cache.beans.CacheableService;
import org.springframework.context.test.fixtures.cache.beans.DefaultCacheableService;
import static org.assertj.core.api.Assertions.assertThat;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -17,15 +17,11 @@
package org.springframework.cache.aspectj;
import org.springframework.cache.CacheManager;
import org.springframework.cache.CacheTestUtils;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.config.AbstractCacheAnnotationTests;
import org.springframework.cache.config.AnnotatedClassCacheableService;
import org.springframework.cache.config.CacheableService;
import org.springframework.cache.config.DefaultCacheableService;
import org.springframework.cache.config.SomeCustomKeyGenerator;
import org.springframework.cache.config.SomeKeyGenerator;
import org.springframework.cache.interceptor.CacheErrorHandler;
import org.springframework.cache.interceptor.KeyGenerator;
import org.springframework.cache.interceptor.SimpleCacheErrorHandler;
@ -34,6 +30,9 @@ import org.springframework.context.annotation.AdviceMode;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.test.fixtures.cache.CacheTestUtils;
import org.springframework.context.test.fixtures.cache.SomeCustomKeyGenerator;
import org.springframework.context.test.fixtures.cache.SomeKeyGenerator;
/**
* @author Stephane Nicoll

View File

@ -25,6 +25,10 @@ import org.springframework.cache.annotation.Cacheable;
import org.springframework.cache.annotation.Caching;
/**
* Copy of the shared {@code AbstractCacheAnnotationTests}: necessary
* due to issues with Gradle test fixtures and AspectJ configuration
* in the Gradle build.
*
* @author Costin Leau
* @author Phillip Webb
* @author Stephane Nicoll

View File

@ -17,7 +17,11 @@
package org.springframework.cache.config;
/**
* Basic service interface for caching tests.
* Copy of the shared {@code CacheableService}: necessary
* due to issues with Gradle test fixtures and AspectJ configuration
* in the Gradle build.
*
* <p>Basic service interface for caching tests.
*
* @author Costin Leau
* @author Phillip Webb

View File

@ -25,7 +25,11 @@ import org.springframework.cache.annotation.Cacheable;
import org.springframework.cache.annotation.Caching;
/**
* Simple cacheable service.
* Copy of the shared {@code DefaultCacheableService}: necessary
* due to issues with Gradle test fixtures and AspectJ configuration
* in the Gradle build.
*
* <p>Simple cacheable service.
*
* @author Costin Leau
* @author Phillip Webb

View File

@ -1,22 +0,0 @@
/*
* Copyright 2002-2016 the original author 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.config;
import org.springframework.cache.interceptor.SimpleKeyGenerator;
public class SomeKeyGenerator extends SimpleKeyGenerator {
}

View File

@ -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.
@ -19,7 +19,11 @@ package org.springframework.cache.config;
import org.springframework.util.ObjectUtils;
/**
* Simple test entity for use with caching tests.
* Copy of the shared {@code TestEntity}: necessary
* due to issues with Gradle test fixtures and AspectJ configuration
* in the Gradle build.
*
* <p>Simple test entity for use with caching tests.
*
* @author Michael Plod
*/
@ -53,5 +57,4 @@ public class TestEntity {
}
return false;
}
}

View File

@ -22,7 +22,7 @@
<cache:annotation-driven mode="aspectj" key-generator="keyGenerator"/>
<bean id="keyGenerator" class="org.springframework.cache.config.SomeKeyGenerator"/>
<bean id="keyGenerator" class="org.springframework.context.test.fixtures.cache.SomeKeyGenerator"/>
<bean id="cacheManager" class="org.springframework.cache.support.SimpleCacheManager">
<property name="caches">
@ -40,7 +40,7 @@
</property>
</bean>
<bean id="customKeyGenerator" class="org.springframework.cache.config.SomeCustomKeyGenerator"/>
<bean id="customKeyGenerator" class="org.springframework.context.test.fixtures.cache.SomeCustomKeyGenerator"/>
<bean id="customCacheManager" class="org.springframework.cache.support.SimpleCacheManager">
<property name="caches">

View File

@ -12,6 +12,8 @@ dependencies {
optional("org.jetbrains.kotlin:kotlin-stdlib")
testCompile(testFixtures(project(":spring-core")))
testCompile("javax.annotation:javax.annotation-api")
testFixturesApi("org.junit.jupiter:junit-jupiter-api")
testFixturesImplementation("org.assertj:assertj-core")
}
// This module does joint compilation for Java and Groovy code with the compileGroovy task.

View File

@ -43,6 +43,11 @@ import org.springframework.beans.propertyeditors.CustomNumberEditor;
import org.springframework.beans.propertyeditors.StringArrayPropertyEditor;
import org.springframework.beans.propertyeditors.StringTrimmerEditor;
import org.springframework.beans.support.DerivedFromProtectedBaseBean;
import org.springframework.beans.test.fixtures.beans.BooleanTestBean;
import org.springframework.beans.test.fixtures.beans.ITestBean;
import org.springframework.beans.test.fixtures.beans.IndexedTestBean;
import org.springframework.beans.test.fixtures.beans.NumberTestBean;
import org.springframework.beans.test.fixtures.beans.TestBean;
import org.springframework.core.convert.ConversionFailedException;
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.core.convert.support.DefaultConversionService;
@ -50,11 +55,6 @@ import org.springframework.core.convert.support.GenericConversionService;
import org.springframework.core.test.fixtures.Assume;
import org.springframework.core.test.fixtures.EnabledForTestGroups;
import org.springframework.lang.Nullable;
import org.springframework.tests.sample.beans.BooleanTestBean;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.IndexedTestBean;
import org.springframework.tests.sample.beans.NumberTestBean;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.util.StopWatch;
import org.springframework.util.StringUtils;

View File

@ -34,12 +34,12 @@ import org.junit.jupiter.params.provider.ValueSource;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.beans.test.fixtures.beans.DerivedTestBean;
import org.springframework.beans.test.fixtures.beans.ITestBean;
import org.springframework.beans.test.fixtures.beans.TestBean;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceEditor;
import org.springframework.lang.Nullable;
import org.springframework.tests.sample.beans.DerivedTestBean;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

View File

@ -21,9 +21,9 @@ import java.util.Map;
import org.junit.jupiter.api.Test;
import org.springframework.beans.test.fixtures.beans.CustomEnum;
import org.springframework.beans.test.fixtures.beans.GenericBean;
import org.springframework.core.convert.support.DefaultConversionService;
import org.springframework.tests.sample.beans.CustomEnum;
import org.springframework.tests.sample.beans.GenericBean;
import static org.assertj.core.api.Assertions.assertThat;

View File

@ -33,11 +33,11 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.propertyeditors.CustomNumberEditor;
import org.springframework.beans.propertyeditors.StringTrimmerEditor;
import org.springframework.beans.test.fixtures.beans.GenericBean;
import org.springframework.beans.test.fixtures.beans.GenericIntegerBean;
import org.springframework.beans.test.fixtures.beans.GenericSetOfIntegerBean;
import org.springframework.beans.test.fixtures.beans.TestBean;
import org.springframework.core.io.UrlResource;
import org.springframework.tests.sample.beans.GenericBean;
import org.springframework.tests.sample.beans.GenericIntegerBean;
import org.springframework.tests.sample.beans.GenericSetOfIntegerBean;
import org.springframework.tests.sample.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

View File

@ -22,7 +22,7 @@ import java.util.Optional;
import org.junit.jupiter.api.Test;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.beans.test.fixtures.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

View File

@ -22,8 +22,8 @@ import java.util.ArrayList;
import org.junit.jupiter.api.Test;
import org.springframework.beans.test.fixtures.beans.TestBean;
import org.springframework.core.OverridingClassLoader;
import org.springframework.tests.sample.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;
@ -42,7 +42,7 @@ public class CachedIntrospectionResultsTests {
assertThat(CachedIntrospectionResults.strongClassCache.containsKey(TestBean.class)).isTrue();
ClassLoader child = new OverridingClassLoader(getClass().getClassLoader());
Class<?> tbClass = child.loadClass("org.springframework.tests.sample.beans.TestBean");
Class<?> tbClass = child.loadClass("org.springframework.beans.test.fixtures.beans.TestBean");
assertThat(CachedIntrospectionResults.strongClassCache.containsKey(tbClass)).isFalse();
CachedIntrospectionResults.acceptClassLoader(child);
bw = new BeanWrapperImpl(tbClass);

View File

@ -18,7 +18,7 @@ package org.springframework.beans;
import org.junit.jupiter.api.Test;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.beans.test.fixtures.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;

View File

@ -25,7 +25,7 @@ import java.math.BigDecimal;
import org.junit.jupiter.api.Test;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.beans.test.fixtures.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;

View File

@ -26,14 +26,14 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.support.StaticListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.beans.test.fixtures.beans.AnnotatedBean;
import org.springframework.beans.test.fixtures.beans.ITestBean;
import org.springframework.beans.test.fixtures.beans.IndexedTestBean;
import org.springframework.beans.test.fixtures.beans.TestAnnotation;
import org.springframework.beans.test.fixtures.beans.TestBean;
import org.springframework.beans.test.fixtures.beans.factory.DummyFactory;
import org.springframework.cglib.proxy.NoOp;
import org.springframework.core.io.Resource;
import org.springframework.tests.sample.beans.AnnotatedBean;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.IndexedTestBean;
import org.springframework.tests.sample.beans.TestAnnotation;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.tests.sample.beans.factory.DummyFactory;
import org.springframework.util.ObjectUtils;
import static org.assertj.core.api.Assertions.assertThat;

View File

@ -78,6 +78,14 @@ import org.springframework.beans.factory.support.PropertiesBeanDefinitionReader;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.beans.factory.xml.ConstructorDependenciesBean;
import org.springframework.beans.propertyeditors.CustomNumberEditor;
import org.springframework.beans.test.fixtures.beans.DependenciesBean;
import org.springframework.beans.test.fixtures.beans.DerivedTestBean;
import org.springframework.beans.test.fixtures.beans.ITestBean;
import org.springframework.beans.test.fixtures.beans.LifecycleBean;
import org.springframework.beans.test.fixtures.beans.NestedTestBean;
import org.springframework.beans.test.fixtures.beans.SideEffectBean;
import org.springframework.beans.test.fixtures.beans.TestBean;
import org.springframework.beans.test.fixtures.beans.factory.DummyFactory;
import org.springframework.core.MethodParameter;
import org.springframework.core.ResolvableType;
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
@ -91,14 +99,6 @@ import org.springframework.core.test.fixtures.EnabledForTestGroups;
import org.springframework.core.test.fixtures.TestGroup;
import org.springframework.core.test.fixtures.io.SerializationTestUtils;
import org.springframework.lang.Nullable;
import org.springframework.tests.sample.beans.DependenciesBean;
import org.springframework.tests.sample.beans.DerivedTestBean;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.LifecycleBean;
import org.springframework.tests.sample.beans.NestedTestBean;
import org.springframework.tests.sample.beans.SideEffectBean;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.tests.sample.beans.factory.DummyFactory;
import org.springframework.util.StopWatch;
import org.springframework.util.StringValueResolver;

View File

@ -64,15 +64,15 @@ import org.springframework.beans.factory.support.AutowireCandidateQualifier;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.support.GenericBeanDefinition;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.beans.test.fixtures.beans.ITestBean;
import org.springframework.beans.test.fixtures.beans.IndexedTestBean;
import org.springframework.beans.test.fixtures.beans.NestedTestBean;
import org.springframework.beans.test.fixtures.beans.TestBean;
import org.springframework.core.Ordered;
import org.springframework.core.ResolvableType;
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
import org.springframework.core.annotation.Order;
import org.springframework.core.test.fixtures.io.SerializationTestUtils;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.IndexedTestBean;
import org.springframework.tests.sample.beans.NestedTestBean;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.util.ReflectionUtils;
import static org.assertj.core.api.Assertions.assertThat;

View File

@ -40,11 +40,11 @@ import org.springframework.beans.factory.support.AutowireCandidateQualifier;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.support.GenericBeanDefinition;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.beans.test.fixtures.beans.ITestBean;
import org.springframework.beans.test.fixtures.beans.IndexedTestBean;
import org.springframework.beans.test.fixtures.beans.NestedTestBean;
import org.springframework.beans.test.fixtures.beans.TestBean;
import org.springframework.core.test.fixtures.io.SerializationTestUtils;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.IndexedTestBean;
import org.springframework.tests.sample.beans.NestedTestBean;
import org.springframework.tests.sample.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

View File

@ -22,7 +22,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.beans.test.fixtures.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

View File

@ -33,7 +33,7 @@ import org.springframework.beans.PropertyEditorRegistry;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.beans.test.fixtures.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;

View File

@ -22,7 +22,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.beans.test.fixtures.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource;
@ -115,7 +115,7 @@ public class FieldRetrievingFactoryBeanTests {
@Test
public void testWithConstantOnClassWithPackageLevelVisibility() throws Exception {
FieldRetrievingFactoryBean fr = new FieldRetrievingFactoryBean();
fr.setBeanName("org.springframework.tests.sample.beans.PackageLevelVisibleBean.CONSTANT");
fr.setBeanName("org.springframework.beans.test.fixtures.beans.PackageLevelVisibleBean.CONSTANT");
fr.afterPropertiesSet();
assertThat(fr.getObject()).isEqualTo("Wuby");
}

View File

@ -20,9 +20,9 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.beans.test.fixtures.beans.ITestBean;
import org.springframework.beans.test.fixtures.beans.TestBean;
import org.springframework.core.io.Resource;
import org.springframework.tests.sample.beans.ITestBean;
import org.springframework.tests.sample.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource;

View File

@ -24,9 +24,9 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.test.fixtures.beans.TestBean;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.tests.sample.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.beans.factory.support.BeanDefinitionBuilder.genericBeanDefinition;

View File

@ -39,9 +39,9 @@ import org.springframework.beans.factory.support.ManagedList;
import org.springframework.beans.factory.support.ManagedMap;
import org.springframework.beans.factory.support.ManagedSet;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.beans.test.fixtures.beans.IndexedTestBean;
import org.springframework.beans.test.fixtures.beans.TestBean;
import org.springframework.core.io.Resource;
import org.springframework.tests.sample.beans.IndexedTestBean;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.util.StringUtils;
import static org.assertj.core.api.Assertions.assertThat;

View File

@ -25,7 +25,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.ObjectFactory;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.beans.test.fixtures.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource;

View File

@ -24,7 +24,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.beans.test.fixtures.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.core.test.fixtures.io.ResourceTestUtils.qualifiedResource;

View File

@ -21,7 +21,7 @@ import java.util.Arrays;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.beans.test.fixtures.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;

View File

@ -19,7 +19,7 @@ package org.springframework.beans.factory.support;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.config.BeanDefinitionHolder;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.beans.test.fixtures.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;

View File

@ -43,6 +43,10 @@ import org.springframework.beans.factory.ObjectProvider;
import org.springframework.beans.factory.config.TypedStringValue;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.beans.propertyeditors.CustomNumberEditor;
import org.springframework.beans.test.fixtures.beans.GenericBean;
import org.springframework.beans.test.fixtures.beans.GenericIntegerBean;
import org.springframework.beans.test.fixtures.beans.GenericSetOfIntegerBean;
import org.springframework.beans.test.fixtures.beans.TestBean;
import org.springframework.core.OverridingClassLoader;
import org.springframework.core.ResolvableType;
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
@ -50,10 +54,6 @@ import org.springframework.core.annotation.Order;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.UrlResource;
import org.springframework.core.test.fixtures.EnabledForTestGroups;
import org.springframework.tests.sample.beans.GenericBean;
import org.springframework.tests.sample.beans.GenericIntegerBean;
import org.springframework.tests.sample.beans.GenericSetOfIntegerBean;
import org.springframework.tests.sample.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

View File

@ -20,8 +20,8 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.ObjectFactory;
import org.springframework.tests.sample.beans.DerivedTestBean;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.beans.test.fixtures.beans.DerivedTestBean;
import org.springframework.beans.test.fixtures.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;

View File

@ -20,7 +20,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.RuntimeBeanReference;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.beans.test.fixtures.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;

View File

@ -20,8 +20,8 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.beans.test.fixtures.beans.TestBean;
import org.springframework.core.io.ClassPathResource;
import org.springframework.tests.sample.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

View File

@ -18,8 +18,8 @@ package org.springframework.beans.factory.support;
import org.junit.jupiter.api.Test;
import org.springframework.beans.test.fixtures.beans.TestBean;
import org.springframework.core.io.ClassPathResource;
import org.springframework.tests.sample.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;

View File

@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.beans.test.fixtures.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;

View File

@ -22,8 +22,8 @@ import org.springframework.beans.factory.config.PropertiesFactoryBean;
import org.springframework.beans.factory.config.RuntimeBeanReference;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.beans.test.fixtures.beans.TestBean;
import org.springframework.core.io.ClassPathResource;
import org.springframework.tests.sample.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;

View File

@ -27,8 +27,8 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.support.BeanDefinitionReader;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.test.fixtures.beans.TestBean;
import org.springframework.core.io.ClassPathResource;
import org.springframework.tests.sample.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;

View File

@ -22,8 +22,8 @@ import java.util.Map;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.test.fixtures.beans.TestBean;
import org.springframework.core.io.ClassPathResource;
import org.springframework.tests.sample.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;

View File

@ -18,8 +18,8 @@ package org.springframework.beans.factory.xml;
import java.io.Serializable;
import org.springframework.tests.sample.beans.IndexedTestBean;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.beans.test.fixtures.beans.IndexedTestBean;
import org.springframework.beans.test.fixtures.beans.TestBean;
/**
* Simple bean used to check constructor dependency checking.

View File

@ -17,7 +17,7 @@
package org.springframework.beans.factory.xml;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.beans.test.fixtures.beans.TestBean;
/**
* @author Juergen Hoeller

View File

@ -17,8 +17,8 @@
package org.springframework.beans.factory.xml;
import org.springframework.tests.sample.beans.TestBean;
import org.springframework.tests.sample.beans.factory.DummyFactory;
import org.springframework.beans.test.fixtures.beans.TestBean;
import org.springframework.beans.test.fixtures.beans.factory.DummyFactory;
/**
* @author Juergen Hoeller

View File

@ -19,8 +19,8 @@ package org.springframework.beans.factory.xml;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.test.fixtures.beans.TestBean;
import org.springframework.core.io.ClassPathResource;
import org.springframework.tests.sample.beans.TestBean;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

View File

@ -30,8 +30,8 @@ import org.springframework.beans.factory.parsing.ComponentDefinition;
import org.springframework.beans.factory.parsing.ImportDefinition;
import org.springframework.beans.factory.parsing.PassThroughSourceExtractor;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.test.fixtures.beans.CollectingReaderEventListener;
import org.springframework.core.io.ClassPathResource;
import org.springframework.tests.beans.CollectingReaderEventListener;
import static org.assertj.core.api.Assertions.assertThat;

Some files were not shown because too many files have changed in this diff Show More