Introduce default constructor in TomcatHttpServer

This commit is contained in:
Sam Brannen
2019-09-05 13:43:03 +02:00
parent 40a55b412d
commit d9e3b8b9a5
4 changed files with 14 additions and 11 deletions

View File

@@ -16,7 +16,6 @@
package org.springframework.http.server.reactive;
import java.io.File;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -125,11 +124,10 @@ public abstract class AbstractHttpHandlerIntegrationTests {
}
static Stream<HttpServer> httpServers() {
File base = new File(System.getProperty("java.io.tmpdir"));
return Stream.of(
new JettyHttpServer(),
new ReactorHttpServer(),
new TomcatHttpServer(base.getAbsolutePath()),
new TomcatHttpServer(),
new UndertowHttpServer()
);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -42,6 +42,15 @@ public class TomcatHttpServer extends AbstractHttpServer {
private Tomcat tomcatServer;
/**
* Create a new Tomcat HTTP server using the {@code java.io.tmpdir} JVM
* system property as the {@code baseDir}.
* @since 5.2
*/
public TomcatHttpServer() {
this(new File(System.getProperty("java.io.tmpdir")).getAbsolutePath());
}
public TomcatHttpServer(String baseDir) {
this(baseDir, null);
}

View File

@@ -15,7 +15,6 @@
*/
package org.springframework.web.reactive.result.method.annotation;
import java.io.File;
import org.junit.jupiter.api.Test;
@@ -84,8 +83,7 @@ public class ContextPathIntegrationTests {
context.register(WebAppConfig.class);
context.refresh();
File base = new File(System.getProperty("java.io.tmpdir"));
TomcatHttpServer server = new TomcatHttpServer(base.getAbsolutePath());
TomcatHttpServer server = new TomcatHttpServer();
server.setContextPath("/app");
server.setServletMapping("/api/*");

View File

@@ -16,7 +16,6 @@
package org.springframework.web.reactive.result.method.annotation;
import java.io.File;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -71,14 +70,13 @@ class SseIntegrationTests extends AbstractHttpHandlerIntegrationTests {
}
static Object[][] arguments() {
File base = new File(System.getProperty("java.io.tmpdir"));
return new Object[][] {
{new JettyHttpServer(), new ReactorClientHttpConnector()},
{new JettyHttpServer(), new JettyClientHttpConnector()},
{new ReactorHttpServer(), new ReactorClientHttpConnector()},
{new ReactorHttpServer(), new JettyClientHttpConnector()},
{new TomcatHttpServer(base.getAbsolutePath()), new ReactorClientHttpConnector()},
{new TomcatHttpServer(base.getAbsolutePath()), new JettyClientHttpConnector()},
{new TomcatHttpServer(), new ReactorClientHttpConnector()},
{new TomcatHttpServer(), new JettyClientHttpConnector()},
{new UndertowHttpServer(), new ReactorClientHttpConnector()},
{new UndertowHttpServer(), new JettyClientHttpConnector()}
};