diff options
author | acolyer <acolyer> | 2006-02-21 14:06:49 +0000 |
---|---|---|
committer | acolyer <acolyer> | 2006-02-21 14:06:49 +0000 |
commit | 8fbb060383a4d6d41f5553355f3bf51197d1a2ae (patch) | |
tree | 48a7da56058e97d8df5ddb02e205e2a0bffb58e3 /weaver/testsrc | |
parent | 3b4d09438dd366cf4bb90c9d19cc8134853a347d (diff) | |
download | aspectj-8fbb060383a4d6d41f5553355f3bf51197d1a2ae.tar.gz aspectj-8fbb060383a4d6d41f5553355f3bf51197d1a2ae.zip |
Progress on: PointcutHandlerDesignator.
Ensures that MatchingContext can be used in fast matching too.
Diffstat (limited to 'weaver/testsrc')
-rw-r--r-- | weaver/testsrc/org/aspectj/weaver/tools/PointcutDesignatorHandlerTests.java | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/weaver/testsrc/org/aspectj/weaver/tools/PointcutDesignatorHandlerTests.java b/weaver/testsrc/org/aspectj/weaver/tools/PointcutDesignatorHandlerTests.java index bb678ff58..23acf58a5 100644 --- a/weaver/testsrc/org/aspectj/weaver/tools/PointcutDesignatorHandlerTests.java +++ b/weaver/testsrc/org/aspectj/weaver/tools/PointcutDesignatorHandlerTests.java @@ -60,6 +60,15 @@ public class PointcutDesignatorHandlerTests extends TestCase { assertEquals("service.*",beanHandler.getExpressionLastAskedToParse()); } + public void testParseWithHandlerAndMultipleSegments() { + if (needToSkip) return; + PointcutParser parser = PointcutParser.getPointcutParserSupportingAllPrimitivesAndUsingContextClassloaderForResolution(); + BeanDesignatorHandler beanHandler = new BeanDesignatorHandler(); + parser.registerPointcutDesignatorHandler(beanHandler); + parser.parsePointcutExpression("bean(org.xyz.someapp..*)"); + assertEquals("org.xyz.someapp..*",beanHandler.getExpressionLastAskedToParse()); + } + public void testStaticMatch() throws Exception { if (needToSkip) return; PointcutParser parser = PointcutParser.getPointcutParserSupportingAllPrimitivesAndUsingContextClassloaderForResolution(); @@ -95,7 +104,19 @@ public class PointcutDesignatorHandlerTests extends TestCase { assertFalse(sm.matchesJoinPoint(null, null, null).matches()); } - + public void testFastMatch() { + if (needToSkip) return; + PointcutParser parser = PointcutParser.getPointcutParserSupportingAllPrimitivesAndUsingContextClassloaderForResolution(); + BeanDesignatorHandler beanHandler = new BeanDesignatorHandler(); + parser.registerPointcutDesignatorHandler(beanHandler); + PointcutExpression pc = parser.parsePointcutExpression("bean(myBean)"); + DefaultMatchingContext context = new DefaultMatchingContext(); + context.addContextBinding("beanName","myBean"); + pc.setMatchingContext(context); + assertTrue(pc.couldMatchJoinPointsInType(String.class)); + context.addContextBinding("beanName","yourBean"); + assertFalse(pc.couldMatchJoinPointsInType(String.class)); + } private class BeanDesignatorHandler implements PointcutDesignatorHandler { @@ -130,11 +151,19 @@ public class PointcutDesignatorHandlerTests extends TestCase { } + public boolean couldMatchJoinPointsInType(Class aClass) { + return true; + } + /* (non-Javadoc) * @see org.aspectj.weaver.tools.ContextBasedMatcher#couldMatchJoinPointsInType(java.lang.Class) */ - public boolean couldMatchJoinPointsInType(Class aClass) { - return true; + public boolean couldMatchJoinPointsInType(Class aClass, MatchingContext context) { + if (this.beanNamePattern.equals(context.getBinding("beanName"))) { + return true; + } else { + return false; + } } |