Skip to content

Commit c9f0e68

Browse files
committed
SPR-5307: Committing test but can't be uncommented until Spring depends on AspectJ 1.6.7
1 parent 0437305 commit c9f0e68

1 file changed

Lines changed: 45 additions & 1 deletion

File tree

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

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
import static org.junit.Assert.*;
1919

2020
import java.io.FileNotFoundException;
21+
import java.lang.annotation.Retention;
22+
import java.lang.annotation.RetentionPolicy;
2123
import java.lang.reflect.Method;
2224
import java.lang.reflect.UndeclaredThrowableException;
2325
import java.rmi.RemoteException;
@@ -406,7 +408,22 @@ public void testIntroductionOnTargetExcludedByTypePattern() {
406408
CannotBeUnlocked.class);
407409
assertFalse("Type pattern must have excluded mixin", proxy instanceof Lockable);
408410
}
409-
411+
/* prereq AspectJ 1.6.7
412+
@Test
413+
public void testIntroductionBasedOnAnnotationMatch_Spr5307() {
414+
AnnotatedTarget target = new AnnotatedTargetImpl();
415+
416+
List<Advisor> advisors = getFixture().getAdvisors(
417+
new SingletonMetadataAwareAspectInstanceFactory(new MakeAnnotatedTypeModifiable(),"someBean"));
418+
Object proxy = createProxy(target,
419+
advisors,
420+
AnnotatedTarget.class);
421+
System.out.println(advisors.get(1));
422+
assertTrue(proxy instanceof Lockable);
423+
Lockable lockable = (Lockable)proxy;
424+
lockable.locked();
425+
}
426+
*/
410427
// TODO: Why does this test fail? It hasn't been run before, so it maybe never actually passed...
411428
public void XtestIntroductionWithArgumentBinding() {
412429
TestBean target = new TestBean();
@@ -966,6 +983,21 @@ class MakeITestBeanModifiable extends AbstractMakeModifiable {
966983

967984
}
968985

986+
/**
987+
* Adds a declare parents pointcut - spr5307
988+
* @author Andy Clement
989+
* @since 3.0
990+
*/
991+
@Aspect
992+
class MakeAnnotatedTypeModifiable extends AbstractMakeModifiable {
993+
994+
@DeclareParents(value = "(@org.springframework.aop.aspectj.annotation.Measured *)",
995+
// @DeclareParents(value = "(@Measured *)", // this would be a nice alternative...
996+
defaultImpl=DefaultLockable.class)
997+
public static Lockable mixin;
998+
999+
}
1000+
9691001

9701002
/**
9711003
* Demonstrates introductions, AspectJ annotation style.
@@ -1024,8 +1056,20 @@ interface Modifiable {
10241056

10251057
}
10261058

1059+
/**
1060+
* Used as a target.
1061+
* @author Andy Clement
1062+
*/
1063+
interface AnnotatedTarget {
1064+
}
10271065

1066+
@Measured
1067+
class AnnotatedTargetImpl implements AnnotatedTarget {
1068+
1069+
}
10281070

1071+
@Retention(RetentionPolicy.RUNTIME)
1072+
@interface Measured {}
10291073

10301074
class NotLockable {
10311075

0 commit comments

Comments
 (0)