Search in sources :

Example 16 with MockCoreService

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());
    }
}
Also used : MockCoreService(com.newrelic.agent.MockCoreService) MockRPMService(com.newrelic.agent.MockRPMService) Test(org.junit.Test)

Example 17 with MockCoreService

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);
}
Also used : SqlTraceServiceImpl(com.newrelic.agent.sql.SqlTraceServiceImpl) MockHarvestService(com.newrelic.agent.MockHarvestService) HarvestService(com.newrelic.agent.HarvestService) TransactionService(com.newrelic.agent.TransactionService) AttributesService(com.newrelic.agent.attributes.AttributesService) MockRPMServiceManager(com.newrelic.agent.MockRPMServiceManager) TransactionTraceService(com.newrelic.agent.trace.TransactionTraceService) ThreadService(com.newrelic.agent.ThreadService) SqlTraceService(com.newrelic.agent.sql.SqlTraceService) ConfigService(com.newrelic.agent.config.ConfigService) MockServiceManager(com.newrelic.agent.MockServiceManager) MockCoreService(com.newrelic.agent.MockCoreService) MockHarvestService(com.newrelic.agent.MockHarvestService) MockRPMService(com.newrelic.agent.MockRPMService)

Example 18 with MockCoreService

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);
}
Also used : ThreadService(com.newrelic.agent.ThreadService) SqlTraceService(com.newrelic.agent.sql.SqlTraceService) ConfigService(com.newrelic.agent.config.ConfigService) SqlTraceServiceImpl(com.newrelic.agent.sql.SqlTraceServiceImpl) MockHarvestService(com.newrelic.agent.MockHarvestService) HarvestService(com.newrelic.agent.HarvestService) TransactionService(com.newrelic.agent.TransactionService) MockServiceManager(com.newrelic.agent.MockServiceManager) AttributesService(com.newrelic.agent.attributes.AttributesService) MockCoreService(com.newrelic.agent.MockCoreService) MockHarvestService(com.newrelic.agent.MockHarvestService) MockRPMServiceManager(com.newrelic.agent.MockRPMServiceManager) TransactionTraceService(com.newrelic.agent.trace.TransactionTraceService)

Example 19 with MockCoreService

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() {
        }
    });
}
Also used : ClassRetransformer(com.newrelic.agent.instrumentation.custom.ClassRetransformer) HashMap(java.util.HashMap) InstrumentationProxy(com.newrelic.agent.InstrumentationProxy) JmxService(com.newrelic.agent.jmx.JmxService) InstrumentationContextManager(com.newrelic.agent.instrumentation.context.InstrumentationContextManager) AgentConfig(com.newrelic.agent.config.AgentConfig) MockServiceManager(com.newrelic.agent.MockServiceManager) ClassTransformerService(com.newrelic.agent.instrumentation.ClassTransformerService) MockCoreService(com.newrelic.agent.MockCoreService) ClassWeaverService(com.newrelic.agent.instrumentation.weaver.ClassWeaverService) Before(org.junit.Before)

Example 20 with MockCoreService

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;
}
Also used : SqlTraceServiceImpl(com.newrelic.agent.sql.SqlTraceServiceImpl) MockHarvestService(com.newrelic.agent.MockHarvestService) HarvestService(com.newrelic.agent.HarvestService) TransactionService(com.newrelic.agent.TransactionService) ErrorServiceImpl(com.newrelic.agent.errors.ErrorServiceImpl) StatsService(com.newrelic.agent.stats.StatsService) MockRPMServiceManager(com.newrelic.agent.MockRPMServiceManager) TransactionTraceService(com.newrelic.agent.trace.TransactionTraceService) AgentConfig(com.newrelic.agent.config.AgentConfig) ThreadService(com.newrelic.agent.ThreadService) SqlTraceService(com.newrelic.agent.sql.SqlTraceService) MockConfigService(com.newrelic.agent.MockConfigService) ConfigService(com.newrelic.agent.config.ConfigService) StatsServiceImpl(com.newrelic.agent.stats.StatsServiceImpl) MockServiceManager(com.newrelic.agent.MockServiceManager) MockHarvestService(com.newrelic.agent.MockHarvestService) MockCoreService(com.newrelic.agent.MockCoreService) MockRPMService(com.newrelic.agent.MockRPMService)

Aggregations

MockCoreService (com.newrelic.agent.MockCoreService)29 MockServiceManager (com.newrelic.agent.MockServiceManager)21 MockRPMService (com.newrelic.agent.MockRPMService)20 ConfigService (com.newrelic.agent.config.ConfigService)20 MockRPMServiceManager (com.newrelic.agent.MockRPMServiceManager)19 TransactionService (com.newrelic.agent.TransactionService)19 ThreadService (com.newrelic.agent.ThreadService)17 TransactionTraceService (com.newrelic.agent.trace.TransactionTraceService)17 HarvestService (com.newrelic.agent.HarvestService)15 MockHarvestService (com.newrelic.agent.MockHarvestService)15 ErrorServiceImpl (com.newrelic.agent.errors.ErrorServiceImpl)13 AttributesService (com.newrelic.agent.attributes.AttributesService)12 SqlTraceService (com.newrelic.agent.sql.SqlTraceService)12 SqlTraceServiceImpl (com.newrelic.agent.sql.SqlTraceServiceImpl)12 StatsService (com.newrelic.agent.stats.StatsService)12 StatsServiceImpl (com.newrelic.agent.stats.StatsServiceImpl)12 AgentConfig (com.newrelic.agent.config.AgentConfig)9 NormalizationServiceImpl (com.newrelic.agent.normalization.NormalizationServiceImpl)6 DistributedTraceServiceImpl (com.newrelic.agent.tracing.DistributedTraceServiceImpl)6 Test (org.junit.Test)6