use of com.newrelic.agent.MockCoreService in project newrelic-java-agent by newrelic.
the class CommandTest method shutdown.
@Test
public void shutdown() throws Exception {
MockRPMService rpmService = new MockRPMService();
MockCoreService executor = new MockCoreService() {
@Override
public void shutdownAsync() {
throw new RuntimeException("shutdown");
}
};
Assert.assertEquals(Collections.EMPTY_MAP, new RestartCommand().process(rpmService, Collections.EMPTY_MAP));
try {
new ShutdownCommand(executor).process(rpmService, Collections.EMPTY_MAP);
Assert.fail();
} catch (Exception e) {
Assert.assertEquals("shutdown", e.getMessage());
}
}
use of com.newrelic.agent.MockCoreService 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);
}
use of com.newrelic.agent.MockCoreService in project newrelic-java-agent by newrelic.
the class MessagingUtilTest method createServiceManager.
private static void createServiceManager(Map<String, Object> configMap) throws Exception {
MockServiceManager serviceManager = new MockServiceManager();
ServiceFactory.setServiceManager(serviceManager);
serviceManager.start();
ThreadService threadService = new ThreadService();
serviceManager.setThreadService(threadService);
ConfigService configService = ConfigServiceFactory.createConfigService(AgentConfigImpl.createAgentConfig(configMap), configMap);
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);
AttributesService attService = new AttributesService();
serviceManager.setAttributesService(attService);
MockRPMServiceManager rpmServiceManager = new MockRPMServiceManager();
serviceManager.setRPMServiceManager(rpmServiceManager);
}
use of com.newrelic.agent.MockCoreService in project newrelic-java-agent by newrelic.
the class ExtensionServiceTest method setUpAgent.
@Before
public void setUpAgent() throws Exception {
Map<String, Object> configMap = new HashMap<>();
configMap.put(AgentConfigImpl.APP_NAME, EXTENSION_NAME);
AgentConfig config = AgentConfigImpl.createAgentConfig(configMap);
configService = ConfigServiceFactory.createConfigService(config, Collections.<String, Object>emptyMap());
serviceManager = new MockServiceManager(configService);
ServiceFactory.setServiceManager(serviceManager);
final InstrumentationProxy instrumentationProxy = Mockito.mock(InstrumentationProxy.class);
serviceManager.setCoreService(new MockCoreService() {
@Override
public InstrumentationProxy getInstrumentation() {
return instrumentationProxy;
}
});
Mockito.when(instrumentationProxy.isRetransformClassesSupported()).thenReturn(true);
Mockito.when(instrumentationProxy.getAllLoadedClasses()).thenReturn(new Class[] {});
extensionService = new ExtensionService(configService, ExtensionsLoadedListener.NOOP);
serviceManager.setExtensionService(extensionService);
serviceManager.setJmxService(Mockito.mock(JmxService.class));
ClassTransformerService classTransformerService = serviceManager.getClassTransformerService();
ClassRetransformer mockRetransformer = Mockito.mock(ClassRetransformer.class);
Mockito.when(classTransformerService.getLocalRetransformer()).thenReturn(mockRetransformer);
InstrumentationContextManager mockContextManager = Mockito.mock(InstrumentationContextManager.class);
Mockito.when(classTransformerService.getContextManager()).thenReturn(mockContextManager);
ClassWeaverService mockWeaverService = Mockito.mock(ClassWeaverService.class);
Mockito.when(mockContextManager.getClassWeaverService()).thenReturn(mockWeaverService);
Mockito.when(mockWeaverService.reloadExternalWeavePackages(Mockito.<File>anyCollection(), Mockito.<File>anyCollection())).thenReturn(new Runnable() {
@Override
public void run() {
}
});
}
use of com.newrelic.agent.MockCoreService in project newrelic-java-agent by newrelic.
the class DatabaseServiceTest method createServiceManager.
private MockServiceManager createServiceManager(Map<String, Object> configMap) throws Exception {
AgentConfig config = AgentConfigImpl.createAgentConfig(configMap);
MockServiceManager serviceManager = new MockServiceManager();
ServiceFactory.setServiceManager(serviceManager);
ConfigService configService = ConfigServiceFactory.createConfigService(config, configMap);
serviceManager.setConfigService(configService);
ThreadService threadService = new ThreadService();
serviceManager.setThreadService(threadService);
HarvestService harvestService = new MockHarvestService();
serviceManager.setHarvestService(harvestService);
TransactionService transactionService = new TransactionService();
serviceManager.setTransactionService(transactionService);
StatsService statsService = new StatsServiceImpl();
serviceManager.setStatsService(statsService);
DatabaseService dbService = new DatabaseService();
serviceManager.setDatabaseService(dbService);
SqlTraceService sqlTraceService = new SqlTraceServiceImpl();
serviceManager.setSqlTraceService(sqlTraceService);
MockCoreService agent = new MockCoreService();
serviceManager.setCoreService(agent);
TransactionTraceService transactionTraceService = new TransactionTraceService();
serviceManager.setTransactionTraceService(transactionTraceService);
MockRPMServiceManager rpmServiceManager = new MockRPMServiceManager();
serviceManager.setRPMServiceManager(rpmServiceManager);
MockRPMService rpmService = new MockRPMService();
rpmService.setApplicationName(APP_NAME);
rpmService.setEverConnected(true);
rpmService.setErrorService(new ErrorServiceImpl(APP_NAME));
rpmServiceManager.setRPMService(rpmService);
configService.start();
serviceManager.start();
sqlTraceService.start();
return serviceManager;
}
Aggregations