JoinfacesApplicationAnalyzer implements ApplicationListener<ApplicationStartedEvent> { @SuppressWarnings("unchecked") @Override public void onApplicationEvent(ApplicationStartedEvent event) { try { Class<? extends Annotation> managedBeanClass = (Class<? extends Annotation>) Class.forName("javax.faces.bean.ManagedBean"); warnAboutJsfManagedBeans(event.getApplicationContext(), managedBeanClass); } catch (ClassNotFoundException | LinkageError ignored) { } }  @SuppressWarnings("unchecked") @Override void onApplicationEvent(ApplicationStartedEvent event);  }
@Test public void testJsfManagedBeans() { this.applicationContextRunner .withUserConfiguration(DummyConfiguration.class) .run(context -> { assertThat(context.getBeanNamesForAnnotation(ManagedBean.class)).isNotEmpty(); ApplicationStartedEvent applicationStartedEvent = mock(ApplicationStartedEvent.class); when(applicationStartedEvent.getApplicationContext()).thenReturn(context.getSourceApplicationContext()); this.joinfacesApplicationAnalyzer.onApplicationEvent(applicationStartedEvent); }); }