Search in sources :

Example 21 with MockServiceManager

use of com.newrelic.agent.MockServiceManager in project newrelic-java-agent by newrelic.

the class TransactionTraceTest method setUp.

private void setUp(boolean isCaptureAtts, boolean captureRequestAtts, boolean requestUri, boolean simpleCompression) throws Exception {
    iAgentConfig = mock(AgentConfig.class);
    TransactionTracerConfig transTracerConfig = mock(TransactionTracerConfig.class);
    when(iAgentConfig.getTransactionTracerConfig()).thenReturn(transTracerConfig);
    when(iAgentConfig.isSimpleCompression()).thenReturn(simpleCompression);
    MockServiceManager manager = new MockServiceManager();
    ServiceFactory.setServiceManager(manager);
    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);
    setConfigAttributes(settings, isCaptureAtts, captureRequestAtts, requestUri, simpleCompression);
    ConfigService cService = new MockConfigService(AgentConfigImpl.createAgentConfig(settings));
    manager.setConfigService(cService);
    manager.setTransactionTraceService(new TransactionTraceService());
    manager.setTransactionService(new TransactionService());
    manager.setAttributesService(new AttributesService());
}
Also used : TransactionService(com.newrelic.agent.TransactionService) HashMap(java.util.HashMap) AttributesService(com.newrelic.agent.attributes.AttributesService) MockConfigService(com.newrelic.agent.MockConfigService) AgentConfig(com.newrelic.agent.config.AgentConfig) MockConfigService(com.newrelic.agent.MockConfigService) ConfigService(com.newrelic.agent.config.ConfigService) MockServiceManager(com.newrelic.agent.MockServiceManager) JSONObject(org.json.simple.JSONObject) TransactionTracerConfig(com.newrelic.agent.config.TransactionTracerConfig)

Example 22 with MockServiceManager

use of com.newrelic.agent.MockServiceManager in project newrelic-java-agent by newrelic.

the class TransactionEventsServiceTest method setup.

private void setup(boolean enabled, boolean isAttsEnabled, int size) throws Exception {
    MockServiceManager manager = new MockServiceManager();
    ServiceFactory.setServiceManager(manager);
    Map<String, Object> settings = new HashMap<>();
    settings.put("app_name", APP_NAME);
    Map<String, Object> events = new HashMap<>();
    settings.put("transaction_events", events);
    events.put("max_samples_stored", size);
    events.put("enabled", enabled);
    Map<String, Object> atts = new HashMap<>();
    settings.put("attributes", atts);
    atts.put("enabled", isAttsEnabled);
    Map<String, Object> distributedTracing = new HashMap<>();
    distributedTracing.put("enabled", true);
    settings.put("distributed_tracing", distributedTracing);
    Map<String, Object> spanConfig = new HashMap<>();
    spanConfig.put("collect_span_events", true);
    settings.put("span_events", spanConfig);
    iAgentConfig = AgentConfigImpl.createAgentConfig(settings);
    configService = ConfigServiceFactory.createConfigService(iAgentConfig, settings);
    manager.setConfigService(configService);
    TransactionTraceService transactionTraceService = new TransactionTraceService();
    manager.setTransactionTraceService(transactionTraceService);
    environmentService = new EnvironmentServiceImpl();
    manager.setEnvironmentService(environmentService);
    AttributesService attService = new AttributesService();
    manager.setAttributesService(attService);
    TransactionService transactionService = new TransactionService();
    manager.setTransactionService(transactionService);
    StatsService statsService = new StatsServiceImpl();
    manager.setStatsService(statsService);
    HarvestService harvestService = new MockHarvestService();
    manager.setHarvestService(harvestService);
    // manager.setTransactionEventsService(new TransactionEventsService(mockDistributedTraceIntrinsics));
    DistributedTraceServiceImpl distributedTraceService = new DistributedTraceServiceImpl();
    Map<String, Object> connectInfo = new HashMap<>();
    connectInfo.put(DistributedTracingConfig.ACCOUNT_ID, "1acct234");
    connectInfo.put(DistributedTracingConfig.TRUSTED_ACCOUNT_KEY, "67890");
    AgentConfig agentConfig = AgentHelper.createAgentConfig(true, Collections.<String, Object>emptyMap(), connectInfo);
    distributedTraceService.connected(null, agentConfig);
    manager.setDistributedTraceService(distributedTraceService);
    rpmServiceManager = new MockRPMServiceManager();
    rpmService = new MockRPMService();
    rpmService.setApplicationName(APP_NAME);
    rpmServiceManager.setRPMService(rpmService);
    ErrorServiceImpl errorService = new ErrorServiceImpl(APP_NAME);
    rpmService.setErrorService(errorService);
    rpmServiceAppName2 = (MockRPMService) rpmServiceManager.getOrCreateRPMService(APP_NAME_2);
    rpmServiceAppName2.setErrorService(new ErrorServiceImpl(APP_NAME_2));
    mockDistributedTraceIntrinsics = mock(TransactionDataToDistributedTraceIntrinsics.class);
    service = new TransactionEventsService(mockDistributedTraceIntrinsics);
    manager.setTransactionEventsService(service);
    manager.setRPMServiceManager(rpmServiceManager);
    service.addHarvestableToService(APP_NAME);
    service.doStart();
}
Also used : TransactionService(com.newrelic.agent.TransactionService) MockHarvestService(com.newrelic.agent.MockHarvestService) HarvestService(com.newrelic.agent.HarvestService) ErrorServiceImpl(com.newrelic.agent.errors.ErrorServiceImpl) HashMap(java.util.HashMap) StatsService(com.newrelic.agent.stats.StatsService) DistributedTraceServiceImpl(com.newrelic.agent.tracing.DistributedTraceServiceImpl) AttributesService(com.newrelic.agent.attributes.AttributesService) MockRPMServiceManager(com.newrelic.agent.MockRPMServiceManager) TransactionTraceService(com.newrelic.agent.trace.TransactionTraceService) AgentConfig(com.newrelic.agent.config.AgentConfig) EnvironmentServiceImpl(com.newrelic.agent.environment.EnvironmentServiceImpl) StatsServiceImpl(com.newrelic.agent.stats.StatsServiceImpl) MockServiceManager(com.newrelic.agent.MockServiceManager) MockHarvestService(com.newrelic.agent.MockHarvestService) MockRPMService(com.newrelic.agent.MockRPMService)

Example 23 with MockServiceManager

use of com.newrelic.agent.MockServiceManager in project newrelic-java-agent by newrelic.

the class DeadlockServiceTest method testServiceEnabledExplicitly.

@Test
public void testServiceEnabledExplicitly() {
    MockServiceManager mockServiceManager = new MockServiceManager();
    ServiceFactory.setServiceManager(mockServiceManager);
    mockServiceManager.setConfigService(Mockito.mock(ConfigService.class));
    Map<String, Object> root = new HashMap<>();
    Map<String, Object> deadlockDetector = new HashMap<>();
    deadlockDetector.put("enabled", true);
    root.put("deadlock_detector", deadlockDetector);
    AgentConfig config = AgentConfigImpl.createAgentConfig(root);
    Mockito.when(ServiceFactory.getConfigService().getDefaultAgentConfig()).thenReturn(config);
    DeadlockDetectorService dds = new DeadlockDetectorService();
    Assert.assertTrue(dds.isEnabled());
}
Also used : AgentConfig(com.newrelic.agent.config.AgentConfig) ConfigService(com.newrelic.agent.config.ConfigService) HashMap(java.util.HashMap) MockServiceManager(com.newrelic.agent.MockServiceManager) DeadlockDetectorService(com.newrelic.agent.deadlock.DeadlockDetectorService) Test(org.junit.Test)

Example 24 with MockServiceManager

use of com.newrelic.agent.MockServiceManager in project newrelic-java-agent by newrelic.

the class StatsServiceTest method createServiceManager.

private MockServiceManager createServiceManager(Map<String, Object> map) throws Exception {
    MockServiceManager serviceManager = new MockServiceManager();
    ServiceFactory.setServiceManager(serviceManager);
    ConfigService configService = ConfigServiceFactory.createConfigService(AgentConfigImpl.createAgentConfig(map), map);
    serviceManager.setConfigService(configService);
    ThreadService threadService = new ThreadService();
    serviceManager.setThreadService(threadService);
    MockRPMServiceManager rpmServiceManager = new MockRPMServiceManager();
    serviceManager.setRPMServiceManager(rpmServiceManager);
    StatsService statsService = new StatsServiceImpl();
    statsService.start();
    serviceManager.setStatsService(statsService);
    return serviceManager;
}
Also used : ThreadService(com.newrelic.agent.ThreadService) ConfigService(com.newrelic.agent.config.ConfigService) MockServiceManager(com.newrelic.agent.MockServiceManager) MockRPMServiceManager(com.newrelic.agent.MockRPMServiceManager)

Example 25 with MockServiceManager

use of com.newrelic.agent.MockServiceManager in project newrelic-java-agent by newrelic.

the class RumStreamParserTest 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);
    ConfigService configService = ConfigServiceFactory.createConfigService(AgentConfigImpl.createAgentConfig(map), map);
    serviceManager.setConfigService(configService);
    MockCoreService agent = new MockCoreService();
    serviceManager.setCoreService(agent);
    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);
    MockRPMService rpmService = new MockRPMService();
    rpmService.setApplicationName(APP_NAME);
    rpmService.setErrorService(new ErrorServiceImpl(APP_NAME));
    rpmServiceManager.setRPMService(rpmService);
    configService.start();
    serviceManager.setNormalizationService(new NormalizationServiceImpl());
    StatsService statsService = new StatsServiceImpl();
    serviceManager.setStatsService(statsService);
    statsService.start();
}
Also used : SqlTraceServiceImpl(com.newrelic.agent.sql.SqlTraceServiceImpl) MockHarvestService(com.newrelic.agent.MockHarvestService) HarvestService(com.newrelic.agent.HarvestService) TransactionService(com.newrelic.agent.TransactionService) ErrorServiceImpl(com.newrelic.agent.errors.ErrorServiceImpl) StatsService(com.newrelic.agent.stats.StatsService) MockRPMServiceManager(com.newrelic.agent.MockRPMServiceManager) TransactionTraceService(com.newrelic.agent.trace.TransactionTraceService) ThreadService(com.newrelic.agent.ThreadService) SqlTraceService(com.newrelic.agent.sql.SqlTraceService) ConfigService(com.newrelic.agent.config.ConfigService) StatsServiceImpl(com.newrelic.agent.stats.StatsServiceImpl) MockServiceManager(com.newrelic.agent.MockServiceManager) MockCoreService(com.newrelic.agent.MockCoreService) MockHarvestService(com.newrelic.agent.MockHarvestService) MockRPMService(com.newrelic.agent.MockRPMService) NormalizationServiceImpl(com.newrelic.agent.normalization.NormalizationServiceImpl)

Aggregations

MockServiceManager (com.newrelic.agent.MockServiceManager)127 ConfigService (com.newrelic.agent.config.ConfigService)61 Test (org.junit.Test)49 MockRPMServiceManager (com.newrelic.agent.MockRPMServiceManager)48 HashMap (java.util.HashMap)44 TransactionService (com.newrelic.agent.TransactionService)42 MockRPMService (com.newrelic.agent.MockRPMService)37 ThreadService (com.newrelic.agent.ThreadService)34 AgentConfig (com.newrelic.agent.config.AgentConfig)34 AttributesService (com.newrelic.agent.attributes.AttributesService)28 HarvestService (com.newrelic.agent.HarvestService)27 TransactionTraceService (com.newrelic.agent.trace.TransactionTraceService)27 MockHarvestService (com.newrelic.agent.MockHarvestService)26 MockCoreService (com.newrelic.agent.MockCoreService)21 StatsService (com.newrelic.agent.stats.StatsService)21 StatsServiceImpl (com.newrelic.agent.stats.StatsServiceImpl)21 Before (org.junit.Before)19 ErrorServiceImpl (com.newrelic.agent.errors.ErrorServiceImpl)16 SqlTraceServiceImpl (com.newrelic.agent.sql.SqlTraceServiceImpl)16 SqlTraceService (com.newrelic.agent.sql.SqlTraceService)15