Java 类org.springframework.boot.context.embedded.ExampleServlet 实例源码

项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:UndertowEmbeddedServletContainerFactoryTests.java   
@Test
public void accessLogCanBeEnabled()
        throws IOException, URISyntaxException, InterruptedException {
    UndertowEmbeddedServletContainerFactory factory = getFactory();
    factory.setAccessLogEnabled(true);
    File accessLogDirectory = this.temporaryFolder.getRoot();
    factory.setAccessLogDirectory(accessLogDirectory);
    assertThat(accessLogDirectory.listFiles()).isEmpty();
    this.container = factory.getEmbeddedServletContainer(
            new ServletRegistrationBean(new ExampleServlet(), "/hello"));
    this.container.start();
    assertThat(getResponse(getLocalUrl("/hello"))).isEqualTo("Hello World");
    File accessLog = new File(accessLogDirectory, "access_log.log");
    awaitFile(accessLog);
    assertThat(accessLogDirectory.listFiles()).contains(accessLog);
}
项目:spring-boot-concourse    文件:UndertowEmbeddedServletContainerFactoryTests.java   
@Test
public void accessLogCanBeEnabled()
        throws IOException, URISyntaxException, InterruptedException {
    UndertowEmbeddedServletContainerFactory factory = getFactory();
    factory.setAccessLogEnabled(true);
    File accessLogDirectory = this.temporaryFolder.getRoot();
    factory.setAccessLogDirectory(accessLogDirectory);
    assertThat(accessLogDirectory.listFiles()).isEmpty();
    this.container = factory.getEmbeddedServletContainer(
            new ServletRegistrationBean(new ExampleServlet(), "/hello"));
    this.container.start();
    assertThat(getResponse(getLocalUrl("/hello"))).isEqualTo("Hello World");
    File accessLog = new File(accessLogDirectory, "access_log.log");
    awaitFile(accessLog);
    assertThat(accessLogDirectory.listFiles()).contains(accessLog);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:UndertowEmbeddedServletContainerFactoryTests.java   
@Test
public void errorPage404() throws Exception {
    AbstractEmbeddedServletContainerFactory factory = getFactory();
    factory.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND, "/hello"));
    this.container = factory.getEmbeddedServletContainer(
            new ServletRegistrationBean(new ExampleServlet(), "/hello"));
    this.container.start();
    assertThat(getResponse(getLocalUrl("/hello"))).isEqualTo("Hello World");
    assertThat(getResponse(getLocalUrl("/not-found"))).isEqualTo("Hello World");
}
项目:spring-boot-concourse    文件:UndertowEmbeddedServletContainerFactoryTests.java   
@Test
public void errorPage404() throws Exception {
    AbstractEmbeddedServletContainerFactory factory = getFactory();
    factory.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND, "/hello"));
    this.container = factory.getEmbeddedServletContainer(
            new ServletRegistrationBean(new ExampleServlet(), "/hello"));
    this.container.start();
    assertThat(getResponse(getLocalUrl("/hello"))).isEqualTo("Hello World");
    assertThat(getResponse(getLocalUrl("/not-found"))).isEqualTo("Hello World");
}
项目:contestparser    文件:UndertowEmbeddedServletContainerFactoryTests.java   
@Test
public void errorPage404() throws Exception {
    AbstractEmbeddedServletContainerFactory factory = getFactory();
    factory.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND, "/hello"));
    this.container = factory.getEmbeddedServletContainer(
            new ServletRegistrationBean(new ExampleServlet(), "/hello"));
    this.container.start();
    assertThat(getResponse(getLocalUrl("/hello")), equalTo("Hello World"));
    assertThat(getResponse(getLocalUrl("/not-found")), equalTo("Hello World"));
}