Search in sources :

Example 1 with PointCutConfiguration

use of com.newrelic.agent.instrumentation.PointCutConfiguration in project newrelic-java-agent by newrelic.

the class ClassTransformerConfigImplTest method testPointcutGroupDisabled.

@Test
public void testPointcutGroupDisabled() {
    Map<String, Object> configuration = new HashMap<>();
    configuration.put("class_transformer:my_pointcut_group:enabled", true);
    configuration.put("class_transformer:instrumentation_default:enabled", 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);
    PointCutConfiguration pointCutConfiguration = new PointCutConfiguration("PointcutClassName", "my_pointcut_group", true, agentConfig.getClassTransformerConfig());
    assertTrue(pointCutConfiguration.isEnabled());
}
Also used : HashMap(java.util.HashMap) MockServiceManager(com.newrelic.agent.MockServiceManager) ServiceManager(com.newrelic.agent.service.ServiceManager) MockServiceManager(com.newrelic.agent.MockServiceManager) PointCutConfiguration(com.newrelic.agent.instrumentation.PointCutConfiguration) Test(org.junit.Test)

Example 2 with PointCutConfiguration

use of com.newrelic.agent.instrumentation.PointCutConfiguration 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());
}
Also used : HashMap(java.util.HashMap) MockServiceManager(com.newrelic.agent.MockServiceManager) ServiceManager(com.newrelic.agent.service.ServiceManager) MockServiceManager(com.newrelic.agent.MockServiceManager) PointCutConfiguration(com.newrelic.agent.instrumentation.PointCutConfiguration) Test(org.junit.Test)

Example 3 with PointCutConfiguration

use of com.newrelic.agent.instrumentation.PointCutConfiguration 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());
}
Also used : HashMap(java.util.HashMap) MockServiceManager(com.newrelic.agent.MockServiceManager) ServiceManager(com.newrelic.agent.service.ServiceManager) MockServiceManager(com.newrelic.agent.MockServiceManager) PointCutConfiguration(com.newrelic.agent.instrumentation.PointCutConfiguration) Test(org.junit.Test)

Example 4 with PointCutConfiguration

use of com.newrelic.agent.instrumentation.PointCutConfiguration in project newrelic-java-agent by newrelic.

the class ClassTransformerConfigImplTest method testPointcutEnabled.

@Test
public void testPointcutEnabled() {
    Map<String, Object> classTransformerMap = new HashMap<>();
    ClassTransformerConfig config = ClassTransformerConfigImpl.createClassTransformerConfig(classTransformerMap, true, false);
    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);
    PointCutConfiguration pointCutConfiguration = new PointCutConfiguration("name", null, true, config);
    assertTrue(pointCutConfiguration.isEnabled());
}
Also used : HashMap(java.util.HashMap) MockServiceManager(com.newrelic.agent.MockServiceManager) ServiceManager(com.newrelic.agent.service.ServiceManager) MockServiceManager(com.newrelic.agent.MockServiceManager) PointCutConfiguration(com.newrelic.agent.instrumentation.PointCutConfiguration) Test(org.junit.Test)

Aggregations

MockServiceManager (com.newrelic.agent.MockServiceManager)4 PointCutConfiguration (com.newrelic.agent.instrumentation.PointCutConfiguration)4 ServiceManager (com.newrelic.agent.service.ServiceManager)4 HashMap (java.util.HashMap)4 Test (org.junit.Test)4