aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraclement <aclement>2005-02-01 08:03:33 +0000
committeraclement <aclement>2005-02-01 08:03:33 +0000
commitfd3b7dc5342d95ce675aea787e16222b4413e9c1 (patch)
tree8a2b87e005d210479a91a3125196ebc1ae1d9be7
parent94251be73e24166f25ee2d8ca477879fea53dfa2 (diff)
downloadaspectj-fd3b7dc5342d95ce675aea787e16222b4413e9c1.tar.gz
aspectj-fd3b7dc5342d95ce675aea787e16222b4413e9c1.zip
Annotation Binding - more test data.
-rw-r--r--tests/java5/annotations/binding/AdviceExecBinding.aj43
-rw-r--r--tests/java5/annotations/binding/CtorAnnBinding1.aj41
-rw-r--r--tests/java5/annotations/binding/CtorAnnBinding2.aj41
-rw-r--r--tests/java5/annotations/binding/FieldAnnBinding1.aj39
-rw-r--r--tests/java5/annotations/binding/FieldAnnBinding2.aj43
-rw-r--r--tests/java5/annotations/binding/FieldAnnBinding3.aj39
-rw-r--r--tests/java5/annotations/binding/HandlerBinding.aj40
-rw-r--r--tests/java5/annotations/binding/InitBinding.aj42
-rw-r--r--tests/java5/annotations/binding/PreInitBinding.aj43
-rw-r--r--tests/java5/annotations/binding/StaticInitBinding.aj37
10 files changed, 408 insertions, 0 deletions
diff --git a/tests/java5/annotations/binding/AdviceExecBinding.aj b/tests/java5/annotations/binding/AdviceExecBinding.aj
new file mode 100644
index 000000000..6771928ef
--- /dev/null
+++ b/tests/java5/annotations/binding/AdviceExecBinding.aj
@@ -0,0 +1,43 @@
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface Colored { String color(); }
+
+public class AdviceExecBinding {
+ public static void main(String[]argv) {
+ m1();
+ m2();
+ m3();
+ X.verifyRun();
+ }
+
+ static void m1() {}
+ static void m2() {}
+ static void m3() {}
+}
+
+aspect B {
+ @Colored(color="orange") before(): execution(* m1()) {}
+ @Colored(color="yellow") before(): execution(* m2()) {}
+ @Colored(color="brown") before(): execution(* m3()) {}
+}
+
+aspect X {
+
+ // Expected color order
+ static String exp[] = new String[]{"orange","yellow","brown"};
+
+ static int i = 0; // Count of advice executions
+
+ before(Colored c): adviceexecution() && within(B) && @annotation(c) {
+ System.err.println(thisJoinPoint+" color="+c.color());
+ if (!c.color().equals(exp[i])) throw new RuntimeException("not "+exp[i]+"? "+c.color());
+ i++;
+ }
+
+ public static void verifyRun() {
+ if (X.i != exp.length)
+ throw new RuntimeException("Expected "+exp.length+" advice runs but did "+X.i);
+ }
+}
+
diff --git a/tests/java5/annotations/binding/CtorAnnBinding1.aj b/tests/java5/annotations/binding/CtorAnnBinding1.aj
new file mode 100644
index 000000000..613af3b21
--- /dev/null
+++ b/tests/java5/annotations/binding/CtorAnnBinding1.aj
@@ -0,0 +1,41 @@
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface Colored { String color(); }
+
+public class CtorAnnBinding1 {
+ public static void main(String[]argv) {
+ new C();
+ new C("hello");
+ new C(new int[]{1,2,3});
+ X.verifyRun();
+ }
+
+ static class C {
+
+ @Colored(color="red") public C() {System.err.println("<init>() running");}
+ @Colored(color="green") public C(String s) {System.err.println("<init>("+s+") running");}
+ @Colored(color="blue") public C(int[] is) {System.err.println("<init>(int[]) running");}
+ public C(boolean b) {System.err.println("<init>("+b+") running");}
+ }
+
+}
+
+aspect X {
+
+ // Expected color order
+ static String exp[] = new String[]{"red","green","blue"};
+
+ static int i = 0; // Count of advice executions
+
+ before(Colored c): call(new(..)) && withincode(* main(..)) && @annotation(c) {
+ System.err.println(thisJoinPoint+" color="+c.color());
+ if (!c.color().equals(exp[i])) throw new RuntimeException("not "+exp[i]+"? "+c.color());
+ i++;
+ }
+
+ public static void verifyRun() {
+ if (X.i != exp.length)
+ throw new RuntimeException("Expected "+exp.length+" advice runs but did "+X.i);
+ }
+} \ No newline at end of file
diff --git a/tests/java5/annotations/binding/CtorAnnBinding2.aj b/tests/java5/annotations/binding/CtorAnnBinding2.aj
new file mode 100644
index 000000000..f67e87458
--- /dev/null
+++ b/tests/java5/annotations/binding/CtorAnnBinding2.aj
@@ -0,0 +1,41 @@
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface Colored { String color(); }
+
+public class CtorAnnBinding2 {
+ public static void main(String[]argv) {
+ new C();
+ new C("hello");
+ new C(new int[]{1,2,3});
+ X.verifyRun();
+ }
+
+ static class C {
+
+ @Colored(color="red") public C() {System.err.println("<init>() running");}
+ @Colored(color="green") public C(String s) {System.err.println("<init>("+s+") running");}
+ @Colored(color="blue") public C(int[] is) {System.err.println("<init>(int[]) running");}
+ public C(boolean b) {System.err.println("<init>("+b+") running");}
+ }
+
+}
+
+aspect X {
+
+ // Expected color order
+ static String exp[] = new String[]{"red","green","blue"};
+
+ static int i = 0; // Count of advice executions
+
+ before(Colored c): execution(new(..)) && within(CtorAnnBinding2) && @annotation(c) {
+ System.err.println(thisJoinPoint+" color="+c.color());
+ if (!c.color().equals(exp[i])) throw new RuntimeException("not "+exp[i]+"? "+c.color());
+ i++;
+ }
+
+ public static void verifyRun() {
+ if (X.i != exp.length)
+ throw new RuntimeException("Expected "+exp.length+" advice runs but did "+X.i);
+ }
+} \ No newline at end of file
diff --git a/tests/java5/annotations/binding/FieldAnnBinding1.aj b/tests/java5/annotations/binding/FieldAnnBinding1.aj
new file mode 100644
index 000000000..68f8c3313
--- /dev/null
+++ b/tests/java5/annotations/binding/FieldAnnBinding1.aj
@@ -0,0 +1,39 @@
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface Colored { String color();}
+
+public class FieldAnnBinding1 {
+
+ @Colored(color="red") static int i;
+
+ @Colored(color="blue") String s;
+
+ @Colored(color="green") boolean b;
+
+ public static void main(String[]argv) {
+ i = 5;
+ new FieldAnnBinding1().s = "abc";
+ new FieldAnnBinding1().b = true;
+ X.verifyRun();
+ }
+}
+
+aspect X {
+
+ // Expected color order
+ static String exp[] = new String[]{"red","blue","green"};
+
+ static int i = 0; // Count of advice executions
+
+ before(Colored c): set(* *) && withincode(* main(..)) && @annotation(c) {
+ System.err.println(thisJoinPoint+" color="+c.color());
+ if (!c.color().equals(exp[i])) throw new RuntimeException("not "+exp[i]+"? "+c.color());
+ i++;
+ }
+
+ public static void verifyRun() {
+ if (X.i != exp.length)
+ throw new RuntimeException("Expected "+exp.length+" advice runs but did "+X.i);
+ }
+}
diff --git a/tests/java5/annotations/binding/FieldAnnBinding2.aj b/tests/java5/annotations/binding/FieldAnnBinding2.aj
new file mode 100644
index 000000000..5c52594ca
--- /dev/null
+++ b/tests/java5/annotations/binding/FieldAnnBinding2.aj
@@ -0,0 +1,43 @@
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface Colored { String color();}
+
+public class FieldAnnBinding2 {
+
+ @Colored(color="red") static int i;
+
+ @Colored(color="blue") String s;
+
+ @Colored(color="green") boolean b;
+
+ public static void main(String[]argv) {
+ FieldAnnBinding2 fab = new FieldAnnBinding2();
+ i = 5;
+ fab.s = "abc";
+ fab.b = true;
+
+ System.err.println("i="+fab.i);
+ System.err.println("s="+fab.s);
+ System.err.println("b="+fab.b);
+ X.verifyRun();
+ }
+}
+aspect X {
+
+ // Expected color order
+ static String exp[] = new String[]{"red","blue","green"};
+
+ static int i = 0; // Count of advice executions
+
+ before(Colored c): get(* *) && withincode(* main(..)) && @annotation(c) {
+ System.err.println(thisJoinPoint+" color="+c.color());
+ if (!c.color().equals(exp[i])) throw new RuntimeException("not "+exp[i]+"? "+c.color());
+ i++;
+ }
+
+ public static void verifyRun() {
+ if (X.i != exp.length)
+ throw new RuntimeException("Expected "+exp.length+" advice runs but did "+X.i);
+ }
+}
diff --git a/tests/java5/annotations/binding/FieldAnnBinding3.aj b/tests/java5/annotations/binding/FieldAnnBinding3.aj
new file mode 100644
index 000000000..a6ccb683c
--- /dev/null
+++ b/tests/java5/annotations/binding/FieldAnnBinding3.aj
@@ -0,0 +1,39 @@
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface Colored { String color();}
+
+public class FieldAnnBinding3 {
+
+ @Colored(color="red") String s[];
+
+ @Colored(color="blue") boolean b[];
+
+ public static void main(String[]argv) {
+ FieldAnnBinding3 fab = new FieldAnnBinding3();
+ fab.s = new String[]{"abc","def"};
+ fab.b = new boolean[]{true,false,true};
+
+ System.err.println("s="+fab.s);
+ System.err.println("b="+fab.b);
+ X.verifyRun();
+ }
+}
+aspect X {
+
+ // Expected color order
+ static String exp[] = new String[]{"red","blue"};
+
+ static int i = 0; // Count of advice executions
+
+ before(Colored c): get(* *) && withincode(* main(..)) && @annotation(c) {
+ System.err.println(thisJoinPoint+" color="+c.color());
+ if (!c.color().equals(exp[i])) throw new RuntimeException("not "+exp[i]+"? "+c.color());
+ i++;
+ }
+
+ public static void verifyRun() {
+ if (X.i != exp.length)
+ throw new RuntimeException("Expected "+exp.length+" advice runs but did "+X.i);
+ }
+} \ No newline at end of file
diff --git a/tests/java5/annotations/binding/HandlerBinding.aj b/tests/java5/annotations/binding/HandlerBinding.aj
new file mode 100644
index 000000000..fc2d0d3c4
--- /dev/null
+++ b/tests/java5/annotations/binding/HandlerBinding.aj
@@ -0,0 +1,40 @@
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface Colored { String color(); }
+
+public class HandlerBinding {
+ public static void main(String[]argv) {
+ try {
+ throw new AndyException();
+ } catch (AndyException ae) {
+ System.err.println(ae);
+ }
+ X.verifyRun();
+ }
+
+ @Colored(color="red") static class AndyException extends Exception {
+ public AndyException() {
+ }
+ }
+
+}
+
+aspect X {
+
+ // Expected color order
+ static String exp[] = new String[]{"red"};
+
+ static int i = 0; // Count of advice executions
+
+ before(Colored c): handler(*) && !within(X) && @annotation(c) {
+ System.err.println(thisJoinPoint+" color="+c.color());
+ if (!c.color().equals(exp[i])) throw new RuntimeException("not "+exp[i]+"? "+c.color());
+ i++;
+ }
+
+ public static void verifyRun() {
+ if (X.i != exp.length)
+ throw new RuntimeException("Expected "+exp.length+" advice runs but did "+X.i);
+ }
+ }
diff --git a/tests/java5/annotations/binding/InitBinding.aj b/tests/java5/annotations/binding/InitBinding.aj
new file mode 100644
index 000000000..87e8caca4
--- /dev/null
+++ b/tests/java5/annotations/binding/InitBinding.aj
@@ -0,0 +1,42 @@
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface Colored { String color(); }
+
+public class InitBinding {
+ public static void main(String[]argv) {
+ new A();
+ new B();
+ new C();
+ X.verifyRun();
+ }
+}
+
+class A {
+@Colored(color="orange") public A() {}
+}
+class B {
+@Colored(color="yellow") public B() {}
+}
+class C {
+@Colored(color="brown") public C() {}
+}
+
+aspect X {
+
+ // Expected color order
+ static String exp[] = new String[]{"orange","yellow","brown"};
+
+ static int i = 0; // Count of advice executions
+
+ before(Colored c): preinitialization(new(..)) && !within(X) && @annotation(c) {
+ System.err.println(thisJoinPoint+" color="+c.color());
+ if (!c.color().equals(exp[i])) throw new RuntimeException("not "+exp[i]+"? "+c.color());
+ i++;
+ }
+
+ public static void verifyRun() {
+ if (X.i != exp.length)
+ throw new RuntimeException("Expected "+exp.length+" advice runs but did "+X.i);
+ }
+ }
diff --git a/tests/java5/annotations/binding/PreInitBinding.aj b/tests/java5/annotations/binding/PreInitBinding.aj
new file mode 100644
index 000000000..92c6d1aea
--- /dev/null
+++ b/tests/java5/annotations/binding/PreInitBinding.aj
@@ -0,0 +1,43 @@
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface Colored { String color(); }
+
+public class PreInitBinding {
+ public static void main(String[]argv) {
+ new A();
+ new B();
+ new C();
+ X.verifyRun();
+ }
+}
+
+class A {
+@Colored(color="orange") public A() {}
+}
+class B {
+@Colored(color="yellow") public B() {}
+}
+class C {
+@Colored(color="brown") public C() {}
+}
+
+
+aspect X {
+
+ // Expected color order
+ static String exp[] = new String[]{"orange","yellow","brown"};
+
+ static int i = 0; // Count of advice executions
+
+ before(Colored c): preinitialization(new(..)) && !within(X) && @annotation(c) {
+ System.err.println(thisJoinPoint+" color="+c.color());
+ if (!c.color().equals(exp[i])) throw new RuntimeException("not "+exp[i]+"? "+c.color());
+ i++;
+ }
+
+ public static void verifyRun() {
+ if (X.i != exp.length)
+ throw new RuntimeException("Expected "+exp.length+" advice runs but did "+X.i);
+ }
+ }
diff --git a/tests/java5/annotations/binding/StaticInitBinding.aj b/tests/java5/annotations/binding/StaticInitBinding.aj
new file mode 100644
index 000000000..7473dafe3
--- /dev/null
+++ b/tests/java5/annotations/binding/StaticInitBinding.aj
@@ -0,0 +1,37 @@
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface Colored { String color(); }
+
+public class StaticInitBinding {
+ public static void main(String[]argv) {
+ new A();
+ new B();
+ new C();
+ X.verifyRun();
+ }
+}
+
+@Colored(color="orange") class A {}
+@Colored(color="yellow") class B {}
+@Colored(color="brown") class C {}
+
+
+aspect X {
+
+ // Expected color order
+ static String exp[] = new String[]{"orange","yellow","brown"};
+
+ static int i = 0; // Count of advice executions
+
+ before(Colored c): staticinitialization(*) && !within(X) && @annotation(c) {
+ System.err.println(thisJoinPoint+" color="+c.color());
+ if (!c.color().equals(exp[i])) throw new RuntimeException("not "+exp[i]+"? "+c.color());
+ i++;
+ }
+
+ public static void verifyRun() {
+ if (X.i != exp.length)
+ throw new RuntimeException("Expected "+exp.length+" advice runs but did "+X.i);
+ }
+} \ No newline at end of file