Search in sources :

Example 16 with ThreadService

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);
}
Also used : SqlTraceServiceImpl(com.newrelic.agent.sql.SqlTraceServiceImpl) MockHarvestService(com.newrelic.agent.MockHarvestService) HarvestService(com.newrelic.agent.HarvestService) AsyncTransactionService(com.newrelic.agent.service.async.AsyncTransactionService) TransactionService(com.newrelic.agent.TransactionService) StatsService(com.newrelic.agent.stats.StatsService) DistributedTraceServiceImpl(com.newrelic.agent.tracing.DistributedTraceServiceImpl) AttributesService(com.newrelic.agent.attributes.AttributesService) MockRPMServiceManager(com.newrelic.agent.MockRPMServiceManager) AsyncTransactionService(com.newrelic.agent.service.async.AsyncTransactionService) TransactionTraceService(com.newrelic.agent.trace.TransactionTraceService) TransactionDataToDistributedTraceIntrinsics(com.newrelic.agent.service.analytics.TransactionDataToDistributedTraceIntrinsics) ThreadService(com.newrelic.agent.ThreadService) AgentConfig(com.newrelic.agent.config.AgentConfig) SqlTraceService(com.newrelic.agent.sql.SqlTraceService) ConfigService(com.newrelic.agent.config.ConfigService) EnvironmentServiceImpl(com.newrelic.agent.environment.EnvironmentServiceImpl) StatsServiceImpl(com.newrelic.agent.stats.StatsServiceImpl) MockServiceManager(com.newrelic.agent.MockServiceManager) TransactionEventsService(com.newrelic.agent.service.analytics.TransactionEventsService) MockCoreService(com.newrelic.agent.MockCoreService) MockHarvestService(com.newrelic.agent.MockHarvestService) EnvironmentService(com.newrelic.agent.environment.EnvironmentService)

Example 17 with ThreadService

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);
}
Also used : SqlTraceServiceImpl(com.newrelic.agent.sql.SqlTraceServiceImpl) MockHarvestService(com.newrelic.agent.MockHarvestService) HarvestService(com.newrelic.agent.HarvestService) TransactionService(com.newrelic.agent.TransactionService) DistributedTraceServiceImpl(com.newrelic.agent.tracing.DistributedTraceServiceImpl) AttributesService(com.newrelic.agent.attributes.AttributesService) MockRPMServiceManager(com.newrelic.agent.MockRPMServiceManager) TransactionTraceService(com.newrelic.agent.trace.TransactionTraceService) TransactionDataToDistributedTraceIntrinsics(com.newrelic.agent.service.analytics.TransactionDataToDistributedTraceIntrinsics) ThreadService(com.newrelic.agent.ThreadService) AgentConfig(com.newrelic.agent.config.AgentConfig) SqlTraceService(com.newrelic.agent.sql.SqlTraceService) ConfigService(com.newrelic.agent.config.ConfigService) EnvironmentServiceImpl(com.newrelic.agent.environment.EnvironmentServiceImpl) StatsServiceImpl(com.newrelic.agent.stats.StatsServiceImpl) MockServiceManager(com.newrelic.agent.MockServiceManager) TransactionEventsService(com.newrelic.agent.service.analytics.TransactionEventsService) MockCoreService(com.newrelic.agent.MockCoreService) MockHarvestService(com.newrelic.agent.MockHarvestService) EnvironmentService(com.newrelic.agent.environment.EnvironmentService)

Example 18 with ThreadService

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);
}
Also used : AgentConfig(com.newrelic.agent.config.AgentConfig) ThreadService(com.newrelic.agent.ThreadService) MockServiceManager(com.newrelic.agent.MockServiceManager) MockConfigService(com.newrelic.agent.MockConfigService) UtilizationDataConfig(com.newrelic.agent.config.UtilizationDataConfig) Before(org.junit.Before)

Example 19 with ThreadService

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);
}
Also used : TransactionService(com.newrelic.agent.TransactionService) ErrorServiceImpl(com.newrelic.agent.errors.ErrorServiceImpl) StatsService(com.newrelic.agent.stats.StatsService) AttributesService(com.newrelic.agent.attributes.AttributesService) MockRPMServiceManager(com.newrelic.agent.MockRPMServiceManager) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) TransactionTraceService(com.newrelic.agent.trace.TransactionTraceService) ThreadService(com.newrelic.agent.ThreadService) MockConfigService(com.newrelic.agent.MockConfigService) ConfigService(com.newrelic.agent.config.ConfigService) MockServiceManager(com.newrelic.agent.MockServiceManager) MockCoreService(com.newrelic.agent.MockCoreService) MockRPMService(com.newrelic.agent.MockRPMService)

Example 20 with ThreadService

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();
}
Also used : AgentConfig(com.newrelic.agent.config.AgentConfig) Returns(org.mockito.internal.stubbing.answers.Returns) ThreadService(com.newrelic.agent.ThreadService) ConfigService(com.newrelic.agent.config.ConfigService) MockServiceManager(com.newrelic.agent.MockServiceManager) Environment(com.newrelic.agent.environment.Environment) EnvironmentService(com.newrelic.agent.environment.EnvironmentService) BeforeClass(org.junit.BeforeClass)

Aggregations

ThreadService (com.newrelic.agent.ThreadService)37 MockServiceManager (com.newrelic.agent.MockServiceManager)34 ConfigService (com.newrelic.agent.config.ConfigService)32 TransactionService (com.newrelic.agent.TransactionService)30 TransactionTraceService (com.newrelic.agent.trace.TransactionTraceService)24 MockRPMServiceManager (com.newrelic.agent.MockRPMServiceManager)23 HarvestService (com.newrelic.agent.HarvestService)21 MockHarvestService (com.newrelic.agent.MockHarvestService)18 AgentConfig (com.newrelic.agent.config.AgentConfig)18 MockCoreService (com.newrelic.agent.MockCoreService)17 SqlTraceService (com.newrelic.agent.sql.SqlTraceService)16 SqlTraceServiceImpl (com.newrelic.agent.sql.SqlTraceServiceImpl)16 MockRPMService (com.newrelic.agent.MockRPMService)15 AttributesService (com.newrelic.agent.attributes.AttributesService)13 StatsService (com.newrelic.agent.stats.StatsService)13 StatsServiceImpl (com.newrelic.agent.stats.StatsServiceImpl)13 ErrorServiceImpl (com.newrelic.agent.errors.ErrorServiceImpl)12 EnvironmentService (com.newrelic.agent.environment.EnvironmentService)8 HashMap (java.util.HashMap)8 EnvironmentServiceImpl (com.newrelic.agent.environment.EnvironmentServiceImpl)7