use of com.newrelic.agent.service.module.JarCollectorService in project newrelic-java-agent by newrelic.
the class ClassTransformerConfigImplTest method classloaderExcludes.
@Test
public void classloaderExcludes() throws Exception {
Map<String, Object> classTransformerMap = new HashMap<>();
final String prefix = ClassTransformerConfigImplTest.class.getName();
classTransformerMap.put(ClassTransformerConfigImpl.CLASSLOADER_EXCLUDES, prefix + "$BadClassLoader, " + prefix + "$BadClassLoaderOther");
Map<String, Object> configMap = new HashMap<>();
configMap.put("class_transformer", classTransformerMap);
configMap.put(AgentConfigImpl.APP_NAME, "unittest");
AgentConfig config = AgentConfigImpl.createAgentConfig(configMap);
ClassTransformerConfig classTransformerConfig = config.getClassTransformerConfig();
classTransformerConfig = ClassTransformerConfigImpl.createClassTransformerConfig(classTransformerMap, true, false);
Set<String> exclusions = classTransformerConfig.getClassloaderExclusions();
// 6 included by default ClassTransformerConfigImpl#initializeClassloaderExcludes
Assert.assertEquals(8, exclusions.size());
ConfigService configService = ConfigServiceFactory.createConfigService(config, Collections.<String, Object>emptyMap());
MockServiceManager serviceManager = new MockServiceManager(configService);
ServiceFactory.setServiceManager(serviceManager);
JarCollectorService mockJarCollector = serviceManager.getJarCollectorService();
when(mockJarCollector.getSourceVisitor()).thenReturn(ClassMatchVisitorFactory.NO_OP_FACTORY);
InstrumentationContextManager icm = new InstrumentationContextManager(Mockito.mock(InstrumentationProxy.class));
Assert.assertFalse(icm.isClassloaderExcluded(new GoodClassLoader()));
assertTrue(icm.isClassloaderExcluded(new BadClassLoader()));
assertTrue(icm.isClassloaderExcluded(new BadClassLoaderOther()));
}
use of com.newrelic.agent.service.module.JarCollectorService in project newrelic-java-agent by newrelic.
the class IncludeExcludeTest method createServiceManager.
private void createServiceManager(Map<String, Object> configMap) throws Exception {
ConfigService configService = ConfigServiceFactory.createConfigService(AgentConfigImpl.createAgentConfig(configMap), configMap);
MockServiceManager serviceManager = new MockServiceManager(configService);
ServiceFactory.setServiceManager(serviceManager);
JarCollectorService mockJarCollector = serviceManager.getJarCollectorService();
when(mockJarCollector.getSourceVisitor()).thenReturn(ClassMatchVisitorFactory.NO_OP_FACTORY);
}
Aggregations