use of org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent in project spring-boot by spring-projects.
the class ConfigFileApplicationListenerTests method postProcessorsAreOrderedCorrectly.
@Test
public void postProcessorsAreOrderedCorrectly() {
TestConfigFileApplicationListener testListener = new TestConfigFileApplicationListener();
testListener.onApplicationEvent(new ApplicationEnvironmentPreparedEvent(this.application, new String[0], this.environment));
}
use of org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent in project spring-boot by spring-projects.
the class DelegatingApplicationListenerTests method orderedInitialize.
@Test
public void orderedInitialize() throws Exception {
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.context, "context.listener.classes=" + MockInitB.class.getName() + "," + MockInitA.class.getName());
this.listener.onApplicationEvent(new ApplicationEnvironmentPreparedEvent(new SpringApplication(), new String[0], this.context.getEnvironment()));
this.context.getBeanFactory().registerSingleton("testListener", this.listener);
this.context.refresh();
assertThat(this.context.getBeanFactory().getSingleton("a")).isEqualTo("a");
assertThat(this.context.getBeanFactory().getSingleton("b")).isEqualTo("b");
}
use of org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent in project spring-boot by spring-projects.
the class DelegatingApplicationListener method onApplicationEvent.
@Override
public void onApplicationEvent(ApplicationEvent event) {
if (event instanceof ApplicationEnvironmentPreparedEvent) {
List<ApplicationListener<ApplicationEvent>> delegates = getListeners(((ApplicationEnvironmentPreparedEvent) event).getEnvironment());
if (delegates.isEmpty()) {
return;
}
this.multicaster = new SimpleApplicationEventMulticaster();
for (ApplicationListener<ApplicationEvent> listener : delegates) {
this.multicaster.addApplicationListener(listener);
}
}
if (this.multicaster != null) {
this.multicaster.multicastEvent(event);
}
}
use of org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent in project spring-boot by spring-projects.
the class DelegatingApplicationListenerTests method emptyInitializers.
@Test
public void emptyInitializers() throws Exception {
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.context, "context.listener.classes:");
this.listener.onApplicationEvent(new ApplicationEnvironmentPreparedEvent(new SpringApplication(), new String[0], this.context.getEnvironment()));
}
Aggregations