[bs-78] Add port=0 option to switch off main servlet container

[Fixes #48888639]
This commit is contained in:
Dave Syer
2013-04-29 09:15:03 +01:00
parent 628a8c79aa
commit e8e059bc90
5 changed files with 56 additions and 7 deletions

View File

@@ -38,10 +38,6 @@ import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.rules.TemporaryFolder;
import org.mockito.InOrder;
import org.springframework.bootstrap.context.embedded.AbstractEmbeddedServletContainerFactory;
import org.springframework.bootstrap.context.embedded.EmbeddedServletContainer;
import org.springframework.bootstrap.context.embedded.FilterRegistrationBean;
import org.springframework.bootstrap.context.embedded.ServletRegistrationBean;
import org.springframework.http.HttpMethod;
import org.springframework.http.client.ClientHttpRequest;
import org.springframework.http.client.ClientHttpResponse;
@@ -90,6 +86,17 @@ public abstract class AbstractEmbeddedServletContainerFactoryTests {
assertThat(getResponse("http://localhost:8080/hello"), equalTo("Hello World"));
}
@Test
public void emptyServer() throws Exception {
AbstractEmbeddedServletContainerFactory factory = getFactory();
factory.setPort(0);
this.container = factory
.getEmbdeddedServletContainer(exampleServletRegistration());
this.thrown.expect(ConnectException.class);
this.thrown.expectMessage("Connection refused");
getResponse("http://localhost:8080/hello");
}
@Test
public void stopServlet() throws Exception {
AbstractEmbeddedServletContainerFactory factory = getFactory();