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"));
}
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));
}
}
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();
}
}
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();
}
}
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();
}
}
Aggregations