use of org.springframework.boot.actuate.beans.BeansEndpoint.ApplicationBeans in project spring-boot by spring-projects.
the class BeansEndpointTests method infrastructureBeansAreOmitted.
@Test
void infrastructureBeansAreOmitted() {
ApplicationContextRunner contextRunner = new ApplicationContextRunner().withUserConfiguration(EndpointConfiguration.class);
contextRunner.run((context) -> {
ConfigurableListableBeanFactory factory = (ConfigurableListableBeanFactory) context.getAutowireCapableBeanFactory();
List<String> infrastructureBeans = Stream.of(context.getBeanDefinitionNames()).filter((name) -> BeanDefinition.ROLE_INFRASTRUCTURE == factory.getBeanDefinition(name).getRole()).collect(Collectors.toList());
ApplicationBeans result = context.getBean(BeansEndpoint.class).beans();
ContextBeans contextDescriptor = result.getContexts().get(context.getId());
Map<String, BeanDescriptor> beans = contextDescriptor.getBeans();
for (String infrastructureBean : infrastructureBeans) {
assertThat(beans).doesNotContainKey(infrastructureBean);
}
});
}
use of org.springframework.boot.actuate.beans.BeansEndpoint.ApplicationBeans in project spring-boot by spring-projects.
the class BeansEndpointTests method beansInParentContextAreFound.
@Test
void beansInParentContextAreFound() {
ApplicationContextRunner parentRunner = new ApplicationContextRunner().withUserConfiguration(BeanConfiguration.class);
parentRunner.run((parent) -> {
new ApplicationContextRunner().withUserConfiguration(EndpointConfiguration.class).withParent(parent).run((child) -> {
ApplicationBeans result = child.getBean(BeansEndpoint.class).beans();
assertThat(result.getContexts().get(parent.getId()).getBeans()).containsKey("bean");
assertThat(result.getContexts().get(child.getId()).getBeans()).containsKey("endpoint");
});
});
}
use of org.springframework.boot.actuate.beans.BeansEndpoint.ApplicationBeans in project spring-boot by spring-projects.
the class BeansEndpointTests method lazyBeansAreOmitted.
@Test
void lazyBeansAreOmitted() {
ApplicationContextRunner contextRunner = new ApplicationContextRunner().withUserConfiguration(EndpointConfiguration.class, LazyBeanConfiguration.class);
contextRunner.run((context) -> {
ApplicationBeans result = context.getBean(BeansEndpoint.class).beans();
ContextBeans contextDescriptor = result.getContexts().get(context.getId());
assertThat(context).hasBean("lazyBean");
assertThat(contextDescriptor.getBeans()).doesNotContainKey("lazyBean");
});
}
use of org.springframework.boot.actuate.beans.BeansEndpoint.ApplicationBeans in project spring-boot by spring-projects.
the class BeansEndpointTests method beansAreFound.
@Test
void beansAreFound() {
ApplicationContextRunner contextRunner = new ApplicationContextRunner().withUserConfiguration(EndpointConfiguration.class);
contextRunner.run((context) -> {
ApplicationBeans result = context.getBean(BeansEndpoint.class).beans();
ContextBeans descriptor = result.getContexts().get(context.getId());
assertThat(descriptor.getParentId()).isNull();
Map<String, BeanDescriptor> beans = descriptor.getBeans();
assertThat(beans.size()).isLessThanOrEqualTo(context.getBeanDefinitionCount());
assertThat(beans).containsKey("endpoint");
});
}
Aggregations