Search in sources :

Example 11 with Match

use of com.newrelic.agent.instrumentation.classmatchers.OptimizedClassMatcher.Match in project newrelic-java-agent by newrelic.

the class OptimizedClassMatcherTest method testAnnotationMatch.

@Test
public void testAnnotationMatch() throws IOException {
    InstrumentationContext instrumentationContext = getInstrumentationContext(matcher, AnnotatedClass.class);
    Match match = instrumentationContext.getMatches().values().iterator().next();
    Assert.assertNotNull(match);
    Assert.assertEquals(2, match.getMethods().size());
    Assert.assertTrue(match.getMethods().contains(new Method("annotation1", "()V")));
    Assert.assertTrue(match.getMethods().contains(new Method("annotation2", "()Z")));
}
Also used : InstrumentationContext(com.newrelic.agent.instrumentation.context.InstrumentationContext) Method(org.objectweb.asm.commons.Method) Match(com.newrelic.agent.instrumentation.classmatchers.OptimizedClassMatcher.Match) Test(org.junit.Test)

Example 12 with Match

use of com.newrelic.agent.instrumentation.classmatchers.OptimizedClassMatcher.Match in project newrelic-java-agent by newrelic.

the class OptimizedClassMatcherTest method testOrMatch.

@Test
public void testOrMatch() throws IOException {
    Runnable run = new Runnable() {

        public void run() {
        }
    };
    Match match = getMatch(matcher, run.getClass());
    Assert.assertNotNull(match);
    Assert.assertEquals(1, match.getMethods().size());
    Assert.assertTrue(match.getMethods().contains(new Method("run", "()V")));
    Assert.assertEquals(1, match.getClassMatches().size());
    Assert.assertTrue(match.getClassMatches().containsKey(match5));
}
Also used : Method(org.objectweb.asm.commons.Method) Match(com.newrelic.agent.instrumentation.classmatchers.OptimizedClassMatcher.Match) Test(org.junit.Test)

Aggregations

Match (com.newrelic.agent.instrumentation.classmatchers.OptimizedClassMatcher.Match)12 Test (org.junit.Test)12 Method (org.objectweb.asm.commons.Method)11 ClassMatchVisitorFactory (com.newrelic.agent.instrumentation.context.ClassMatchVisitorFactory)3 InstrumentationContext (com.newrelic.agent.instrumentation.context.InstrumentationContext)3 ExactReturnTypeMethodMatcher (com.newrelic.agent.instrumentation.methodmatchers.ExactReturnTypeMethodMatcher)2 AccessMethodMatcher (com.newrelic.agent.instrumentation.methodmatchers.AccessMethodMatcher)1 AllMethodsMatcher (com.newrelic.agent.instrumentation.methodmatchers.AllMethodsMatcher)1 AnnotationMethodMatcher (com.newrelic.agent.instrumentation.methodmatchers.AnnotationMethodMatcher)1 ExactMethodMatcher (com.newrelic.agent.instrumentation.methodmatchers.ExactMethodMatcher)1 MethodMatcher (com.newrelic.agent.instrumentation.methodmatchers.MethodMatcher)1 NameMethodMatcher (com.newrelic.agent.instrumentation.methodmatchers.NameMethodMatcher)1 OrMethodMatcher (com.newrelic.agent.instrumentation.methodmatchers.OrMethodMatcher)1 InvocationHandler (java.lang.reflect.InvocationHandler)1 ArrayList (java.util.ArrayList)1