Johnny Lim opened SPR-14199 and commented
LiveBeansView doesn't contain singletons registered programmatically.
With the following test, the second assertion is passed:
public class LiveBeansViewTests {
@Test
public void test() {
AnnotationConfigApplicationContext context
= new AnnotationConfigApplicationContext();
context.register(TestConfiguration.class);
context.getBeanFactory().registerSingleton("bean2", new MyBean());
context.refresh();
LiveBeansView view = new LiveBeansView();
view.setApplicationContext(context);
String json = view.getSnapshotAsJson();
assertThat(json).contains("bean1");
// FIXME: Should work with `contains()` not `doesNotContain()`.
assertThat(json).doesNotContain("bean2");
}
@Configuration
public static class TestConfiguration {
@Bean
public MyBean bean1() {
return new MyBean();
}
}
private static class MyBean {
}
}
The second assertion should fail.
This was originally reported at https://github.com/spring-projects/spring-boot/issues/5761
Reference URL: https://github.com/izeye/spring-boot-throwaway-branches/blob/rest-and-actuator/src/test/java/learningtest/org/springframework/context/support/LiveBeansViewTests.java
Issue Links: - #19051 LiveBeansView should expose FactoryBean's scope - #21438 LiveBeansView should support double quotes in application context id
Comment From: sbrannen
Closing since LiveBeansView is now deprecated (see #25820).