]> source.dussan.org Git - aspectj.git/commitdiff
197719: second testcase
authoraclement <aclement>
Wed, 11 Jun 2008 19:40:32 +0000 (19:40 +0000)
committeraclement <aclement>
Wed, 11 Jun 2008 19:40:32 +0000 (19:40 +0000)
tests/bugs161/pr197719/test/aspects/C1.java [new file with mode: 0644]
tests/bugs161/pr197719/test/aspects/C3.java [new file with mode: 0644]
tests/bugs161/pr197719/test/aspects/MyAnn.java [new file with mode: 0644]
tests/bugs161/pr197719/test/aspects/MyAnnAspect.java [new file with mode: 0644]
tests/bugs161/pr197719/test/aspects2/C2.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc161/Ajc161Tests.java
tests/src/org/aspectj/systemtest/ajc161/ajc161.xml

diff --git a/tests/bugs161/pr197719/test/aspects/C1.java b/tests/bugs161/pr197719/test/aspects/C1.java
new file mode 100644 (file)
index 0000000..a82ab4c
--- /dev/null
@@ -0,0 +1,15 @@
+package test.aspects;
+
+
+public class C1 {
+
+    @MyAnn
+    protected void aMethod() {
+        System.out.println("Calling aMethod");
+    }
+    
+    public void callAMethod() {
+        aMethod(); // Should be a marker here...
+    }
+
+}
diff --git a/tests/bugs161/pr197719/test/aspects/C3.java b/tests/bugs161/pr197719/test/aspects/C3.java
new file mode 100644 (file)
index 0000000..64a5ba0
--- /dev/null
@@ -0,0 +1,42 @@
+package test.aspects;
+
+import test.aspects2.C2;
+
+
+public class C3 {
+
+    public void callAMethodC2() {
+        C1 c1 = new C1();
+        c1.aMethod(); // Should be a marker here...
+        
+        C2 c2 = new C2();
+        c2.aMethod();  // Should be a marker here...
+    }
+    
+    public void innerClassCall() {
+        InnerClass ic = new InnerClass();
+        
+        ic.foo();
+    }
+    protected class InnerClass {
+        public void foo() {
+            C1 c1 = new C1();
+            c1.aMethod();  // Should be a marker here...
+
+            C2 c2 = new C2();
+            c2.aMethod();  // Should be a marker here...
+        }
+    }
+    
+    public static void main(String [] args) {
+        C1 c1 = new C1();
+        
+        c1.aMethod(); // Should be a marker here...
+        c1.callAMethod();
+        
+        C3 c2 = new C3();
+        
+        c2.callAMethodC2();
+        c2.innerClassCall();
+    }
+}
diff --git a/tests/bugs161/pr197719/test/aspects/MyAnn.java b/tests/bugs161/pr197719/test/aspects/MyAnn.java
new file mode 100644 (file)
index 0000000..ccad57d
--- /dev/null
@@ -0,0 +1,13 @@
+package test.aspects;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Inherited
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+public @interface MyAnn {
+}
diff --git a/tests/bugs161/pr197719/test/aspects/MyAnnAspect.java b/tests/bugs161/pr197719/test/aspects/MyAnnAspect.java
new file mode 100644 (file)
index 0000000..83a12e1
--- /dev/null
@@ -0,0 +1,24 @@
+package test.aspects;
+
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Pointcut;
+
+@Aspect
+public class MyAnnAspect {
+       
+       @Pointcut("call(@MyAnn * *(..))")
+       void validatedMethod() {}
+       
+
+    @Around("validatedMethod()")
+    public Object validateMethodImpl(ProceedingJoinPoint thisJoinPoint) throws Throwable {
+               return doInvoke(thisJoinPoint);
+       }
+       
+    private Object doInvoke(final ProceedingJoinPoint thisJoinPoint) throws Throwable {
+        System.out.println("Invoking : " + thisJoinPoint+ "  "+thisJoinPoint.getTarget().getClass().getName());
+        return thisJoinPoint.proceed();
+    }
+}
diff --git a/tests/bugs161/pr197719/test/aspects2/C2.java b/tests/bugs161/pr197719/test/aspects2/C2.java
new file mode 100644 (file)
index 0000000..93361ba
--- /dev/null
@@ -0,0 +1,34 @@
+package test.aspects2;
+
+import test.aspects.C1;
+
+
+public class C2 extends C1 {
+    public void callAMethodC2() {
+        aMethod(); // Should be a marker here...
+    }
+    
+    public void innerClassCall() {
+        InnerClass ic = new InnerClass();
+        
+        ic.foo();
+    }
+    protected class InnerClass {
+        public void foo() {
+            aMethod(); // Should be a marker here...
+        }
+    }
+    
+    public static void main(String [] args) {
+        C1 c1 = new C1();
+        
+        c1.callAMethod();
+        
+        C2 c2 = new C2();
+        
+        c2.aMethod(); // Should be a marker here...
+        c2.callAMethod();
+        c2.callAMethodC2();
+        c2.innerClassCall();
+    }
+}
index ed8cd9f32093d060a18b4917e58b99280b1f2674..04551984b977edaa0eaf12a4d734aaa711e024a0 100644 (file)
@@ -23,6 +23,7 @@ import org.aspectj.testing.XMLBasedAjcTestCase;
 public class Ajc161Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
        
        // AspectJ1.6.1
+       public void testProtectedMethodsAroundAdvice_pr197719_2() { runTest("protected methods and around advice - again - 2");}
        public void testProtectedMethodsAroundAdvice_pr197719() { runTest("protected methods and around advice - again");}
        public void testProtectedMethodsAroundAdvice_pr230075() { runTest("protected methods and around advice");}
        public void testFinalStringsAnnotationPointcut_pr174385() { runTest("static strings in annotation pointcuts");}
index 0265aa7d7c1a1edf354e645a48c6ac8b6922b83c..59838531e3a67548e2bdb2640c4be7ee1beb5619 100644 (file)
@@ -3,6 +3,27 @@
 <!-- AspectJ v1.6.1 Tests -->
 <suite>
 
+       <ajc-test dir="bugs161/pr197719" title="protected methods and around advice - again - 2">
+       <compile files="test/aspects/C1.java test/aspects/C3.java test/aspects/MyAnn.java test/aspects/MyAnnAspect.java test/aspects2/C2.java" options="-1.5 -showWeaveInfo">
+         <message kind="weave" text="Join point 'method-call(void test.aspects.C1.aMethod())' in Type 'test.aspects.C1' (C1.java:12) "/>
+         
+         <!-- first of these through accessor - so line number wrong and target wrong -->
+         <message kind="weave" text="Join point 'method-call(void test.aspects.C1.aMethod())' in Type 'test.aspects2.C2' (C2.java:1) "/><!-- was line 18 -->
+         <message kind="weave" text="Join point 'method-call(void test.aspects2.C2.aMethod())' in Type 'test.aspects2.C2' (C2.java:8) "/>
+         <message kind="weave" text="Join point 'method-call(void test.aspects2.C2.aMethod())' in Type 'test.aspects2.C2' (C2.java:29) "/>
+
+         <message kind="weave" text="Join point 'method-call(void test.aspects.C1.aMethod())' in Type 'test.aspects.C3' (C3.java:10) "/>
+         <message kind="weave" text="Join point 'method-call(void test.aspects2.C2.aMethod())' in Type 'test.aspects.C3' (C3.java:13) "/>
+         <message kind="weave" text="Join point 'method-call(void test.aspects.C1.aMethod())' in Type 'test.aspects.C3$InnerClass' (C3.java:24) "/>
+         <message kind="weave" text="Join point 'method-call(void test.aspects2.C2.aMethod())' in Type 'test.aspects.C3$InnerClass' (C3.java:27) "/>
+         <message kind="weave" text="Join point 'method-call(void test.aspects.C1.aMethod())' in Type 'test.aspects.C3' (C3.java:34) "/>
+
+       </compile>
+
+       <run class="test.aspects.C3">
+       </run>
+    </ajc-test>
+    
        <ajc-test dir="bugs161/pr197719" title="protected methods and around advice - again">
        <compile files="A.java B.java X.java" options="-1.5"/>
        <run class="b.B">