]> source.dussan.org Git - aspectj.git/commitdiff
154427: test and fix
authoraclement <aclement>
Mon, 1 Dec 2008 19:02:43 +0000 (19:02 +0000)
committeraclement <aclement>
Mon, 1 Dec 2008 19:02:43 +0000 (19:02 +0000)
tests/bugs163/pr154427/Authorization.java [new file with mode: 0644]
tests/bugs163/pr154427/AuthorizationAdmin.java [new file with mode: 0644]
tests/bugs163/pr154427/AuthorizationImpl.java [new file with mode: 0644]
tests/bugs163/pr154427/CallAndMethodSignatureAspect.java [new file with mode: 0644]
tests/bugs163/pr154427/CallTest.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc163/Ajc163Tests.java
tests/src/org/aspectj/systemtest/ajc163/ajc163.xml

diff --git a/tests/bugs163/pr154427/Authorization.java b/tests/bugs163/pr154427/Authorization.java
new file mode 100644 (file)
index 0000000..76553f9
--- /dev/null
@@ -0,0 +1,4 @@
+public interface Authorization {
+  boolean mayPerform(String user, String action);
+}
+
diff --git a/tests/bugs163/pr154427/AuthorizationAdmin.java b/tests/bugs163/pr154427/AuthorizationAdmin.java
new file mode 100644 (file)
index 0000000..a8509f4
--- /dev/null
@@ -0,0 +1,4 @@
+public interface AuthorizationAdmin extends Authorization {
+      boolean mayPerform2(String user, String action);
+}
+
diff --git a/tests/bugs163/pr154427/AuthorizationImpl.java b/tests/bugs163/pr154427/AuthorizationImpl.java
new file mode 100644 (file)
index 0000000..010a46e
--- /dev/null
@@ -0,0 +1,18 @@
+public class AuthorizationImpl implements AuthorizationAdmin {
+
+      /* ========== interface Authorization ============*/
+
+      public boolean mayPerform(String user, String action) {
+            System.out.println("mayPerform() executing");
+            return true;
+      }
+
+      /* ========== interface AuthorizationAdmin  ============*/
+
+      public boolean mayPerform2(String user, String action) {
+            System.out.println("mayPerform2() executing");
+            return true;
+      }
+
+}
+
diff --git a/tests/bugs163/pr154427/CallAndMethodSignatureAspect.java b/tests/bugs163/pr154427/CallAndMethodSignatureAspect.java
new file mode 100644 (file)
index 0000000..2f8e8cf
--- /dev/null
@@ -0,0 +1,21 @@
+import org.aspectj.lang.reflect.*;
+import java.lang.reflect.*;
+
+public aspect CallAndMethodSignatureAspect {
+
+      pointcut callAnyPublicMethodInAuthorization() : call(public * Authorization+.*(..) );
+
+      Object around() : callAnyPublicMethodInAuthorization() {
+
+            MethodSignature methodSignature = (MethodSignature) thisJoinPoint.getSignature();
+
+            // returns NULL when calling a method defined in the top interface "Authorization"
+            Method method = methodSignature.getMethod();
+
+            System.out.println(method);
+            System.out.println(methodSignature.toLongString());
+
+            return proceed();
+      }
+}
+
diff --git a/tests/bugs163/pr154427/CallTest.java b/tests/bugs163/pr154427/CallTest.java
new file mode 100644 (file)
index 0000000..8c1ea50
--- /dev/null
@@ -0,0 +1,36 @@
+public class CallTest {
+
+
+ public static void main(String[]argv) {
+   new CallTest().testMayPerform();
+   new CallTest().testMayPerform2();
+   new CallTest().testMayPerform3();
+ }
+
+      private AuthorizationAdmin admin;
+      private Authorization auth;
+
+      public void testMayPerform() {
+        admin = new AuthorizationImpl();
+        boolean bool = admin.mayPerform("peter", "query");
+        if (!bool) throw new RuntimeException();
+      }
+
+      public void testMayPerform2() {
+            admin = new AuthorizationImpl();
+
+            boolean bool = admin.mayPerform2("peter2", "query2");
+   if (!bool) throw new RuntimeException();
+
+      }
+
+        public void testMayPerform3() {
+                auth = new AuthorizationImpl();
+
+                boolean bool = auth.mayPerform("peter2", "query2");
+
+   if (!bool) throw new RuntimeException();
+        }
+
+}
+
index 48b904560e9e71130227d08c571e244d820f9b6a..60fe1616ffb302258cb7bf45faf2a0a6b88fdb7e 100644 (file)
@@ -28,6 +28,10 @@ import org.aspectj.testing.XMLBasedAjcTestCase;
 
 public class Ajc163Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
 
+       public void testGetMethodNull_pr154427() {
+               runTest("getMethod returning null");
+       }
+
        public void testFQType_pr256937() {
                runTest("fully qualified return type");
                IHierarchy top = AsmManager.lastActiveStructureModel.getHierarchy();
index a35e25473747fb0d8dd5d3cba02e66d6c458aa73..400923d5a18ec009a7c7d3e964a27c5a09fe2f8d 100644 (file)
@@ -2,6 +2,23 @@
 
 <suite>
 
+    <ajc-test dir="bugs163/pr154427" title="getMethod returning null">
+         <compile files="AuthorizationImpl.java Authorization.java AuthorizationAdmin.java CallAndMethodSignatureAspect.java CallTest.java" options=""/>
+         <run class="CallTest">
+           <stdout>
+             <line text="public abstract boolean Authorization.mayPerform(java.lang.String,java.lang.String)"/>
+             <line text="public abstract interface boolean AuthorizationAdmin.mayPerform(java.lang.String, java.lang.String)"/>
+             <line text="mayPerform() executing"/>
+             <line text="public abstract boolean AuthorizationAdmin.mayPerform2(java.lang.String,java.lang.String)"/>
+             <line text="public abstract interface boolean AuthorizationAdmin.mayPerform2(java.lang.String, java.lang.String)"/>
+             <line text="mayPerform2() executing"/>
+             <line text="public abstract boolean Authorization.mayPerform(java.lang.String,java.lang.String)"/>
+             <line text="public abstract interface boolean Authorization.mayPerform(java.lang.String, java.lang.String)"/>
+             <line text="mayPerform() executing"/>
+           </stdout>
+         </run>
+    </ajc-test>
+    
     <ajc-test dir="bugs163/pr256937" title="fully qualified return type">
          <compile files="Ship.java ShipAccessor.java" options="-emacssym -1.5"/>
     </ajc-test>