use of org.springframework.boot.web.servlet.server.ExampleServlet in project spring-boot by spring-projects.
the class UndertowServletWebServerFactoryTests method errorPage404.
@Test
public 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();
assertThat(getResponse(getLocalUrl("/hello"))).isEqualTo("Hello World");
assertThat(getResponse(getLocalUrl("/not-found"))).isEqualTo("Hello World");
}
use of org.springframework.boot.web.servlet.server.ExampleServlet in project spring-boot by spring-projects.
the class SkipSslVerificationHttpRequestFactoryTests method getHttpsUrl.
private String getHttpsUrl() {
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(0);
factory.setSsl(getSsl("password", "classpath:test.jks"));
WebServer webServer = factory.getWebServer(new ServletRegistrationBean<>(new ExampleServlet(), "/hello"));
webServer.start();
return "https://localhost:" + webServer.getPort() + "/hello";
}
use of org.springframework.boot.web.servlet.server.ExampleServlet in project spring-boot by spring-projects.
the class UndertowServletWebServerFactoryTests method testAccessLog.
private void testAccessLog(String prefix, String suffix, String expectedFile) throws IOException, URISyntaxException, InterruptedException {
UndertowServletWebServerFactory factory = getFactory();
factory.setAccessLogEnabled(true);
factory.setAccessLogPrefix(prefix);
factory.setAccessLogSuffix(suffix);
File accessLogDirectory = this.temporaryFolder.getRoot();
factory.setAccessLogDirectory(accessLogDirectory);
assertThat(accessLogDirectory.listFiles()).isEmpty();
this.webServer = factory.getWebServer(new ServletRegistrationBean<>(new ExampleServlet(), "/hello"));
this.webServer.start();
assertThat(getResponse(getLocalUrl("/hello"))).isEqualTo("Hello World");
File accessLog = new File(accessLogDirectory, expectedFile);
awaitFile(accessLog);
assertThat(accessLogDirectory.listFiles()).contains(accessLog);
}
Aggregations