From 9120f87897d2e3ad8f0577199c2e7d3ee0815413 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Wed, 20 Sep 2023 15:53:25 +0200 Subject: [PATCH] Consolidate AspectJ test fixtures --- .../AbstractAspectJAdvisorFactoryTests.java | 12 ++--- .../AspectJPointcutAdvisorTests.java | 4 +- .../annotation/AspectMetadataTests.java | 4 +- .../annotation/AspectProxyFactoryTests.java | 4 +- .../src/test/java/test/aop/PerThisAspect.java | 37 -------------- .../test/java/test/aop/TwoAdviceAspect.java | 37 -------------- .../testfixture/aspectj}/CommonPointcuts.java | 2 +- .../testfixture/aspectj}/PerTargetAspect.java | 4 +- .../testfixture/aspectj}/PerThisAspect.java | 6 +-- .../testfixture/aspectj}/TwoAdviceAspect.java | 4 +- .../testfixture/mixin}/DefaultLockable.java | 4 +- .../aop/testfixture}/mixin/LockMixin.java | 4 +- .../testfixture}/mixin/LockMixinAdvisor.java | 4 +- .../aop/testfixture/mixin}/Lockable.java | 8 ++- .../testfixture}/mixin/LockedException.java | 6 +-- .../aop/aspectj/DeclareParentsTests.java | 4 +- .../AspectJAutoProxyCreatorTests.java | 29 +---------- .../aop/framework/AbstractAopProxyTests.java | 8 +-- .../aop/framework/CglibProxyTests.java | 2 +- .../aop/framework/ProxyFactoryBeanTests.java | 4 +- .../AdvisorAutoProxyCreatorTests.java | 2 +- .../BeanNameAutoProxyCreatorTests.java | 6 +-- .../java/test/aspect/PerTargetAspect.java | 50 ------------------- .../test/java/test/mixin/DefaultLockable.java | 44 ---------------- .../src/test/java/test/mixin/Lockable.java | 33 ------------ .../aop/aspectj/DeclareParentsTests.xml | 12 ++--- ...AspectJAutoProxyCreatorTests-pertarget.xml | 3 +- .../AspectJAutoProxyCreatorTests-perthis.xml | 2 +- ...JAutoProxyCreatorTests-twoAdviceAspect.xml | 2 +- ...yCreatorTests-twoAdviceAspectPrototype.xml | 2 +- ...yCreatorTests-twoAdviceAspectSingleton.xml | 2 +- .../ProxyFactoryBeanTests-context.xml | 6 +-- ...oProxyCreatorTests-common-interceptors.xml | 2 +- .../BeanNameAutoProxyCreatorTests-context.xml | 3 +- 34 files changed, 62 insertions(+), 294 deletions(-) delete mode 100644 spring-aop/src/test/java/test/aop/PerThisAspect.java delete mode 100644 spring-aop/src/test/java/test/aop/TwoAdviceAspect.java rename {spring-context/src/test/java/test/aspect => spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/aspectj}/CommonPointcuts.java (93%) rename spring-aop/src/{test/java/test/aop => testFixtures/java/org/springframework/aop/testfixture/aspectj}/PerTargetAspect.java (91%) rename {spring-context/src/test/java/test/aspect => spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/aspectj}/PerThisAspect.java (79%) rename {spring-context/src/test/java/test/aspect => spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/aspectj}/TwoAdviceAspect.java (91%) rename spring-aop/src/{test/java/test/aop => testFixtures/java/org/springframework/aop/testfixture/mixin}/DefaultLockable.java (89%) rename {spring-context/src/test/java/test => spring-aop/src/testFixtures/java/org/springframework/aop/testfixture}/mixin/LockMixin.java (94%) rename {spring-context/src/test/java/test => spring-aop/src/testFixtures/java/org/springframework/aop/testfixture}/mixin/LockMixinAdvisor.java (89%) rename spring-aop/src/{test/java/test/aop => testFixtures/java/org/springframework/aop/testfixture/mixin}/Lockable.java (82%) rename {spring-context/src/test/java/test => spring-aop/src/testFixtures/java/org/springframework/aop/testfixture}/mixin/LockedException.java (86%) delete mode 100644 spring-context/src/test/java/test/aspect/PerTargetAspect.java delete mode 100644 spring-context/src/test/java/test/mixin/DefaultLockable.java delete mode 100644 spring-context/src/test/java/test/mixin/Lockable.java diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactoryTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactoryTests.java index a4030f8d2ea..978cd049540 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactoryTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactoryTests.java @@ -40,10 +40,6 @@ import org.aspectj.lang.annotation.Pointcut; import org.aspectj.lang.reflect.MethodSignature; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; -import test.aop.DefaultLockable; -import test.aop.Lockable; -import test.aop.PerTargetAspect; -import test.aop.TwoAdviceAspect; import org.springframework.aop.Advisor; import org.springframework.aop.framework.Advised; @@ -51,6 +47,10 @@ 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.aop.testfixture.aspectj.PerTargetAspect; +import org.springframework.aop.testfixture.aspectj.TwoAdviceAspect; +import org.springframework.aop.testfixture.mixin.DefaultLockable; +import org.springframework.aop.testfixture.mixin.Lockable; import org.springframework.beans.testfixture.beans.ITestBean; import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.core.OrderComparator; @@ -459,10 +459,10 @@ abstract class AbstractAspectJAdvisorFactoryTests { assertThat(advisors).as("Two advice methods found").hasSize(2); ITestBean itb = createProxy(target, ITestBean.class, advisors); itb.setName(""); - assertThat(itb.getAge()).isEqualTo(0); + assertThat(itb.age()).isEqualTo(0); int newAge = 32; itb.setAge(newAge); - assertThat(itb.getAge()).isEqualTo(1); + assertThat(itb.age()).isEqualTo(1); } @Test diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectJPointcutAdvisorTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectJPointcutAdvisorTests.java index 806f30587bb..15203879aad 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectJPointcutAdvisorTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectJPointcutAdvisorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,13 +17,13 @@ package org.springframework.aop.aspectj.annotation; import org.junit.jupiter.api.Test; -import test.aop.PerTargetAspect; import org.springframework.aop.Pointcut; import org.springframework.aop.aspectj.AspectJExpressionPointcut; import org.springframework.aop.aspectj.AspectJExpressionPointcutTests; import org.springframework.aop.aspectj.annotation.AbstractAspectJAdvisorFactoryTests.ExceptionThrowingAspect; import org.springframework.aop.framework.AopConfigException; +import org.springframework.aop.testfixture.aspectj.PerTargetAspect; import org.springframework.beans.testfixture.beans.TestBean; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectMetadataTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectMetadataTests.java index 2554895430f..242d72ce993 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectMetadataTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectMetadataTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,11 +18,11 @@ package org.springframework.aop.aspectj.annotation; import org.aspectj.lang.reflect.PerClauseKind; import org.junit.jupiter.api.Test; -import test.aop.PerTargetAspect; import org.springframework.aop.Pointcut; import org.springframework.aop.aspectj.AspectJExpressionPointcut; import org.springframework.aop.aspectj.annotation.AbstractAspectJAdvisorFactoryTests.ExceptionThrowingAspect; +import org.springframework.aop.testfixture.aspectj.PerTargetAspect; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; diff --git a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectProxyFactoryTests.java b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectProxyFactoryTests.java index a00a27bb6de..3fb1b05d81b 100644 --- a/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectProxyFactoryTests.java +++ b/spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectProxyFactoryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,8 +24,8 @@ import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; import org.junit.jupiter.api.Test; -import test.aop.PerThisAspect; +import org.springframework.aop.testfixture.aspectj.PerThisAspect; import org.springframework.core.testfixture.io.SerializationTestUtils; import static org.assertj.core.api.Assertions.assertThat; diff --git a/spring-aop/src/test/java/test/aop/PerThisAspect.java b/spring-aop/src/test/java/test/aop/PerThisAspect.java deleted file mode 100644 index f6b9a3d4a95..00000000000 --- a/spring-aop/src/test/java/test/aop/PerThisAspect.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2002-2005 the original author 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 test.aop; - -import org.aspectj.lang.ProceedingJoinPoint; -import org.aspectj.lang.annotation.Around; -import org.aspectj.lang.annotation.Aspect; - -@Aspect("perthis(execution(* getAge()))") -public class PerThisAspect { - - private int invocations = 0; - - public int getInvocations() { - return this.invocations; - } - - @Around("execution(* getAge())") - public int changeAge(ProceedingJoinPoint pjp) throws Throwable { - return invocations++; - } - -} diff --git a/spring-aop/src/test/java/test/aop/TwoAdviceAspect.java b/spring-aop/src/test/java/test/aop/TwoAdviceAspect.java deleted file mode 100644 index f77ad9a5170..00000000000 --- a/spring-aop/src/test/java/test/aop/TwoAdviceAspect.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2002-2008 the original author 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 test.aop; - -import org.aspectj.lang.ProceedingJoinPoint; -import org.aspectj.lang.annotation.Around; -import org.aspectj.lang.annotation.Aspect; -import org.aspectj.lang.annotation.Before; - -@Aspect -public class TwoAdviceAspect { - private int totalCalls; - - @Around("execution(* getAge())") - public int returnCallCount(ProceedingJoinPoint pjp) throws Exception { - return totalCalls; - } - - @Before("execution(* setAge(int)) && args(newAge)") - public void countSet(int newAge) throws Exception { - ++totalCalls; - } -} diff --git a/spring-context/src/test/java/test/aspect/CommonPointcuts.java b/spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/aspectj/CommonPointcuts.java similarity index 93% rename from spring-context/src/test/java/test/aspect/CommonPointcuts.java rename to spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/aspectj/CommonPointcuts.java index c7dfd107ff5..8421c8a1d2c 100644 --- a/spring-context/src/test/java/test/aspect/CommonPointcuts.java +++ b/spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/aspectj/CommonPointcuts.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package test.aspect; +package org.springframework.aop.testfixture.aspectj; import org.aspectj.lang.annotation.Pointcut; diff --git a/spring-aop/src/test/java/test/aop/PerTargetAspect.java b/spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/aspectj/PerTargetAspect.java similarity index 91% rename from spring-aop/src/test/java/test/aop/PerTargetAspect.java rename to spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/aspectj/PerTargetAspect.java index 4dd5c29dbb1..0f9a34dde09 100644 --- a/spring-aop/src/test/java/test/aop/PerTargetAspect.java +++ b/spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/aspectj/PerTargetAspect.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package test.aop; +package org.springframework.aop.testfixture.aspectj; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; diff --git a/spring-context/src/test/java/test/aspect/PerThisAspect.java b/spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/aspectj/PerThisAspect.java similarity index 79% rename from spring-context/src/test/java/test/aspect/PerThisAspect.java rename to spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/aspectj/PerThisAspect.java index e4e8e02b3d5..fa7b5133e44 100644 --- a/spring-context/src/test/java/test/aspect/PerThisAspect.java +++ b/spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/aspectj/PerThisAspect.java @@ -14,13 +14,13 @@ * limitations under the License. */ -package test.aspect; +package org.springframework.aop.testfixture.aspectj; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; -@Aspect("perthis(test.aspect.CommonPointcuts.getAgeExecution())") +@Aspect("perthis(org.springframework.aop.testfixture.aspectj.CommonPointcuts.getAgeExecution())") public class PerThisAspect { private int invocations = 0; @@ -29,7 +29,7 @@ public class PerThisAspect { return this.invocations; } - @Around("test.aspect.CommonPointcuts.getAgeExecution()") + @Around("org.springframework.aop.testfixture.aspectj.CommonPointcuts.getAgeExecution()") public int changeAge(ProceedingJoinPoint pjp) { return this.invocations++; } diff --git a/spring-context/src/test/java/test/aspect/TwoAdviceAspect.java b/spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/aspectj/TwoAdviceAspect.java similarity index 91% rename from spring-context/src/test/java/test/aspect/TwoAdviceAspect.java rename to spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/aspectj/TwoAdviceAspect.java index 3e544072e4e..449bbdc7146 100644 --- a/spring-context/src/test/java/test/aspect/TwoAdviceAspect.java +++ b/spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/aspectj/TwoAdviceAspect.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package test.aspect; +package org.springframework.aop.testfixture.aspectj; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; diff --git a/spring-aop/src/test/java/test/aop/DefaultLockable.java b/spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/mixin/DefaultLockable.java similarity index 89% rename from spring-aop/src/test/java/test/aop/DefaultLockable.java rename to spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/mixin/DefaultLockable.java index 1e9499df807..b495d2dc884 100644 --- a/spring-aop/src/test/java/test/aop/DefaultLockable.java +++ b/spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/mixin/DefaultLockable.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package test.aop; +package org.springframework.aop.testfixture.mixin; /** * Simple implementation of Lockable interface for use in mixins. diff --git a/spring-context/src/test/java/test/mixin/LockMixin.java b/spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/mixin/LockMixin.java similarity index 94% rename from spring-context/src/test/java/test/mixin/LockMixin.java rename to spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/mixin/LockMixin.java index 12915b678b3..33ffc13f39f 100644 --- a/spring-context/src/test/java/test/mixin/LockMixin.java +++ b/spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/mixin/LockMixin.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package test.mixin; +package org.springframework.aop.testfixture.mixin; import org.aopalliance.intercept.MethodInvocation; diff --git a/spring-context/src/test/java/test/mixin/LockMixinAdvisor.java b/spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/mixin/LockMixinAdvisor.java similarity index 89% rename from spring-context/src/test/java/test/mixin/LockMixinAdvisor.java rename to spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/mixin/LockMixinAdvisor.java index 6ec81a798ce..21a7255c882 100644 --- a/spring-context/src/test/java/test/mixin/LockMixinAdvisor.java +++ b/spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/mixin/LockMixinAdvisor.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package test.mixin; +package org.springframework.aop.testfixture.mixin; import org.springframework.aop.support.DefaultIntroductionAdvisor; diff --git a/spring-aop/src/test/java/test/aop/Lockable.java b/spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/mixin/Lockable.java similarity index 82% rename from spring-aop/src/test/java/test/aop/Lockable.java rename to spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/mixin/Lockable.java index 7e9058d1a06..83d0ea05f0d 100644 --- a/spring-aop/src/test/java/test/aop/Lockable.java +++ b/spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/mixin/Lockable.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,14 +14,12 @@ * limitations under the License. */ -package test.aop; - +package org.springframework.aop.testfixture.mixin; /** - * Simple interface to use for mixins + * Simple interface to use for mixins. * * @author Rod Johnson - * */ public interface Lockable { diff --git a/spring-context/src/test/java/test/mixin/LockedException.java b/spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/mixin/LockedException.java similarity index 86% rename from spring-context/src/test/java/test/mixin/LockedException.java rename to spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/mixin/LockedException.java index 6f8d8537a85..04a8268e8f0 100644 --- a/spring-context/src/test/java/test/mixin/LockedException.java +++ b/spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/mixin/LockedException.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,12 +14,12 @@ * limitations under the License. */ -package test.mixin; - +package org.springframework.aop.testfixture.mixin; @SuppressWarnings("serial") public class LockedException extends RuntimeException { public LockedException() { } + } diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/DeclareParentsTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/DeclareParentsTests.java index de1c9ae8daf..a063eb7fb93 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/DeclareParentsTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/DeclareParentsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,9 +19,9 @@ package org.springframework.aop.aspectj; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import test.mixin.Lockable; import org.springframework.aop.support.AopUtils; +import org.springframework.aop.testfixture.mixin.Lockable; import org.springframework.beans.testfixture.beans.ITestBean; import org.springframework.context.support.ClassPathXmlApplicationContext; diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests.java index e87949928e6..8a7e0b50116 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests.java @@ -46,6 +46,7 @@ import org.springframework.aop.framework.ProxyConfig; import org.springframework.aop.support.AbstractPointcutAdvisor; import org.springframework.aop.support.AopUtils; import org.springframework.aop.support.StaticMethodMatcherPointcutAdvisor; +import org.springframework.aop.testfixture.aspectj.PerTargetAspect; import org.springframework.beans.PropertyValue; import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.config.MethodInvokingFactoryBean; @@ -62,7 +63,6 @@ import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.context.support.GenericApplicationContext; import org.springframework.core.DecoratingProxy; import org.springframework.core.NestedRuntimeException; -import org.springframework.core.Ordered; import org.springframework.core.annotation.Order; import org.springframework.lang.Nullable; @@ -354,33 +354,6 @@ class AspectJAutoProxyCreatorTests { } -@Aspect("pertarget(execution(* *.getSpouse()))") -class PerTargetAspect implements Ordered { - - public int count; - - private int order = Ordered.LOWEST_PRECEDENCE; - - @Around("execution(int *.getAge())") - public int returnCountAsAge() { - return count++; - } - - @Before("execution(void *.set*(int))") - public void countSetter() { - ++count; - } - - @Override - public int getOrder() { - return this.order; - } - - public void setOrder(int order) { - this.order = order; - } -} - @Aspect class AdviceUsingThisJoinPoint { diff --git a/spring-context/src/test/java/org/springframework/aop/framework/AbstractAopProxyTests.java b/spring-context/src/test/java/org/springframework/aop/framework/AbstractAopProxyTests.java index 193d58451ec..9460d8c969c 100644 --- a/spring-context/src/test/java/org/springframework/aop/framework/AbstractAopProxyTests.java +++ b/spring-context/src/test/java/org/springframework/aop/framework/AbstractAopProxyTests.java @@ -34,10 +34,6 @@ import org.aopalliance.intercept.MethodInvocation; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import test.mixin.LockMixin; -import test.mixin.LockMixinAdvisor; -import test.mixin.Lockable; -import test.mixin.LockedException; import org.springframework.aop.Advisor; import org.springframework.aop.AfterReturningAdvice; @@ -64,6 +60,10 @@ import org.springframework.aop.testfixture.advice.MyThrowsHandler; import org.springframework.aop.testfixture.interceptor.NopInterceptor; import org.springframework.aop.testfixture.interceptor.SerializableNopInterceptor; import org.springframework.aop.testfixture.interceptor.TimestampIntroductionInterceptor; +import org.springframework.aop.testfixture.mixin.LockMixin; +import org.springframework.aop.testfixture.mixin.LockMixinAdvisor; +import org.springframework.aop.testfixture.mixin.Lockable; +import org.springframework.aop.testfixture.mixin.LockedException; import org.springframework.beans.testfixture.beans.IOther; import org.springframework.beans.testfixture.beans.ITestBean; import org.springframework.beans.testfixture.beans.Person; diff --git a/spring-context/src/test/java/org/springframework/aop/framework/CglibProxyTests.java b/spring-context/src/test/java/org/springframework/aop/framework/CglibProxyTests.java index 3fddbf2af9f..1c99d3fb0e7 100644 --- a/spring-context/src/test/java/org/springframework/aop/framework/CglibProxyTests.java +++ b/spring-context/src/test/java/org/springframework/aop/framework/CglibProxyTests.java @@ -21,7 +21,6 @@ import java.io.Serializable; import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInvocation; import org.junit.jupiter.api.Test; -import test.mixin.LockMixinAdvisor; import org.springframework.aop.ClassFilter; import org.springframework.aop.MethodMatcher; @@ -31,6 +30,7 @@ import org.springframework.aop.support.DefaultPointcutAdvisor; import org.springframework.aop.support.annotation.AnnotationMatchingPointcut; import org.springframework.aop.testfixture.advice.CountingBeforeAdvice; import org.springframework.aop.testfixture.interceptor.NopInterceptor; +import org.springframework.aop.testfixture.mixin.LockMixinAdvisor; import org.springframework.beans.testfixture.beans.ITestBean; import org.springframework.beans.testfixture.beans.TestBean; import org.springframework.context.ApplicationContext; diff --git a/spring-context/src/test/java/org/springframework/aop/framework/ProxyFactoryBeanTests.java b/spring-context/src/test/java/org/springframework/aop/framework/ProxyFactoryBeanTests.java index 1ec383a4689..9d1c9b89878 100644 --- a/spring-context/src/test/java/org/springframework/aop/framework/ProxyFactoryBeanTests.java +++ b/spring-context/src/test/java/org/springframework/aop/framework/ProxyFactoryBeanTests.java @@ -27,8 +27,6 @@ import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInvocation; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import test.mixin.Lockable; -import test.mixin.LockedException; import org.springframework.aop.ClassFilter; import org.springframework.aop.IntroductionAdvisor; @@ -42,6 +40,8 @@ import org.springframework.aop.testfixture.advice.CountingBeforeAdvice; import org.springframework.aop.testfixture.advice.MyThrowsHandler; import org.springframework.aop.testfixture.interceptor.NopInterceptor; import org.springframework.aop.testfixture.interceptor.TimestampIntroductionInterceptor; +import org.springframework.aop.testfixture.mixin.Lockable; +import org.springframework.aop.testfixture.mixin.LockedException; import org.springframework.beans.factory.BeanCreationException; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.FactoryBean; diff --git a/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests.java b/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests.java index de560cbf8ea..5c3c66ffe8e 100644 --- a/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests.java +++ b/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests.java @@ -19,7 +19,6 @@ package org.springframework.aop.framework.autoproxy; import java.io.IOException; import org.junit.jupiter.api.Test; -import test.mixin.Lockable; import org.springframework.aop.Advisor; import org.springframework.aop.framework.Advised; @@ -32,6 +31,7 @@ import org.springframework.aop.target.PrototypeTargetSource; import org.springframework.aop.target.ThreadLocalTargetSource; import org.springframework.aop.testfixture.advice.CountingBeforeAdvice; import org.springframework.aop.testfixture.interceptor.NopInterceptor; +import org.springframework.aop.testfixture.mixin.Lockable; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.testfixture.beans.CountingTestBean; import org.springframework.beans.testfixture.beans.ITestBean; diff --git a/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorTests.java b/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorTests.java index 153080c0ee1..e316ac4baec 100644 --- a/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorTests.java +++ b/spring-context/src/test/java/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,13 +17,13 @@ package org.springframework.aop.framework.autoproxy; import org.junit.jupiter.api.Test; -import test.mixin.Lockable; -import test.mixin.LockedException; import org.springframework.aop.framework.Advised; import org.springframework.aop.support.AopUtils; import org.springframework.aop.testfixture.advice.CountingBeforeAdvice; import org.springframework.aop.testfixture.interceptor.NopInterceptor; +import org.springframework.aop.testfixture.mixin.Lockable; +import org.springframework.aop.testfixture.mixin.LockedException; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.testfixture.beans.ITestBean; diff --git a/spring-context/src/test/java/test/aspect/PerTargetAspect.java b/spring-context/src/test/java/test/aspect/PerTargetAspect.java deleted file mode 100644 index cb93dc492d8..00000000000 --- a/spring-context/src/test/java/test/aspect/PerTargetAspect.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2002-2018 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package test.aspect; - -import org.aspectj.lang.annotation.Around; -import org.aspectj.lang.annotation.Aspect; -import org.aspectj.lang.annotation.Before; - -import org.springframework.core.Ordered; - -@Aspect("pertarget(execution(* *.getSpouse()))") -public class PerTargetAspect implements Ordered { - - public int count; - - private int order = Ordered.LOWEST_PRECEDENCE; - - @Around("execution(int *.getAge())") - public int returnCountAsAge() { - return count++; - } - - @Before("execution(void *.set*(int))") - public void countSetter() { - ++count; - } - - @Override - public int getOrder() { - return this.order; - } - - public void setOrder(int order) { - this.order = order; - } -} diff --git a/spring-context/src/test/java/test/mixin/DefaultLockable.java b/spring-context/src/test/java/test/mixin/DefaultLockable.java deleted file mode 100644 index 0482eb09616..00000000000 --- a/spring-context/src/test/java/test/mixin/DefaultLockable.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2002-2018 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package test.mixin; - - -/** - * Simple implementation of Lockable interface for use in mixins. - * - * @author Rod Johnson - */ -public class DefaultLockable implements Lockable { - - private boolean locked; - - @Override - public void lock() { - this.locked = true; - } - - @Override - public void unlock() { - this.locked = false; - } - - @Override - public boolean locked() { - return this.locked; - } - -} diff --git a/spring-context/src/test/java/test/mixin/Lockable.java b/spring-context/src/test/java/test/mixin/Lockable.java deleted file mode 100644 index 41abef3bc49..00000000000 --- a/spring-context/src/test/java/test/mixin/Lockable.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2002-2018 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package test.mixin; - - -/** - * Simple interface to use for mixins - * - * @author Rod Johnson - * - */ -public interface Lockable { - - void lock(); - - void unlock(); - - boolean locked(); -} diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/DeclareParentsTests.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/DeclareParentsTests.xml index 96779df3338..5212c81601e 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/DeclareParentsTests.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/DeclareParentsTests.xml @@ -1,16 +1,16 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:aop="http://www.springframework.org/schema/aop" + xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-2.0.xsd + http://www.springframework.org/schema/aop https://www.springframework.org/schema/aop/spring-aop-2.0.xsd"> - + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-perthis.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-perthis.xml index 231038cafc5..836577fcc5a 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-perthis.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-perthis.xml @@ -5,7 +5,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-twoAdviceAspect.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-twoAdviceAspect.xml index c8dcfe9ee96..c3cd370b751 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-twoAdviceAspect.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-twoAdviceAspect.xml @@ -5,7 +5,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-twoAdviceAspectPrototype.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-twoAdviceAspectPrototype.xml index 5bb345353ce..99e1ca8cd26 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-twoAdviceAspectPrototype.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-twoAdviceAspectPrototype.xml @@ -5,7 +5,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-twoAdviceAspectSingleton.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-twoAdviceAspectSingleton.xml index 9202f08e820..23fc9356186 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-twoAdviceAspectSingleton.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests-twoAdviceAspectSingleton.xml @@ -5,7 +5,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-context.xml b/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-context.xml index a8a77341e52..ed794c1e2c5 100644 --- a/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-context.xml +++ b/spring-context/src/test/resources/org/springframework/aop/framework/ProxyFactoryBeanTests-context.xml @@ -135,7 +135,7 @@ --> - + @@ -150,13 +150,13 @@ - + org.springframework.beans.testfixture.beans.ITestBean - test.mixin.Lockable + org.springframework.aop.testfixture.mixin.Lockable false diff --git a/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-common-interceptors.xml b/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-common-interceptors.xml index 7819d2c86db..c526e0c90fe 100644 --- a/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-common-interceptors.xml +++ b/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/AdvisorAutoProxyCreatorTests-common-interceptors.xml @@ -31,7 +31,7 @@ - + diff --git a/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorTests-context.xml b/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorTests-context.xml index 6327f5ecba0..4e148eb3e6c 100644 --- a/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorTests-context.xml +++ b/spring-context/src/test/resources/org/springframework/aop/framework/autoproxy/BeanNameAutoProxyCreatorTests-context.xml @@ -54,8 +54,7 @@ - +