From 144143c2970a1e874d74cdbd0f8c622d4282a3c3 Mon Sep 17 00:00:00 2001 From: wisberg Date: Mon, 16 Dec 2002 18:51:06 +0000 Subject: initial version --- tests/base/test111/Driver.java | 11 +++++++++++ tests/base/test111/Readme.txt | 6 ++++++ tests/base/test111/SubClass.java | 5 +++++ tests/base/test111/SuperAspect.java | 12 ++++++++++++ tests/base/test111/SuperClass.java | 8 ++++++++ 5 files changed, 42 insertions(+) create mode 100644 tests/base/test111/Driver.java create mode 100644 tests/base/test111/Readme.txt create mode 100644 tests/base/test111/SubClass.java create mode 100644 tests/base/test111/SuperAspect.java create mode 100644 tests/base/test111/SuperClass.java (limited to 'tests/base/test111') diff --git a/tests/base/test111/Driver.java b/tests/base/test111/Driver.java new file mode 100644 index 000000000..00ec6c33c --- /dev/null +++ b/tests/base/test111/Driver.java @@ -0,0 +1,11 @@ +import org.aspectj.testing.Tester; + +public class Driver { + public static void main(String[] args) { test(); } + + public static void test() { + SubClass sub = new SubClass(3); + //System.out.println("Invoking SubClass's getX method"); + Tester.checkEqual(sub.getX(), 3+42, "x value"); + } +} diff --git a/tests/base/test111/Readme.txt b/tests/base/test111/Readme.txt new file mode 100644 index 000000000..3995ae7bf --- /dev/null +++ b/tests/base/test111/Readme.txt @@ -0,0 +1,6 @@ +Mode: VM Run +Title: Inheritance of methods advised by aspects + +A subclass SubClass inherits a super-class SuperClass's method getX +which is affected by the aspect SuperAspect. + diff --git a/tests/base/test111/SubClass.java b/tests/base/test111/SubClass.java new file mode 100644 index 000000000..2aadb8d3f --- /dev/null +++ b/tests/base/test111/SubClass.java @@ -0,0 +1,5 @@ +public class SubClass extends SuperClass { + public SubClass(int _x) { + super(_x); + } +} diff --git a/tests/base/test111/SuperAspect.java b/tests/base/test111/SuperAspect.java new file mode 100644 index 000000000..df97973b8 --- /dev/null +++ b/tests/base/test111/SuperAspect.java @@ -0,0 +1,12 @@ +import org.aspectj.testing.Tester; + +public aspect SuperAspect { + before(SuperClass s): target(s) && call(* getX(..)) { + Tester.checkEqual(thisJoinPoint.getSignature().getName(), "getX", "method name"); + //!!! It's unclear what they value of this really should be + //Tester.checkEqual(thisJoinPoint.className, "SubClass", "class name"); + // make a change to prove this is run + //x = x+42; + s.setX( s.checkX()+42 ); + } +} diff --git a/tests/base/test111/SuperClass.java b/tests/base/test111/SuperClass.java new file mode 100644 index 000000000..3e57e0473 --- /dev/null +++ b/tests/base/test111/SuperClass.java @@ -0,0 +1,8 @@ +public class SuperClass { + int x; + + public SuperClass(int _x) { x = _x; } + public int getX() { return x; } + public int checkX() { return x; } + public void setX( int newX ) { x = newX; } +} -- cgit v1.2.3