use of com.newrelic.agent.instrumentation.classmatchers.ExactClassMatcher in project newrelic-java-agent by newrelic.
the class InstrumentationConstructorTest method andOrClassMatchers.
@Test
public void andOrClassMatchers() throws Exception {
String classes = "[ !exact_class_matcher 'java/lang/Dude', !exact_class_matcher 'java/lang/Object' ]";
ClassMatcher[] matchers = new ClassMatcher[] { new ExactClassMatcher("java/lang/Dude"), new ExactClassMatcher("java/lang/Object") };
AndClassMatcher classMatcher = load("!and_class_matcher " + classes);
Assert.assertEquals(new AndClassMatcher(matchers), classMatcher);
ClassMatcher orClassMatcher = load("!or_class_matcher " + classes);
Assert.assertEquals(OrClassMatcher.getClassMatcher(matchers), orClassMatcher);
}
use of com.newrelic.agent.instrumentation.classmatchers.ExactClassMatcher in project newrelic-java-agent by newrelic.
the class InstrumentationConstructorTest method exactClassMatcher.
@Test
public void exactClassMatcher() throws Exception {
ExactClassMatcher classMatcher = load("!exact_class_matcher 'java/lang/Object'");
Assert.assertEquals(new ExactClassMatcher("java/lang/Object"), classMatcher);
}
use of com.newrelic.agent.instrumentation.classmatchers.ExactClassMatcher in project newrelic-java-agent by newrelic.
the class InstrumentationConstructorTest method notClassMatcher.
@Test
public void notClassMatcher() throws Exception {
NotMatcher classMatcher = load("!not_class_matcher [ !exact_class_matcher 'java/lang/Object' ]");
Assert.assertEquals(new NotMatcher(new ExactClassMatcher("java/lang/Object")), classMatcher);
}
use of com.newrelic.agent.instrumentation.classmatchers.ExactClassMatcher in project newrelic-java-agent by newrelic.
the class ExtensionConversionUtilityTest method createClassMatcher.
@Test
public void createClassMatcher() throws XmlException {
Pointcut pointcut = new Pointcut();
ClassName name = new ClassName();
name.setValue(ArrayList.class.getName());
pointcut.setClassName(name);
ClassMatcher classMatcher = ExtensionConversionUtility.createClassMatcher(pointcut, "test");
Assert.assertTrue(classMatcher instanceof ExactClassMatcher);
Assert.assertTrue(classMatcher.isMatch(ArrayList.class));
}
use of com.newrelic.agent.instrumentation.classmatchers.ExactClassMatcher in project newrelic-java-agent by newrelic.
the class ClassesMatcherTest method getMatchingClasses_Simple.
@Test
public void getMatchingClasses_Simple() {
ClassMatchVisitorFactory matcher = OptimizedClassMatcherBuilder.newBuilder().addClassMethodMatcher(new DefaultClassAndMethodMatcher(new ExactClassMatcher(Type.getType(ArrayList.class).getInternalName()), new ExactMethodMatcher("size", "()I"))).build();
Set<Class<?>> matchingClasses = ClassesMatcher.getMatchingClasses(Collections.singletonList(matcher), matcherHelper, ArrayList.class);
assertFalse(matchingClasses.isEmpty());
assertTrue(matchingClasses.contains(ArrayList.class));
}
Aggregations