Search in sources :

Example 21 with MethodMatcher

use of com.newrelic.agent.instrumentation.methodmatchers.MethodMatcher in project newrelic-java-agent by newrelic.

the class PointCutConfigTest method incrediblyConcisePointcut.

@Test
public void incrediblyConcisePointcut() throws Exception {
    final String yaml = "oder:\n  java/lang/String.concat(Ljava/lang/String;)Ljava/lang/String;";
    PointCutConfig config = new PointCutConfig(new ByteArrayInputStream(yaml.getBytes(StandardCharsets.UTF_8)));
    Assert.assertEquals(1, config.getPointCuts().size());
    Assert.assertNotNull(config.getPointCuts().get(0));
    MethodMatcher methodMatcher = config.getPointCuts().get(0).getMethodMatcher();
    ClassMatcher classMatcher = config.getPointCuts().get(0).getClassMatcher();
    Assert.assertTrue(classMatcher instanceof ExactClassMatcher);
    Assert.assertTrue(classMatcher.isMatch(String.class));
    Assert.assertFalse(classMatcher.isMatch(List.class));
    Assert.assertTrue(methodMatcher instanceof ExactMethodMatcher);
}
Also used : ExactClassMatcher(com.newrelic.agent.instrumentation.classmatchers.ExactClassMatcher) ClassMatcher(com.newrelic.agent.instrumentation.classmatchers.ClassMatcher) ExactClassMatcher(com.newrelic.agent.instrumentation.classmatchers.ExactClassMatcher) ByteArrayInputStream(java.io.ByteArrayInputStream) List(java.util.List) ExactMethodMatcher(com.newrelic.agent.instrumentation.methodmatchers.ExactMethodMatcher) ExtensionClassAndMethodMatcher(com.newrelic.agent.instrumentation.custom.ExtensionClassAndMethodMatcher) MethodMatcher(com.newrelic.agent.instrumentation.methodmatchers.MethodMatcher) ExactMethodMatcher(com.newrelic.agent.instrumentation.methodmatchers.ExactMethodMatcher) Test(org.junit.Test)

Aggregations

MethodMatcher (com.newrelic.agent.instrumentation.methodmatchers.MethodMatcher)21 ExtensionClassAndMethodMatcher (com.newrelic.agent.instrumentation.custom.ExtensionClassAndMethodMatcher)19 Test (org.junit.Test)16 ExactMethodMatcher (com.newrelic.agent.instrumentation.methodmatchers.ExactMethodMatcher)11 ArrayList (java.util.ArrayList)9 ByteArrayInputStream (java.io.ByteArrayInputStream)8 ClassMatcher (com.newrelic.agent.instrumentation.classmatchers.ClassMatcher)3 ExactClassMatcher (com.newrelic.agent.instrumentation.classmatchers.ExactClassMatcher)3 AnnotationMethodMatcher (com.newrelic.agent.instrumentation.methodmatchers.AnnotationMethodMatcher)3 OrMethodMatcher (com.newrelic.agent.instrumentation.methodmatchers.OrMethodMatcher)3 LambdaMethodMatcher (com.newrelic.agent.instrumentation.methodmatchers.LambdaMethodMatcher)2 ReturnTypeMethodMatcher (com.newrelic.agent.instrumentation.methodmatchers.ReturnTypeMethodMatcher)2 ParameterAttributeName (com.newrelic.agent.instrumentation.tracing.ParameterAttributeName)2 List (java.util.List)2 BaseConfig (com.newrelic.agent.config.BaseConfig)1 Config (com.newrelic.agent.config.Config)1 Extension (com.newrelic.agent.extension.beans.Extension)1 Pointcut (com.newrelic.agent.extension.beans.Extension.Instrumentation.Pointcut)1 Method (com.newrelic.agent.extension.beans.Extension.Instrumentation.Pointcut.Method)1 AllClassesMatcher (com.newrelic.agent.instrumentation.classmatchers.AllClassesMatcher)1