use of com.newrelic.agent.MockServiceManager in project newrelic-java-agent by newrelic.
the class ProfilerServiceTest method enabled.
@Test
public void enabled() throws Exception {
MockServiceManager serviceManager = createServiceManager(createAgentConfig(true));
Assert.assertTrue(serviceManager.getProfilerService().isEnabled());
}
use of com.newrelic.agent.MockServiceManager in project newrelic-java-agent by newrelic.
the class ProfilerServiceTest method startProfiler.
@Test
public void startProfiler() throws Exception {
final CountDownLatch latch = new CountDownLatch(1);
MockServiceManager serviceManager = createServiceManager(createAgentConfig(true));
MockRPMService rpmService = new MockRPMService();
MockRPMServiceManager rpmServiceManager = new MockRPMServiceManager();
serviceManager.setRPMServiceManager(rpmServiceManager);
rpmService.setApplicationName("Unit Test");
rpmServiceManager.setRPMService(rpmService);
ProfilerService profilerService = new ProfilerService() {
@Override
void sessionCompleted(ProfileSession session) {
super.sessionCompleted(session);
latch.countDown();
}
};
serviceManager.setProfilerService(profilerService);
Assert.assertNull(profilerService.getCurrentSession());
ProfilerParameters parameters = new ProfilerParameters(0L, 50L, 500L, false, false, Agent.isDebugEnabled(), null, null);
profilerService.startProfiler(parameters);
latch.await(10000, TimeUnit.MILLISECONDS);
Assert.assertNull(profilerService.getCurrentSession());
Assert.assertEquals(1, rpmService.getProfiles().size());
}
use of com.newrelic.agent.MockServiceManager in project newrelic-java-agent by newrelic.
the class ProfilerServiceTest method disabled.
@Test
public void disabled() throws Exception {
Map<String, Object> config = createAgentConfig(false);
MockServiceManager serviceManager = createServiceManager(config);
Assert.assertTrue(!serviceManager.getProfilerService().isEnabled());
}
use of com.newrelic.agent.MockServiceManager in project newrelic-java-agent by newrelic.
the class MetricNormalizerTest method beforeClass.
@BeforeClass
public static void beforeClass() throws Exception {
MockServiceManager serviceManager = new MockServiceManager();
ServiceFactory.setServiceManager(serviceManager);
serviceManager.start();
ThreadService threadService = new ThreadService();
serviceManager.setThreadService(threadService);
Map<String, Object> settings = AgentConfigFactoryTest.createStagingMap();
AgentConfig config = AgentConfigFactory.createAgentConfig(settings, null, null);
MockConfigService configService = new MockConfigService(null);
configService.setAgentConfig(config);
serviceManager.setConfigService(configService);
MockRPMServiceManager rpmServiceManager = new MockRPMServiceManager();
serviceManager.setRPMServiceManager(rpmServiceManager);
MockRPMService rpmService = new MockRPMService();
rpmService.setApplicationName("Metric Normalizer Test");
rpmServiceManager.setRPMService(rpmService);
serviceManager.setNormalizationService(new NormalizationServiceImpl());
}
use of com.newrelic.agent.MockServiceManager in project newrelic-java-agent by newrelic.
the class TransactionNamingTest method createServiceManager.
private static void createServiceManager(Map<String, Object> map) throws Exception {
MockServiceManager serviceManager = new MockServiceManager();
ServiceFactory.setServiceManager(serviceManager);
serviceManager.start();
ThreadService threadService = new ThreadService();
serviceManager.setThreadService(threadService);
ConfigService configService = ConfigServiceFactory.createConfigService(AgentConfigImpl.createAgentConfig(map), map);
serviceManager.setConfigService(configService);
MockCoreService agent = new MockCoreService();
serviceManager.setCoreService(agent);
HarvestService harvestService = new MockHarvestService();
serviceManager.setHarvestService(harvestService);
TransactionService transactionService = new TransactionService();
serviceManager.setTransactionService(transactionService);
TransactionTraceService transactionTraceService = new TransactionTraceService();
serviceManager.setTransactionTraceService(transactionTraceService);
SqlTraceService sqlTraceService = new SqlTraceServiceImpl();
serviceManager.setSqlTraceService(sqlTraceService);
MockRPMServiceManager rpmServiceManager = new MockRPMServiceManager();
serviceManager.setRPMServiceManager(rpmServiceManager);
MockRPMService rpmService = new MockRPMService();
rpmService.setApplicationName("Unit Test");
rpmServiceManager.setRPMService(rpmService);
NormalizationService normalizationService = new NormalizationServiceImpl();
serviceManager.setNormalizationService(normalizationService);
AttributesService attributeService = new AttributesService();
serviceManager.setAttributesService(attributeService);
}
Aggregations