Search in sources :

Example 1 with ChildClassMatcher

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

the class InstrumentationConstructorTest method childClassMatcher.

@Test
public void childClassMatcher() throws Exception {
    ChildClassMatcher classMatcher = load("!child_class_matcher 'java/lang/Object'");
    Assert.assertEquals(new ChildClassMatcher("java/lang/Object"), classMatcher);
}
Also used : ChildClassMatcher(com.newrelic.agent.instrumentation.classmatchers.ChildClassMatcher) Test(org.junit.Test)

Example 2 with ChildClassMatcher

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

the class ExtensionDomParserTest method testSuperclassPointCut.

@Test
public void testSuperclassPointCut() throws Exception {
    Extension ext = ExtensionDomParser.readFile(getFile(SUPERCLASS_FILE_PATH));
    Instrumentation inst = ext.getInstrumentation();
    List<Pointcut> thePcs = inst.getPointcut();
    Assert.assertEquals(2, thePcs.size());
    Pointcut pc = thePcs.get(0);
    Assert.assertNotNull(pc.getClassName());
    Assert.assertEquals("test.SuperTest", pc.getClassName().getValue());
    List<ExtensionClassAndMethodMatcher> pcs = ExtensionConversionUtility.convertToPointCutsForValidation(ext);
    Assert.assertNotNull(pcs);
    Assert.assertEquals(2, pcs.size());
    ExtensionClassAndMethodMatcher actual = pcs.get(0);
    Assert.assertTrue(actual.getClassMatcher() instanceof ChildClassMatcher);
    ExtensionClassAndMethodMatcher returnMatcher = pcs.get(1);
    Assert.assertTrue(returnMatcher.getClassMatcher() instanceof ChildClassMatcher);
    Assert.assertTrue(returnMatcher.getMethodMatcher() instanceof ExactReturnTypeMethodMatcher);
    Assert.assertTrue(returnMatcher.getMethodMatcher().matches(Opcodes.ACC_PUBLIC, "bogus", "()Lcom/framework/Result;", com.google.common.collect.ImmutableSet.<String>of()));
    Assert.assertFalse(returnMatcher.getMethodMatcher().matches(Opcodes.ACC_PUBLIC, "test", "()[Lcom/framework/Result;", com.google.common.collect.ImmutableSet.<String>of()));
    Assert.assertFalse(returnMatcher.getMethodMatcher().matches(Opcodes.ACC_PUBLIC, "dude", "(Lcom/framework/Result;)V", com.google.common.collect.ImmutableSet.<String>of()));
}
Also used : Extension(com.newrelic.agent.extension.beans.Extension) Pointcut(com.newrelic.agent.extension.beans.Extension.Instrumentation.Pointcut) ExactReturnTypeMethodMatcher(com.newrelic.agent.instrumentation.methodmatchers.ExactReturnTypeMethodMatcher) ExtensionClassAndMethodMatcher(com.newrelic.agent.instrumentation.custom.ExtensionClassAndMethodMatcher) Instrumentation(com.newrelic.agent.extension.beans.Extension.Instrumentation) ChildClassMatcher(com.newrelic.agent.instrumentation.classmatchers.ChildClassMatcher) Test(org.junit.Test)

Aggregations

ChildClassMatcher (com.newrelic.agent.instrumentation.classmatchers.ChildClassMatcher)2 Test (org.junit.Test)2 Extension (com.newrelic.agent.extension.beans.Extension)1 Instrumentation (com.newrelic.agent.extension.beans.Extension.Instrumentation)1 Pointcut (com.newrelic.agent.extension.beans.Extension.Instrumentation.Pointcut)1 ExtensionClassAndMethodMatcher (com.newrelic.agent.instrumentation.custom.ExtensionClassAndMethodMatcher)1 ExactReturnTypeMethodMatcher (com.newrelic.agent.instrumentation.methodmatchers.ExactReturnTypeMethodMatcher)1