|
|
|
@ -229,7 +229,8 @@ public class SpringApplicationTests { |
|
|
|
SpringApplication application = new SpringApplication(ExampleConfig.class); |
|
|
|
SpringApplication application = new SpringApplication(ExampleConfig.class); |
|
|
|
application.setWebEnvironment(false); |
|
|
|
application.setWebEnvironment(false); |
|
|
|
final AtomicReference<SpringApplication> reference = new AtomicReference<SpringApplication>(); |
|
|
|
final AtomicReference<SpringApplication> reference = new AtomicReference<SpringApplication>(); |
|
|
|
class ApplicationReadyEventListener implements ApplicationListener<ApplicationReadyEvent> { |
|
|
|
class ApplicationReadyEventListener implements |
|
|
|
|
|
|
|
ApplicationListener<ApplicationReadyEvent> { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onApplicationEvent(ApplicationReadyEvent event) { |
|
|
|
public void onApplicationEvent(ApplicationReadyEvent event) { |
|
|
|
reference.set(event.getSpringApplication()); |
|
|
|
reference.set(event.getSpringApplication()); |
|
|
|
@ -263,7 +264,8 @@ public class SpringApplicationTests { |
|
|
|
SpringApplication application = new SpringApplication(ExampleConfig.class); |
|
|
|
SpringApplication application = new SpringApplication(ExampleConfig.class); |
|
|
|
application.setWebEnvironment(false); |
|
|
|
application.setWebEnvironment(false); |
|
|
|
final List<ApplicationEvent> events = new ArrayList<ApplicationEvent>(); |
|
|
|
final List<ApplicationEvent> events = new ArrayList<ApplicationEvent>(); |
|
|
|
class ApplicationRunningEventListener implements ApplicationListener<ApplicationEvent> { |
|
|
|
class ApplicationRunningEventListener implements |
|
|
|
|
|
|
|
ApplicationListener<ApplicationEvent> { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onApplicationEvent(ApplicationEvent event) { |
|
|
|
public void onApplicationEvent(ApplicationEvent event) { |
|
|
|
events.add((event)); |
|
|
|
events.add((event)); |
|
|
|
@ -273,7 +275,8 @@ public class SpringApplicationTests { |
|
|
|
this.context = application.run(); |
|
|
|
this.context = application.run(); |
|
|
|
assertThat(5, is(events.size())); |
|
|
|
assertThat(5, is(events.size())); |
|
|
|
assertThat(events.get(0), is(instanceOf(ApplicationStartedEvent.class))); |
|
|
|
assertThat(events.get(0), is(instanceOf(ApplicationStartedEvent.class))); |
|
|
|
assertThat(events.get(1), is(instanceOf(ApplicationEnvironmentPreparedEvent.class))); |
|
|
|
assertThat(events.get(1), |
|
|
|
|
|
|
|
is(instanceOf(ApplicationEnvironmentPreparedEvent.class))); |
|
|
|
assertThat(events.get(2), is(instanceOf(ApplicationPreparedEvent.class))); |
|
|
|
assertThat(events.get(2), is(instanceOf(ApplicationPreparedEvent.class))); |
|
|
|
assertThat(events.get(3), is(instanceOf(ContextRefreshedEvent.class))); |
|
|
|
assertThat(events.get(3), is(instanceOf(ContextRefreshedEvent.class))); |
|
|
|
assertThat(events.get(4), is(instanceOf(ApplicationReadyEvent.class))); |
|
|
|
assertThat(events.get(4), is(instanceOf(ApplicationReadyEvent.class))); |
|
|
|
|