use of com.newrelic.agent.service.ServiceManager in project newrelic-java-agent by newrelic.
the class ClassTransformerConfigImplTest method testPoincutExplicitEnable.
@Test
public void testPoincutExplicitEnable() {
Map<String, Object> config = new HashMap<>();
config.put("class_transformer:PointcutClassName:enabled", true);
config.put("class_transformer:instrumentation_default:enabled", true);
config.put("app_name", "Unit Test");
config = buildConfigMap(config);
AgentConfig agentConfig = AgentConfigImpl.createAgentConfig(config);
ConfigService configService = ConfigServiceFactory.createConfigService(agentConfig, Collections.<String, Object>emptyMap());
ServiceManager serviceManager = new MockServiceManager(configService);
ServiceFactory.setServiceManager(serviceManager);
PointCutConfiguration pointCutConfiguration = new PointCutConfiguration("PointcutClassName", null, true, agentConfig.getClassTransformerConfig());
assertTrue(pointCutConfiguration.isEnabled());
}
use of com.newrelic.agent.service.ServiceManager in project newrelic-java-agent by newrelic.
the class ClassTransformerConfigImplTest method testPointcutDisabled.
@Test
public void testPointcutDisabled() {
Map<String, Object> configuration = new HashMap<>();
configuration.put("class_transformer:instrumentation_default:enabled", true);
configuration.put("class_transformer:my_pointcut_group:enabled", false);
configuration.put("app_name", "Unit Test");
configuration = buildConfigMap(configuration);
AgentConfig agentConfig = AgentConfigImpl.createAgentConfig(configuration);
ClassTransformerConfig classTransformerConfig = agentConfig.getClassTransformerConfig();
ConfigService configService = ConfigServiceFactory.createConfigService(agentConfig, Collections.<String, Object>emptyMap());
ServiceManager serviceManager = new MockServiceManager(configService);
ServiceFactory.setServiceManager(serviceManager);
PointCutConfiguration pointCutConfiguration = new PointCutConfiguration("name", "my_pointcut_group", true, classTransformerConfig);
assertFalse(pointCutConfiguration.isEnabled());
}
use of com.newrelic.agent.service.ServiceManager in project newrelic-java-agent by newrelic.
the class ClassTransformerConfigImplTest method testBuiltinExtension.
@Test
public void testBuiltinExtension() {
Map<String, Object> configuration = new HashMap<>();
configuration.put("class_transformer:instrumentation_default:enabled", false);
configuration.put("class_transformer:builtin_extensions:enabled", 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(agentConfig);
assertTrue(agentConfig.getClassTransformerConfig().isBuiltinExtensionEnabled());
}
use of com.newrelic.agent.service.ServiceManager in project newrelic-java-agent by newrelic.
the class MockCoreService method getMockAgentAndBootstrapTheServiceManager.
public static CoreService getMockAgentAndBootstrapTheServiceManager() throws Exception {
AgentHelper.initializeConfig();
MockCoreService mockCoreService = new MockCoreService();
mockCoreService.setInstrumentation(Mockito.mock(InstrumentationProxy.class));
Mockito.when(mockCoreService.getInstrumentation().getAllLoadedClasses()).thenReturn(new Class[] {});
ConfigService configService = ConfigServiceFactory.createConfigService(mock(Logger.class), false);
ServiceManager serviceManager = new ServiceManagerImpl(mockCoreService, configService);
ServiceFactory.setServiceManager(serviceManager);
serviceManager.start();
return mockCoreService;
}
use of com.newrelic.agent.service.ServiceManager in project newrelic-java-agent by newrelic.
the class SqlTraceServiceTest method afterTest.
@After
public void afterTest() throws Exception {
Transaction.clearTransaction();
ServiceManager serviceManager = ServiceFactory.getServiceManager();
if (serviceManager != null) {
serviceManager.stop();
}
}
Aggregations