public void testMethodExecutionMatching02() {
checkAlwaysMatches("execution(* *val*(..))", "java.lang.String", "valueOf", "(Z)Ljava/lang/String;");
checkAlwaysMatches("execution(String *(..))", "java.lang.String", "valueOf", "(Z)Ljava/lang/String;");
checkAlwaysMatches("execution(* *(boolean))", "java.lang.String", "valueOf", "(Z)Ljava/lang/String;");
checkAlwaysMatches("execution(* j*..*.valueOf(..))", "java.lang.String", "valueOf", "(Z)Ljava/lang/String;");
checkAlwaysMatches("execution(* *(*))", "java.lang.String", "valueOf", "(Z)Ljava/lang/String;");
checkNeverMatches("execution(* vulueOf(..))", "java.lang.String", "valueOf", "(Z)Ljava/lang/String;");
checkNeverMatches("execution(int *(..))", "java.lang.String", "valueOf", "(Z)Ljava/lang/String;");
checkNeverMatches("execution(* valueOf(String))", "java.lang.String", "valueOf", "(Z)Ljava/lang/String;");
checkNeverMatches("execution(private * valueOf(..))", "java.lang.String", "valueOf", "(Z)Ljava/lang/String;");
}
The method 'checkAlwaysMatches' constructs a pointcut _expression_ from the first string:
StandardPointcutExpression ex = pointcutParser.parsePointcutExpression(pointcutExpression);
Then uses the world to retrieve the specified member (e.g. "String valueOf(boolean)" from the String class, in the case of the first test entry there:
ResolvedType resolvedType = world.resolve(type);
ResolvedMember method = getMethod(resolvedType, methodName, methodSignature);
Then compares the two:
boolean b = ex.matchesMethodExecution(method).alwaysMatches();
Using it without a world of types, I'm not sure about that.
cheers,
Andy