Search in sources :

Example 6 with ExactClassMatcher

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);
}
Also used : ExactClassMatcher(com.newrelic.agent.instrumentation.classmatchers.ExactClassMatcher) ClassMatcher(com.newrelic.agent.instrumentation.classmatchers.ClassMatcher) AndClassMatcher(com.newrelic.agent.instrumentation.classmatchers.AndClassMatcher) OrClassMatcher(com.newrelic.agent.instrumentation.classmatchers.OrClassMatcher) ChildClassMatcher(com.newrelic.agent.instrumentation.classmatchers.ChildClassMatcher) ExactClassMatcher(com.newrelic.agent.instrumentation.classmatchers.ExactClassMatcher) AndClassMatcher(com.newrelic.agent.instrumentation.classmatchers.AndClassMatcher) Test(org.junit.Test)

Example 7 with ExactClassMatcher

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);
}
Also used : ExactClassMatcher(com.newrelic.agent.instrumentation.classmatchers.ExactClassMatcher) Test(org.junit.Test)

Example 8 with ExactClassMatcher

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);
}
Also used : ExactClassMatcher(com.newrelic.agent.instrumentation.classmatchers.ExactClassMatcher) NotMatcher(com.newrelic.agent.instrumentation.classmatchers.NotMatcher) Test(org.junit.Test)

Example 9 with ExactClassMatcher

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));
}
Also used : Pointcut(com.newrelic.agent.extension.beans.Extension.Instrumentation.Pointcut) ExactClassMatcher(com.newrelic.agent.instrumentation.classmatchers.ExactClassMatcher) ClassMatcher(com.newrelic.agent.instrumentation.classmatchers.ClassMatcher) ExactClassMatcher(com.newrelic.agent.instrumentation.classmatchers.ExactClassMatcher) ClassName(com.newrelic.agent.extension.beans.Extension.Instrumentation.Pointcut.ClassName) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 10 with ExactClassMatcher

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));
}
Also used : ExactClassMatcher(com.newrelic.agent.instrumentation.classmatchers.ExactClassMatcher) DefaultClassAndMethodMatcher(com.newrelic.agent.instrumentation.classmatchers.DefaultClassAndMethodMatcher) ExactMethodMatcher(com.newrelic.agent.instrumentation.methodmatchers.ExactMethodMatcher) Test(org.junit.Test)

Aggregations

ExactClassMatcher (com.newrelic.agent.instrumentation.classmatchers.ExactClassMatcher)14 Test (org.junit.Test)12 ExactMethodMatcher (com.newrelic.agent.instrumentation.methodmatchers.ExactMethodMatcher)7 DefaultClassAndMethodMatcher (com.newrelic.agent.instrumentation.classmatchers.DefaultClassAndMethodMatcher)5 ExtensionClassAndMethodMatcher (com.newrelic.agent.instrumentation.custom.ExtensionClassAndMethodMatcher)4 ClassMatcher (com.newrelic.agent.instrumentation.classmatchers.ClassMatcher)3 HashSafeClassAndMethodMatcher (com.newrelic.agent.instrumentation.classmatchers.HashSafeClassAndMethodMatcher)3 AllMethodsMatcher (com.newrelic.agent.instrumentation.methodmatchers.AllMethodsMatcher)2 MethodMatcher (com.newrelic.agent.instrumentation.methodmatchers.MethodMatcher)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2 Pointcut (com.newrelic.agent.extension.beans.Extension.Instrumentation.Pointcut)1 ClassName (com.newrelic.agent.extension.beans.Extension.Instrumentation.Pointcut.ClassName)1 AndClassMatcher (com.newrelic.agent.instrumentation.classmatchers.AndClassMatcher)1 ChildClassMatcher (com.newrelic.agent.instrumentation.classmatchers.ChildClassMatcher)1 NotMatcher (com.newrelic.agent.instrumentation.classmatchers.NotMatcher)1 OrClassMatcher (com.newrelic.agent.instrumentation.classmatchers.OrClassMatcher)1 AccessMethodMatcher (com.newrelic.agent.instrumentation.methodmatchers.AccessMethodMatcher)1 NotMethodMatcher (com.newrelic.agent.instrumentation.methodmatchers.NotMethodMatcher)1