Skip to content

Commit 9120f87

Browse files
committed
Consolidate AspectJ test fixtures
1 parent edd1e91 commit 9120f87

34 files changed

+62
-294
lines changed

spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactoryTests.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,17 @@
4040
import org.aspectj.lang.reflect.MethodSignature;
4141
import org.junit.jupiter.api.Disabled;
4242
import org.junit.jupiter.api.Test;
43-
import test.aop.DefaultLockable;
44-
import test.aop.Lockable;
45-
import test.aop.PerTargetAspect;
46-
import test.aop.TwoAdviceAspect;
4743

4844
import org.springframework.aop.Advisor;
4945
import org.springframework.aop.framework.Advised;
5046
import org.springframework.aop.framework.AopConfigException;
5147
import org.springframework.aop.framework.ProxyFactory;
5248
import org.springframework.aop.interceptor.ExposeInvocationInterceptor;
5349
import org.springframework.aop.support.AopUtils;
50+
import org.springframework.aop.testfixture.aspectj.PerTargetAspect;
51+
import org.springframework.aop.testfixture.aspectj.TwoAdviceAspect;
52+
import org.springframework.aop.testfixture.mixin.DefaultLockable;
53+
import org.springframework.aop.testfixture.mixin.Lockable;
5454
import org.springframework.beans.testfixture.beans.ITestBean;
5555
import org.springframework.beans.testfixture.beans.TestBean;
5656
import org.springframework.core.OrderComparator;
@@ -459,10 +459,10 @@ void twoAdvicesOnOneAspect() {
459459
assertThat(advisors).as("Two advice methods found").hasSize(2);
460460
ITestBean itb = createProxy(target, ITestBean.class, advisors);
461461
itb.setName("");
462-
assertThat(itb.getAge()).isEqualTo(0);
462+
assertThat(itb.age()).isEqualTo(0);
463463
int newAge = 32;
464464
itb.setAge(newAge);
465-
assertThat(itb.getAge()).isEqualTo(1);
465+
assertThat(itb.age()).isEqualTo(1);
466466
}
467467

468468
@Test

spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectJPointcutAdvisorTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,13 +17,13 @@
1717
package org.springframework.aop.aspectj.annotation;
1818

1919
import org.junit.jupiter.api.Test;
20-
import test.aop.PerTargetAspect;
2120

2221
import org.springframework.aop.Pointcut;
2322
import org.springframework.aop.aspectj.AspectJExpressionPointcut;
2423
import org.springframework.aop.aspectj.AspectJExpressionPointcutTests;
2524
import org.springframework.aop.aspectj.annotation.AbstractAspectJAdvisorFactoryTests.ExceptionThrowingAspect;
2625
import org.springframework.aop.framework.AopConfigException;
26+
import org.springframework.aop.testfixture.aspectj.PerTargetAspect;
2727
import org.springframework.beans.testfixture.beans.TestBean;
2828

2929
import static org.assertj.core.api.Assertions.assertThat;

spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectMetadataTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,11 +18,11 @@
1818

1919
import org.aspectj.lang.reflect.PerClauseKind;
2020
import org.junit.jupiter.api.Test;
21-
import test.aop.PerTargetAspect;
2221

2322
import org.springframework.aop.Pointcut;
2423
import org.springframework.aop.aspectj.AspectJExpressionPointcut;
2524
import org.springframework.aop.aspectj.annotation.AbstractAspectJAdvisorFactoryTests.ExceptionThrowingAspect;
25+
import org.springframework.aop.testfixture.aspectj.PerTargetAspect;
2626

2727
import static org.assertj.core.api.Assertions.assertThat;
2828
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;

spring-aop/src/test/java/org/springframework/aop/aspectj/annotation/AspectProxyFactoryTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -24,8 +24,8 @@
2424
import org.aspectj.lang.annotation.Around;
2525
import org.aspectj.lang.annotation.Aspect;
2626
import org.junit.jupiter.api.Test;
27-
import test.aop.PerThisAspect;
2827

28+
import org.springframework.aop.testfixture.aspectj.PerThisAspect;
2929
import org.springframework.core.testfixture.io.SerializationTestUtils;
3030

3131
import static org.assertj.core.api.Assertions.assertThat;

spring-aop/src/test/java/test/aop/PerThisAspect.java

Lines changed: 0 additions & 37 deletions
This file was deleted.

spring-aop/src/test/java/test/aop/TwoAdviceAspect.java

Lines changed: 0 additions & 37 deletions
This file was deleted.

spring-context/src/test/java/test/aspect/CommonPointcuts.java renamed to spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/aspectj/CommonPointcuts.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package test.aspect;
17+
package org.springframework.aop.testfixture.aspectj;
1818

1919
import org.aspectj.lang.annotation.Pointcut;
2020

spring-aop/src/test/java/test/aop/PerTargetAspect.java renamed to spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/aspectj/PerTargetAspect.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package test.aop;
17+
package org.springframework.aop.testfixture.aspectj;
1818

1919
import org.aspectj.lang.annotation.Around;
2020
import org.aspectj.lang.annotation.Aspect;

spring-context/src/test/java/test/aspect/PerThisAspect.java renamed to spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/aspectj/PerThisAspect.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
* limitations under the License.
1515
*/
1616

17-
package test.aspect;
17+
package org.springframework.aop.testfixture.aspectj;
1818

1919
import org.aspectj.lang.ProceedingJoinPoint;
2020
import org.aspectj.lang.annotation.Around;
2121
import org.aspectj.lang.annotation.Aspect;
2222

23-
@Aspect("perthis(test.aspect.CommonPointcuts.getAgeExecution())")
23+
@Aspect("perthis(org.springframework.aop.testfixture.aspectj.CommonPointcuts.getAgeExecution())")
2424
public class PerThisAspect {
2525

2626
private int invocations = 0;
@@ -29,7 +29,7 @@ public int getInvocations() {
2929
return this.invocations;
3030
}
3131

32-
@Around("test.aspect.CommonPointcuts.getAgeExecution()")
32+
@Around("org.springframework.aop.testfixture.aspectj.CommonPointcuts.getAgeExecution()")
3333
public int changeAge(ProceedingJoinPoint pjp) {
3434
return this.invocations++;
3535
}

spring-context/src/test/java/test/aspect/TwoAdviceAspect.java renamed to spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/aspectj/TwoAdviceAspect.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package test.aspect;
17+
package org.springframework.aop.testfixture.aspectj;
1818

1919
import org.aspectj.lang.ProceedingJoinPoint;
2020
import org.aspectj.lang.annotation.Around;

spring-aop/src/test/java/test/aop/DefaultLockable.java renamed to spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/mixin/DefaultLockable.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package test.aop;
17+
package org.springframework.aop.testfixture.mixin;
1818

1919
/**
2020
* Simple implementation of Lockable interface for use in mixins.

spring-context/src/test/java/test/mixin/LockMixin.java renamed to spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/mixin/LockMixin.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package test.mixin;
17+
package org.springframework.aop.testfixture.mixin;
1818

1919
import org.aopalliance.intercept.MethodInvocation;
2020

spring-context/src/test/java/test/mixin/LockMixinAdvisor.java renamed to spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/mixin/LockMixinAdvisor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package test.mixin;
17+
package org.springframework.aop.testfixture.mixin;
1818

1919
import org.springframework.aop.support.DefaultIntroductionAdvisor;
2020

spring-aop/src/test/java/test/aop/Lockable.java renamed to spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/mixin/Lockable.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,14 +14,12 @@
1414
* limitations under the License.
1515
*/
1616

17-
package test.aop;
18-
17+
package org.springframework.aop.testfixture.mixin;
1918

2019
/**
21-
* Simple interface to use for mixins
20+
* Simple interface to use for mixins.
2221
*
2322
* @author Rod Johnson
24-
*
2523
*/
2624
public interface Lockable {
2725

spring-context/src/test/java/test/mixin/LockedException.java renamed to spring-aop/src/testFixtures/java/org/springframework/aop/testfixture/mixin/LockedException.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,12 +14,12 @@
1414
* limitations under the License.
1515
*/
1616

17-
package test.mixin;
18-
17+
package org.springframework.aop.testfixture.mixin;
1918

2019
@SuppressWarnings("serial")
2120
public class LockedException extends RuntimeException {
2221

2322
public LockedException() {
2423
}
24+
2525
}

spring-context/src/test/java/org/springframework/aop/aspectj/DeclareParentsTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,9 +19,9 @@
1919
import org.junit.jupiter.api.AfterEach;
2020
import org.junit.jupiter.api.BeforeEach;
2121
import org.junit.jupiter.api.Test;
22-
import test.mixin.Lockable;
2322

2423
import org.springframework.aop.support.AopUtils;
24+
import org.springframework.aop.testfixture.mixin.Lockable;
2525
import org.springframework.beans.testfixture.beans.ITestBean;
2626
import org.springframework.context.support.ClassPathXmlApplicationContext;
2727

spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJAutoProxyCreatorTests.java

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import org.springframework.aop.support.AbstractPointcutAdvisor;
4747
import org.springframework.aop.support.AopUtils;
4848
import org.springframework.aop.support.StaticMethodMatcherPointcutAdvisor;
49+
import org.springframework.aop.testfixture.aspectj.PerTargetAspect;
4950
import org.springframework.beans.PropertyValue;
5051
import org.springframework.beans.factory.FactoryBean;
5152
import org.springframework.beans.factory.config.MethodInvokingFactoryBean;
@@ -62,7 +63,6 @@
6263
import org.springframework.context.support.GenericApplicationContext;
6364
import org.springframework.core.DecoratingProxy;
6465
import org.springframework.core.NestedRuntimeException;
65-
import org.springframework.core.Ordered;
6666
import org.springframework.core.annotation.Order;
6767
import org.springframework.lang.Nullable;
6868

@@ -354,33 +354,6 @@ private String qName(String fileSuffix) {
354354

355355
}
356356

357-
@Aspect("pertarget(execution(* *.getSpouse()))")
358-
class PerTargetAspect implements Ordered {
359-
360-
public int count;
361-
362-
private int order = Ordered.LOWEST_PRECEDENCE;
363-
364-
@Around("execution(int *.getAge())")
365-
public int returnCountAsAge() {
366-
return count++;
367-
}
368-
369-
@Before("execution(void *.set*(int))")
370-
public void countSetter() {
371-
++count;
372-
}
373-
374-
@Override
375-
public int getOrder() {
376-
return this.order;
377-
}
378-
379-
public void setOrder(int order) {
380-
this.order = order;
381-
}
382-
}
383-
384357
@Aspect
385358
class AdviceUsingThisJoinPoint {
386359

0 commit comments

Comments
 (0)