summaryrefslogtreecommitdiffstats
path: root/tests/java5/ataspectj/annotationGen/DeclarePrecedenceTest.aj
diff options
context:
space:
mode:
Diffstat (limited to 'tests/java5/ataspectj/annotationGen/DeclarePrecedenceTest.aj')
-rw-r--r--tests/java5/ataspectj/annotationGen/DeclarePrecedenceTest.aj35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/java5/ataspectj/annotationGen/DeclarePrecedenceTest.aj b/tests/java5/ataspectj/annotationGen/DeclarePrecedenceTest.aj
new file mode 100644
index 000000000..d8cda81a1
--- /dev/null
+++ b/tests/java5/ataspectj/annotationGen/DeclarePrecedenceTest.aj
@@ -0,0 +1,35 @@
+import org.aspectj.lang.reflect.*;
+import java.lang.reflect.*;
+
+@org.aspectj.lang.annotation.DeclarePrecedence("DeclarePrecedenceTest,*")
+public aspect DeclarePrecedenceTest {
+
+ declare precedence : org.xyz..*, org.abc..*;
+
+ declare precedence : org.abc..*, org.def..*;
+
+
+ public static void main(String[] args) throws ClassNotFoundException {
+ AjType<DeclarePrecedenceTest> myType = AjTypeSystem.getAjType(DeclarePrecedenceTest.class);
+ DeclarePrecedence[] decPs = myType.getDeclarePrecedence();
+ if (decPs.length != 3) throw new RuntimeException("Expecting 3 members, got " + decPs.length);
+ for(int i = 0; i < decPs.length; i++) {
+ validateDecP(decPs[i]);
+ }
+ }
+
+ private static void validateDecP(DeclarePrecedence dp) {
+ TypePattern[] tps = dp.getPrecedenceOrder();
+ if (tps.length != 2) throw new RuntimeException("Expecting 2 type patterns, got " + tps.length);
+ if (tps[0].asString().equals("DeclarePrecedenceTest")) {
+ if (!tps[1].asString().equals("*")) throw new RuntimeException("Excepting '*', got '" + tps[1].asString() + "'");
+ } else if (tps[0].asString().equals("org.xyz..*")) {
+ if (!tps[1].asString().equals("org.abc..*")) throw new RuntimeException("Excepting 'org.abc..*', got '" + tps[1].asString() + "'");
+ } else if (tps[0].asString().equals("org.abc..*")) {
+ if (!tps[1].asString().equals("org.def..*")) throw new RuntimeException("Excepting 'org.def..*', got '" + tps[1].asString() + "'");
+ } else {
+ throw new RuntimeException("Unexpected type pattern: " + tps[0].asString());
+ }
+ }
+
+}