use of com.newrelic.agent.ThreadService 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.ThreadService 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.ThreadService in project newrelic-java-agent by newrelic.
the class UtilizationServiceTest method before.
@Before
public void before() {
MockServiceManager mockServiceManager = new MockServiceManager();
config = mock(AgentConfig.class);
MockConfigService configService = new MockConfigService(null);
configService.setAgentConfig(config);
ServiceFactory.setServiceManager(mockServiceManager);
mockServiceManager.setConfigService(configService);
ThreadService mockThreadService = mock(ThreadService.class);
mockServiceManager.setThreadService(mockThreadService);
// Do not make AWS/Azure/GCP/PCF calls. Unit tests should work even without internet connection :)
when(config.getValue(UtilizationService.DETECT_DOCKER_KEY, true)).thenReturn(false);
when(config.getValue(UtilizationService.DETECT_AWS_KEY, true)).thenReturn(false);
when(config.getValue(UtilizationService.DETECT_AZURE_KEY, true)).thenReturn(false);
when(config.getValue(UtilizationService.DETECT_GOOGLE_CLOUD_PROVIDER_KEY, true)).thenReturn(false);
when(config.getValue(UtilizationService.DETECT_PIVOTAL_CLOUD_FOUNDRY_KEY, true)).thenReturn(false);
when(config.getValue(UtilizationService.DETECT_KUBERNETES_KEY, true)).thenReturn(false);
UtilizationDataConfig utilDataConfig = mock(UtilizationDataConfig.class);
when(config.getUtilizationDataConfig()).thenReturn(utilDataConfig);
}
use of com.newrelic.agent.ThreadService 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.ThreadService in project newrelic-java-agent by newrelic.
the class RPMConnectionServiceTest method beforeClass.
@BeforeClass
public static void beforeClass() throws Exception {
AgentHelper.initializeConfig();
MockServiceManager serviceManager = new MockServiceManager();
ServiceFactory.setServiceManager(serviceManager);
serviceManager.start();
Map<String, Object> settings = AgentConfigFactoryTest.createStagingMap();
AgentConfig config = AgentConfigFactory.createAgentConfig(settings, null, null);
Environment env = new Environment(config, "c:\\test\\log");
EnvironmentService envService = Mockito.mock(EnvironmentService.class, new Returns(env));
serviceManager.setEnvironmentService(envService);
ConfigService configService = ConfigServiceFactory.createConfigServiceUsingSettings(settings);
serviceManager.setConfigService(configService);
ThreadService threadService = new ThreadService();
serviceManager.setThreadService(threadService);
rpmConnectionService = new TestRPMConnectionService();
}
Aggregations