From 540f4a1526ee162a20be6200bd7d5aa94d5e1a33 Mon Sep 17 00:00:00 2001 From: Georgios Andrianakis Date: Mon, 6 Jul 2020 09:03:05 +0300 Subject: [PATCH] Ensure that %test.quarkus.http.test-port works properly Fixes: #10477 --- .../vertx/http/runtime/VertxHttpRecorder.java | 13 +++++++++---- .../src/main/resources/application.properties | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxHttpRecorder.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxHttpRecorder.java index 136ac025bf788..2c4b35a293769 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxHttpRecorder.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxHttpRecorder.java @@ -865,10 +865,15 @@ private void setupTcpHttpServer(HttpServer httpServer, HttpServerOptions options clearHttpProperty = true; schema = "http"; } - System.setProperty( - launchMode == LaunchMode.TEST ? "quarkus." + schema + ".test-port" - : "quarkus." + schema + ".port", - String.valueOf(actualPort)); + String portPropertyValue = String.valueOf(actualPort); + String portPropertyName = (launchMode == LaunchMode.TEST ? "quarkus." + schema + ".test-port" + : "quarkus." + schema + ".port"); + System.setProperty(portPropertyName, portPropertyValue); + if (launchMode.isDevOrTest()) { + // set the profile property as well to make sure we don't have any inconsistencies + System.setProperty("%" + launchMode.getDefaultProfile() + "." + portPropertyName, + portPropertyValue); + } // Set in HttpOptions to output the port in the Timing class options.setPort(actualPort); } diff --git a/integration-tests/spring-web/src/main/resources/application.properties b/integration-tests/spring-web/src/main/resources/application.properties index 3f44daa1d2e17..24fb66ecc39d4 100644 --- a/integration-tests/spring-web/src/main/resources/application.properties +++ b/integration-tests/spring-web/src/main/resources/application.properties @@ -2,3 +2,4 @@ quarkus.security.users.file.enabled=true quarkus.security.users.file.users=test-users.properties quarkus.security.users.file.roles=test-roles.properties quarkus.security.users.file.plain-text=true +%test.quarkus.http.test-port=0