|
18 | 18 | import static org.junit.Assert.*; |
19 | 19 |
|
20 | 20 | import java.io.FileNotFoundException; |
| 21 | +import java.lang.annotation.Retention; |
| 22 | +import java.lang.annotation.RetentionPolicy; |
21 | 23 | import java.lang.reflect.Method; |
22 | 24 | import java.lang.reflect.UndeclaredThrowableException; |
23 | 25 | import java.rmi.RemoteException; |
@@ -406,7 +408,22 @@ public void testIntroductionOnTargetExcludedByTypePattern() { |
406 | 408 | CannotBeUnlocked.class); |
407 | 409 | assertFalse("Type pattern must have excluded mixin", proxy instanceof Lockable); |
408 | 410 | } |
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 | + */ |
410 | 427 | // TODO: Why does this test fail? It hasn't been run before, so it maybe never actually passed... |
411 | 428 | public void XtestIntroductionWithArgumentBinding() { |
412 | 429 | TestBean target = new TestBean(); |
@@ -966,6 +983,21 @@ class MakeITestBeanModifiable extends AbstractMakeModifiable { |
966 | 983 |
|
967 | 984 | } |
968 | 985 |
|
| 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 | + |
969 | 1001 |
|
970 | 1002 | /** |
971 | 1003 | * Demonstrates introductions, AspectJ annotation style. |
@@ -1024,8 +1056,20 @@ interface Modifiable { |
1024 | 1056 |
|
1025 | 1057 | } |
1026 | 1058 |
|
| 1059 | +/** |
| 1060 | + * Used as a target. |
| 1061 | + * @author Andy Clement |
| 1062 | + */ |
| 1063 | +interface AnnotatedTarget { |
| 1064 | +} |
1027 | 1065 |
|
| 1066 | +@Measured |
| 1067 | +class AnnotatedTargetImpl implements AnnotatedTarget { |
| 1068 | + |
| 1069 | +} |
1028 | 1070 |
|
| 1071 | +@Retention(RetentionPolicy.RUNTIME) |
| 1072 | +@interface Measured {} |
1029 | 1073 |
|
1030 | 1074 | class NotLockable { |
1031 | 1075 |
|
|
0 commit comments