From 5dcfe73f9b4e4bd5544aeb43adb9df05fd11885c Mon Sep 17 00:00:00 2001 From: aclement Date: Mon, 1 Dec 2008 19:02:43 +0000 Subject: [PATCH] 154427: test and fix --- tests/bugs163/pr154427/Authorization.java | 4 +++ .../bugs163/pr154427/AuthorizationAdmin.java | 4 +++ tests/bugs163/pr154427/AuthorizationImpl.java | 18 ++++++++++ .../CallAndMethodSignatureAspect.java | 21 +++++++++++ tests/bugs163/pr154427/CallTest.java | 36 +++++++++++++++++++ .../systemtest/ajc163/Ajc163Tests.java | 4 +++ .../org/aspectj/systemtest/ajc163/ajc163.xml | 17 +++++++++ 7 files changed, 104 insertions(+) create mode 100644 tests/bugs163/pr154427/Authorization.java create mode 100644 tests/bugs163/pr154427/AuthorizationAdmin.java create mode 100644 tests/bugs163/pr154427/AuthorizationImpl.java create mode 100644 tests/bugs163/pr154427/CallAndMethodSignatureAspect.java create mode 100644 tests/bugs163/pr154427/CallTest.java diff --git a/tests/bugs163/pr154427/Authorization.java b/tests/bugs163/pr154427/Authorization.java new file mode 100644 index 000000000..76553f938 --- /dev/null +++ b/tests/bugs163/pr154427/Authorization.java @@ -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 index 000000000..a8509f4a0 --- /dev/null +++ b/tests/bugs163/pr154427/AuthorizationAdmin.java @@ -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 index 000000000..010a46e2c --- /dev/null +++ b/tests/bugs163/pr154427/AuthorizationImpl.java @@ -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 index 000000000..2f8e8cf86 --- /dev/null +++ b/tests/bugs163/pr154427/CallAndMethodSignatureAspect.java @@ -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 index 000000000..8c1ea5036 --- /dev/null +++ b/tests/bugs163/pr154427/CallTest.java @@ -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(); + } + +} + diff --git a/tests/src/org/aspectj/systemtest/ajc163/Ajc163Tests.java b/tests/src/org/aspectj/systemtest/ajc163/Ajc163Tests.java index 48b904560..60fe1616f 100644 --- a/tests/src/org/aspectj/systemtest/ajc163/Ajc163Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc163/Ajc163Tests.java @@ -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(); diff --git a/tests/src/org/aspectj/systemtest/ajc163/ajc163.xml b/tests/src/org/aspectj/systemtest/ajc163/ajc163.xml index a35e25473..400923d5a 100644 --- a/tests/src/org/aspectj/systemtest/ajc163/ajc163.xml +++ b/tests/src/org/aspectj/systemtest/ajc163/ajc163.xml @@ -2,6 +2,23 @@ + + + + + + + + + + + + + + + + + -- 2.39.5