Example usage for org.springframework.boot.context.event ApplicationFailedEvent getApplicationContext

List of usage examples for org.springframework.boot.context.event ApplicationFailedEvent getApplicationContext

Introduction

In this page you can find the example usage for org.springframework.boot.context.event ApplicationFailedEvent getApplicationContext.

Prototype

public ConfigurableApplicationContext getApplicationContext() 

Source Link

Document

Return the application context.

Usage

From source file:org.springframework.boot.actuate.autoconfigure.EndpointWebMvcAutoConfigurationTests.java

@Test
public void onDifferentPortWithPrimaryFailure() throws Exception {
    EnvironmentTestUtils.addEnvironment(this.applicationContext, "management.port=" + ports.get().management);
    this.applicationContext.register(RootConfig.class, EndpointConfig.class, DifferentPortConfig.class,
            BaseConfiguration.class, EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class);
    this.applicationContext.refresh();
    ApplicationContext managementContext = this.applicationContext.getBean(ManagementContextResolver.class)
            .getApplicationContext();//from   w  w  w.  j a  va  2 s . c  om
    ApplicationFailedEvent event = mock(ApplicationFailedEvent.class);
    given(event.getApplicationContext()).willReturn(this.applicationContext);
    this.applicationContext.publishEvent(event);
    assertThat(((ConfigurableApplicationContext) managementContext).isActive()).isFalse();
}

From source file:org.springframework.boot.devtools.restart.RestartApplicationListener.java

private void onApplicationFailedEvent(ApplicationFailedEvent event) {
    Restarter.getInstance().remove(event.getApplicationContext());
}