use of com.newrelic.agent.instrumentation.classmatchers.DefaultClassAndMethodMatcher in project newrelic-java-agent by newrelic.
the class ClassTransformerServiceTest method addTraceMatcher.
@Test
public void addTraceMatcher() throws UnmodifiableClassException {
Assert.assertFalse(TestClass.class.isAnnotationPresent(InstrumentedClass.class));
ServiceFactory.getClassTransformerService().addTraceMatcher(new DefaultClassAndMethodMatcher(new ExactClassMatcher(Type.getType(ClassTransformerServiceTest.class).getInternalName() + "$TestClass"), new AllMethodsMatcher()), "dude");
ServiceFactory.getCoreService().getInstrumentation().retransformClasses(TestClass.class);
Assert.assertTrue(TestClass.class.isAnnotationPresent(InstrumentedClass.class));
}
use of com.newrelic.agent.instrumentation.classmatchers.DefaultClassAndMethodMatcher in project newrelic-java-agent by newrelic.
the class ClassesMatcherTest method getMatchingClasses_Annotation.
@Trace
@Test
public void getMatchingClasses_Annotation() {
ClassMatchVisitorFactory matcher = OptimizedClassMatcherBuilder.newBuilder().addClassMethodMatcher(new DefaultClassAndMethodMatcher(new AllClassesMatcher(), new AnnotationMethodMatcher(Type.getType(Trace.class)))).build();
Set<Class<?>> matchingClasses = ClassesMatcher.getMatchingClasses(Collections.singletonList(matcher), matcherHelper, ClassesMatcherTest.class, ArrayList.class, HashMap.class);
assertEquals(1, matchingClasses.size());
assertTrue(matchingClasses.contains(ClassesMatcherTest.class));
}
Aggregations