use of com.newrelic.agent.MockServiceManager in project newrelic-java-agent by newrelic.
the class BrowserTransactionStateTest method createServiceManager.
public static void createServiceManager(Set<String> include, Set<String> exclude) throws Exception {
MockServiceManager serviceManager = new MockServiceManager();
ServiceFactory.setServiceManager(serviceManager);
// Needed by TransactionService
ThreadService threadService = new ThreadService();
serviceManager.setThreadService(threadService);
// Needed by TransactionTraceService
Map<String, Object> map = createConfigMap(include, exclude);
ConfigService configService = ConfigServiceFactory.createConfigService(AgentConfigImpl.createAgentConfig(map), map);
serviceManager.setConfigService(configService);
// Needed by Transaction
TransactionService transactionService = new TransactionService();
serviceManager.setTransactionService(transactionService);
MockCoreService agent = new MockCoreService();
serviceManager.setCoreService(agent);
// Null pointers if not set
serviceManager.setStatsService(Mockito.mock(StatsService.class));
// Needed by Transaction
TransactionTraceService transactionTraceService = new TransactionTraceService();
serviceManager.setTransactionTraceService(transactionTraceService);
// Needed by Transaction
MockRPMServiceManager rpmServiceManager = new MockRPMServiceManager();
serviceManager.setRPMServiceManager(rpmServiceManager);
MockRPMService rpmService = new MockRPMService();
rpmService.setApplicationName("name");
rpmService.setErrorService(new ErrorServiceImpl("name"));
rpmServiceManager.setRPMService(rpmService);
AttributesService attService = new AttributesService();
serviceManager.setAttributesService(attService);
ServiceFactory.setServiceManager(serviceManager);
}
use of com.newrelic.agent.MockServiceManager in project newrelic-java-agent by newrelic.
the class CircuitBreakerServiceTest method setup.
@BeforeClass
public static void setup() {
MockServiceManager serviceManager = new MockServiceManager();
ServiceFactory.setServiceManager(serviceManager);
try {
serviceManager.start();
} catch (Exception e) {
throw new RuntimeException(e);
}
AgentBridge.instrumentation = new InstrumentationImpl(Agent.LOG);
AgentBridge.agent = new AgentImpl(Agent.LOG);
}
use of com.newrelic.agent.MockServiceManager in project newrelic-java-agent by newrelic.
the class LaspHighSecurityTest method laspAndHsmEnabled.
@Test
public void laspAndHsmEnabled() throws ConfigurationException {
Map<String, Object> settings = createSecurityProps();
ConfigService configService = ConfigServiceFactory.createConfigServiceUsingSettings(settings);
ServiceManager serviceManager = new MockServiceManager(configService);
ServiceFactory.setServiceManager(serviceManager);
AgentConfig agentConfig = AgentConfigFactory.createAgentConfig(settings, null, null);
assertTrue(agentConfig.laspEnabled());
assertTrue(agentConfig.isHighSecurity());
try {
ConfigServiceFactory.validateConfig(agentConfig);
fail();
} catch (ForceDisconnectException ex) {
}
}
use of com.newrelic.agent.MockServiceManager in project newrelic-java-agent by newrelic.
the class ClassTransformerConfigImplTest method testLitemode.
@Test
public void testLitemode() {
AgentConfig agentConfig = AgentConfigImpl.createAgentConfig(ImmutableMap.<String, Object>of("lite_mode", true, "app_name", "Unit Test"));
ConfigService configService = ConfigServiceFactory.createConfigService(agentConfig, Collections.<String, Object>emptyMap());
ServiceManager serviceManager = new MockServiceManager(configService);
ServiceFactory.setServiceManager(serviceManager);
ClassTransformerConfig classTransformerConfig = serviceManager.getConfigService().getDefaultAgentConfig().getClassTransformerConfig();
assertFalse(classTransformerConfig.isDefaultInstrumentationEnabled());
assertFalse(classTransformerConfig.isBuiltinExtensionEnabled());
}
use of com.newrelic.agent.MockServiceManager 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());
}
Aggregations