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.
This commit is contained in:
@@ -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
|
||||
|
||||
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
|
||||
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());
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@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()}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user