use of com.newrelic.agent.MockRPMService in project newrelic-java-agent by newrelic.
the class RequestUriConfigTests method runTransactionTraceTest.
public void runTransactionTraceTest(RequestUriConfigTransactionTest test) throws Exception {
setupConfig(test);
// run a transaction
Tracer requestDispatcherTracer = startDispatcherTracer(test.getTxnName());
startTracer().finish(Opcodes.RETURN, null);
requestDispatcherTracer.finish(Opcodes.RETURN, null);
MockRPMService mockRPMService = runHarvest();
// verify results
List<TransactionTrace> transactionTraces = mockRPMService.getTraces();
assertFalse(transactionTraces.isEmpty());
matchUri(test.getExpectedUriValues(), transactionTraces.get(0).getRequestUri());
}
use of com.newrelic.agent.MockRPMService in project newrelic-java-agent by newrelic.
the class RequestUriConfigTests method runHarvest.
public MockRPMService runHarvest() {
MockHarvestService mockharvestService = (MockHarvestService) ServiceFactory.getHarvestService();
mockharvestService.runHarvest(ServiceFactory.getConfigService().getDefaultAgentConfig().getApplicationName(), new StatsEngineImpl());
return (MockRPMService) ServiceFactory.getRPMService();
}
use of com.newrelic.agent.MockRPMService in project newrelic-java-agent by newrelic.
the class BrowserTransactionStateTest method createServiceManager.
public static void createServiceManager(Set<String> include, Set<String> exclude) throws Exception {
MockServiceManager serviceManager = new MockServiceManager();
ServiceFactory.setServiceManager(serviceManager);
// Needed by TransactionService
ThreadService threadService = new ThreadService();
serviceManager.setThreadService(threadService);
// Needed by TransactionTraceService
Map<String, Object> map = createConfigMap(include, exclude);
ConfigService configService = ConfigServiceFactory.createConfigService(AgentConfigImpl.createAgentConfig(map), map);
serviceManager.setConfigService(configService);
// Needed by Transaction
TransactionService transactionService = new TransactionService();
serviceManager.setTransactionService(transactionService);
MockCoreService agent = new MockCoreService();
serviceManager.setCoreService(agent);
// Null pointers if not set
serviceManager.setStatsService(Mockito.mock(StatsService.class));
// Needed by Transaction
TransactionTraceService transactionTraceService = new TransactionTraceService();
serviceManager.setTransactionTraceService(transactionTraceService);
// Needed by Transaction
MockRPMServiceManager rpmServiceManager = new MockRPMServiceManager();
serviceManager.setRPMServiceManager(rpmServiceManager);
MockRPMService rpmService = new MockRPMService();
rpmService.setApplicationName("name");
rpmService.setErrorService(new ErrorServiceImpl("name"));
rpmServiceManager.setRPMService(rpmService);
AttributesService attService = new AttributesService();
serviceManager.setAttributesService(attService);
ServiceFactory.setServiceManager(serviceManager);
}
use of com.newrelic.agent.MockRPMService in project newrelic-java-agent by newrelic.
the class CommandParserTest method restart.
@Test
public void restart() throws Exception {
CountDownLatch latch = new CountDownLatch(1);
MockRPMService rpmService = new MockRPMService();
List<List<?>> commands = new ArrayList<>();
commands.add(createCommand(1, RestartCommand.COMMAND_NAME));
commandParser.processCommands(rpmService, commands);
Assert.assertEquals(1, rpmService.getRestartCount());
Assert.assertEquals(0, agentControl.getShutdownCount());
}
use of com.newrelic.agent.MockRPMService in project newrelic-java-agent by newrelic.
the class CommandParserTest method shutdown.
@Test
public void shutdown() {
MockRPMService rpmService = new MockRPMService();
for (int i = 0; i < 5; i++) {
List<List<?>> commands = new ArrayList<>();
commands.add(createCommand(1, ShutdownCommand.COMMAND_NAME));
commandParser.processCommands(rpmService, commands);
}
Assert.assertEquals(0, rpmService.getRestartCount());
Assert.assertEquals(5, agentControl.getShutdownCount());
}
Aggregations