Search in sources :

Example 1 with MockConfigService

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

the class BrowserTransactionStateTest method setup.

@Before
public void setup() {
    MockServiceManager serviceManager = new MockServiceManager();
    serviceManager.setConfigService(new MockConfigService(AgentConfigFactory.createAgentConfig(Collections.<String, Object>emptyMap(), Collections.<String, Object>emptyMap(), null)));
    ServiceFactory.setServiceManager(serviceManager);
    MockitoAnnotations.initMocks(this);
}
Also used : MockServiceManager(com.newrelic.agent.MockServiceManager) MockConfigService(com.newrelic.agent.MockConfigService) Before(org.junit.Before)

Example 2 with MockConfigService

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

the class TransactionTraceTest method setUp.

private void setUp(boolean isCaptureAtts, boolean captureRequestAtts, boolean requestUri, boolean simpleCompression) throws Exception {
    iAgentConfig = mock(AgentConfig.class);
    TransactionTracerConfig transTracerConfig = mock(TransactionTracerConfig.class);
    when(iAgentConfig.getTransactionTracerConfig()).thenReturn(transTracerConfig);
    when(iAgentConfig.isSimpleCompression()).thenReturn(simpleCompression);
    MockServiceManager manager = new MockServiceManager();
    ServiceFactory.setServiceManager(manager);
    ImmutableMap<String, Object> distributedTracingSettings = ImmutableMap.<String, Object>builder().put(DistributedTracingConfig.ENABLED, Boolean.FALSE).build();
    Map<String, Object> settings = new HashMap<>();
    settings.put(AgentConfigImpl.DISTRIBUTED_TRACING, distributedTracingSettings);
    setConfigAttributes(settings, isCaptureAtts, captureRequestAtts, requestUri, simpleCompression);
    ConfigService cService = new MockConfigService(AgentConfigImpl.createAgentConfig(settings));
    manager.setConfigService(cService);
    manager.setTransactionTraceService(new TransactionTraceService());
    manager.setTransactionService(new TransactionService());
    manager.setAttributesService(new AttributesService());
}
Also used : TransactionService(com.newrelic.agent.TransactionService) HashMap(java.util.HashMap) AttributesService(com.newrelic.agent.attributes.AttributesService) MockConfigService(com.newrelic.agent.MockConfigService) AgentConfig(com.newrelic.agent.config.AgentConfig) MockConfigService(com.newrelic.agent.MockConfigService) ConfigService(com.newrelic.agent.config.ConfigService) MockServiceManager(com.newrelic.agent.MockServiceManager) JSONObject(org.json.simple.JSONObject) TransactionTracerConfig(com.newrelic.agent.config.TransactionTracerConfig)

Example 3 with MockConfigService

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

the class SpringPointCutTest 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> settings = AgentConfigFactoryTest.createStagingMap();
    AgentConfig config = AgentConfigFactory.createAgentConfig(settings, null, null);
    MockConfigService configService = new MockConfigService(null);
    configService.setAgentConfig(config);
    serviceManager.setConfigService(configService);
    MockRPMServiceManager rpmServiceManager = new MockRPMServiceManager();
    serviceManager.setRPMServiceManager(rpmServiceManager);
    MockRPMService rpmService = new MockRPMService();
    rpmService.setApplicationName("Unit Test");
    rpmServiceManager.setRPMService(rpmService);
    serviceManager.setNormalizationService(new NormalizationServiceImpl());
}
Also used : ThreadService(com.newrelic.agent.ThreadService) AgentConfig(com.newrelic.agent.config.AgentConfig) MockServiceManager(com.newrelic.agent.MockServiceManager) MockRPMServiceManager(com.newrelic.agent.MockRPMServiceManager) MockConfigService(com.newrelic.agent.MockConfigService) MockRPMService(com.newrelic.agent.MockRPMService) NormalizationServiceImpl(com.newrelic.agent.normalization.NormalizationServiceImpl) BeforeClass(org.junit.BeforeClass)

Example 4 with MockConfigService

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

the class OptimizedClassMatcherTest method initializeServiceManager.

private void initializeServiceManager() {
    MockServiceManager serviceManager = new MockServiceManager();
    ServiceFactory.setServiceManager(serviceManager);
    Map<String, Object> confProps = new HashMap<>();
    confProps.put(AgentConfigImpl.APP_NAME, "Hello");
    MockConfigService service = new MockConfigService(AgentConfigImpl.createAgentConfig(confProps));
    serviceManager.setConfigService(service);
}
Also used : HashMap(java.util.HashMap) MockServiceManager(com.newrelic.agent.MockServiceManager) MockConfigService(com.newrelic.agent.MockConfigService)

Example 5 with MockConfigService

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

the class UtilizationServiceTest method before.

@Before
public void before() {
    MockServiceManager mockServiceManager = new MockServiceManager();
    config = mock(AgentConfig.class);
    MockConfigService configService = new MockConfigService(null);
    configService.setAgentConfig(config);
    ServiceFactory.setServiceManager(mockServiceManager);
    mockServiceManager.setConfigService(configService);
    ThreadService mockThreadService = mock(ThreadService.class);
    mockServiceManager.setThreadService(mockThreadService);
    // Do not make AWS/Azure/GCP/PCF calls. Unit tests should work even without internet connection :)
    when(config.getValue(UtilizationService.DETECT_DOCKER_KEY, true)).thenReturn(false);
    when(config.getValue(UtilizationService.DETECT_AWS_KEY, true)).thenReturn(false);
    when(config.getValue(UtilizationService.DETECT_AZURE_KEY, true)).thenReturn(false);
    when(config.getValue(UtilizationService.DETECT_GOOGLE_CLOUD_PROVIDER_KEY, true)).thenReturn(false);
    when(config.getValue(UtilizationService.DETECT_PIVOTAL_CLOUD_FOUNDRY_KEY, true)).thenReturn(false);
    when(config.getValue(UtilizationService.DETECT_KUBERNETES_KEY, true)).thenReturn(false);
    UtilizationDataConfig utilDataConfig = mock(UtilizationDataConfig.class);
    when(config.getUtilizationDataConfig()).thenReturn(utilDataConfig);
}
Also used : AgentConfig(com.newrelic.agent.config.AgentConfig) ThreadService(com.newrelic.agent.ThreadService) MockServiceManager(com.newrelic.agent.MockServiceManager) MockConfigService(com.newrelic.agent.MockConfigService) UtilizationDataConfig(com.newrelic.agent.config.UtilizationDataConfig) Before(org.junit.Before)

Aggregations

MockConfigService (com.newrelic.agent.MockConfigService)8 MockServiceManager (com.newrelic.agent.MockServiceManager)8 AgentConfig (com.newrelic.agent.config.AgentConfig)5 ThreadService (com.newrelic.agent.ThreadService)3 HashMap (java.util.HashMap)3 JSONObject (org.json.simple.JSONObject)3 MockRPMService (com.newrelic.agent.MockRPMService)2 MockRPMServiceManager (com.newrelic.agent.MockRPMServiceManager)2 ConfigService (com.newrelic.agent.config.ConfigService)2 Before (org.junit.Before)2 BeforeClass (org.junit.BeforeClass)2 TransactionService (com.newrelic.agent.TransactionService)1 AttributesService (com.newrelic.agent.attributes.AttributesService)1 AgentConfigListener (com.newrelic.agent.config.AgentConfigListener)1 TransactionTracerConfig (com.newrelic.agent.config.TransactionTracerConfig)1 UtilizationDataConfig (com.newrelic.agent.config.UtilizationDataConfig)1 DefaultSqlObfuscator (com.newrelic.agent.database.SqlObfuscator.DefaultSqlObfuscator)1 NormalizationServiceImpl (com.newrelic.agent.normalization.NormalizationServiceImpl)1 Test (org.junit.Test)1