use of cn.taketoday.framework.context.event.ApplicationEnvironmentPreparedEvent in project today-infrastructure by TAKETODAY.
the class ApplicationTests method addBootstrapRegistryInitializer.
@Test
void addBootstrapRegistryInitializer() {
Application application = new Application(ExampleConfig.class);
application.setApplicationType(ApplicationType.NONE_WEB);
application.addBootstrapRegistryInitializer((bootstrapContext) -> bootstrapContext.register(String.class, InstanceSupplier.of("boot")));
TestApplicationListener listener = new TestApplicationListener();
application.addListeners(listener);
application.run();
ApplicationStartingEvent startingEvent = listener.getEvent(ApplicationStartingEvent.class);
assertThat(startingEvent.getBootstrapContext().get(String.class)).isEqualTo("boot");
ApplicationEnvironmentPreparedEvent environmentPreparedEvent = listener.getEvent(ApplicationEnvironmentPreparedEvent.class);
assertThat(environmentPreparedEvent.getBootstrapContext().get(String.class)).isEqualTo("boot");
}
use of cn.taketoday.framework.context.event.ApplicationEnvironmentPreparedEvent in project today-framework by TAKETODAY.
the class ApplicationTests method addBootstrapRegistryInitializer.
@Test
void addBootstrapRegistryInitializer() {
Application application = new Application(ExampleConfig.class);
application.setApplicationType(ApplicationType.NONE_WEB);
application.addBootstrapRegistryInitializer((bootstrapContext) -> bootstrapContext.register(String.class, InstanceSupplier.of("boot")));
TestApplicationListener listener = new TestApplicationListener();
application.addListeners(listener);
application.run();
ApplicationStartingEvent startingEvent = listener.getEvent(ApplicationStartingEvent.class);
assertThat(startingEvent.getBootstrapContext().get(String.class)).isEqualTo("boot");
ApplicationEnvironmentPreparedEvent environmentPreparedEvent = listener.getEvent(ApplicationEnvironmentPreparedEvent.class);
assertThat(environmentPreparedEvent.getBootstrapContext().get(String.class)).isEqualTo("boot");
}
Aggregations