Search in sources :

Example 21 with DefaultProfilerConfig

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

the class TargetBeanFilterTest method target2.

@Test
public void target2() {
    Properties properties = new Properties();
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 1 + SpringBeansConfig.SPRING_BEANS_NAME_PATTERN_POSTFIX, "");
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 1 + SpringBeansConfig.SPRING_BEANS_CLASS_PATTERN_POSTFIX, "");
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 1 + SpringBeansConfig.SPRING_BEANS_ANNOTATION_POSTFIX, "");
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 2 + SpringBeansConfig.SPRING_BEANS_NAME_PATTERN_POSTFIX, "Target.*");
    ProfilerConfig config = new DefaultProfilerConfig(properties);
    TargetBeanFilter filter = TargetBeanFilter.of(config);
    filter.clear();
    BeanDefinition beanDefinition = new RootBeanDefinition(String.class);
    assertTrue(filter.isTarget(SpringBeansTargetScope.COMPONENT_SCAN, "Target0", beanDefinition));
}
Also used : ProfilerConfig(com.navercorp.pinpoint.bootstrap.config.ProfilerConfig) DefaultProfilerConfig(com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig) DefaultProfilerConfig(com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig) RootBeanDefinition(org.springframework.beans.factory.support.RootBeanDefinition) Properties(java.util.Properties) RootBeanDefinition(org.springframework.beans.factory.support.RootBeanDefinition) BeanDefinition(org.springframework.beans.factory.config.BeanDefinition) Test(org.junit.Test)

Example 22 with DefaultProfilerConfig

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

the class TargetBeanFilterTest method target5.

@Test
public void target5() {
    Properties properties = new Properties();
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 1 + SpringBeansConfig.SPRING_BEANS_NAME_PATTERN_POSTFIX, "Target1, Target2");
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 1 + SpringBeansConfig.SPRING_BEANS_CLASS_PATTERN_POSTFIX, "");
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 1 + SpringBeansConfig.SPRING_BEANS_ANNOTATION_POSTFIX, "");
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 2 + SpringBeansConfig.SPRING_BEANS_NAME_PATTERN_POSTFIX, "Target0");
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 2 + SpringBeansConfig.SPRING_BEANS_ANNOTATION_POSTFIX, "org.springframework.stereotype.Controller");
    ProfilerConfig config = new DefaultProfilerConfig(properties);
    TargetBeanFilter filter = TargetBeanFilter.of(config);
    filter.clear();
    BeanDefinition beanDefinition = new RootBeanDefinition(String.class);
    assertFalse(filter.isTarget(SpringBeansTargetScope.COMPONENT_SCAN, "Target0", beanDefinition));
    assertTrue(filter.isTarget(SpringBeansTargetScope.COMPONENT_SCAN, "Target1", beanDefinition));
    assertTrue(filter.isTarget(SpringBeansTargetScope.COMPONENT_SCAN, "Target2", beanDefinition));
}
Also used : ProfilerConfig(com.navercorp.pinpoint.bootstrap.config.ProfilerConfig) DefaultProfilerConfig(com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig) DefaultProfilerConfig(com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig) RootBeanDefinition(org.springframework.beans.factory.support.RootBeanDefinition) Properties(java.util.Properties) RootBeanDefinition(org.springframework.beans.factory.support.RootBeanDefinition) BeanDefinition(org.springframework.beans.factory.config.BeanDefinition) Test(org.junit.Test)

Example 23 with DefaultProfilerConfig

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

the class TargetBeanFilterTest method empty.

@Test
public void empty() {
    Properties properties = new Properties();
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 1 + SpringBeansConfig.SPRING_BEANS_NAME_PATTERN_POSTFIX, "");
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 1 + SpringBeansConfig.SPRING_BEANS_CLASS_PATTERN_POSTFIX, "");
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 1 + SpringBeansConfig.SPRING_BEANS_ANNOTATION_POSTFIX, "");
    ProfilerConfig config = new DefaultProfilerConfig(properties);
    TargetBeanFilter filter = TargetBeanFilter.of(config);
    filter.clear();
    BeanDefinition beanDefinition = new RootBeanDefinition(String.class);
    assertFalse(filter.isTarget(SpringBeansTargetScope.COMPONENT_SCAN, "Target0", beanDefinition));
    filter.addTransformed(String.class.getName());
    assertFalse(filter.isTarget(SpringBeansTargetScope.COMPONENT_SCAN, "Target0", beanDefinition));
    assertFalse(filter.isTarget(SpringBeansTargetScope.COMPONENT_SCAN, "Target0", beanDefinition));
}
Also used : ProfilerConfig(com.navercorp.pinpoint.bootstrap.config.ProfilerConfig) DefaultProfilerConfig(com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig) DefaultProfilerConfig(com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig) RootBeanDefinition(org.springframework.beans.factory.support.RootBeanDefinition) Properties(java.util.Properties) RootBeanDefinition(org.springframework.beans.factory.support.RootBeanDefinition) BeanDefinition(org.springframework.beans.factory.config.BeanDefinition) Test(org.junit.Test)

Example 24 with DefaultProfilerConfig

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

the class AgentClassLoaderTest method boot.

@Test
public void boot() throws IOException, ClassNotFoundException {
    AgentClassLoader agentClassLoader = new AgentClassLoader(new URL[0]);
    agentClassLoader.setBootClass("com.navercorp.pinpoint.bootstrap.DummyAgent");
    AgentOption option = new DefaultAgentOption(new DummyInstrumentation(), "testCaseAgent", "testCaseAppName", new DefaultProfilerConfig(), new URL[0], null, new DefaultServiceTypeRegistryService(), new DefaultAnnotationKeyRegistryService());
    agentClassLoader.boot(option);
// TODO need verification - implementation for obtaining logger changed
//        PLoggerBinder loggerBinder = (PLoggerBinder) agentClassLoader.initializeLoggerBinder();
//        PLogger test = loggerBinder.getLogger("test");
//        test.info("slf4j logger test");
}
Also used : DefaultProfilerConfig(com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig) DefaultServiceTypeRegistryService(com.navercorp.pinpoint.common.service.DefaultServiceTypeRegistryService) DefaultAnnotationKeyRegistryService(com.navercorp.pinpoint.common.service.DefaultAnnotationKeyRegistryService) Test(org.junit.Test)

Example 25 with DefaultProfilerConfig

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

the class SpringBeansConfigTest method invalid.

@Test
public void invalid() {
    Properties properties = new Properties();
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 1 + "foo", "Target.*");
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 1 + "bar", "org.springframework.stereotype.Controller");
    // empty
    properties.put("foo" + 2 + SpringBeansConfig.SPRING_BEANS_NAME_PATTERN_POSTFIX, "");
    properties.put("bar" + 2 + SpringBeansConfig.SPRING_BEANS_ANNOTATION_POSTFIX, "");
    // wrong number 1.
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 6.12 + SpringBeansConfig.SPRING_BEANS_CLASS_PATTERN_POSTFIX, "java.lang.String");
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 6.12 + SpringBeansConfig.SPRING_BEANS_ANNOTATION_POSTFIX, "org.springframework.stereotype.Service");
    // wrong number 2.
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + "A" + SpringBeansConfig.SPRING_BEANS_CLASS_PATTERN_POSTFIX, "java.lang.String");
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + "A" + SpringBeansConfig.SPRING_BEANS_ANNOTATION_POSTFIX, "org.springframework.stereotype.Service");
    // not found number
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + SpringBeansConfig.SPRING_BEANS_CLASS_PATTERN_POSTFIX, "java.lang.String");
    properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + SpringBeansConfig.SPRING_BEANS_ANNOTATION_POSTFIX, "org.springframework.stereotype.Service");
    ProfilerConfig config = new DefaultProfilerConfig(properties);
    SpringBeansConfig springBeansConfig = new SpringBeansConfig(config);
    assertEquals(0, springBeansConfig.getTargets().size());
}
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