|
|
|
@ -26,7 +26,13 @@ import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
|
|
import javax.naming.InitialContext;
|
|
|
|
|
import javax.naming.NamingException;
|
|
|
|
|
import javax.servlet.Filter;
|
|
|
|
|
import javax.servlet.FilterChain;
|
|
|
|
|
import javax.servlet.FilterConfig;
|
|
|
|
|
import javax.servlet.ServletContext;
|
|
|
|
|
import javax.servlet.ServletException;
|
|
|
|
|
import javax.servlet.ServletRequest;
|
|
|
|
|
import javax.servlet.ServletResponse;
|
|
|
|
|
|
|
|
|
|
import org.apache.catalina.Container;
|
|
|
|
|
import org.apache.catalina.Context;
|
|
|
|
@ -51,6 +57,7 @@ import org.mockito.InOrder;
|
|
|
|
|
import org.springframework.boot.testutil.InternalOutputCapture;
|
|
|
|
|
import org.springframework.boot.web.server.Ssl;
|
|
|
|
|
import org.springframework.boot.web.server.WebServerException;
|
|
|
|
|
import org.springframework.boot.web.servlet.ServletContextInitializer;
|
|
|
|
|
import org.springframework.boot.web.servlet.server.AbstractServletWebServerFactory;
|
|
|
|
|
import org.springframework.boot.web.servlet.server.AbstractServletWebServerFactoryTests;
|
|
|
|
|
import org.springframework.test.util.ReflectionTestUtils;
|
|
|
|
@ -444,6 +451,38 @@ public class TomcatServletWebServerFactoryTests
|
|
|
|
|
assertThat(sessionIdGenerator.getJvmRoute()).isEqualTo("test");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void faultyFilterCausesStartFailure() throws Exception {
|
|
|
|
|
TomcatServletWebServerFactory factory = getFactory();
|
|
|
|
|
factory.addInitializers(new ServletContextInitializer() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onStartup(ServletContext servletContext) throws ServletException {
|
|
|
|
|
servletContext.addFilter("faulty", new Filter() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void init(FilterConfig filterConfig) throws ServletException {
|
|
|
|
|
throw new ServletException("Faulty filter");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void doFilter(ServletRequest request, ServletResponse response,
|
|
|
|
|
FilterChain chain) throws IOException, ServletException {
|
|
|
|
|
chain.doFilter(request, response);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void destroy() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
this.thrown.expect(WebServerException.class);
|
|
|
|
|
factory.getWebServer().start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected JspServlet getJspServlet() throws ServletException {
|
|
|
|
|
Tomcat tomcat = ((TomcatWebServer) this.webServer).getTomcat();
|
|
|
|
|