use of com.newrelic.agent.instrumentation.pointcuts.frameworks.spring.SpringExceptionHandlerPointCut in project newrelic-java-agent by newrelic.
the class ClassTransformerTest method test.
@Test
public void test() {
PointCutClassTransformer classTransformer = ServiceFactory.getClassTransformerService().getClassTransformer();
Collection<PointCut> pcs = new ArrayList<>();
try {
Method method = classTransformer.getClass().getDeclaredMethod("findEnabledPointCuts");
method.setAccessible(true);
pcs = (Collection<PointCut>) method.invoke(classTransformer);
} catch (Exception e) {
e.printStackTrace();
fail("An exception occurred: " + e.getMessage());
}
List<? extends PointCut> manual = Arrays.asList(// struts
new StrutsActionPointCut(classTransformer), new Struts2ActionPointCut(classTransformer), new StrutsActionConfigMatcherPointCut(classTransformer), new XWork2ResultPC(classTransformer), // Spring
new SpringPointCut(classTransformer), // new SpringWildcardPathPointCut(classTransformer),
new SpringDispatcherPointCut(classTransformer), new HandlerInterceptorPointCut(classTransformer), new HandlerMethodInvokerPointCut(classTransformer), new SpringExceptionHandlerPointCut(classTransformer), // Faces
new LifecyclePointCut(classTransformer), // CXF
new CXFPointCut(classTransformer), new CXFInvokerPointCut(classTransformer), new ClientProxyPointCut(classTransformer), // portlet
new ProcessActionPortletPointCut(classTransformer), new RenderPortletPointCut(classTransformer), // Tomcat
new JasperCompilerPointCut(classTransformer), new XmlRpcPointCut(classTransformer), // java concurrent
new MathCSConcurrentPointCut(classTransformer));
Set<String> manualNamesEnabled = new HashSet<>();
Set<String> manualNamesDisabled = new HashSet<>();
for (PointCut pc : manual) {
if (pc.isEnabled()) {
manualNamesEnabled.add(pc.getClass().getName());
} else {
manualNamesDisabled.add(pc.getClass().getName());
}
}
Set<String> allNames = new HashSet<>();
for (PointCut pc : pcs) {
allNames.add(pc.getClass().getName());
}
Set<String> missing = new HashSet<>(manualNamesEnabled);
missing.removeAll(allNames);
// all of the enabled should be present
Assert.assertTrue(missing.toString(), allNames.containsAll(manualNamesEnabled));
// all of the disabled should not be present
for (String disabled : manualNamesDisabled) {
Assert.assertFalse(allNames.contains(disabled));
}
}
Aggregations