You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by or...@apache.org on 2023/08/07 13:51:45 UTC

[camel] branch main updated: CAMEL-19647: do not use a fixed port number in camel-platform-http-main tests

This is an automated email from the ASF dual-hosted git repository.

orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 3788278cc9c CAMEL-19647: do not use a fixed port number in camel-platform-http-main tests
3788278cc9c is described below

commit 3788278cc9cfedd97b3a7fe99bb6852bd6fd13ff
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Aug 7 15:51:22 2023 +0200

    CAMEL-19647: do not use a fixed port number in camel-platform-http-main tests
---
 .../camel/component/platform/http/main/MainHttpServerTest.java     | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/components/camel-platform-http-main/src/test/java/org/apache/camel/component/platform/http/main/MainHttpServerTest.java b/components/camel-platform-http-main/src/test/java/org/apache/camel/component/platform/http/main/MainHttpServerTest.java
index 3979e1ac740..02e6d4544e7 100644
--- a/components/camel-platform-http-main/src/test/java/org/apache/camel/component/platform/http/main/MainHttpServerTest.java
+++ b/components/camel-platform-http-main/src/test/java/org/apache/camel/component/platform/http/main/MainHttpServerTest.java
@@ -25,6 +25,7 @@ import java.net.http.HttpResponse;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.test.AvailablePortFinder;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -33,6 +34,8 @@ class MainHttpServerTest {
 
     private CamelContext camelContext;
 
+    private final int port = AvailablePortFinder.getNextAvailable();
+
     @Test
     public void statusIsNotSatisfied() throws IOException, InterruptedException {
         MainHttpServer server = new MainHttpServer();
@@ -43,14 +46,14 @@ class MainHttpServerTest {
         camelContext.getRegistry().bind("fake", new MainHttpFakeHealthCheck());
 
         server.setHost("0.0.0.0");
-        server.setPort(8080);
+        server.setPort(port);
         server.setPath("/");
 
         server.setHealthCheckEnabled(true);
         server.start();
 
         HttpRequest request = HttpRequest.newBuilder()
-                .uri(URI.create("http://localhost:8080/q/health/ready"))
+                .uri(URI.create("http://localhost:" + port + "/q/health/ready"))
                 .build();
 
         HttpResponse<String> response = HttpClient.newBuilder().build().send(request, HttpResponse.BodyHandlers.ofString());