From: aclement Date: Fri, 25 Jan 2008 02:30:08 +0000 (+0000) Subject: paramannos: testcode X-Git-Tag: V1_6_0M2~94 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=2f2ea564c21a05edb9a99dd42805231cdc53d02f;p=aspectj.git paramannos: testcode --- diff --git a/tests/features160/parameterAnnotationMatching/Anno1.java b/tests/features160/parameterAnnotationMatching/Anno1.java new file mode 100644 index 000000000..8adf61659 --- /dev/null +++ b/tests/features160/parameterAnnotationMatching/Anno1.java @@ -0,0 +1,5 @@ + +import java.lang.annotation.*; + +@Retention(RetentionPolicy.RUNTIME) +@interface Anno1 {} diff --git a/tests/features160/parameterAnnotationMatching/Anno2.java b/tests/features160/parameterAnnotationMatching/Anno2.java new file mode 100644 index 000000000..22c291167 --- /dev/null +++ b/tests/features160/parameterAnnotationMatching/Anno2.java @@ -0,0 +1,5 @@ + +import java.lang.annotation.*; + +@Retention(RetentionPolicy.RUNTIME) +@interface Anno2 {} diff --git a/tests/features160/parameterAnnotationMatching/AnnotatedWithAnno1.java b/tests/features160/parameterAnnotationMatching/AnnotatedWithAnno1.java new file mode 100644 index 000000000..4e76656e1 --- /dev/null +++ b/tests/features160/parameterAnnotationMatching/AnnotatedWithAnno1.java @@ -0,0 +1,4 @@ + +@Anno1 +class AnnotatedWithAnno1 { } + diff --git a/tests/features160/parameterAnnotationMatching/AnnotatedWithAnno2.java b/tests/features160/parameterAnnotationMatching/AnnotatedWithAnno2.java new file mode 100644 index 000000000..f3c6d4b9b --- /dev/null +++ b/tests/features160/parameterAnnotationMatching/AnnotatedWithAnno2.java @@ -0,0 +1,3 @@ + +@Anno2 +class AnnotatedWithAnno2 {} diff --git a/tests/features160/parameterAnnotationMatching/AnnotatedWithBoth.java b/tests/features160/parameterAnnotationMatching/AnnotatedWithBoth.java new file mode 100644 index 000000000..b3a8ea79b --- /dev/null +++ b/tests/features160/parameterAnnotationMatching/AnnotatedWithBoth.java @@ -0,0 +1,3 @@ + +@Anno1 @Anno2 +class AnnotatedWithBoth {} diff --git a/tests/features160/parameterAnnotationMatching/HasMethodMatching.aj b/tests/features160/parameterAnnotationMatching/HasMethodMatching.aj new file mode 100644 index 000000000..ee8b756f7 --- /dev/null +++ b/tests/features160/parameterAnnotationMatching/HasMethodMatching.aj @@ -0,0 +1,39 @@ +import java.io.*; + +// Should match as indicated +public aspect HasMethodMatching { + + declare parents: hasmethod(* a(@Anno1 *)) implements Serializable; // yes Target1 + declare parents: hasmethod(* b(@Anno1 *)) implements Serializable; // no + declare parents: hasmethod(* c(@Anno1 (*))) implements Serializable; // yes Target3 + declare parents: hasmethod(* d(@Anno1 (@Anno2 *))) implements Serializable; // yes Target4 + declare parents: hasmethod(* e(@Anno1 (@Anno2 *))) implements Serializable; // no + + public static void main(String []argv) { + System.out.println("Target1? "+(new Target1() instanceof Serializable)); + System.out.println("Target2? "+(new Target2() instanceof Serializable)); + System.out.println("Target3? "+(new Target3() instanceof Serializable)); + System.out.println("Target4? "+(new Target4() instanceof Serializable)); + System.out.println("Target5? "+(new Target5() instanceof Serializable)); + } +} + +class Target1 { + public void a(AnnotatedWithAnno1 p) {} +} + +class Target2 { + public void b(@Anno1 String p) {} +} + +class Target3 { + public void c(@Anno1 String p) {} +} + +class Target4 { + public void d(@Anno1 AnnotatedWithAnno2 p) {} +} + +class Target5 { + public void e(@Anno1 AnnotatedWithAnno1 p) {} +} diff --git a/tests/features160/parameterAnnotationMatching/TestMatching.aj b/tests/features160/parameterAnnotationMatching/TestMatching.aj new file mode 100644 index 000000000..29efba8b9 --- /dev/null +++ b/tests/features160/parameterAnnotationMatching/TestMatching.aj @@ -0,0 +1,64 @@ +// Each pointcut should match as specified the methods that immediately follow it +aspect TestMatching { + before(): execution(* m001*(@Anno1 *)) {} + public void m001a(AnnotatedWithAnno1 p) {} // yes + + before(): execution(* m002*(@Anno1 (*))) {} + public void m002a(@Anno1 String p) {} // yes + public void m002b(Integer p) {} // no + + before(): execution(* m003*(@Anno2 (*))) {} + public void m003a(@Anno2 String p) {} // yes + public void m003b(@Anno1 String p) {} // no + public void m003c(Integer p) {} // no + + before(): execution(* m004*(@Anno1 (@Anno2 *))) {} + public void m004a(@Anno1 AnnotatedWithAnno2 p) {} // yes + public void m004b(@Anno2 String p) {} // no + public void m004c(@Anno1 String p) {} // no + public void m004d(Integer p) {} // no + + before(): execution(* m005*(@Anno1 *,@Anno2 *)) {} + public void m005a(AnnotatedWithAnno1 p,AnnotatedWithAnno2 q) {} // yes + public void m005b(AnnotatedWithAnno1 p,@Anno2 String q) {} // no + public void m005c(String p,AnnotatedWithAnno2 q) {} // no + + before(): execution(* m006*(@Anno1 (*),@Anno2 (*))) {} + public void m006a(@Anno1 String p,@Anno2 String q) {} // yes + public void m006b(AnnotatedWithAnno1 p,@Anno2 String q) {} // no + public void m006c(String p,AnnotatedWithAnno2 q) {} // no + public void m006d(AnnotatedWithAnno1 p,AnnotatedWithAnno2 q) {} // no + public void m006e(@Anno1 @Anno2 String p,@Anno1 @Anno2 String q) {} // yes + + before(): execution(* m007*(@Anno1 (@Anno2 *))) {} + public void m007a(@Anno1 AnnotatedWithAnno2 p) {} // yes + public void m007b(@Anno1 String p) {} // no + public void m007c(AnnotatedWithAnno2 p) {} // no + public void m007d(@Anno1 AnnotatedWithAnno1 p) {} // no + + before(): execution(* m008*(@Anno1 (*),..,@Anno2 (*))) {} + public void m008a(@Anno1 String p,Integer q,@Anno2 String r) {} // yes + public void m008b(@Anno1 String p,@Anno2 String r) {} // yes + public void m008c(@Anno1 String p,Integer q,String r,@Anno2 String s) {} // yes + public void m008d(@Anno1 String p,Integer q,String r,@Anno2 String s,String t) {} // no + public void m008e(String p,Integer q,String r,@Anno2 String s) {} // no + + before(): execution(* m009*(@Anno1 (*),..,@Anno2 *)) {} + public void m009a(@Anno1 String p, Integer q,AnnotatedWithAnno2 r) {} // yes + public void m009b(@Anno1 String p, Integer q,@Anno2 AnnotatedWithAnno2 r) {} // yes + public void m009c(@Anno1 String p, Integer q,@Anno2 Integer r) {} // no + public void m009d(String p, Integer q,@Anno2 Integer r) {} // no + + before(): execution(* m010*(..,@Anno1 (*))) {} + public void m010a(@Anno1 String p,@Anno1 String q) {} // yes + public void m010b(String p,@Anno1 String q) {} // yes + public void m010c(@Anno1 String p,String q) {} // no + + before(): execution(* m011*(@Anno1 *...)) {} + public void m011a(AnnotatedWithAnno1... p) {} // no (the array is not annotated) + public void m011b(@Anno1 String... p) {} // no + + before(): execution(* m012*(@Anno1 (*...))) {} + public void m012a(@Anno1 String... p) {} // yes + public void m012b(AnnotatedWithAnno1... p) {} // no +}