Skip to content

Commit

Permalink
Merge pull request #10488 from geoand/#10477
Browse files Browse the repository at this point in the history
Ensure that %test.quarkus.http.test-port works properly
geoand authored Jul 6, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents 45a847b + e925c3f commit 9f19c94
Showing 2 changed files with 25 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -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(propertyWithProfilePrefix(portPropertyName),
portPropertyValue);
}
// Set in HttpOptions to output the port in the Timing class
options.setPort(actualPort);
}
@@ -882,10 +887,19 @@ private void setupTcpHttpServer(HttpServer httpServer, HttpServerOptions options
@Override
public void stop(Future<Void> stopFuture) {
if (clearHttpProperty) {
System.clearProperty(launchMode == LaunchMode.TEST ? "quarkus.http.test-port" : "quarkus.http.port");
String portPropertyName = launchMode == LaunchMode.TEST ? "quarkus.http.test-port" : "quarkus.http.port";
System.clearProperty(portPropertyName);
if (launchMode.isDevOrTest()) {
System.clearProperty(propertyWithProfilePrefix(portPropertyName));
}

}
if (clearHttpsProperty) {
System.clearProperty(launchMode == LaunchMode.TEST ? "quarkus.https.test-port" : "quarkus.https.port");
String portPropertyName = launchMode == LaunchMode.TEST ? "quarkus.https.test-port" : "quarkus.https.port";
System.clearProperty(portPropertyName);
if (launchMode.isDevOrTest()) {
System.clearProperty(propertyWithProfilePrefix(portPropertyName));
}
}

final AtomicInteger remainingCount = new AtomicInteger(0);
@@ -915,6 +929,10 @@ public void stop(Future<Void> stopFuture) {
domainSocketServer.close(handleClose);
}
}

private String propertyWithProfilePrefix(String portPropertyName) {
return "%" + launchMode.getDefaultProfile() + "." + portPropertyName;
}
}

protected static ServerBootstrap virtualBootstrap;
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 9f19c94

Please sign in to comment.