From 5e2673ab5a5143efb093f95ac213c0b603fc1a7e Mon Sep 17 00:00:00 2001 From: aclement Date: Mon, 25 Feb 2008 21:28:33 +0000 Subject: [PATCH] annoValMatch: testcode --- .../annotationValueMatching/AllKinds.java | 39 +++++++++++++++ .../BooleanValueMatching.java | 17 +++++++ .../ByteValueMatching.java | 17 +++++++ .../CharValueMatching.java | 17 +++++++ .../DoubleValueMatching.java | 17 +++++++ .../annotationValueMatching/Error.java | 36 ++++++++++++++ .../annotationValueMatching/ErrorOne.java | 16 +++++++ .../annotationValueMatching/ExampleOne.java | 48 +++++++++++++++++++ .../FloatValueMatching.java | 28 +++++++++++ .../IntValueMatching.java | 32 +++++++++++++ .../LongValueMatching.java | 17 +++++++ .../MultiTypePatterns.java | 25 ++++++++++ .../annotationValueMatching/Parsing.java | 4 +- .../ShortValueMatching.java | 17 +++++++ .../StringValueMatching.java | 17 +++++++ .../annotationValueMatching/Test.java | 16 +++++++ 16 files changed, 361 insertions(+), 2 deletions(-) create mode 100644 tests/features160/annotationValueMatching/AllKinds.java create mode 100644 tests/features160/annotationValueMatching/BooleanValueMatching.java create mode 100644 tests/features160/annotationValueMatching/ByteValueMatching.java create mode 100644 tests/features160/annotationValueMatching/CharValueMatching.java create mode 100644 tests/features160/annotationValueMatching/DoubleValueMatching.java create mode 100644 tests/features160/annotationValueMatching/Error.java create mode 100644 tests/features160/annotationValueMatching/ErrorOne.java create mode 100644 tests/features160/annotationValueMatching/ExampleOne.java create mode 100644 tests/features160/annotationValueMatching/FloatValueMatching.java create mode 100644 tests/features160/annotationValueMatching/IntValueMatching.java create mode 100644 tests/features160/annotationValueMatching/LongValueMatching.java create mode 100644 tests/features160/annotationValueMatching/MultiTypePatterns.java create mode 100644 tests/features160/annotationValueMatching/ShortValueMatching.java create mode 100644 tests/features160/annotationValueMatching/StringValueMatching.java create mode 100644 tests/features160/annotationValueMatching/Test.java diff --git a/tests/features160/annotationValueMatching/AllKinds.java b/tests/features160/annotationValueMatching/AllKinds.java new file mode 100644 index 000000000..9ba322194 --- /dev/null +++ b/tests/features160/annotationValueMatching/AllKinds.java @@ -0,0 +1,39 @@ +import java.lang.annotation.*; + +public class AllKinds { + public static void main(String[] args) { + + } +} + +enum Color { RED, GREEN, AMBER } + +@Retention(RetentionPolicy.RUNTIME) +@interface ComplexAnnotation { + int ival(); + byte bval(); + char cval(); + long jval(); + double dval(); + boolean zval(); + short sval(); + float fval(); + Color enumval(); + String strval(); + Class clazzval(); + int[] arrayval(); +} + +aspect X { + pointcut p1(): execution(@ComplexAnnotation(ival=5) * *(..)); + pointcut p2(): execution(@ComplexAnnotation(bval=5) * *(..)); + pointcut p3(): execution(@ComplexAnnotation(cval='5') * *(..)); + pointcut p4(): execution(@ComplexAnnotation(jval=32232323) * *(..)); + pointcut p5(): execution(@ComplexAnnotation(dval=5.0) * *(..)); + pointcut p6(): execution(@ComplexAnnotation(zval=true) * *(..)); + pointcut p7(): execution(@ComplexAnnotation(sval=42) * *(..)); + pointcut p8(): execution(@ComplexAnnotation(enumval=Color.GREEN) * *(..)); + pointcut p9(): execution(@ComplexAnnotation(strval="Hello") * *(..)); +// pointcut pa(): execution(@ComplexAnnotation(clazzval=String.class) * *(..)); +// pointcut pb(): execution(@ComplexAnnotation(arrayval={1,2,3}) * *(..)); +} diff --git a/tests/features160/annotationValueMatching/BooleanValueMatching.java b/tests/features160/annotationValueMatching/BooleanValueMatching.java new file mode 100644 index 000000000..bb11e2a3a --- /dev/null +++ b/tests/features160/annotationValueMatching/BooleanValueMatching.java @@ -0,0 +1,17 @@ +import java.lang.annotation.*; + +public class BooleanValueMatching { + public static void main(String[] args) { } + + @Anno(zval=true) public void methodOne() {} + @Anno(zval=false) public void methodTwo() {} +} + +@interface Anno { + boolean zval(); +} + + +aspect X { + before(): execution(@Anno(zval=true) * *(..)) {} +} diff --git a/tests/features160/annotationValueMatching/ByteValueMatching.java b/tests/features160/annotationValueMatching/ByteValueMatching.java new file mode 100644 index 000000000..8c9001c89 --- /dev/null +++ b/tests/features160/annotationValueMatching/ByteValueMatching.java @@ -0,0 +1,17 @@ +import java.lang.annotation.*; + +public class ByteValueMatching { + public static void main(String[] args) { } + + @Anno(bval=123) public void methodOne() {} + @Anno(bval=27) public void methodTwo() {} +} + +@interface Anno { + byte bval(); +} + + +aspect X { + before(): execution(@Anno(bval=123) * *(..)) {} +} diff --git a/tests/features160/annotationValueMatching/CharValueMatching.java b/tests/features160/annotationValueMatching/CharValueMatching.java new file mode 100644 index 000000000..8a440a5a6 --- /dev/null +++ b/tests/features160/annotationValueMatching/CharValueMatching.java @@ -0,0 +1,17 @@ +import java.lang.annotation.*; + +public class CharValueMatching { + public static void main(String[] args) { } + + @Anno(cval='e') public void methodOne() {} + @Anno(cval='a') public void methodTwo() {} +} + +@interface Anno { + char cval(); +} + + +aspect X { + before(): execution(@Anno(cval='a') * *(..)) {} +} diff --git a/tests/features160/annotationValueMatching/DoubleValueMatching.java b/tests/features160/annotationValueMatching/DoubleValueMatching.java new file mode 100644 index 000000000..f6b310929 --- /dev/null +++ b/tests/features160/annotationValueMatching/DoubleValueMatching.java @@ -0,0 +1,17 @@ +import java.lang.annotation.*; + +public class DoubleValueMatching { + public static void main(String[] args) { } + + @Anno(dval=37.01) public void methodOne() {} + @Anno(dval=52.123) public void methodTwo() {} +} + +@interface Anno { + double dval(); +} + + +aspect X { + before(): execution(@Anno(dval=37.01) * *(..)) {} +} diff --git a/tests/features160/annotationValueMatching/Error.java b/tests/features160/annotationValueMatching/Error.java new file mode 100644 index 000000000..c36e2f42b --- /dev/null +++ b/tests/features160/annotationValueMatching/Error.java @@ -0,0 +1,36 @@ +import java.lang.annotation.*; + +public class Error { + public static void main(String[] args) { } + +} + +@interface Anno { + int ival(); + float fval(); + double dval(); + byte bval(); + short sval(); + boolean zval(); + long jval(); + Color enumval(); + char cval(); + String stringval(); +} + +enum Color { RED,GREEN,BLUE }; + +aspect X { + before(): execution(@Anno(ival=Color.GREEN) * *(..)) {} + before(): execution(@Anno(fval="hello") * *(..)) {} // invalid + before(): execution(@Anno(bval="foo") * *(..)) {} + before(): execution(@Anno(cval="no") * *(..)) {} + before(): execution(@Anno(jval=30.0f) * *(..)) {} + before(): execution(@Anno(dval="foo") * *(..)) {} + before(): execution(@Anno(zval=123) * *(..)) {} + before(): execution(@Anno(sval=4212312312) * *(..)) {} + before(): execution(@Anno(enumval=12) * *(..)) {} + before(): execution(@Anno(stringval=234) * *(..)) {} +// before(): execution(@Anno(clazzval=String.class) * *(..)); +// before(): execution(@Anno(arrayval={1,2,3}) * *(..)); +} diff --git a/tests/features160/annotationValueMatching/ErrorOne.java b/tests/features160/annotationValueMatching/ErrorOne.java new file mode 100644 index 000000000..aae8074d5 --- /dev/null +++ b/tests/features160/annotationValueMatching/ErrorOne.java @@ -0,0 +1,16 @@ +import java.lang.annotation.*; + +public class ErrorOne { + public static void main(String[] args) { } +} + +@interface Anno { + float fval(); +} + +enum Color { RED,GREEN,BLUE }; + +// Non existent value of the annotation! +aspect X { + before(): execution(@Anno(ival=Color.GREEN) * *(..)) {} +} diff --git a/tests/features160/annotationValueMatching/ExampleOne.java b/tests/features160/annotationValueMatching/ExampleOne.java new file mode 100644 index 000000000..5cb6ca87d --- /dev/null +++ b/tests/features160/annotationValueMatching/ExampleOne.java @@ -0,0 +1,48 @@ + +enum TraceLevel { NONE, LEVEL1, LEVEL2, LEVEL3 } + +@interface Trace { + TraceLevel value() default TraceLevel.NONE; +} + +aspect X { + before(): execution(@Trace !@Trace(TraceLevel.NONE) * *(..)) { + System.err.println("tracing "+thisJoinPoint); + } +} + +public class ExampleOne { + + public static void main(String[] args) { + ExampleOne eOne = new ExampleOne(); + eOne.m001(); + eOne.m002(); + eOne.m003(); + eOne.m004(); + eOne.m005(); + eOne.m006(); + eOne.m007(); + } + + @Trace(TraceLevel.NONE) + public void m001() {} + + @Trace(TraceLevel.LEVEL2) + public void m002() {} + + @Trace(TraceLevel.LEVEL3) + public void m003() {} + + @Trace(TraceLevel.NONE) + public void m004() {} + + @Trace(TraceLevel.LEVEL2) + public void m005() {} + + @Trace(TraceLevel.NONE) + public void m006() {} + + @Trace + public void m007() {} + +} diff --git a/tests/features160/annotationValueMatching/FloatValueMatching.java b/tests/features160/annotationValueMatching/FloatValueMatching.java new file mode 100644 index 000000000..d20b7df51 --- /dev/null +++ b/tests/features160/annotationValueMatching/FloatValueMatching.java @@ -0,0 +1,28 @@ +import java.lang.annotation.*; + +public class FloatValueMatching { + public static void main(String[] args) { } + + @Anno(fval=37.0f) public void methodOne() {} + @Anno(fval=52.1f) public void methodTwo() {} +} + +@interface Anno { + float fval(); +} + + +aspect X { +// before(): execution(@Anno(ival=5) * *(..)) {} + before(): execution(@Anno(fval=52.1f) * *(..)) {} +// before(): execution(@Anno(bval=5) * *(..)) {} +// before(): execution(@Anno(cval='5') * *(..)) {} +// before(): execution(@Anno(jval=32232323) * *(..)) {} +// before(): execution(@Anno(dval=5.0) * *(..)) {} +// before(): execution(@Anno(zval=true) * *(..)) {} +// before(): execution(@Anno(sval=42) * *(..)) {} +// before(): execution(@Anno(enumval=Color.GREEN) * *(..)) {} +// before(): execution(@Anno(strval="Hello") * *(..)) {} +// before(): execution(@Anno(clazzval=String.class) * *(..)); +// before(): execution(@Anno(arrayval={1,2,3}) * *(..)); +} diff --git a/tests/features160/annotationValueMatching/IntValueMatching.java b/tests/features160/annotationValueMatching/IntValueMatching.java new file mode 100644 index 000000000..c04af38c2 --- /dev/null +++ b/tests/features160/annotationValueMatching/IntValueMatching.java @@ -0,0 +1,32 @@ +import java.lang.annotation.*; + +public class IntValueMatching { + public static void main(String[] args) { + + } + + @Anno(ival=3) public void a() {} + @Anno(ival=5) public void b() {} +} + +enum Color { RED, GREEN, AMBER } + +@Retention(RetentionPolicy.RUNTIME) +@interface Anno { + int ival(); +} + + +aspect X { + before(): execution(@Anno(ival=5) * *(..)) {} +// before(): execution(@Anno(bval=5) * *(..)) {} +// before(): execution(@Anno(cval='5') * *(..)) {} +// before(): execution(@Anno(jval=32232323) * *(..)) {} +// before(): execution(@Anno(dval=5.0) * *(..)) {} +// before(): execution(@Anno(zval=true) * *(..)) {} +// before(): execution(@Anno(sval=42) * *(..)) {} +// before(): execution(@Anno(enumval=Color.GREEN) * *(..)) {} +// before(): execution(@Anno(strval="Hello") * *(..)) {} +// before(): execution(@Anno(clazzval=String.class) * *(..)); +// before(): execution(@Anno(arrayval={1,2,3}) * *(..)); +} diff --git a/tests/features160/annotationValueMatching/LongValueMatching.java b/tests/features160/annotationValueMatching/LongValueMatching.java new file mode 100644 index 000000000..f3eec424e --- /dev/null +++ b/tests/features160/annotationValueMatching/LongValueMatching.java @@ -0,0 +1,17 @@ +import java.lang.annotation.*; + +public class LongValueMatching { + public static void main(String[] args) { } + + @Anno(jval=123123123) public void methodOne() {} + @Anno(jval=8) public void methodTwo() {} +} + +@interface Anno { + long jval(); +} + + +aspect X { + before(): execution(@Anno(jval=123123123) * *(..)) {} +} diff --git a/tests/features160/annotationValueMatching/MultiTypePatterns.java b/tests/features160/annotationValueMatching/MultiTypePatterns.java new file mode 100644 index 000000000..84cf4682a --- /dev/null +++ b/tests/features160/annotationValueMatching/MultiTypePatterns.java @@ -0,0 +1,25 @@ +// testing what happens with multiple annotations together in a type pattern list @(A B C) type thing + + +enum Rainbow { RED, ORANGE, YELLOW, GREEN, BLUE, INDIGO, VIOLET } + +@interface Col1 { Rainbow value() default Rainbow.RED; } +@interface Col2 { Rainbow value() default Rainbow.YELLOW; } + +aspect X { + before(): execution(@(Col1 && Col2) * *(..)) { + System.err.println("advising "+thisJoinPoint); + } +} + +public class MultiTypePatterns { + + public static void main(String[] args) { + MultiTypePatterns eOne = new MultiTypePatterns(); + } + + @Col1 public void m001() {} + @Col2 public void m002() {} + @Col1 @Col2 public void m003() {} + +} diff --git a/tests/features160/annotationValueMatching/Parsing.java b/tests/features160/annotationValueMatching/Parsing.java index f541a8610..0bbb6e241 100644 --- a/tests/features160/annotationValueMatching/Parsing.java +++ b/tests/features160/annotationValueMatching/Parsing.java @@ -1,7 +1,7 @@ enum Color { RED, GREEN, AMBER } @interface TrafficLight { - Color value() default Color.RED; + Color value() default Color.RED; Color a() default Color.GREEN; Color c() default Color.GREEN; Color e() default Color.GREEN; } public class Parsing { @@ -29,4 +29,4 @@ aspect X { pointcut p2(): execution(@TrafficLight(a=Color.GREEN) * *(..)); pointcut p3(): execution(@TrafficLight(a=Color.RED,c=Color.RED) * *(..)); pointcut p4(): execution(@TrafficLight(a=Color.RED,c=Color.RED,e=Color.RED) * *(..)); -} \ No newline at end of file +} diff --git a/tests/features160/annotationValueMatching/ShortValueMatching.java b/tests/features160/annotationValueMatching/ShortValueMatching.java new file mode 100644 index 000000000..b24825acb --- /dev/null +++ b/tests/features160/annotationValueMatching/ShortValueMatching.java @@ -0,0 +1,17 @@ +import java.lang.annotation.*; + +public class ShortValueMatching { + public static void main(String[] args) { } + + @Anno(sval=32700) public void methodOne() {} + @Anno(sval=27) public void methodTwo() {} +} + +@interface Anno { + short sval(); +} + + +aspect X { + before(): execution(@Anno(sval=32700) * *(..)) {} +} diff --git a/tests/features160/annotationValueMatching/StringValueMatching.java b/tests/features160/annotationValueMatching/StringValueMatching.java new file mode 100644 index 000000000..17de47af3 --- /dev/null +++ b/tests/features160/annotationValueMatching/StringValueMatching.java @@ -0,0 +1,17 @@ +import java.lang.annotation.*; + +public class StringValueMatching { + public static void main(String[] args) { } + + @Anno(stringval="foobar") public void methodOne() {} + @Anno(stringval="goo") public void methodTwo() {} +} + +@interface Anno { + String stringval(); +} + + +aspect X { + before(): execution(@Anno(stringval="foobar") * *(..)) {} +} diff --git a/tests/features160/annotationValueMatching/Test.java b/tests/features160/annotationValueMatching/Test.java new file mode 100644 index 000000000..5cf17a7b3 --- /dev/null +++ b/tests/features160/annotationValueMatching/Test.java @@ -0,0 +1,16 @@ +//@Retention(RetentionPolicy.RUNTIME) +@interface ComplexAnnotation { + int ival(); + byte bval(); + char cval(); + long jval(); + double dval(); + boolean zval(); + short sval(); + float fval(); +// Color enumval(); + String strval(); + Class classval(); + int[] arrayval(); +} + -- 2.39.5