Search in sources :

Example 1 with PluginPackageFilter

use of com.navercorp.pinpoint.profiler.plugin.PluginPackageFilter in project pinpoint by naver.

the class JarProfilerPluginClassInjectorTest method testInjectClass.

@Test
public void testInjectClass() throws Exception {
    final URL sampleJar = getSampleJar("org.slf4j.impl.Log4jLoggerAdapter");
    final ClassLoader contextTypeMatchClassLoader = createContextTypeMatchClassLoader(new URL[] { sampleJar });
    final ProfilerPlugin profilerPlugin = Mockito.mock(ProfilerPlugin.class);
    final PluginPackageFilter pluginPackageFilter = new PluginPackageFilter(Arrays.asList(LOG4_IMPL));
    PluginConfig pluginConfig = new PluginConfig(sampleJar, pluginPackageFilter);
    logger.debug("pluginConfig:{}", pluginConfig);
    PlainClassLoaderHandler injector = new PlainClassLoaderHandler(pluginConfig);
    final Class<?> loggerClass = injector.injectClass(contextTypeMatchClassLoader, logger.getClass().getName());
    logger.debug("ClassLoader{}", loggerClass.getClassLoader());
    Assert.assertEquals("check className", loggerClass.getName(), "org.slf4j.impl.Log4jLoggerAdapter");
    Assert.assertEquals("check ClassLoader", loggerClass.getClassLoader().getClass().getName(), CONTEXT_TYPE_MATCH_CLASS_LOADER);
}
Also used : PluginConfig(com.navercorp.pinpoint.profiler.plugin.PluginConfig) PinpointURLClassLoader(com.navercorp.pinpoint.bootstrap.PinpointURLClassLoader) ProfilerPlugin(com.navercorp.pinpoint.bootstrap.plugin.ProfilerPlugin) PluginPackageFilter(com.navercorp.pinpoint.profiler.plugin.PluginPackageFilter) URL(java.net.URL) Test(org.junit.Test)

Aggregations

PinpointURLClassLoader (com.navercorp.pinpoint.bootstrap.PinpointURLClassLoader)1 ProfilerPlugin (com.navercorp.pinpoint.bootstrap.plugin.ProfilerPlugin)1 PluginConfig (com.navercorp.pinpoint.profiler.plugin.PluginConfig)1 PluginPackageFilter (com.navercorp.pinpoint.profiler.plugin.PluginPackageFilter)1 URL (java.net.URL)1 Test (org.junit.Test)1