use of com.newrelic.agent.service.ServiceManager in project newrelic-java-agent by newrelic.
the class AgentHelper method mockAgentConfig.
public static AgentConfig mockAgentConfig() {
ServiceManager serviceManger = Mockito.spy(ServiceFactory.getServiceManager());
ConfigService configService = Mockito.spy(serviceManger.getConfigService());
Mockito.doReturn(configService).when(serviceManger).getConfigService();
ServiceFactory.setServiceManager(serviceManger);
AgentConfig agentConfig = Mockito.spy(configService.getDefaultAgentConfig());
Mockito.doReturn(agentConfig).when(configService).getDefaultAgentConfig();
Mockito.doReturn(agentConfig).when(configService).getAgentConfig(anyString());
return agentConfig;
}
use of com.newrelic.agent.service.ServiceManager in project newrelic-java-agent by newrelic.
the class AgentHelper method mockAgentConfig.
public static AgentConfig mockAgentConfig(TransactionTracerConfig transactionTracerConfig) {
ServiceManager serviceManger = Mockito.spy(ServiceFactory.getServiceManager());
ConfigService configService = Mockito.spy(serviceManger.getConfigService());
Mockito.doReturn(configService).when(serviceManger).getConfigService();
ServiceFactory.setServiceManager(serviceManger);
AgentConfig agentConfig = Mockito.spy(configService.getDefaultAgentConfig());
Mockito.doReturn(agentConfig).when(configService).getDefaultAgentConfig();
Mockito.doReturn(agentConfig).when(configService).getAgentConfig(anyString());
Mockito.doReturn(transactionTracerConfig).when(configService).getTransactionTracerConfig(anyString());
return agentConfig;
}
use of com.newrelic.agent.service.ServiceManager in project newrelic-java-agent by newrelic.
the class TracedErrorTest method after.
@AfterClass
public static void after() throws Exception {
ServiceManager serviceManager = ServiceFactory.getServiceManager();
if (serviceManager != null) {
serviceManager.stop();
}
ServiceFactory.setServiceManager(null);
}
use of com.newrelic.agent.service.ServiceManager in project newrelic-java-agent by newrelic.
the class DefaultSqlTracerTest method getJSON.
private String getJSON(RecordSql recordSql) {
MockServiceManager serviceManager = new MockServiceManager();
serviceManager.setConfigService(new MockConfigService(AgentConfigFactory.createAgentConfig(Collections.<String, Object>emptyMap(), Collections.<String, Object>emptyMap(), null)));
ServiceManager originalServiceManager = ServiceFactory.getServiceManager();
try {
ServiceFactory.setServiceManager(serviceManager);
Transaction transaction = mock(Transaction.class);
TransactionActivity txa = mock(TransactionActivity.class);
when(transaction.getTransactionActivity()).thenReturn(txa);
when(txa.getTransaction()).thenReturn(transaction);
TransactionTracerConfig ttConfig = mock(TransactionTracerConfig.class);
when(ttConfig.getRecordSql()).thenReturn(recordSql.toString());
when(transaction.getTransactionTracerConfig()).thenReturn(ttConfig);
ClassMethodSignature sig = new ClassMethodSignature("", "", "");
DefaultSqlTracer tracer = new DefaultSqlTracer(transaction, sig, new Object(), new SimpleMetricNameFormat("BoundedConcurrentCacheTest"), TracerFlags.GENERATE_SCOPED_METRIC);
tracer.setRawSql("select * from user where ssn = ?");
tracer.setParams(new Object[] { 666666666 });
Object sqlObject = tracer.getSql();
return sqlObject.toString();
} finally {
ServiceFactory.setServiceManager(originalServiceManager);
}
}
use of com.newrelic.agent.service.ServiceManager in project newrelic-java-agent by newrelic.
the class BasicRequestDispatcherTracerTest method statusCodePolicyProperty.
@Test
public void statusCodePolicyProperty() throws Exception {
ServiceManager old = ServiceFactory.getServiceManager();
Map<String, Object> configMap = createConfigMap(0);
configMap.put(HiddenProperties.LAST_STATUS_CODE_POLICY, false);
createServiceManager(AgentConfigImpl.createAgentConfig(configMap), configMap);
MockHttpRequest httpRequest = new MockHttpRequest();
WebRequestDispatcher dispatcher = createDispatcher(httpRequest);
dispatcher.setStatus(404);
dispatcher.setStatus(200);
Assert.assertEquals(404, dispatcher.getStatus());
ServiceFactory.getServiceManager().stop();
ServiceFactory.setServiceManager(old);
}
Aggregations