Browse Source

Merge branch 'gh-4670'

pull/4670/merge
Andy Wilkinson 10 years ago
parent
commit
74ea3b9c9c
  1. 2
      spring-boot/src/main/java/org/springframework/boot/context/embedded/undertow/UndertowEmbeddedServletContainerFactory.java
  2. 20
      spring-boot/src/test/java/org/springframework/boot/context/embedded/undertow/UndertowEmbeddedServletContainerFactoryTests.java

2
spring-boot/src/main/java/org/springframework/boot/context/embedded/undertow/UndertowEmbeddedServletContainerFactory.java

@ -384,7 +384,7 @@ public class UndertowEmbeddedServletContainerFactory @@ -384,7 +384,7 @@ public class UndertowEmbeddedServletContainerFactory
try {
createAccessLogDirectoryIfNecessary();
AccessLogReceiver accessLogReceiver = new DefaultAccessLogReceiver(
createWorker(), this.accessLogDirectory, "access_log");
createWorker(), this.accessLogDirectory, "access_log.");
String formatString = (this.accessLogPattern != null) ? this.accessLogPattern
: "common";
return new AccessLogHandler(handler, accessLogReceiver, formatString,

20
spring-boot/src/test/java/org/springframework/boot/context/embedded/undertow/UndertowEmbeddedServletContainerFactoryTests.java

@ -16,6 +16,9 @@ @@ -16,6 +16,9 @@
package org.springframework.boot.context.embedded.undertow;
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
@ -39,6 +42,8 @@ import org.springframework.boot.context.embedded.ServletRegistrationBean; @@ -39,6 +42,8 @@ import org.springframework.boot.context.embedded.ServletRegistrationBean;
import org.springframework.http.HttpStatus;
import org.springframework.test.util.ReflectionTestUtils;
import static org.hamcrest.Matchers.arrayContaining;
import static org.hamcrest.Matchers.arrayWithSize;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
@ -172,6 +177,21 @@ public class UndertowEmbeddedServletContainerFactoryTests @@ -172,6 +177,21 @@ public class UndertowEmbeddedServletContainerFactoryTests
is(not(equalTo(getServletContainerFromNewFactory()))));
}
@Test
public void accessLogCanBeEnabled() throws IOException, URISyntaxException {
UndertowEmbeddedServletContainerFactory factory = getFactory();
factory.setAccessLogEnabled(true);
File accessLogDirectory = this.temporaryFolder.getRoot();
factory.setAccessLogDirectory(accessLogDirectory);
assertThat(accessLogDirectory.listFiles(), is(arrayWithSize(0)));
this.container = factory.getEmbeddedServletContainer(
new ServletRegistrationBean(new ExampleServlet(), "/hello"));
this.container.start();
assertThat(getResponse(getLocalUrl("/hello")), equalTo("Hello World"));
assertThat(accessLogDirectory.listFiles(),
is(arrayContaining(new File(accessLogDirectory, "access_log.log"))));
}
@Override
protected Object getJspServlet() {
return null; // Undertow does not support JSPs

Loading…
Cancel
Save