use of com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig in project pinpoint by naver.
the class SpringBeansConfigTest method config.
@Test
public void config() {
Properties properties = new Properties();
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 1 + SpringBeansConfig.SPRING_BEANS_NAME_PATTERN_POSTFIX, "Target.*");
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 1 + SpringBeansConfig.SPRING_BEANS_ANNOTATION_POSTFIX, "org.springframework.stereotype.Controller");
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 2 + SpringBeansConfig.SPRING_BEANS_CLASS_PATTERN_POSTFIX, "java.lang.String");
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 2 + SpringBeansConfig.SPRING_BEANS_ANNOTATION_POSTFIX, "org.springframework.stereotype.Service");
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 3 + SpringBeansConfig.SPRING_BEANS_ANNOTATION_POSTFIX, "org.springframework.stereotype.Repository");
ProfilerConfig config = new DefaultProfilerConfig(properties);
SpringBeansConfig springBeansConfig = new SpringBeansConfig(config);
assertEquals(3, springBeansConfig.getTargets().size());
assertEquals(SpringBeansTargetScope.COMPONENT_SCAN, springBeansConfig.getTarget(1).getScope());
assertEquals(null, springBeansConfig.getTarget(1).getBasePackages());
assertEquals(1, springBeansConfig.getTarget(1).getNamePatterns().size());
assertEquals(1, springBeansConfig.getTarget(1).getAnnotations().size());
assertEquals(null, springBeansConfig.getTarget(1).getClassPatterns());
assertEquals(SpringBeansTargetScope.COMPONENT_SCAN, springBeansConfig.getTarget(2).getScope());
assertEquals(null, springBeansConfig.getTarget(2).getBasePackages());
assertEquals(null, springBeansConfig.getTarget(2).getNamePatterns());
assertEquals(1, springBeansConfig.getTarget(2).getAnnotations().size());
assertEquals(1, springBeansConfig.getTarget(2).getClassPatterns().size());
assertEquals(SpringBeansTargetScope.COMPONENT_SCAN, springBeansConfig.getTarget(3).getScope());
assertEquals(null, springBeansConfig.getTarget(3).getBasePackages());
assertEquals(null, springBeansConfig.getTarget(3).getNamePatterns());
assertEquals(1, springBeansConfig.getTarget(3).getAnnotations().size());
assertEquals(null, springBeansConfig.getTarget(3).getClassPatterns());
}
use of com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig in project pinpoint by naver.
the class SpringBeansConfigTest method empty.
@Test
public void empty() {
Properties properties = new Properties();
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 1 + SpringBeansConfig.SPRING_BEANS_NAME_PATTERN_POSTFIX, "Target.*");
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 1 + SpringBeansConfig.SPRING_BEANS_ANNOTATION_POSTFIX, "org.springframework.stereotype.Controller");
// empty
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 2 + SpringBeansConfig.SPRING_BEANS_NAME_PATTERN_POSTFIX, "");
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 2 + SpringBeansConfig.SPRING_BEANS_ANNOTATION_POSTFIX, "");
// empty
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 3 + SpringBeansConfig.SPRING_BEANS_ANNOTATION_POSTFIX, "");
// empty
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 4 + SpringBeansConfig.SPRING_BEANS_NAME_PATTERN_POSTFIX, "");
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 4 + SpringBeansConfig.SPRING_BEANS_ANNOTATION_POSTFIX, "");
// empty
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 5 + SpringBeansConfig.SPRING_BEANS_NAME_PATTERN_POSTFIX, "");
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 5 + SpringBeansConfig.SPRING_BEANS_ANNOTATION_POSTFIX, "");
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 6 + SpringBeansConfig.SPRING_BEANS_CLASS_PATTERN_POSTFIX, "java.lang.String");
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 6 + SpringBeansConfig.SPRING_BEANS_ANNOTATION_POSTFIX, "org.springframework.stereotype.Service");
ProfilerConfig config = new DefaultProfilerConfig(properties);
SpringBeansConfig springBeansConfig = new SpringBeansConfig(config);
assertEquals(2, springBeansConfig.getTargets().size());
}
use of com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig in project pinpoint by naver.
the class SpringBeansConfigTest method scope.
@Test
public void scope() {
Properties properties = new Properties();
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 1 + SpringBeansConfig.SPRING_BEANS_SCOPE_POSTFIX, "component-scan");
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 1 + SpringBeansConfig.SPRING_BEANS_ANNOTATION_POSTFIX, "org.springframework.stereotype.Service");
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 2 + SpringBeansConfig.SPRING_BEANS_SCOPE_POSTFIX, "component-scan");
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 2 + SpringBeansConfig.SPRING_BEANS_BASE_PACKAGES_POSTFIX, "com.navercorp");
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 2 + SpringBeansConfig.SPRING_BEANS_ANNOTATION_POSTFIX, "org.springframework.stereotype.Service");
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 3 + SpringBeansConfig.SPRING_BEANS_SCOPE_POSTFIX, "post-processor");
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 3 + SpringBeansConfig.SPRING_BEANS_BASE_PACKAGES_POSTFIX, "com.navercorp");
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 3 + SpringBeansConfig.SPRING_BEANS_ANNOTATION_POSTFIX, "org.springframework.stereotype.Service");
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 4 + SpringBeansConfig.SPRING_BEANS_SCOPE_POSTFIX, "post-processor");
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 4 + SpringBeansConfig.SPRING_BEANS_ANNOTATION_POSTFIX, "org.springframework.stereotype.Service");
ProfilerConfig config = new DefaultProfilerConfig(properties);
SpringBeansConfig springBeansConfig = new SpringBeansConfig(config);
assertEquals(4, springBeansConfig.getTargets().size());
}
use of com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig in project pinpoint by naver.
the class TargetBeanFilterTest method testClassLoadedByBootClassLoader.
@Test
public void testClassLoadedByBootClassLoader() {
Properties properties = new Properties();
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 1 + SpringBeansConfig.SPRING_BEANS_ANNOTATION_POSTFIX, "org.springframework.stereotype.Controller");
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 2 + SpringBeansConfig.SPRING_BEANS_ANNOTATION_POSTFIX, "org.springframework.stereotype.Service");
properties.put(SpringBeansConfig.SPRING_BEANS_PREFIX + 3 + SpringBeansConfig.SPRING_BEANS_ANNOTATION_POSTFIX, "org.springframework.stereotype.Repository");
ProfilerConfig config = new DefaultProfilerConfig(properties);
TargetBeanFilter filter = TargetBeanFilter.of(config);
filter.clear();
if (String.class.getClassLoader() != null) {
logger.debug("String is not loaded by: {}. Skip test.", String.class.getClassLoader());
return;
}
BeanDefinition beanDefinition = new RootBeanDefinition(String.class);
assertEquals(false, filter.isTarget(SpringBeansTargetScope.COMPONENT_SCAN, "someBean", beanDefinition));
}
use of com.navercorp.pinpoint.bootstrap.config.DefaultProfilerConfig in project pinpoint by naver.
the class TargetBeanFilterTest method target6.
@Test
public void target6() {
Properties properties = new Properties();
properties.put(SpringBeansConfig.SPRING_BEANS_NAME_PATTERN, "foo");
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);
assertTrue(filter.isTarget(SpringBeansTargetScope.COMPONENT_SCAN, "foo", beanDefinition));
assertFalse(filter.isTarget(SpringBeansTargetScope.COMPONENT_SCAN, "Target0", beanDefinition));
assertTrue(filter.isTarget(SpringBeansTargetScope.COMPONENT_SCAN, "Target1", beanDefinition));
assertTrue(filter.isTarget(SpringBeansTargetScope.COMPONENT_SCAN, "Target2", beanDefinition));
}
Aggregations