|
|
@ -178,8 +178,21 @@ public class UndertowEmbeddedServletContainerFactoryTests
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void accessLogCanBeEnabled()
|
|
|
|
public void accessLogCanBeEnabled()
|
|
|
|
throws IOException, URISyntaxException, InterruptedException {
|
|
|
|
throws IOException, URISyntaxException, InterruptedException {
|
|
|
|
|
|
|
|
testAccessLog(null, null, "access_log.log");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
public void accessLogCanBeCustomized()
|
|
|
|
|
|
|
|
throws IOException, URISyntaxException, InterruptedException {
|
|
|
|
|
|
|
|
testAccessLog("my_access.", "logz", "my_access.logz");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void testAccessLog(String prefix, String suffix, String expectedFile)
|
|
|
|
|
|
|
|
throws IOException, URISyntaxException, InterruptedException {
|
|
|
|
UndertowEmbeddedServletContainerFactory factory = getFactory();
|
|
|
|
UndertowEmbeddedServletContainerFactory factory = getFactory();
|
|
|
|
factory.setAccessLogEnabled(true);
|
|
|
|
factory.setAccessLogEnabled(true);
|
|
|
|
|
|
|
|
factory.setAccessLogPrefix(prefix);
|
|
|
|
|
|
|
|
factory.setAccessLogSuffix(suffix);
|
|
|
|
File accessLogDirectory = this.temporaryFolder.getRoot();
|
|
|
|
File accessLogDirectory = this.temporaryFolder.getRoot();
|
|
|
|
factory.setAccessLogDirectory(accessLogDirectory);
|
|
|
|
factory.setAccessLogDirectory(accessLogDirectory);
|
|
|
|
assertThat(accessLogDirectory.listFiles()).isEmpty();
|
|
|
|
assertThat(accessLogDirectory.listFiles()).isEmpty();
|
|
|
@ -187,7 +200,7 @@ public class UndertowEmbeddedServletContainerFactoryTests
|
|
|
|
new ServletRegistrationBean(new ExampleServlet(), "/hello"));
|
|
|
|
new ServletRegistrationBean(new ExampleServlet(), "/hello"));
|
|
|
|
this.container.start();
|
|
|
|
this.container.start();
|
|
|
|
assertThat(getResponse(getLocalUrl("/hello"))).isEqualTo("Hello World");
|
|
|
|
assertThat(getResponse(getLocalUrl("/hello"))).isEqualTo("Hello World");
|
|
|
|
File accessLog = new File(accessLogDirectory, "access_log.log");
|
|
|
|
File accessLog = new File(accessLogDirectory, expectedFile);
|
|
|
|
awaitFile(accessLog);
|
|
|
|
awaitFile(accessLog);
|
|
|
|
assertThat(accessLogDirectory.listFiles()).contains(accessLog);
|
|
|
|
assertThat(accessLogDirectory.listFiles()).contains(accessLog);
|
|
|
|
}
|
|
|
|
}
|
|
|
|