Detect Tomcat start failures

Detect if the tomcat container fails to start and propagate an
exception to the caller.
This commit is contained in:
Phillip Webb
2013-11-05 16:50:29 -08:00
parent 2910fe618b
commit 4c75700164
3 changed files with 14 additions and 3 deletions

View File

@@ -24,7 +24,6 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.mockito.Mockito;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.boot.TestUtils;
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext;
@@ -35,6 +34,7 @@ import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory
import org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.properties.ServerProperties;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.context.ApplicationContextException;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -133,7 +133,7 @@ public class ServerPropertiesAutoConfigurationTests {
this.context.register(Config.class, MutiServerPropertiesBeanConfig.class,
ServerPropertiesAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class);
this.thrown.expect(BeanCreationException.class);
this.thrown.expect(ApplicationContextException.class);
this.thrown.expectMessage("Multiple ServerProperties");
this.context.refresh();
}