use of com.newrelic.agent.config.ConfigService 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.config.ConfigService in project newrelic-java-agent by newrelic.
the class CPUSamplerTest method createServiceManager.
private MockServiceManager createServiceManager(Map<String, Object> map) throws Exception {
MockServiceManager serviceManager = new MockServiceManager();
ServiceFactory.setServiceManager(serviceManager);
ThreadService threadService = new ThreadService();
serviceManager.setThreadService(threadService);
ConfigService configService = ConfigServiceFactory.createConfigService(AgentConfigImpl.createAgentConfig(map), map);
serviceManager.setConfigService(configService);
TransactionService transactionService = new TransactionService();
serviceManager.setTransactionService(transactionService);
ProfilerService profilerService = new ProfilerService();
serviceManager.setProfilerService(profilerService);
return serviceManager;
}
use of com.newrelic.agent.config.ConfigService in project newrelic-java-agent by newrelic.
the class ServiceManagerTest method dynamicServices.
@Test
public void dynamicServices() throws Exception {
AgentHelper.initializeConfig();
CoreService agent = new MockCoreService();
ConfigService configService = ConfigServiceFactory.createConfigService(mock(Logger.class), false);
ServiceManager serviceManager = new ServiceManagerImpl(agent, configService);
Service testService = new TestService("My Service");
serviceManager.addService(testService);
Assert.assertEquals(testService, serviceManager.getService(testService.getName()));
Assert.assertFalse(testService.isStarted());
}
use of com.newrelic.agent.config.ConfigService in project newrelic-java-agent by newrelic.
the class CollectorSpanEventReservoirManagerTest method attemptToSendDoesSend.
@Test
public void attemptToSendDoesSend() {
ConfigService mockConfigService = mock21Samples();
CollectorSpanEventReservoirManager target = initWith25Tries(mockConfigService);
// boolean arrays can be final so that nested classes can use them
final boolean[] resultFlags = new boolean[] { false };
ReservoirManager.HarvestResult harvestResult = target.attemptToSendReservoir(APP_NAME, (appName, reservoirSize, eventsSeen, events) -> {
assertEquals(APP_NAME, appName);
assertEquals(21, reservoirSize);
assertEquals(25, eventsSeen);
assertEquals(21, events.size());
resultFlags[0] = true;
}, mock(Logger.class));
assertTrue("It doesn't seem like the sendEvents call succeeded.", resultFlags[0]);
assertEquals(25, harvestResult.seen);
assertEquals(21, harvestResult.sent);
}
use of com.newrelic.agent.config.ConfigService in project newrelic-java-agent by newrelic.
the class CollectorSpanEventReservoirManagerTest method doesNotSendWithEmptyReservoir.
@Test
public void doesNotSendWithEmptyReservoir() {
ConfigService mockConfigService = mock21Samples();
CollectorSpanEventReservoirManager target = new CollectorSpanEventReservoirManager(mockConfigService);
final boolean[] wasSent = new boolean[] { false };
ReservoirManager.HarvestResult harvestResult = target.attemptToSendReservoir(APP_NAME, (appName, reservoirSize, eventsSeen, events) -> wasSent[0] = true, mock(Logger.class));
assertNull(harvestResult);
assertFalse(wasSent[0]);
}
Aggregations