use of cn.taketoday.context.event.ContextRefreshedEvent in project today-infrastructure by TAKETODAY.
the class BeanFactoryPostProcessorTests method testBeanFactoryPostProcessorAsApplicationListener.
@Test
public void testBeanFactoryPostProcessorAsApplicationListener() {
StaticApplicationContext ac = new StaticApplicationContext();
ac.registerBeanDefinition("bfpp", new RootBeanDefinition(ListeningBeanFactoryPostProcessor.class));
ac.refresh();
boolean condition = ac.getBean(ListeningBeanFactoryPostProcessor.class).received instanceof ContextRefreshedEvent;
assertThat(condition).isTrue();
}
use of cn.taketoday.context.event.ContextRefreshedEvent in project today-infrastructure by TAKETODAY.
the class BeanFactoryPostProcessorTests method testBeanFactoryPostProcessorWithInnerBeanAsApplicationListener.
@Test
public void testBeanFactoryPostProcessorWithInnerBeanAsApplicationListener() {
StaticApplicationContext ac = new StaticApplicationContext();
RootBeanDefinition rbd = new RootBeanDefinition(NestingBeanFactoryPostProcessor.class);
rbd.getPropertyValues().add("listeningBean", new RootBeanDefinition(ListeningBean.class));
ac.registerBeanDefinition("bfpp", rbd);
ac.refresh();
boolean condition = ac.getBean(NestingBeanFactoryPostProcessor.class).getListeningBean().received instanceof ContextRefreshedEvent;
assertThat(condition).isTrue();
}
use of cn.taketoday.context.event.ContextRefreshedEvent in project today-infrastructure by TAKETODAY.
the class ApplicationListenerTests method testAddApplicationListener.
@Test
void testAddApplicationListener() throws NoSuchBeanDefinitionException, BeanDefinitionStoreException {
try (StandardApplicationContext applicationContext = new StandardApplicationContext()) {
applicationContext.addApplicationListener(new ApplicationListener<ContextRefreshedEvent>() {
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
i = true;
}
});
applicationContext.register(ContextCloseMetaInfoListener.class);
applicationContext.refresh();
assert i;
}
}
use of cn.taketoday.context.event.ContextRefreshedEvent in project today-framework by TAKETODAY.
the class ApplicationListenerTests method testAddApplicationListener.
@Test
void testAddApplicationListener() throws NoSuchBeanDefinitionException, BeanDefinitionStoreException {
try (StandardApplicationContext applicationContext = new StandardApplicationContext()) {
applicationContext.addApplicationListener(new ApplicationListener<ContextRefreshedEvent>() {
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
i = true;
}
});
applicationContext.register(ContextCloseMetaInfoListener.class);
applicationContext.refresh();
assert i;
}
}
use of cn.taketoday.context.event.ContextRefreshedEvent in project today-framework by TAKETODAY.
the class BeanFactoryPostProcessorTests method testBeanFactoryPostProcessorAsApplicationListener.
@Test
public void testBeanFactoryPostProcessorAsApplicationListener() {
StaticApplicationContext ac = new StaticApplicationContext();
ac.registerBeanDefinition("bfpp", new RootBeanDefinition(ListeningBeanFactoryPostProcessor.class));
ac.refresh();
boolean condition = ac.getBean(ListeningBeanFactoryPostProcessor.class).received instanceof ContextRefreshedEvent;
assertThat(condition).isTrue();
}
Aggregations