use of com.newrelic.agent.instrumentation.pointcuts.frameworks.spring.SpringPointCut in project newrelic-java-agent by newrelic.
the class ClassTransformerConfigImplTest method testSpringPointcutEnabledDefaultDisabled.
@Test
public void testSpringPointcutEnabledDefaultDisabled() {
Map<String, Object> configuration = new HashMap<>();
configuration.put("class_transformer:instrumentation_default:enabled", false);
configuration.put("enable_spring_tracing", true);
configuration.put("app_name", "Unit Test");
configuration = buildConfigMap(configuration);
AgentConfig agentConfig = AgentConfigImpl.createAgentConfig(configuration);
ConfigService configService = ConfigServiceFactory.createConfigService(agentConfig, Collections.<String, Object>emptyMap());
ServiceManager serviceManager = new MockServiceManager(configService);
ServiceFactory.setServiceManager(serviceManager);
SpringPointCut springPointCut = new SpringPointCut(null, agentConfig);
assertTrue(springPointCut.isEnabled());
}
use of com.newrelic.agent.instrumentation.pointcuts.frameworks.spring.SpringPointCut in project newrelic-java-agent by newrelic.
the class ClassTransformerConfigImplTest method testSpringPointcutEnabled.
@Test
public void testSpringPointcutEnabled() {
Map<String, Object> configuration = new HashMap<>();
configuration.put("lite_mode", true);
configuration.put("class_transformer:instrumentation_default:enabled", true);
configuration.put("enable_spring_tracing", true);
configuration.put("app_name", "Unit Test");
configuration = buildConfigMap(configuration);
AgentConfig agentConfig = AgentConfigImpl.createAgentConfig(configuration);
ConfigService configService = ConfigServiceFactory.createConfigService(agentConfig, Collections.<String, Object>emptyMap());
ServiceManager serviceManager = new MockServiceManager(configService);
ServiceFactory.setServiceManager(serviceManager);
SpringPointCut springPointCut = new SpringPointCut(null, agentConfig);
assertTrue(springPointCut.isEnabled());
}
use of com.newrelic.agent.instrumentation.pointcuts.frameworks.spring.SpringPointCut in project newrelic-java-agent by newrelic.
the class ClassTransformerConfigImplTest method testSpringPointcutDisabled.
@Test
public void testSpringPointcutDisabled() {
Map<String, Object> classTransformerMap = new HashMap<>();
Map<String, Object> defaultInstrumentationSettings = new HashMap<>();
defaultInstrumentationSettings.put("enabled", false);
classTransformerMap.put(ClassTransformerConfigImpl.DEFAULT_INSTRUMENTATION, defaultInstrumentationSettings);
Map<String, Object> configSettings = new HashMap<>();
configSettings.put(AgentConfigImpl.CLASS_TRANSFORMER, classTransformerMap);
configSettings.put(AgentConfigImpl.APP_NAME, "Unit Test");
AgentConfig agentConfig = AgentConfigImpl.createAgentConfig(configSettings);
ConfigService configService = ConfigServiceFactory.createConfigService(agentConfig, Collections.<String, Object>emptyMap());
ServiceManager serviceManager = new MockServiceManager(configService);
ServiceFactory.setServiceManager(serviceManager);
SpringPointCut springPointCut = new SpringPointCut(null, agentConfig);
assertFalse(springPointCut.isEnabled());
}
use of com.newrelic.agent.instrumentation.pointcuts.frameworks.spring.SpringPointCut 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));
}
}
use of com.newrelic.agent.instrumentation.pointcuts.frameworks.spring.SpringPointCut in project newrelic-java-agent by newrelic.
the class ClassTransformerConfigImplTest method testSpringPointcutDisabledDefaultEnabled.
@Test
public void testSpringPointcutDisabledDefaultEnabled() {
Map<String, Object> configuration = new HashMap<>();
configuration.put("class_transformer:instrumentation_default:enabled", true);
configuration.put("enable_spring_tracing", false);
configuration.put("app_name", "Unit Test");
configuration = buildConfigMap(configuration);
AgentConfig agentConfig = AgentConfigImpl.createAgentConfig(configuration);
ConfigService configService = ConfigServiceFactory.createConfigService(agentConfig, Collections.<String, Object>emptyMap());
ServiceManager serviceManager = new MockServiceManager(configService);
ServiceFactory.setServiceManager(serviceManager);
SpringPointCut springPointCut = new SpringPointCut(null, agentConfig);
assertFalse(springPointCut.isEnabled());
}
Aggregations