try {
ExpressionNamespace space = ExpressionNamespace.getExpressionNamespace();
space.registerExpression("*->* test.ExpressionTest.set(..)", "", "pc1", PointcutType.CALL);
space.registerExpression("*->* test.ExpressionTest.get(..)", "", "pc2", PointcutType.CALL);
Expression root = space.createExpression("pc1 || pc2");
Expression rootAnonymous = space.createExpression("pc1 || call(*->* test.ExpressionTest.get(..))");
ClassMetaData classMetaData1 = ReflectionMetaDataMaker.createClassMetaData(ExpressionTest.class);
MethodMetaData methodMetaData1 = ReflectionMetaDataMaker.createMethodMetaData(
ExpressionTest.class.getDeclaredMethod("set", new Class[]{})
);
MethodMetaData methodMetaData2 = ReflectionMetaDataMaker.createMethodMetaData(
ExpressionTest.class.getDeclaredMethod("get", new Class[]{})
);
MethodMetaData methodMetaData3 = ReflectionMetaDataMaker.createMethodMetaData(
ExpressionTest.class.getDeclaredMethod("suite", new Class[]{})
);
assertTrue(root.match(classMetaData1, PointcutType.CALL));
assertTrue(rootAnonymous.match(classMetaData1, PointcutType.CALL));
assertTrue(root.match(classMetaData1, methodMetaData1, PointcutType.CALL));
assertTrue(rootAnonymous.match(classMetaData1, methodMetaData1, PointcutType.CALL));
assertTrue(root.match(classMetaData1, methodMetaData2, PointcutType.CALL));
assertTrue(rootAnonymous.match(classMetaData1, methodMetaData2, PointcutType.CALL));
assertFalse(root.match(classMetaData1, methodMetaData3, PointcutType.CALL));
assertFalse(rootAnonymous.match(classMetaData1, methodMetaData3, PointcutType.CALL));
}
catch (Exception e) {
fail(e.toString());
}
}