use of com.newrelic.agent.MockServiceManager in project newrelic-java-agent by newrelic.
the class SameOrHigherPriorityTransactionNamingPolicyTest method createServiceManager.
private MockServiceManager createServiceManager() throws Exception {
MockServiceManager serviceManager = new MockServiceManager();
ServiceFactory.setServiceManager(serviceManager);
ThreadService threadService = new ThreadService();
serviceManager.setThreadService(threadService);
ImmutableMap<String, Object> distributedTracingSettings = ImmutableMap.<String, Object>builder().put(DistributedTracingConfig.ENABLED, Boolean.FALSE).build();
Map<String, Object> settings = new HashMap<>();
settings.put(AgentConfigImpl.DISTRIBUTED_TRACING, distributedTracingSettings);
ConfigService configService = ConfigServiceFactory.createConfigService(AgentConfigImpl.createAgentConfig(settings), settings);
serviceManager.setConfigService(configService);
HarvestService harvestService = new MockHarvestService();
serviceManager.setHarvestService(harvestService);
TransactionService transactionService = new TransactionService();
serviceManager.setTransactionService(transactionService);
TransactionTraceService transactionTraceService = new TransactionTraceService();
serviceManager.setTransactionTraceService(transactionTraceService);
SqlTraceService sqlTraceService = new SqlTraceServiceImpl();
serviceManager.setSqlTraceService(sqlTraceService);
MockRPMServiceManager rpmServiceManager = new MockRPMServiceManager();
serviceManager.setRPMServiceManager(rpmServiceManager);
return serviceManager;
}
use of com.newrelic.agent.MockServiceManager in project newrelic-java-agent by newrelic.
the class SegmentTest method createServiceManager.
private static void createServiceManager(Map<String, Object> map, ExpirationService expirationService) throws Exception {
MockServiceManager serviceManager = new MockServiceManager();
ServiceFactory.setServiceManager(serviceManager);
serviceManager.start();
ThreadService threadService = new ThreadService();
serviceManager.setThreadService(threadService);
AgentConfig agentConfig = AgentHelper.createAgentConfig(true, map, Collections.<String, Object>emptyMap());
ConfigService configService = ConfigServiceFactory.createConfigService(agentConfig, map);
serviceManager.setConfigService(configService);
StatsService statsService = new StatsServiceImpl();
serviceManager.setStatsService(statsService);
MockCoreService agent = new MockCoreService();
serviceManager.setCoreService(agent);
HarvestService harvestService = new MockHarvestService();
serviceManager.setHarvestService(harvestService);
AsyncTransactionService asyncTxService = new AsyncTransactionService();
serviceManager.setAsyncTransactionService(asyncTxService);
TransactionService transactionService = new TransactionService();
serviceManager.setTransactionService(transactionService);
EnvironmentService envService = new EnvironmentServiceImpl();
serviceManager.setEnvironmentService(envService);
TransactionTraceService transactionTraceService = new TransactionTraceService();
serviceManager.setTransactionTraceService(transactionTraceService);
SqlTraceService sqlTraceService = new SqlTraceServiceImpl();
serviceManager.setSqlTraceService(sqlTraceService);
serviceManager.setAttributesService(new AttributesService());
DistributedTraceServiceImpl distributedTraceService = new DistributedTraceServiceImpl();
serviceManager.setDistributedTraceService(distributedTraceService);
TransactionDataToDistributedTraceIntrinsics transactionDataToDistributedTraceIntrinsics = new TransactionDataToDistributedTraceIntrinsics(distributedTraceService);
serviceManager.setTransactionEventsService(new TransactionEventsService(transactionDataToDistributedTraceIntrinsics));
MockRPMServiceManager rpmServiceManager = new MockRPMServiceManager();
serviceManager.setRPMServiceManager(rpmServiceManager);
serviceManager.setExpirationService(expirationService);
}
use of com.newrelic.agent.MockServiceManager in project newrelic-java-agent by newrelic.
the class TransactionTimesTest method createServiceManager.
private static void createServiceManager(Map<String, Object> map) throws Exception {
MockServiceManager serviceManager = new MockServiceManager();
ServiceFactory.setServiceManager(serviceManager);
serviceManager.start();
ThreadService threadService = new ThreadService();
serviceManager.setThreadService(threadService);
AgentConfig agentConfig = AgentHelper.createAgentConfig(true, map, Collections.<String, Object>emptyMap());
ConfigService configService = ConfigServiceFactory.createConfigService(agentConfig, map);
serviceManager.setConfigService(configService);
MockCoreService agent = new MockCoreService();
serviceManager.setCoreService(agent);
HarvestService harvestService = new MockHarvestService();
serviceManager.setHarvestService(harvestService);
EnvironmentService envService = new EnvironmentServiceImpl();
serviceManager.setEnvironmentService(envService);
TransactionService transactionService = new TransactionService();
serviceManager.setTransactionService(transactionService);
StatsServiceImpl statsService = new StatsServiceImpl();
serviceManager.setStatsService(statsService);
TransactionTraceService transactionTraceService = new TransactionTraceService();
serviceManager.setTransactionTraceService(transactionTraceService);
SqlTraceService sqlTraceService = new SqlTraceServiceImpl();
serviceManager.setSqlTraceService(sqlTraceService);
serviceManager.setAttributesService(new AttributesService());
DistributedTraceServiceImpl distributedTraceService = new DistributedTraceServiceImpl();
serviceManager.setDistributedTraceService(distributedTraceService);
TransactionDataToDistributedTraceIntrinsics transactionDataToDistributedTraceIntrinsics = new TransactionDataToDistributedTraceIntrinsics(distributedTraceService);
serviceManager.setTransactionEventsService(new TransactionEventsService(transactionDataToDistributedTraceIntrinsics));
MockRPMServiceManager rpmServiceManager = new MockRPMServiceManager();
serviceManager.setRPMServiceManager(rpmServiceManager);
}
use of com.newrelic.agent.MockServiceManager in project newrelic-java-agent by newrelic.
the class DataSenderImplConnectCycleTest method testReconnectCycleNoSecurity.
@Test
public void testReconnectCycleNoSecurity() throws Exception {
MockitoAnnotations.initMocks(this);
final Map<String, Object> settings = new HashMap<>();
settings.put(AgentConfigImpl.APP_NAME, "Unit Test");
settings.put(AgentConfigImpl.HOST, "no-collector.example.com");
final MockServiceManager serviceManager = new MockServiceManager(ConfigServiceFactory.createConfigServiceUsingSettings(settings));
serviceManager.setStatsService(mockStatsService);
HttpClientWrapper wrapper = new ConnectCycleNoSecuritySuccessClientWrapper();
DataSenderImpl target = new DataSenderImpl(serviceManager.getConfigService().getDefaultAgentConfig(), wrapper, null, Agent.LOG, ServiceFactory.getConfigService());
target.setAgentRunId("agent run id");
Map<String, Object> startupOptions = new HashMap<>();
startupOptions.put("test-sentinel", "test-value");
Map<String, Object> result = target.connect(startupOptions);
assertEquals("my-run-id", target.getAgentRunId());
assertEquals("value", result.get("other"));
// This will assert that preconnect was called with the original host, not the redirect host.
target.connect(startupOptions);
}
use of com.newrelic.agent.MockServiceManager in project newrelic-java-agent by newrelic.
the class DataSenderImplConnectCycleTest method testFullPreconnectConnectCycleWithLasp.
@Test
public void testFullPreconnectConnectCycleWithLasp() throws Exception {
MockitoAnnotations.initMocks(this);
final Map<String, Object> settings = new HashMap<>();
settings.put(AgentConfigImpl.APP_NAME, "Unit Test");
settings.put(AgentConfigImpl.HOST, "no-collector.example.com");
settings.put(AgentConfigImpl.LASP_TOKEN, "ffff-ffff-ffff-ffff");
final MockServiceManager serviceManager = new MockServiceManager(ConfigServiceFactory.createConfigServiceUsingSettings(settings));
serviceManager.setStatsService(mockStatsService);
HttpClientWrapper wrapper = new ConnectCycleLaspSuccessClientWrapper();
DataSenderImpl target = new DataSenderImpl(serviceManager.getConfigService().getDefaultAgentConfig(), wrapper, null, Agent.LOG, ServiceFactory.getConfigService());
target.setAgentRunId("agent run id");
Map<String, Object> startupOptions = new HashMap<>();
startupOptions.put("test-sentinel", "test-value");
Map<String, Object> result = target.connect(startupOptions);
assertEquals("my-run-id", target.getAgentRunId());
assertEquals("value", result.get("other"));
}
Aggregations