Search in sources :

Example 26 with ExampleServlet

use of cn.taketoday.test.web.servlet.ExampleServlet in project today-infrastructure by TAKETODAY.

the class UndertowServletWebServerFactoryTests method errorPage404.

@Test
void errorPage404() throws Exception {
    AbstractServletWebServerFactory factory = getFactory();
    factory.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND, "/hello"));
    this.webServer = factory.getWebServer(new ServletRegistrationBean<>(new ExampleServlet(), "/hello"));
    this.webServer.start();
    Assertions.assertThat(getResponse(getLocalUrl("/hello"))).isEqualTo("Hello World");
    Assertions.assertThat(getResponse(getLocalUrl("/not-found"))).isEqualTo("Hello World");
}
Also used : ErrorPage(cn.taketoday.framework.web.server.ErrorPage) AbstractServletWebServerFactory(cn.taketoday.framework.web.servlet.server.AbstractServletWebServerFactory) ServletRegistrationBean(cn.taketoday.framework.web.servlet.ServletRegistrationBean) ExampleServlet(cn.taketoday.test.web.servlet.ExampleServlet) Test(org.junit.jupiter.api.Test)

Aggregations

ServletRegistrationBean (cn.taketoday.framework.web.servlet.ServletRegistrationBean)26 ExampleServlet (cn.taketoday.test.web.servlet.ExampleServlet)26 Test (org.junit.jupiter.api.Test)16 HttpComponentsClientHttpRequestFactory (cn.taketoday.http.client.HttpComponentsClientHttpRequestFactory)14 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)14 HttpClient (org.apache.http.client.HttpClient)12 SSLConnectionSocketFactory (org.apache.http.conn.ssl.SSLConnectionSocketFactory)12 SSLContextBuilder (org.apache.http.ssl.SSLContextBuilder)12 TrustSelfSignedStrategy (org.apache.http.conn.ssl.TrustSelfSignedStrategy)10 Ssl (cn.taketoday.framework.web.server.Ssl)6 ClientHttpResponse (cn.taketoday.http.client.ClientHttpResponse)4 ServletRequest (jakarta.servlet.ServletRequest)4 ServletResponse (jakarta.servlet.ServletResponse)4 HttpServletRequest (jakarta.servlet.http.HttpServletRequest)4 HttpServletResponse (jakarta.servlet.http.HttpServletResponse)4 Compression (cn.taketoday.framework.web.server.Compression)2 ErrorPage (cn.taketoday.framework.web.server.ErrorPage)2 AbstractServletWebServerFactory (cn.taketoday.framework.web.servlet.server.AbstractServletWebServerFactory)2 HttpSession (jakarta.servlet.http.HttpSession)2 File (java.io.File)2