1
1
/*
2
- * Copyright 2002-2023 the original author or authors.
2
+ * Copyright 2002-2024 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
38
38
import org .aspectj .lang .annotation .DeclarePrecedence ;
39
39
import org .aspectj .lang .annotation .Pointcut ;
40
40
import org .aspectj .lang .reflect .MethodSignature ;
41
- import org .junit .jupiter .api .Disabled ;
42
41
import org .junit .jupiter .api .Test ;
43
42
44
43
import org .springframework .aop .Advisor ;
@@ -84,15 +83,15 @@ abstract class AbstractAspectJAdvisorFactoryTests {
84
83
@ Test
85
84
void rejectsPerCflowAspect () {
86
85
assertThatExceptionOfType (AopConfigException .class )
87
- .isThrownBy (() -> getAdvisorFactory ().getAdvisors (aspectInstanceFactory (new PerCflowAspect (), "someBean" )))
88
- .withMessageContaining ("PERCFLOW" );
86
+ .isThrownBy (() -> getAdvisorFactory ().getAdvisors (aspectInstanceFactory (new PerCflowAspect (), "someBean" )))
87
+ .withMessageContaining ("PERCFLOW" );
89
88
}
90
89
91
90
@ Test
92
91
void rejectsPerCflowBelowAspect () {
93
92
assertThatExceptionOfType (AopConfigException .class )
94
- .isThrownBy (() -> getAdvisorFactory ().getAdvisors (aspectInstanceFactory (new PerCflowBelowAspect (), "someBean" )))
95
- .withMessageContaining ("PERCFLOWBELOW" );
93
+ .isThrownBy (() -> getAdvisorFactory ().getAdvisors (aspectInstanceFactory (new PerCflowBelowAspect (), "someBean" )))
94
+ .withMessageContaining ("PERCFLOWBELOW" );
96
95
}
97
96
98
97
@ Test
@@ -363,7 +362,7 @@ void introductionOnTargetImplementingInterface() {
363
362
assertThat (lockable .locked ()).as ("Already locked" ).isTrue ();
364
363
lockable .lock ();
365
364
assertThat (lockable .locked ()).as ("Real target ignores locking" ).isTrue ();
366
- assertThatExceptionOfType (UnsupportedOperationException .class ).isThrownBy (() -> lockable . unlock () );
365
+ assertThatExceptionOfType (UnsupportedOperationException .class ).isThrownBy (lockable :: unlock );
367
366
}
368
367
369
368
@ Test
@@ -389,9 +388,7 @@ void introductionBasedOnAnnotationMatch() { // gh-9980
389
388
assertThat (lockable .locked ()).isTrue ();
390
389
}
391
390
392
- // TODO: Why does this test fail? It hasn't been run before, so it maybe never actually passed...
393
391
@ Test
394
- @ Disabled
395
392
void introductionWithArgumentBinding () {
396
393
TestBean target = new TestBean ();
397
394
@@ -648,7 +645,7 @@ void getAge() {
648
645
static class NamedPointcutAspectWithFQN {
649
646
650
647
@ SuppressWarnings ("unused" )
651
- private ITestBean fieldThatShouldBeIgnoredBySpringAtAspectJProcessing = new TestBean ();
648
+ private final ITestBean fieldThatShouldBeIgnoredBySpringAtAspectJProcessing = new TestBean ();
652
649
653
650
@ Around ("org.springframework.aop.aspectj.annotation.AbstractAspectJAdvisorFactoryTests.CommonPointcuts.getAge()()" )
654
651
int changeReturnValue (ProceedingJoinPoint pjp ) {
@@ -765,16 +762,22 @@ Object echo(Object obj) throws Exception {
765
762
766
763
767
764
@ Aspect
768
- class DoublingAspect {
765
+ static class DoublingAspect {
769
766
770
767
@ Around ("execution(* getAge())" )
771
768
public Object doubleAge (ProceedingJoinPoint pjp ) throws Throwable {
772
769
return ((int ) pjp .proceed ()) * 2 ;
773
770
}
774
771
}
775
772
773
+
776
774
@ Aspect
777
- class IncrementingAspect extends DoublingAspect {
775
+ static class IncrementingAspect extends DoublingAspect {
776
+
777
+ @ Override
778
+ public Object doubleAge (ProceedingJoinPoint pjp ) throws Throwable {
779
+ return ((int ) pjp .proceed ()) * 2 ;
780
+ }
778
781
779
782
@ Around ("execution(* getAge())" )
780
783
public int incrementAge (ProceedingJoinPoint pjp ) throws Throwable {
@@ -783,7 +786,6 @@ public int incrementAge(ProceedingJoinPoint pjp) throws Throwable {
783
786
}
784
787
785
788
786
-
787
789
@ Aspect
788
790
private static class InvocationTrackingAspect {
789
791
@@ -1083,7 +1085,7 @@ class PerThisAspect {
1083
1085
1084
1086
// Just to check that this doesn't cause problems with introduction processing
1085
1087
@ SuppressWarnings ("unused" )
1086
- private ITestBean fieldThatShouldBeIgnoredBySpringAtAspectJProcessing = new TestBean ();
1088
+ private final ITestBean fieldThatShouldBeIgnoredBySpringAtAspectJProcessing = new TestBean ();
1087
1089
1088
1090
@ Around ("execution(int *.getAge())" )
1089
1091
int returnCountAsAge () {
0 commit comments