Search in sources :

Example 1 with StrutsActionPointCut

use of com.newrelic.agent.instrumentation.pointcuts.frameworks.struts.StrutsActionPointCut 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));
    }
}
Also used : SpringPointCut(com.newrelic.agent.instrumentation.pointcuts.frameworks.spring.SpringPointCut) ProcessActionPortletPointCut(com.newrelic.agent.instrumentation.pointcuts.frameworks.ProcessActionPortletPointCut) SpringExceptionHandlerPointCut(com.newrelic.agent.instrumentation.pointcuts.frameworks.spring.SpringExceptionHandlerPointCut) SpringDispatcherPointCut(com.newrelic.agent.instrumentation.pointcuts.frameworks.spring.SpringDispatcherPointCut) ArrayList(java.util.ArrayList) CXFPointCut(com.newrelic.agent.instrumentation.pointcuts.frameworks.cxf.CXFPointCut) SpringExceptionHandlerPointCut(com.newrelic.agent.instrumentation.pointcuts.frameworks.spring.SpringExceptionHandlerPointCut) JasperCompilerPointCut(com.newrelic.agent.instrumentation.pointcuts.container.JasperCompilerPointCut) CXFInvokerPointCut(com.newrelic.agent.instrumentation.pointcuts.frameworks.cxf.CXFInvokerPointCut) LifecyclePointCut(com.newrelic.agent.instrumentation.pointcuts.frameworks.faces.LifecyclePointCut) HandlerInterceptorPointCut(com.newrelic.agent.instrumentation.pointcuts.frameworks.spring.HandlerInterceptorPointCut) SpringPointCut(com.newrelic.agent.instrumentation.pointcuts.frameworks.spring.SpringPointCut) Struts2ActionPointCut(com.newrelic.agent.instrumentation.pointcuts.frameworks.struts.Struts2ActionPointCut) StrutsActionPointCut(com.newrelic.agent.instrumentation.pointcuts.frameworks.struts.StrutsActionPointCut) RenderPortletPointCut(com.newrelic.agent.instrumentation.pointcuts.frameworks.RenderPortletPointCut) MathCSConcurrentPointCut(com.newrelic.agent.instrumentation.pointcuts.MathCSConcurrentPointCut) ProcessActionPortletPointCut(com.newrelic.agent.instrumentation.pointcuts.frameworks.ProcessActionPortletPointCut) XmlRpcPointCut(com.newrelic.agent.instrumentation.pointcuts.XmlRpcPointCut) HandlerMethodInvokerPointCut(com.newrelic.agent.instrumentation.pointcuts.frameworks.spring.HandlerMethodInvokerPointCut) SpringDispatcherPointCut(com.newrelic.agent.instrumentation.pointcuts.frameworks.spring.SpringDispatcherPointCut) ClientProxyPointCut(com.newrelic.agent.instrumentation.pointcuts.frameworks.cxf.ClientProxyPointCut) StrutsActionConfigMatcherPointCut(com.newrelic.agent.instrumentation.pointcuts.frameworks.struts.StrutsActionConfigMatcherPointCut) CXFInvokerPointCut(com.newrelic.agent.instrumentation.pointcuts.frameworks.cxf.CXFInvokerPointCut) CXFPointCut(com.newrelic.agent.instrumentation.pointcuts.frameworks.cxf.CXFPointCut) StrutsActionPointCut(com.newrelic.agent.instrumentation.pointcuts.frameworks.struts.StrutsActionPointCut) XmlRpcPointCut(com.newrelic.agent.instrumentation.pointcuts.XmlRpcPointCut) MathCSConcurrentPointCut(com.newrelic.agent.instrumentation.pointcuts.MathCSConcurrentPointCut) LifecyclePointCut(com.newrelic.agent.instrumentation.pointcuts.frameworks.faces.LifecyclePointCut) HandlerInterceptorPointCut(com.newrelic.agent.instrumentation.pointcuts.frameworks.spring.HandlerInterceptorPointCut) JasperCompilerPointCut(com.newrelic.agent.instrumentation.pointcuts.container.JasperCompilerPointCut) HashSet(java.util.HashSet) RenderPortletPointCut(com.newrelic.agent.instrumentation.pointcuts.frameworks.RenderPortletPointCut) Method(java.lang.reflect.Method) Struts2ActionPointCut(com.newrelic.agent.instrumentation.pointcuts.frameworks.struts.Struts2ActionPointCut) StrutsActionConfigMatcherPointCut(com.newrelic.agent.instrumentation.pointcuts.frameworks.struts.StrutsActionConfigMatcherPointCut) XWork2ResultPC(com.newrelic.agent.instrumentation.pointcuts.frameworks.struts.XWork2ResultPC) HandlerMethodInvokerPointCut(com.newrelic.agent.instrumentation.pointcuts.frameworks.spring.HandlerMethodInvokerPointCut) ClientProxyPointCut(com.newrelic.agent.instrumentation.pointcuts.frameworks.cxf.ClientProxyPointCut) Test(org.junit.Test)

Aggregations

MathCSConcurrentPointCut (com.newrelic.agent.instrumentation.pointcuts.MathCSConcurrentPointCut)1 XmlRpcPointCut (com.newrelic.agent.instrumentation.pointcuts.XmlRpcPointCut)1 JasperCompilerPointCut (com.newrelic.agent.instrumentation.pointcuts.container.JasperCompilerPointCut)1 ProcessActionPortletPointCut (com.newrelic.agent.instrumentation.pointcuts.frameworks.ProcessActionPortletPointCut)1 RenderPortletPointCut (com.newrelic.agent.instrumentation.pointcuts.frameworks.RenderPortletPointCut)1 CXFInvokerPointCut (com.newrelic.agent.instrumentation.pointcuts.frameworks.cxf.CXFInvokerPointCut)1 CXFPointCut (com.newrelic.agent.instrumentation.pointcuts.frameworks.cxf.CXFPointCut)1 ClientProxyPointCut (com.newrelic.agent.instrumentation.pointcuts.frameworks.cxf.ClientProxyPointCut)1 LifecyclePointCut (com.newrelic.agent.instrumentation.pointcuts.frameworks.faces.LifecyclePointCut)1 HandlerInterceptorPointCut (com.newrelic.agent.instrumentation.pointcuts.frameworks.spring.HandlerInterceptorPointCut)1 HandlerMethodInvokerPointCut (com.newrelic.agent.instrumentation.pointcuts.frameworks.spring.HandlerMethodInvokerPointCut)1 SpringDispatcherPointCut (com.newrelic.agent.instrumentation.pointcuts.frameworks.spring.SpringDispatcherPointCut)1 SpringExceptionHandlerPointCut (com.newrelic.agent.instrumentation.pointcuts.frameworks.spring.SpringExceptionHandlerPointCut)1 SpringPointCut (com.newrelic.agent.instrumentation.pointcuts.frameworks.spring.SpringPointCut)1 Struts2ActionPointCut (com.newrelic.agent.instrumentation.pointcuts.frameworks.struts.Struts2ActionPointCut)1 StrutsActionConfigMatcherPointCut (com.newrelic.agent.instrumentation.pointcuts.frameworks.struts.StrutsActionConfigMatcherPointCut)1 StrutsActionPointCut (com.newrelic.agent.instrumentation.pointcuts.frameworks.struts.StrutsActionPointCut)1 XWork2ResultPC (com.newrelic.agent.instrumentation.pointcuts.frameworks.struts.XWork2ResultPC)1 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1