aboutsummaryrefslogtreecommitdiffstats
path: root/weaver5/java5-testsrc/org/aspectj/weaver/tools
diff options
context:
space:
mode:
authoraclement <aclement>2008-02-25 21:46:11 +0000
committeraclement <aclement>2008-02-25 21:46:11 +0000
commitfdb16f70ce79ff3ac1d62bcc5021e24f21756291 (patch)
tree0fb2aa53a5fd897d20bcc9b3fe2a90a6e4c2175e /weaver5/java5-testsrc/org/aspectj/weaver/tools
parentaff8542d4f5e6b386dd0a216b4cf9adf5d413212 (diff)
downloadaspectj-fdb16f70ce79ff3ac1d62bcc5021e24f21756291.tar.gz
aspectj-fdb16f70ce79ff3ac1d62bcc5021e24f21756291.zip
annoValMatch: implementation
Diffstat (limited to 'weaver5/java5-testsrc/org/aspectj/weaver/tools')
-rw-r--r--weaver5/java5-testsrc/org/aspectj/weaver/tools/Java15PointcutExpressionTest.java41
1 files changed, 41 insertions, 0 deletions
diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/tools/Java15PointcutExpressionTest.java b/weaver5/java5-testsrc/org/aspectj/weaver/tools/Java15PointcutExpressionTest.java
index 98da1b2b5..fa1e1d17d 100644
--- a/weaver5/java5-testsrc/org/aspectj/weaver/tools/Java15PointcutExpressionTest.java
+++ b/weaver5/java5-testsrc/org/aspectj/weaver/tools/Java15PointcutExpressionTest.java
@@ -100,6 +100,47 @@ public class Java15PointcutExpressionTest extends TestCase {
}
+ public void testMatchingAnnotationValueExpressions() throws SecurityException, NoSuchMethodException {
+ PointcutParser p = PointcutParser.getPointcutParserSupportingAllPrimitivesAndUsingSpecifiedClassloaderForResolution(this.getClass().getClassLoader());
+ PointcutExpression pexpr = null;
+ ShadowMatch match = null;
+
+ Method n = test.AnnoValues.class.getMethod("none",null);
+ Method r = test.AnnoValues.class.getMethod("redMethod",null);
+ Method g = test.AnnoValues.class.getMethod("greenMethod",null);
+ Method b = test.AnnoValues.class.getMethod("blueMethod",null);
+ Method d = test.AnnoValues.class.getMethod("defaultMethod",null);
+
+ pexpr = p.parsePointcutExpression("execution(@test.A3(test.Color.RED) public void *(..))");
+ assertTrue("Should match", pexpr.matchesMethodExecution(n).neverMatches()); // default value RED
+ assertTrue("Should match", pexpr.matchesMethodExecution(r).alwaysMatches());
+ assertTrue("Should not match", pexpr.matchesMethodExecution(g).neverMatches());
+ assertTrue("Should not match", pexpr.matchesMethodExecution(b).neverMatches());
+ assertTrue("Should match", pexpr.matchesMethodExecution(d).alwaysMatches());
+
+ pexpr = p.parsePointcutExpression("execution(@test.A3(test.Color.GREEN) public void *(..))");
+ assertTrue("Should not match", pexpr.matchesMethodExecution(n).neverMatches()); // default value RED
+ assertTrue("Should not match", pexpr.matchesMethodExecution(r).neverMatches());
+ assertTrue("Should match", pexpr.matchesMethodExecution(g).alwaysMatches());
+ assertTrue("Should not match", pexpr.matchesMethodExecution(b).neverMatches());
+ assertTrue("Should not match", pexpr.matchesMethodExecution(d).neverMatches());
+
+ pexpr = p.parsePointcutExpression("execution(@test.A3(test.Color.BLUE) public void *(..))");
+ assertTrue("Should not match", pexpr.matchesMethodExecution(n).neverMatches()); // default value RED
+ assertTrue("Should not match", pexpr.matchesMethodExecution(r).neverMatches());
+ assertTrue("Should not match", pexpr.matchesMethodExecution(g).neverMatches());
+ assertTrue("Should match", pexpr.matchesMethodExecution(b).alwaysMatches());
+ assertTrue("Should not match", pexpr.matchesMethodExecution(d).neverMatches());
+
+ pexpr = p.parsePointcutExpression("execution(@test.A3 public void *(..))");
+ assertTrue("Should match", pexpr.matchesMethodExecution(n).neverMatches()); // default value RED
+ assertTrue("Should match", pexpr.matchesMethodExecution(r).alwaysMatches());
+ assertTrue("Should match", pexpr.matchesMethodExecution(g).alwaysMatches());
+ assertTrue("Should match", pexpr.matchesMethodExecution(b).alwaysMatches());
+ assertTrue("Should match", pexpr.matchesMethodExecution(d).alwaysMatches());
+
+ }
+
/**
* Test matching of pointcuts against expressions. A reflection world is being used on the backend here (not a Bcel one).