diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/AbstractHttpHandlerIntegrationTests.java b/spring-web/src/test/java/org/springframework/http/server/reactive/AbstractHttpHandlerIntegrationTests.java index e6abf87f7d..830e9ad38b 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/AbstractHttpHandlerIntegrationTests.java +++ b/spring-web/src/test/java/org/springframework/http/server/reactive/AbstractHttpHandlerIntegrationTests.java @@ -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 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() ); } diff --git a/spring-web/src/test/java/org/springframework/http/server/reactive/bootstrap/TomcatHttpServer.java b/spring-web/src/test/java/org/springframework/http/server/reactive/bootstrap/TomcatHttpServer.java index 0cbc79c37f..fb34b471cf 100644 --- a/spring-web/src/test/java/org/springframework/http/server/reactive/bootstrap/TomcatHttpServer.java +++ b/spring-web/src/test/java/org/springframework/http/server/reactive/bootstrap/TomcatHttpServer.java @@ -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); } diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ContextPathIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ContextPathIntegrationTests.java index 2eb722eac8..8e1d40d2dd 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ContextPathIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/ContextPathIntegrationTests.java @@ -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/*"); diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SseIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SseIntegrationTests.java index fdc39904b4..8e7019904f 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SseIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/SseIntegrationTests.java @@ -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()} };