Search in sources :

Example 1 with ApplicationEnvironmentPreparedEvent

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");
}
Also used : ApplicationStartingEvent(cn.taketoday.framework.context.event.ApplicationStartingEvent) ApplicationEnvironmentPreparedEvent(cn.taketoday.framework.context.event.ApplicationEnvironmentPreparedEvent) Test(org.junit.jupiter.api.Test)

Example 2 with ApplicationEnvironmentPreparedEvent

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");
}
Also used : ApplicationStartingEvent(cn.taketoday.framework.context.event.ApplicationStartingEvent) ApplicationEnvironmentPreparedEvent(cn.taketoday.framework.context.event.ApplicationEnvironmentPreparedEvent) Test(org.junit.jupiter.api.Test)

Aggregations

ApplicationEnvironmentPreparedEvent (cn.taketoday.framework.context.event.ApplicationEnvironmentPreparedEvent)2 ApplicationStartingEvent (cn.taketoday.framework.context.event.ApplicationStartingEvent)2 Test (org.junit.jupiter.api.Test)2