Search in sources :

Example 31 with MockServiceManager

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

the class RandomTransactionSamplerTest method createServiceManager.

private void createServiceManager() throws Exception {
    MockServiceManager serviceManager = new MockServiceManager();
    ServiceFactory.setServiceManager(serviceManager);
    Map<String, Object> configMap = createConfigMap();
    ConfigService configService = ConfigServiceFactory.createConfigService(AgentConfigImpl.createAgentConfig(configMap), configMap);
    serviceManager.setConfigService(configService);
    DatabaseService dbService = new DatabaseService();
    serviceManager.setDatabaseService(dbService);
    TransactionTraceService ttService = new TransactionTraceService();
    serviceManager.setTransactionTraceService(ttService);
    AttributesService attService = new AttributesService();
    serviceManager.setAttributesService(attService);
}
Also used : ConfigService(com.newrelic.agent.config.ConfigService) MockServiceManager(com.newrelic.agent.MockServiceManager) AttributesService(com.newrelic.agent.attributes.AttributesService) DatabaseService(com.newrelic.agent.database.DatabaseService)

Example 32 with MockServiceManager

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

the class TransactionSegmentTest method testTransactionSegmentFilter.

@Test
public void testTransactionSegmentFilter() throws Exception {
    // Exclude red, yellow, and http.url attributes
    Map<String, Object> transactionSegmentsConfig = new HashMap<>();
    Map<String, Object> attributesMap = new HashMap<>();
    transactionSegmentsConfig.put("attributes", attributesMap);
    attributesMap.put("enabled", true);
    attributesMap.put("exclude", "red,yellow,http.url");
    MockServiceManager manager = setupServiceManager(transactionSegmentsConfig);
    Map<String, Object> tracerAttributes = new HashMap<>();
    tracerAttributes.put("red", "red");
    tracerAttributes.put("yellow", "yellow");
    tracerAttributes.put("green", "green");
    TransactionSegment segment = createSegment(manager, tracerAttributes);
    JSONArray array = (JSONArray) AgentHelper.serializeJSON(segment);
    Map<String, Object> attributes = (Map<String, Object>) array.get(3);
    Assert.assertEquals("green", attributes.get("green"));
    // Red and yellow should be filtered out
    Assert.assertNull(attributes.get("red"));
    Assert.assertNull(attributes.get("yellow"));
    Assert.assertNull(attributes.get("http.url"));
}
Also used : HashMap(java.util.HashMap) MockServiceManager(com.newrelic.agent.MockServiceManager) JSONArray(org.json.simple.JSONArray) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 33 with MockServiceManager

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

the class TransactionTraceBucketTest method createServiceManager.

private void createServiceManager(Map<String, Object> configMap) throws Exception {
    MockServiceManager serviceManager = new MockServiceManager();
    ServiceFactory.setServiceManager(serviceManager);
    AgentConfig agentConfig = createConfig(configMap);
    ConfigService configService = ConfigServiceFactory.createConfigService(agentConfig, configMap);
    serviceManager.setConfigService(configService);
    DatabaseService dbService = new DatabaseService();
    serviceManager.setDatabaseService(dbService);
    TransactionTraceService ttService = new TransactionTraceService();
    serviceManager.setTransactionTraceService(ttService);
    AttributesService attService = new AttributesService();
    serviceManager.setAttributesService(attService);
}
Also used : AgentConfig(com.newrelic.agent.config.AgentConfig) ConfigService(com.newrelic.agent.config.ConfigService) MockServiceManager(com.newrelic.agent.MockServiceManager) AttributesService(com.newrelic.agent.attributes.AttributesService) DatabaseService(com.newrelic.agent.database.DatabaseService)

Example 34 with MockServiceManager

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

the class ProfileTest method beforeClass.

@BeforeClass
public static void beforeClass() throws Exception {
    serviceManager = new MockServiceManager();
    ServiceFactory.setServiceManager(serviceManager);
    serviceManager.start();
    ThreadService threadService = new ThreadService();
    serviceManager.setThreadService(threadService);
    Map<String, Object> map = new HashMap<>();
    AgentConfig agentConfig = AgentConfigImpl.createAgentConfig(map);
    ConfigService configService = ConfigServiceFactory.createConfigService(agentConfig, map);
    serviceManager.setConfigService(configService);
    TransactionService transactionService = new TransactionService();
    serviceManager.setTransactionService(transactionService);
    threadNameNormalizer = new ThreadNameNormalizer(agentConfig, threadService);
}
Also used : ThreadService(com.newrelic.agent.ThreadService) AgentConfig(com.newrelic.agent.config.AgentConfig) ConfigService(com.newrelic.agent.config.ConfigService) TransactionService(com.newrelic.agent.TransactionService) HashMap(java.util.HashMap) MockServiceManager(com.newrelic.agent.MockServiceManager) ThreadNameNormalizer(com.newrelic.agent.threads.ThreadNameNormalizer) BeforeClass(org.junit.BeforeClass)

Example 35 with MockServiceManager

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

the class JmxObjectFactoryTest method setUpAgent.

@Before
public void setUpAgent() {
    serviceManager = new MockServiceManager();
    ServiceFactory.setServiceManager(serviceManager);
    AgentConfig config = AgentConfigImpl.createAgentConfig(Collections.<String, Object>emptyMap());
    ConfigService configService = ConfigServiceFactory.createConfigService(config, Collections.<String, Object>emptyMap());
    serviceManager.setConfigService(configService);
    serviceManager.setExtensionService(new ExtensionService(configService, ExtensionsLoadedListener.NOOP));
}
Also used : ExtensionService(com.newrelic.agent.extension.ExtensionService) AgentConfig(com.newrelic.agent.config.AgentConfig) ConfigService(com.newrelic.agent.config.ConfigService) MockServiceManager(com.newrelic.agent.MockServiceManager) Before(org.junit.Before)

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