use of com.newrelic.agent.instrumentation.classmatchers.OptimizedClassMatcher.Match in project newrelic-java-agent by newrelic.
the class OptimizedClassMatcherTest method testSkipObjectMethods_exactMatch.
@Test
public void testSkipObjectMethods_exactMatch() throws IOException {
List<MethodMatcher> matchers = new ArrayList<>();
for (Method m : OBJECT_METHODS) {
matchers.add(new ExactMethodMatcher(m.getName(), m.getDescriptor()));
}
ClassMatchVisitorFactory matcher = OptimizedClassMatcherBuilder.newBuilder().addClassMethodMatcher(new DefaultClassAndMethodMatcher(new AllClassesMatcher(), OrMethodMatcher.getMethodMatcher(matchers))).build();
Match match = getMatch(matcher, MyObject.class);
Assert.assertNull(match);
}
use of com.newrelic.agent.instrumentation.classmatchers.OptimizedClassMatcher.Match in project newrelic-java-agent by newrelic.
the class OptimizedClassMatcherTest method testReturnTypeMatch.
@Test
public void testReturnTypeMatch() throws IOException {
ClassMatchVisitorFactory matcher = OptimizedClassMatcherBuilder.newBuilder().addClassMethodMatcher(new DefaultClassAndMethodMatcher(new AllClassesMatcher(), new ExactReturnTypeMethodMatcher(Type.getType(List.class)))).build();
InstrumentationContext instrumentationContext = getInstrumentationContext(matcher, Arrays.class);
Assert.assertFalse(instrumentationContext.getMatches().isEmpty());
Match match = instrumentationContext.getMatches().values().iterator().next();
Assert.assertNotNull(match);
Assert.assertEquals(1, match.getMethods().size());
Assert.assertTrue(match.getMethods().contains(new Method("asList", "([Ljava/lang/Object;)Ljava/util/List;")));
Assert.assertEquals(1, match.getClassMatches().size());
}
use of com.newrelic.agent.instrumentation.classmatchers.OptimizedClassMatcher.Match in project newrelic-java-agent by newrelic.
the class OptimizedClassMatcherTest method testSkipObjectMethods_looseMatch.
@Test
public void testSkipObjectMethods_looseMatch() throws IOException {
ClassMatchVisitorFactory matcher = OptimizedClassMatcherBuilder.newBuilder().addClassMethodMatcher(new DefaultClassAndMethodMatcher(new AllClassesMatcher(), new AllMethodsMatcher())).build();
Match match = getMatch(matcher, MyObject.class);
Assert.assertNotNull(match);
for (Method m : OBJECT_METHODS) {
Assert.assertFalse(match.getMethods().contains(m));
}
}
use of com.newrelic.agent.instrumentation.classmatchers.OptimizedClassMatcher.Match in project newrelic-java-agent by newrelic.
the class OptimizedClassMatcherTest method testNonMatch.
@Test
public void testNonMatch() throws IOException {
Match match = getMatch(matcher, Executor.class);
Assert.assertNull(match);
}
use of com.newrelic.agent.instrumentation.classmatchers.OptimizedClassMatcher.Match in project newrelic-java-agent by newrelic.
the class OptimizedClassMatcherTest method testSingleMatch2.
@Test
public void testSingleMatch2() throws IOException {
InvocationHandler handler = new InvocationHandler() {
public Object invoke(Object proxy, java.lang.reflect.Method method, Object[] args) throws Throwable {
return null;
}
};
Match match = getMatch(matcher, handler.getClass());
Assert.assertNotNull(match);
Assert.assertEquals(1, match.getMethods().size());
Assert.assertTrue(match.getMethods().contains(new Method("invoke", "(Ljava/lang/Object;Ljava/lang/reflect/Method;[Ljava/lang/Object;)Ljava/lang/Object;")));
Assert.assertEquals(1, match.getClassMatches().size());
Assert.assertTrue(match.getClassMatches().containsKey(match3));
}
Aggregations