use of com.newrelic.agent.instrumentation.classmatchers.ExactClassMatcher in project newrelic-java-agent by newrelic.
the class PointCutConfigTest method exactMethodMatcherEvenMoreConcise.
@Test
public void exactMethodMatcherEvenMoreConcise() throws Exception {
final String yaml = "oder:\n class_matcher: java/lang/String\n method_matcher: concat(Ljava/lang/String;)Ljava/lang/String;";
PointCutConfig config = new PointCutConfig(new ByteArrayInputStream(yaml.getBytes(StandardCharsets.UTF_8)));
Assert.assertEquals(1, config.getPointCuts().size());
Assert.assertNotNull(config.getPointCuts().get(0));
MethodMatcher methodMatcher = config.getPointCuts().get(0).getMethodMatcher();
Assert.assertTrue(config.getPointCuts().get(0).getClassMatcher() instanceof ExactClassMatcher);
Assert.assertTrue(methodMatcher instanceof ExactMethodMatcher);
}
use of com.newrelic.agent.instrumentation.classmatchers.ExactClassMatcher 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.ExactClassMatcher in project newrelic-java-agent by newrelic.
the class PointCutConfigTest method incrediblyConcisePointcut.
@Test
public void incrediblyConcisePointcut() throws Exception {
final String yaml = "oder:\n java/lang/String.concat(Ljava/lang/String;)Ljava/lang/String;";
PointCutConfig config = new PointCutConfig(new ByteArrayInputStream(yaml.getBytes(StandardCharsets.UTF_8)));
Assert.assertEquals(1, config.getPointCuts().size());
Assert.assertNotNull(config.getPointCuts().get(0));
MethodMatcher methodMatcher = config.getPointCuts().get(0).getMethodMatcher();
ClassMatcher classMatcher = config.getPointCuts().get(0).getClassMatcher();
Assert.assertTrue(classMatcher instanceof ExactClassMatcher);
Assert.assertTrue(classMatcher.isMatch(String.class));
Assert.assertFalse(classMatcher.isMatch(List.class));
Assert.assertTrue(methodMatcher instanceof ExactMethodMatcher);
}
use of com.newrelic.agent.instrumentation.classmatchers.ExactClassMatcher in project newrelic-java-agent by newrelic.
the class PointCutTest method verifyEqualsAndHashCode.
@Test
public void verifyEqualsAndHashCode() throws Exception {
AgentTestUtils.createServiceManager(new HashMap<String, Object>());
PointCut pc1 = new DefaultPointCut(new PointCutConfiguration("hi"), null, new ExactClassMatcher("myclass"), new ExactMethodMatcher("mymethod", "()V"));
PointCut pc2 = new DefaultPointCut(new PointCutConfiguration("hi"), null, new ExactClassMatcher("myclass"), new ExactMethodMatcher("mymethod", "()V"));
Assert.assertTrue(pc1.equals(pc2));
Assert.assertEquals(pc1.hashCode(), pc2.hashCode());
pc2 = new DefaultPointCut(new PointCutConfiguration("hi"), null, new ExactClassMatcher("myotherClass"), new ExactMethodMatcher("mymethod", "()V"));
Assert.assertFalse(pc1.equals(pc2));
Assert.assertNotSame(pc1.hashCode(), pc2.hashCode());
pc2 = new DefaultPointCut(new PointCutConfiguration("hi"), null, new ExactClassMatcher("myclass"), new ExactMethodMatcher("myothermethod", "()V"));
Assert.assertFalse(pc1.equals(pc2));
Assert.assertNotSame(pc1.hashCode(), pc2.hashCode());
}
Aggregations