@ -43,14 +43,11 @@ import org.mockito.MockitoAnnotations;
@@ -43,14 +43,11 @@ import org.mockito.MockitoAnnotations;
import org.springframework.beans.MutablePropertyValues ;
import org.springframework.beans.factory.BeanCreationException ;
import org.springframework.beans.factory.DisposableBean ;
import org.springframework.beans.factory.config.BeanDefinition ;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory ;
import org.springframework.beans.factory.config.ConstructorArgumentValues ;
import org.springframework.beans.factory.config.Scope ;
import org.springframework.beans.factory.support.BeanDefinitionBuilder ;
import org.springframework.beans.factory.support.RootBeanDefinition ;
import org.springframework.boot.context.embedded.MockEmbeddedServletContainerFactory.MockEmbeddedServletContainer ;
import org.springframework.boot.context.web.ServerPortInfoApplicationContextInitializer ;
import org.springframework.context.ApplicationContextException ;
import org.springframework.context.ApplicationListener ;
@ -68,7 +65,6 @@ import org.springframework.web.filter.GenericFilterBean;
@@ -68,7 +65,6 @@ import org.springframework.web.filter.GenericFilterBean;
import static org.hamcrest.Matchers.equalTo ;
import static org.hamcrest.Matchers.instanceOf ;
import static org.hamcrest.Matchers.is ;
import static org.hamcrest.Matchers.nullValue ;
import static org.hamcrest.Matchers.sameInstance ;
import static org.junit.Assert.assertEquals ;
@ -485,21 +481,6 @@ public class EmbeddedWebApplicationContextTests {
@@ -485,21 +481,6 @@ public class EmbeddedWebApplicationContextTests {
sameInstance ( scope ) ) ;
}
@Test
public void containerIsStoppedBeforeContextIsClosed ( ) {
addEmbeddedServletContainerFactoryBean ( ) ;
this . context . registerBeanDefinition ( "shutdownOrderingValidator" ,
BeanDefinitionBuilder . rootBeanDefinition ( ShutdownOrderingValidator . class )
. addConstructorArgReference ( "embeddedServletContainerFactory" )
. getBeanDefinition ( ) ) ;
this . context . refresh ( ) ;
ShutdownOrderingValidator validator = this . context
. getBean ( ShutdownOrderingValidator . class ) ;
this . context . close ( ) ;
assertThat ( validator . destroyed , is ( true ) ) ;
assertThat ( validator . containerStoppedFirst , is ( true ) ) ;
}
private void addEmbeddedServletContainerFactoryBean ( ) {
this . context . registerBeanDefinition ( "embeddedServletContainerFactory" ,
new RootBeanDefinition ( MockEmbeddedServletContainerFactory . class ) ) ;
@ -552,25 +533,4 @@ public class EmbeddedWebApplicationContextTests {
@@ -552,25 +533,4 @@ public class EmbeddedWebApplicationContextTests {
}
protected static class ShutdownOrderingValidator implements DisposableBean {
private final MockEmbeddedServletContainer servletContainer ;
private boolean destroyed = false ;
private boolean containerStoppedFirst = false ;
ShutdownOrderingValidator (
MockEmbeddedServletContainerFactory servletContainerFactory ) {
this . servletContainer = servletContainerFactory . getContainer ( ) ;
}
@Override
public void destroy ( ) {
this . destroyed = true ;
this . containerStoppedFirst = this . servletContainer . isStopped ( ) ;
}
}
}