use of com.newrelic.agent.MockServiceManager in project newrelic-java-agent by newrelic.
the class JmxObjectJava6UpTest method setUpAgent.
@Before
public void setUpAgent() {
serviceManager = new MockServiceManager();
ServiceFactory.setServiceManager(serviceManager);
AgentConfig config = AgentConfigImpl.createAgentConfig(Collections.EMPTY_MAP);
ConfigService configService = ConfigServiceFactory.createConfigService(config, Collections.EMPTY_MAP);
serviceManager.setConfigService(configService);
serviceManager.setExtensionService(new ExtensionService(configService, ExtensionsLoadedListener.NOOP));
}
use of com.newrelic.agent.MockServiceManager in project newrelic-java-agent by newrelic.
the class SourceLanguageServiceTest method setup.
@BeforeClass
public static void setup() {
MockServiceManager serviceManager = new MockServiceManager();
serviceManager.setHarvestService(new MockHarvestService());
serviceManager.setSamplerService(new NoopSamplerService());
ServiceFactory.setServiceManager(serviceManager);
try {
serviceManager.start();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of com.newrelic.agent.MockServiceManager in project newrelic-java-agent by newrelic.
the class ProfileSamplerTest 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> 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 ProfileSessionTest method stopSession.
@Test
public void stopSession() throws Exception {
Map<String, Object> config = ProfilerServiceTest.createAgentConfig(true);
MockServiceManager serviceManager = createServiceManager(config);
MockRPMService rpmService = new MockRPMService();
MockRPMServiceManager rpmServiceManager = new MockRPMServiceManager();
serviceManager.setRPMServiceManager(rpmServiceManager);
rpmService.setApplicationName("Unit Test");
rpmServiceManager.setRPMService(rpmService);
ProfilerService profilerService = serviceManager.getProfilerService();
ProfilerParameters parameters = new ProfilerParameters(5L, 100L, 300000L, false, false, false, null, null);
ProfileSession session = new ProfileSession(profilerService, parameters);
session.start();
Thread.sleep(1000);
session.stop(true);
LatchingRunnable.drain(profilerService.getScheduledExecutorService());
Assert.assertTrue(session.isDone());
Assert.assertNotNull(session.getProfile());
Assert.assertTrue(session.getProfile().getSampleCount() > 1);
Assert.assertEquals(parameters.getProfileId(), session.getProfileId());
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 ProfileSessionTest method multiSample.
@Test
public void multiSample() throws Exception {
Map<String, Object> config = ProfilerServiceTest.createAgentConfig(true);
MockServiceManager serviceManager = createServiceManager(config);
MockRPMService rpmService = new MockRPMService();
MockRPMServiceManager rpmServiceManager = new MockRPMServiceManager();
serviceManager.setRPMServiceManager(rpmServiceManager);
rpmService.setApplicationName("Unit Test");
rpmServiceManager.setRPMService(rpmService);
ProfilerService profilerService = serviceManager.getProfilerService();
ProfilerParameters parameters = new ProfilerParameters(5L, 100L, 500L, false, false, false, null, null);
ProfileSession session = new ProfileSession(profilerService, parameters);
session.start();
Thread.sleep(1000L);
Assert.assertTrue(session.isDone());
Assert.assertNotNull(session.getProfile());
Assert.assertTrue(session.getProfile().getSampleCount() > 1);
Assert.assertEquals(parameters.getProfileId(), session.getProfileId());
Assert.assertNull(profilerService.getCurrentSession());
Assert.assertEquals(1, rpmService.getProfiles().size());
}
Aggregations