Search in sources :

Example 6 with Match

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

the class OptimizedClassMatcherTest method testSlowMatch.

@Test
public void testSlowMatch() throws IOException {
    Match match = getMatch(matcher, TestStatement.class);
    Assert.assertNotNull(match);
    Assert.assertEquals(3, match.getMethods().size());
    Assert.assertTrue(match.getMethods().contains(new Method("close", "()V")));
    Assert.assertTrue(match.getMethods().contains(new Method("cancel", "()V")));
    Assert.assertTrue(match.getMethods().contains(new Method("executeBatch", "()[I")));
    Assert.assertEquals(1, match.getClassMatches().size());
    Assert.assertTrue(match.getClassMatches().containsKey(match4));
}
Also used : Method(org.objectweb.asm.commons.Method) Match(com.newrelic.agent.instrumentation.classmatchers.OptimizedClassMatcher.Match) Test(org.junit.Test)

Example 7 with Match

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

the class OptimizedClassMatcherTest method testAccessMatch.

@Test
public void testAccessMatch() throws IOException {
    Match match = getMatch(matcher, HashMap.class);
    Assert.assertNotNull(match);
    Assert.assertTrue(match.getMethods().size() > 0);
    Assert.assertTrue(match.getMethods().contains(new Method("size", "()I")));
    Assert.assertFalse(match.getMethods().contains(new Method("init", "()V")));
    Assert.assertTrue(match.getClassMatches().containsKey(match6));
}
Also used : Method(org.objectweb.asm.commons.Method) Match(com.newrelic.agent.instrumentation.classmatchers.OptimizedClassMatcher.Match) Test(org.junit.Test)

Example 8 with Match

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

the class OptimizedClassMatcherTest method testGenericsMatch.

@Test
public void testGenericsMatch() throws IOException {
    InstrumentationContext instrumentationContext = getInstrumentationContext(matcher, ArgGenerics.class);
    Match match = instrumentationContext.getMatches().values().iterator().next();
    Assert.assertNotNull(match);
    Assert.assertEquals(3, match.getMethods().size());
    Assert.assertTrue(match.getMethods().contains(new Method("add", "(Ljava/lang/Object;)Z")));
    Assert.assertEquals(match.getMethods().size(), match.getClassMatches().size());
    Assert.assertTrue(match.getClassMatches().containsKey(match7));
    Assert.assertEquals(2, instrumentationContext.getBridgeMethods().size());
    Assert.assertEquals(new Method("add", "(Ljava/lang/String;)Z"), instrumentationContext.getBridgeMethods().get(new Method("add", "(Ljava/lang/Object;)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 9 with Match

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

the class OptimizedClassMatcherTest method testSingleMatch.

@Test
public void testSingleMatch() throws IOException {
    Match match = getMatch(matcher, HashSet.class);
    Assert.assertNotNull(match);
    Assert.assertEquals(1, match.getMethods().size());
    Assert.assertTrue(match.getMethods().contains(new Method("size", "()I")));
    Assert.assertEquals(1, match.getClassMatches().size());
    Assert.assertTrue(match.getClassMatches().containsKey(match1));
}
Also used : Method(org.objectweb.asm.commons.Method) Match(com.newrelic.agent.instrumentation.classmatchers.OptimizedClassMatcher.Match) Test(org.junit.Test)

Example 10 with Match

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

the class OptimizedClassMatcherTest method testMultipleMatch.

@Test
public void testMultipleMatch() throws IOException {
    Match match = getMatch(matcher, ArrayList.class);
    Assert.assertNotNull(match);
    Assert.assertEquals(3, match.getMethods().size());
    Assert.assertTrue(match.getMethods().contains(new Method("size", "()I")));
    Assert.assertTrue(match.getMethods().contains(new Method("get", "(I)Ljava/lang/Object;")));
    Assert.assertEquals(3, match.getClassMatches().size());
    Assert.assertTrue(match.getClassMatches().containsKey(match1));
    Assert.assertTrue(match.getClassMatches().containsKey(match2));
}
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