use of com.newrelic.agent.MockServiceManager in project newrelic-java-agent by newrelic.
the class ProfileSessionTest method createServiceManager.
private MockServiceManager createServiceManager(Map<String, Object> config) throws Exception {
MockServiceManager serviceManager = new MockServiceManager();
ServiceFactory.setServiceManager(serviceManager);
ThreadService threadService = new ThreadService();
serviceManager.setThreadService(threadService);
ConfigService configService = ConfigServiceFactory.createConfigService(AgentConfigImpl.createAgentConfig(config), config);
serviceManager.setConfigService(configService);
TransactionService transactionService = new TransactionService();
serviceManager.setTransactionService(transactionService);
ProfilerService profilerService = new ProfilerService();
serviceManager.setProfilerService(profilerService);
return serviceManager;
}
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);
}
use of com.newrelic.agent.MockServiceManager in project newrelic-java-agent by newrelic.
the class ProfilerServiceTest method enabledByDefault.
@Test
public void enabledByDefault() throws Exception {
MockServiceManager serviceManager = createServiceManager(Collections.EMPTY_MAP);
Assert.assertTrue(serviceManager.getProfilerService().isEnabled());
}
use of com.newrelic.agent.MockServiceManager in project newrelic-java-agent by newrelic.
the class ProfilerServiceTest method testOneSampleProfile.
@Test
public void testOneSampleProfile() throws Exception {
MockServiceManager serviceManager = createServiceManager(createAgentConfig(true));
MockRPMService rpmService = new MockRPMService();
MockRPMServiceManager rpmServiceManager = new MockRPMServiceManager();
serviceManager.setRPMServiceManager(rpmServiceManager);
rpmService.setApplicationName("Unit Test");
rpmServiceManager.setRPMService(rpmService);
ProfilerParameters parameters = new ProfilerParameters(5L, 500L, 500L, false, false, false, null, null);
ProfilerService profilerService = serviceManager.getProfilerService();
profilerService.startProfiler(parameters);
LatchingRunnable.drain(profilerService.getScheduledExecutorService());
Assert.assertNull(profilerService.getCurrentSession());
Assert.assertEquals(1, rpmService.getProfiles().size());
ProfileTree profileTree = rpmService.getProfiles().get(0).getProfileTree(ThreadType.BasicThreadType.AGENT_INSTRUMENTATION);
Assert.assertEquals(0, profileTree.getRootSegments().size());
}
use of com.newrelic.agent.MockServiceManager in project newrelic-java-agent by newrelic.
the class ProfilerServiceTest method stopProfiler.
@Test
public void stopProfiler() throws Exception {
MockServiceManager serviceManager = createServiceManager(createAgentConfig(true));
MockRPMService rpmService = new MockRPMService();
MockRPMServiceManager rpmServiceManager = new MockRPMServiceManager();
serviceManager.setRPMServiceManager(rpmServiceManager);
rpmService.setApplicationName("Unit Test");
rpmServiceManager.setRPMService(rpmService);
long profileId = 5;
ProfilerParameters parameters = new ProfilerParameters(profileId, 100L, 200000L, false, false, false, null, null);
ProfilerService profilerService = serviceManager.getProfilerService();
profilerService.startProfiler(parameters);
Thread.sleep(1000);
profilerService.stopProfiler(profileId, false);
LatchingRunnable.drain(profilerService.getScheduledExecutorService());
Assert.assertNull(profilerService.getCurrentSession());
Assert.assertEquals(0, rpmService.getProfiles().size());
}
Aggregations