diff options
author | acolyer <acolyer> | 2005-02-11 12:47:56 +0000 |
---|---|---|
committer | acolyer <acolyer> | 2005-02-11 12:47:56 +0000 |
commit | 1381903ac81cdab2b79b6525096671aa5d62eaeb (patch) | |
tree | f00812eae5c1a626aa99ba954d0899c083a3bc8f /tests/java5/annotations | |
parent | 382b7330f47d14164896671a4bf3c7ec3acf069b (diff) | |
download | aspectj-1381903ac81cdab2b79b6525096671aa5d62eaeb.tar.gz aspectj-1381903ac81cdab2b79b6525096671aa5d62eaeb.zip |
move all java 5 tests out of code and back into .xml files now that we can compile them properly
Diffstat (limited to 'tests/java5/annotations')
-rw-r--r-- | tests/java5/annotations/thisOrtarget/ThisOrTargetTests.aj | 49 |
1 files changed, 45 insertions, 4 deletions
diff --git a/tests/java5/annotations/thisOrtarget/ThisOrTargetTests.aj b/tests/java5/annotations/thisOrtarget/ThisOrTargetTests.aj index cc5ab5cd0..2936b2ec5 100644 --- a/tests/java5/annotations/thisOrtarget/ThisOrTargetTests.aj +++ b/tests/java5/annotations/thisOrtarget/ThisOrTargetTests.aj @@ -1,7 +1,18 @@ import java.util.List;
+import java.util.ArrayList;
+import java.util.Iterator;
+import org.aspectj.lang.JoinPoint.StaticPart;
+import org.aspectj.lang.JoinPoint;
+import org.aspectj.lang.Signature;
public aspect ThisOrTargetTests {
+ List<String> before1Matches = new ArrayList<String>();
+ List<String> before2Matches = new ArrayList<String>();
+ List<String> after1Matches = new ArrayList<String>();
+ List<String> after2Matches = new ArrayList<String>();
+
+
pointcut doSomethingExecution() : execution(* doSomething());
pointcut doSomethingCall() : call(* doSomething());
@@ -9,7 +20,7 @@ public aspect ThisOrTargetTests { // should match:
// b.doSomething(), reallyB.doSomething() [with test],
// c.doSomething()
- System.out.println("@this(@MyAnnotation): " + thisJoinPointStaticPart);
+ add(before1Matches,thisJoinPointStaticPart);
}
before() : doSomethingExecution() && @this(@MyInheritableAnnotation) {
@@ -17,14 +28,14 @@ public aspect ThisOrTargetTests { // c.doSomething()
// d.doSomething()
// reallyD.doSomething()
- System.out.println("@this(@MyInheritableAnnotation): " + thisJoinPointStaticPart);
+ add(before2Matches,thisJoinPointStaticPart);
}
after() returning : doSomethingCall() && @target(@MyAnnotation) {
// should match:
// b.doSomething(), reallyB.doSomething() [with test],
// c.doSomething()
- System.out.println("@target(@MyAnnotation): " + thisJoinPointStaticPart);
+ add(after1Matches,thisJoinPointStaticPart);
}
after() returning : doSomethingCall() && @target(@MyInheritableAnnotation) {
@@ -32,7 +43,37 @@ public aspect ThisOrTargetTests { // c.doSomething()
// d.doSomething()
// reallyD.doSomething()
- System.out.println("@target(@MyInheritableAnnotation): " + thisJoinPointStaticPart);
+ add(after2Matches,thisJoinPointStaticPart);
}
+ private void add(List<String> toList, JoinPoint.StaticPart jpsp) {
+ Signature sig = jpsp.getSignature();
+ String toAdd = sig.getDeclaringTypeName() + "." + sig.getName();
+ toList.add(toAdd);
+ }
+
+ after() returning : execution(* main(String[])) {
+ assertMatches("before1",before1Matches,
+ new String[] {"B.doSomething","C.doSomething","B.doSomething"} );
+ assertMatches("before2",before2Matches,
+ new String[] {"C.doSomething","D.doSomething","D.doSomething"} );
+ assertMatches("after1",after1Matches,
+ new String[] {"B.doSomething","C.doSomething","A.doSomething"} );
+ assertMatches("after2",after2Matches,
+ new String[] {"C.doSomething","D.doSomething","C.doSomething"} );
+ }
+
+ private void assertMatches(String name, List<String> matches,String[] spec) {
+ if (matches.size() != spec.length) {
+ for (Iterator<String> iter = matches.iterator(); iter.hasNext();) {
+ String match = iter.next();
+ System.out.println(match);
+ }
+
+ throw new RuntimeException(name + ": Expected " + spec.length + " matches, got " + matches.size());
+ }
+ for (int i = 0; i < spec.length; i++) {
+ if (!matches.get(i).equals(spec[i])) throw new RuntimeException(name + ":Excepted " + spec[i] + " got " + matches.get(i));
+ }
+ }
}
\ No newline at end of file |