Browse Source

Allow to configure Tomcat baseDir

This commit also set Tomcat baseDir to java.io.tmpdir for
integration tests in order to avoid creation of temporary directories
in the project root.
pull/1111/head
Sebastien Deleuze 10 years ago
parent
commit
0f01729b27
  1. 15
      spring-web-reactive/src/main/java/org/springframework/http/server/reactive/boot/TomcatHttpServer.java
  2. 5
      spring-web-reactive/src/test/java/org/springframework/http/server/reactive/AbstractHttpHandlerIntegrationTests.java

15
spring-web-reactive/src/main/java/org/springframework/http/server/reactive/boot/TomcatHttpServer.java

@ -20,13 +20,11 @@ import java.io.File; @@ -20,13 +20,11 @@ import java.io.File;
import org.apache.catalina.Context;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.core.StandardHost;
import org.apache.catalina.startup.Tomcat;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.http.server.reactive.ServletHttpHandlerAdapter;
import org.springframework.util.Assert;
import org.springframework.util.SocketUtils;
/**
@ -38,6 +36,16 @@ public class TomcatHttpServer extends HttpServerSupport implements InitializingB @@ -38,6 +36,16 @@ public class TomcatHttpServer extends HttpServerSupport implements InitializingB
private boolean running;
private String baseDir;
public TomcatHttpServer() {
}
public TomcatHttpServer(String baseDir) {
this.baseDir = baseDir;
}
@Override
public boolean isRunning() {
@ -48,6 +56,9 @@ public class TomcatHttpServer extends HttpServerSupport implements InitializingB @@ -48,6 +56,9 @@ public class TomcatHttpServer extends HttpServerSupport implements InitializingB
public void afterPropertiesSet() throws Exception {
this.tomcatServer = new Tomcat();
if (this.baseDir != null) {
this.tomcatServer.setBaseDir(baseDir);
}
this.tomcatServer.setHostname(getHost());
this.tomcatServer.setPort(getPort());

5
spring-web-reactive/src/test/java/org/springframework/http/server/reactive/AbstractHttpHandlerIntegrationTests.java

@ -16,6 +16,8 @@ @@ -16,6 +16,8 @@
package org.springframework.http.server.reactive;
import java.io.File;
import org.junit.After;
import org.junit.Before;
import org.junit.runner.RunWith;
@ -41,11 +43,12 @@ public abstract class AbstractHttpHandlerIntegrationTests { @@ -41,11 +43,12 @@ public abstract class AbstractHttpHandlerIntegrationTests {
@Parameterized.Parameters(name = "server [{0}]")
public static Object[][] arguments() {
File base = new File(System.getProperty("java.io.tmpdir"));
return new Object[][] {
{new JettyHttpServer()},
{new RxNettyHttpServer()},
{new ReactorHttpServer()},
{new TomcatHttpServer()},
{new TomcatHttpServer(base.getAbsolutePath())},
{new UndertowHttpServer()}
};
}

Loading…
Cancel
Save