Search in sources :

Example 71 with MockServiceManager

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

the class DataSenderImplConnectCycleTest method testFullPreconnectConnectCycleNoSecurity.

@Test
public void testFullPreconnectConnectCycleNoSecurity() 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"));
}
Also used : HashMap(java.util.HashMap) MockServiceManager(com.newrelic.agent.MockServiceManager) Test(org.junit.Test)

Example 72 with MockServiceManager

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

the class StackTracesTest method testToStringListRemoveParentNullParent.

@Test
public void testToStringListRemoveParentNullParent() {
    // need configuration service set
    MockServiceManager serviceManager = new MockServiceManager();
    ServiceFactory.setServiceManager(serviceManager);
    Map<String, Object> configMap = new HashMap<>();
    AgentConfig config = AgentConfigImpl.createAgentConfig(configMap);
    ConfigService configService = ConfigServiceFactory.createConfigService(config, configMap);
    serviceManager.setConfigService(configService);
    // get stack traces
    List<StackTraceElement> parentTrace = null;
    List<StackTraceElement> childTrace = generateStack(0, 10);
    List<String> trimmed = StackTraces.toStringListRemoveParent(childTrace, parentTrace);
    Assert.assertEquals(childTrace.size(), trimmed.size());
    for (int i = 0; i < childTrace.size(); i++) {
        Assert.assertEquals(childTrace.get(i).toString(), trimmed.get(i));
    }
}
Also used : AgentConfig(com.newrelic.agent.config.AgentConfig) ConfigService(com.newrelic.agent.config.ConfigService) HashMap(java.util.HashMap) MockServiceManager(com.newrelic.agent.MockServiceManager) Test(org.junit.Test)

Example 73 with MockServiceManager

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

the class AttributesServiceTest method setup.

@Before
public void setup() {
    try {
        manager = new MockServiceManager();
        ServiceFactory.setServiceManager(manager);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : MockServiceManager(com.newrelic.agent.MockServiceManager) Before(org.junit.Before)

Example 74 with MockServiceManager

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

the class HighSecurityAttributesTest method setup.

@Before
public void setup() {
    try {
        manager = new MockServiceManager();
        ServiceFactory.setServiceManager(manager);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : MockServiceManager(com.newrelic.agent.MockServiceManager) Before(org.junit.Before)

Example 75 with MockServiceManager

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

the class NoticeErrorAttributesTest method setup.

@Before
public void setup() {
    try {
        manager = new MockServiceManager();
        ServiceFactory.setServiceManager(manager);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : 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