Search in sources :

Example 76 with MockServiceManager

use of com.newrelic.agent.MockServiceManager in project newrelic-java-agent by newrelic.

the class BrowserTransactionStateTest method createServiceManager.

public static void createServiceManager(Set<String> include, Set<String> exclude) throws Exception {
    MockServiceManager serviceManager = new MockServiceManager();
    ServiceFactory.setServiceManager(serviceManager);
    // Needed by TransactionService
    ThreadService threadService = new ThreadService();
    serviceManager.setThreadService(threadService);
    // Needed by TransactionTraceService
    Map<String, Object> map = createConfigMap(include, exclude);
    ConfigService configService = ConfigServiceFactory.createConfigService(AgentConfigImpl.createAgentConfig(map), map);
    serviceManager.setConfigService(configService);
    // Needed by Transaction
    TransactionService transactionService = new TransactionService();
    serviceManager.setTransactionService(transactionService);
    MockCoreService agent = new MockCoreService();
    serviceManager.setCoreService(agent);
    // Null pointers if not set
    serviceManager.setStatsService(Mockito.mock(StatsService.class));
    // Needed by Transaction
    TransactionTraceService transactionTraceService = new TransactionTraceService();
    serviceManager.setTransactionTraceService(transactionTraceService);
    // Needed by Transaction
    MockRPMServiceManager rpmServiceManager = new MockRPMServiceManager();
    serviceManager.setRPMServiceManager(rpmServiceManager);
    MockRPMService rpmService = new MockRPMService();
    rpmService.setApplicationName("name");
    rpmService.setErrorService(new ErrorServiceImpl("name"));
    rpmServiceManager.setRPMService(rpmService);
    AttributesService attService = new AttributesService();
    serviceManager.setAttributesService(attService);
    ServiceFactory.setServiceManager(serviceManager);
}
Also used : TransactionService(com.newrelic.agent.TransactionService) ErrorServiceImpl(com.newrelic.agent.errors.ErrorServiceImpl) StatsService(com.newrelic.agent.stats.StatsService) AttributesService(com.newrelic.agent.attributes.AttributesService) MockRPMServiceManager(com.newrelic.agent.MockRPMServiceManager) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) TransactionTraceService(com.newrelic.agent.trace.TransactionTraceService) ThreadService(com.newrelic.agent.ThreadService) MockConfigService(com.newrelic.agent.MockConfigService) ConfigService(com.newrelic.agent.config.ConfigService) MockServiceManager(com.newrelic.agent.MockServiceManager) MockCoreService(com.newrelic.agent.MockCoreService) MockRPMService(com.newrelic.agent.MockRPMService)

Example 77 with MockServiceManager

use of com.newrelic.agent.MockServiceManager in project newrelic-java-agent by newrelic.

the class CircuitBreakerServiceTest method setup.

@BeforeClass
public static void setup() {
    MockServiceManager serviceManager = new MockServiceManager();
    ServiceFactory.setServiceManager(serviceManager);
    try {
        serviceManager.start();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    AgentBridge.instrumentation = new InstrumentationImpl(Agent.LOG);
    AgentBridge.agent = new AgentImpl(Agent.LOG);
}
Also used : InstrumentationImpl(com.newrelic.agent.instrumentation.InstrumentationImpl) MockServiceManager(com.newrelic.agent.MockServiceManager) AgentImpl(com.newrelic.agent.AgentImpl) BeforeClass(org.junit.BeforeClass)

Example 78 with MockServiceManager

use of com.newrelic.agent.MockServiceManager in project newrelic-java-agent by newrelic.

the class LaspHighSecurityTest method laspAndHsmEnabled.

@Test
public void laspAndHsmEnabled() throws ConfigurationException {
    Map<String, Object> settings = createSecurityProps();
    ConfigService configService = ConfigServiceFactory.createConfigServiceUsingSettings(settings);
    ServiceManager serviceManager = new MockServiceManager(configService);
    ServiceFactory.setServiceManager(serviceManager);
    AgentConfig agentConfig = AgentConfigFactory.createAgentConfig(settings, null, null);
    assertTrue(agentConfig.laspEnabled());
    assertTrue(agentConfig.isHighSecurity());
    try {
        ConfigServiceFactory.validateConfig(agentConfig);
        fail();
    } catch (ForceDisconnectException ex) {
    }
}
Also used : ForceDisconnectException(com.newrelic.agent.ForceDisconnectException) ServiceManager(com.newrelic.agent.service.ServiceManager) MockServiceManager(com.newrelic.agent.MockServiceManager) MockServiceManager(com.newrelic.agent.MockServiceManager) Test(org.junit.Test)

Example 79 with MockServiceManager

use of com.newrelic.agent.MockServiceManager in project newrelic-java-agent by newrelic.

the class ClassTransformerConfigImplTest method testLitemode.

@Test
public void testLitemode() {
    AgentConfig agentConfig = AgentConfigImpl.createAgentConfig(ImmutableMap.<String, Object>of("lite_mode", true, "app_name", "Unit Test"));
    ConfigService configService = ConfigServiceFactory.createConfigService(agentConfig, Collections.<String, Object>emptyMap());
    ServiceManager serviceManager = new MockServiceManager(configService);
    ServiceFactory.setServiceManager(serviceManager);
    ClassTransformerConfig classTransformerConfig = serviceManager.getConfigService().getDefaultAgentConfig().getClassTransformerConfig();
    assertFalse(classTransformerConfig.isDefaultInstrumentationEnabled());
    assertFalse(classTransformerConfig.isBuiltinExtensionEnabled());
}
Also used : MockServiceManager(com.newrelic.agent.MockServiceManager) ServiceManager(com.newrelic.agent.service.ServiceManager) MockServiceManager(com.newrelic.agent.MockServiceManager) Test(org.junit.Test)

Example 80 with MockServiceManager

use of com.newrelic.agent.MockServiceManager in project newrelic-java-agent by newrelic.

the class ClassTransformerConfigImplTest method testPointcutEnabled.

@Test
public void testPointcutEnabled() {
    Map<String, Object> classTransformerMap = new HashMap<>();
    ClassTransformerConfig config = ClassTransformerConfigImpl.createClassTransformerConfig(classTransformerMap, true, false);
    Map<String, Object> configSettings = new HashMap<>();
    configSettings.put(AgentConfigImpl.CLASS_TRANSFORMER, classTransformerMap);
    configSettings.put(AgentConfigImpl.APP_NAME, "Unit Test");
    AgentConfig agentConfig = AgentConfigImpl.createAgentConfig(configSettings);
    ConfigService configService = ConfigServiceFactory.createConfigService(agentConfig, Collections.<String, Object>emptyMap());
    ServiceManager serviceManager = new MockServiceManager(configService);
    ServiceFactory.setServiceManager(serviceManager);
    PointCutConfiguration pointCutConfiguration = new PointCutConfiguration("name", null, true, config);
    assertTrue(pointCutConfiguration.isEnabled());
}
Also used : HashMap(java.util.HashMap) MockServiceManager(com.newrelic.agent.MockServiceManager) ServiceManager(com.newrelic.agent.service.ServiceManager) MockServiceManager(com.newrelic.agent.MockServiceManager) PointCutConfiguration(com.newrelic.agent.instrumentation.PointCutConfiguration) Test(org.junit.Test)

Aggregations

MockServiceManager (com.newrelic.agent.MockServiceManager)127 ConfigService (com.newrelic.agent.config.ConfigService)61 Test (org.junit.Test)49 MockRPMServiceManager (com.newrelic.agent.MockRPMServiceManager)48 HashMap (java.util.HashMap)44 TransactionService (com.newrelic.agent.TransactionService)42 MockRPMService (com.newrelic.agent.MockRPMService)37 ThreadService (com.newrelic.agent.ThreadService)34 AgentConfig (com.newrelic.agent.config.AgentConfig)34 AttributesService (com.newrelic.agent.attributes.AttributesService)28 HarvestService (com.newrelic.agent.HarvestService)27 TransactionTraceService (com.newrelic.agent.trace.TransactionTraceService)27 MockHarvestService (com.newrelic.agent.MockHarvestService)26 MockCoreService (com.newrelic.agent.MockCoreService)21 StatsService (com.newrelic.agent.stats.StatsService)21 StatsServiceImpl (com.newrelic.agent.stats.StatsServiceImpl)21 Before (org.junit.Before)19 ErrorServiceImpl (com.newrelic.agent.errors.ErrorServiceImpl)16 SqlTraceServiceImpl (com.newrelic.agent.sql.SqlTraceServiceImpl)16 SqlTraceService (com.newrelic.agent.sql.SqlTraceService)15