Search in sources :

Example 6 with DefaultProfilerConfig

use of com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig in project pinpoint by naver.

the class JavassistClassTest method getTestClassLoader.

private TestClassLoader getTestClassLoader() {
    PLoggerFactory.initialize(new Slf4jLoggerBinder());
    DefaultProfilerConfig profilerConfig = new DefaultProfilerConfig();
    profilerConfig.setApplicationServerType(ServiceType.TEST_STAND_ALONE.getName());
    MockApplicationContext applicationContext = MockApplicationContext.of(profilerConfig);
    TestClassLoader testClassLoader = new TestClassLoader(applicationContext);
    testClassLoader.initialize();
    return testClassLoader;
}
Also used : TestClassLoader(com.navercorp.pinpoint.test.classloader.TestClassLoader) DefaultProfilerConfig(com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig) Slf4jLoggerBinder(com.navercorp.pinpoint.profiler.logging.Slf4jLoggerBinder) MockApplicationContext(com.navercorp.pinpoint.test.MockApplicationContext)

Example 7 with DefaultProfilerConfig

use of com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig in project pinpoint by naver.

the class AccessorInjectionTest method getTestClassLoader.

private TestClassLoader getTestClassLoader() {
    PLoggerFactory.initialize(new Slf4jLoggerBinder());
    DefaultProfilerConfig profilerConfig = new DefaultProfilerConfig();
    profilerConfig.setApplicationServerType(ServiceType.TEST_STAND_ALONE.getName());
    MockApplicationContext applicationContext = MockApplicationContext.of(profilerConfig);
    TestClassLoader testClassLoader = new TestClassLoader(applicationContext);
    testClassLoader.initialize();
    return testClassLoader;
}
Also used : TestClassLoader(com.navercorp.pinpoint.test.classloader.TestClassLoader) DefaultProfilerConfig(com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig) Slf4jLoggerBinder(com.navercorp.pinpoint.profiler.logging.Slf4jLoggerBinder) MockApplicationContext(com.navercorp.pinpoint.test.MockApplicationContext)

Example 8 with DefaultProfilerConfig

use of com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig in project pinpoint by naver.

the class MockApplicationContextModuleTest method test.

@Test
public void test() {
    ProfilerConfig profilerConfig = new DefaultProfilerConfig();
    AgentOption agentOption = new DefaultAgentOption(new DummyInstrumentation(), "mockAgent", "mockApplicationName", profilerConfig, new URL[0], null, new DefaultServiceTypeRegistryService(), new DefaultAnnotationKeyRegistryService());
    final PluginApplicationContextModule pluginApplicationContextModule = new PluginApplicationContextModule();
    PluginTestAgent pluginTestAgent = new PluginTestAgent(agentOption) {

        @Override
        protected ApplicationContext newApplicationContext(AgentOption agentOption, InterceptorRegistryBinder interceptorRegistryBinder) {
            ApplicationContext applicationContext = new DefaultApplicationContext(agentOption, interceptorRegistryBinder) {

                @Override
                protected Module newApplicationContextModule(AgentOption agentOption, InterceptorRegistryBinder interceptorRegistryBinder) {
                    Module applicationContextModule = super.newApplicationContextModule(agentOption, interceptorRegistryBinder);
                    //                        PluginApplicationContextModule pluginApplicationContextModule = new PluginApplicationContextModule();
                    return Modules.override(applicationContextModule).with(pluginApplicationContextModule);
                }
            };
            return applicationContext;
        }
    };
    try {
        pluginTestAgent.start();
    } finally {
        pluginTestAgent.stop(true);
    }
}
Also used : InterceptorRegistryBinder(com.navercorp.pinpoint.profiler.interceptor.registry.InterceptorRegistryBinder) ProfilerConfig(com.navercorp.pinpoint.bootstrap.config.ProfilerConfig) DefaultProfilerConfig(com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig) DefaultProfilerConfig(com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig) DefaultApplicationContext(com.navercorp.pinpoint.profiler.context.module.DefaultApplicationContext) ApplicationContext(com.navercorp.pinpoint.profiler.context.module.ApplicationContext) DefaultApplicationContext(com.navercorp.pinpoint.profiler.context.module.DefaultApplicationContext) DefaultAgentOption(com.navercorp.pinpoint.bootstrap.DefaultAgentOption) DefaultServiceTypeRegistryService(com.navercorp.pinpoint.common.service.DefaultServiceTypeRegistryService) DefaultAgentOption(com.navercorp.pinpoint.bootstrap.DefaultAgentOption) AgentOption(com.navercorp.pinpoint.bootstrap.AgentOption) DefaultAnnotationKeyRegistryService(com.navercorp.pinpoint.common.service.DefaultAnnotationKeyRegistryService) Module(com.google.inject.Module) Test(org.junit.Test)

Example 9 with DefaultProfilerConfig

use of com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig in project pinpoint by naver.

the class MockApplicationContext method of.

public static MockApplicationContext of(String configPath) {
    ProfilerConfig profilerConfig = null;
    try {
        final URL resource = MockApplicationContext.class.getClassLoader().getResource(configPath);
        if (resource == null) {
            throw new FileNotFoundException("pinpoint.config not found. configPath:" + configPath);
        }
        profilerConfig = DefaultProfilerConfig.load(resource.getPath());
        ((DefaultProfilerConfig) profilerConfig).setApplicationServerType(ServiceType.TEST_STAND_ALONE.getName());
    } catch (IOException ex) {
        throw new RuntimeException(ex.getMessage(), ex);
    }
    return of(profilerConfig);
}
Also used : ProfilerConfig(com.navercorp.pinpoint.bootstrap.config.ProfilerConfig) DefaultProfilerConfig(com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig) DefaultProfilerConfig(com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) URL(java.net.URL)

Example 10 with DefaultProfilerConfig

use of com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig in project pinpoint by naver.

the class VertxConfigTest method config.

@Test
public void config() {
    Properties properties = new Properties();
    properties.setProperty("profiler.vertx.enable", "true");
    properties.setProperty("profiler.vertx.http.server.enable", "true");
    properties.setProperty("profiler.vertx.http.client.enable", "true");
    properties.setProperty("profiler.vertx.bootstrap.main", "io.vertx.core.Starter");
    ProfilerConfig profilerConfig = new DefaultProfilerConfig(properties);
    VertxConfig config = new VertxConfig(profilerConfig);
    assertEquals(true, config.isEnable());
    assertEquals(true, config.isEnableHttpServer());
    assertEquals(true, config.isEnableHttpClient());
    assertEquals(1, config.getBootstrapMains().size());
    assertEquals("io.vertx.core.Starter", config.getBootstrapMains().get(0));
    properties = new Properties();
    properties.setProperty("profiler.vertx.enable", "false");
    properties.setProperty("profiler.vertx.http.server.enable", "false");
    properties.setProperty("profiler.vertx.http.client.enable", "false");
    properties.setProperty("profiler.vertx.bootstrap.main", "");
    profilerConfig = new DefaultProfilerConfig(properties);
    config = new VertxConfig(profilerConfig);
    assertEquals(false, config.isEnable());
    assertEquals(false, config.isEnableHttpServer());
    assertEquals(false, config.isEnableHttpClient());
    assertEquals(1, config.getBootstrapMains().size());
    assertEquals("", config.getBootstrapMains().get(0));
}
Also used : ProfilerConfig(com.navercorp.pinpoint.bootstrap.config.ProfilerConfig) DefaultProfilerConfig(com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig) DefaultProfilerConfig(com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig) Properties(java.util.Properties) Test(org.junit.Test)

Aggregations

DefaultProfilerConfig (com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig)36 ProfilerConfig (com.navercorp.pinpoint.bootstrap.config.ProfilerConfig)33 Test (org.junit.Test)25 Properties (java.util.Properties)24 BeanDefinition (org.springframework.beans.factory.config.BeanDefinition)12 RootBeanDefinition (org.springframework.beans.factory.support.RootBeanDefinition)12 DefaultAnnotationKeyRegistryService (com.navercorp.pinpoint.common.service.DefaultAnnotationKeyRegistryService)5 DefaultServiceTypeRegistryService (com.navercorp.pinpoint.common.service.DefaultServiceTypeRegistryService)5 AgentOption (com.navercorp.pinpoint.bootstrap.AgentOption)4 DefaultAgentOption (com.navercorp.pinpoint.bootstrap.DefaultAgentOption)4 TraceContext (com.navercorp.pinpoint.bootstrap.context.TraceContext)4 InterceptorRegistryBinder (com.navercorp.pinpoint.profiler.interceptor.registry.InterceptorRegistryBinder)4 DefaultApplicationContext (com.navercorp.pinpoint.profiler.context.module.DefaultApplicationContext)3 Module (com.google.inject.Module)2 Trace (com.navercorp.pinpoint.bootstrap.context.Trace)2 Slf4jLoggerBinder (com.navercorp.pinpoint.profiler.logging.Slf4jLoggerBinder)2 TestInterceptorRegistryBinder (com.navercorp.pinpoint.profiler.util.TestInterceptorRegistryBinder)2 MockApplicationContext (com.navercorp.pinpoint.test.MockApplicationContext)2 TestClassLoader (com.navercorp.pinpoint.test.classloader.TestClassLoader)2 Instrumentation (java.lang.instrument.Instrumentation)2