use of com.newrelic.agent.InstrumentationProxy in project newrelic-java-agent by newrelic.
the class RetransformPointCutTest method retransformPointCutClass.
@Test
public void retransformPointCutClass() throws UnmodifiableClassException {
InstrumentationProxy ip = ServiceFactory.getCoreService().getInstrumentation();
ip.retransformClasses(CLASS_LOADED_BEFORE_AGENT);
Assert.assertTrue(CLASS_LOADED_BEFORE_AGENT.getName() + " should have been retransformed.", PointCutClassTransformer.isInstrumented(CLASS_LOADED_BEFORE_AGENT));
ip.retransformClasses(CLASS_LOADED_AFTER_AGENT);
Assert.assertTrue(CLASS_LOADED_AFTER_AGENT.getName() + " should have been retransformed.", PointCutClassTransformer.isInstrumented(CLASS_LOADED_AFTER_AGENT));
}
use of com.newrelic.agent.InstrumentationProxy in project newrelic-java-agent by newrelic.
the class HttpCommonsTest method httpURLConnection.
@Test
public void httpURLConnection() throws Exception {
InstrumentationProxy instrProxy = ServiceFactory.getCoreService().getInstrumentation();
if (!instrProxy.isBootstrapClassInstrumentationEnabled()) {
return;
}
httpURLConnectionTx();
Set<String> metrics = AgentHelper.getMetrics();
assertTrue(metrics.toString(), metrics.contains("External/" + HOST + "/HttpURLConnection"));
Map<String, Integer> metricCounts = getMetricCounts(MetricName.create("External/" + HOST + "/HttpURLConnection", "OtherTransaction/Custom/test.newrelic.test.agent.HttpCommonsTest/httpURLConnectionTx"));
assertEquals(1, (int) metricCounts.get("External/" + HOST + "/HttpURLConnection"));
}
use of com.newrelic.agent.InstrumentationProxy 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() {
}
});
}
Aggregations