[bs-78] Add port=0 option to switch off main servlet container
[Fixes #48888639]
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user