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

gnodet 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 481fc3ea4121 CAMEL-23480: fix port conflict in OAuth servlet tests 
running in same JVM fork
481fc3ea4121 is described below

commit 481fc3ea4121d3e6e8622ac789cd1a2ea4c477e6
Author: Guillaume Nodet <[email protected]>
AuthorDate: Tue Nov 17 11:59:13 2026 +0100

    CAMEL-23480: fix port conflict in OAuth servlet tests running in same JVM 
fork
    
    * CAMEL-23480: fix port conflict in OAuth servlet tests running in same JVM 
fork
    
    AbstractKeycloakTest declared a single static AvailablePortFinder.Port 
shared by
    all subclasses. When OAuthCodeFlowServletTest and 
OAuthClientCredentialsServletTest
    ran in the same JVM fork, the second @BeforeAll attempted to bind Undertow 
to the
    same port already held by the first class, resulting in BindException.
    
    Additionally, Undertow was started unconditionally in @BeforeAll before the 
Keycloak
    assumption check, causing a hard failure instead of a clean skip when 
Keycloak was
    not running.
    
    Fix:
    - Remove the shared static SERVER_PORT/port/APP_BASE_URL from 
AbstractKeycloakTest
    - Add abstract getPort() method so each concrete subclass provides its own 
port
    - Add getAppBaseUrl() instance method using getPort()
    - Each concrete test class (OAuthCodeFlowServletTest, 
OAuthClientCredentialsServletTest,
      OAuthCodeFlowVertxTest, OAuthClientCredentialsVertxTest, 
SSLCertTrustTest) now
      declares its own static final AvailablePortFinder.Port, ensuring each 
test class
      gets a distinct port even when running in the same JVM fork
    - Move the Keycloak assumption check into @BeforeAll for servlet tests, so 
Undertow
      is never started when Keycloak is absent (clean skip instead of hard fail)
    - Change createUndertowServer() to accept an explicit port parameter
    
    Co-authored-by: Claude Sonnet 4.6 <[email protected]>
    
    * CAMEL-23480: address review: remove dead port in SSLCertTrustTest, close 
KeycloakAdmin, drop Thread.sleep
    
    - SSLCertTrustTest: remove SERVER_PORT/PORT fields that were never used by
      the test body; override getPort() to return localHttpsPort directly
    - KeycloakAdmin: implement AutoCloseable to enable try-with-resources usage
    - OAuthClientCredentialsServletTest, OAuthCodeFlowServletTest: use
      try-with-resources in @BeforeAll to close the probe KeycloakAdmin
    - AbstractOAuthClientCredentialsTest, OAuthClientCredentialsVertxTest,
      AbstractOAuthCodeFlowTest, SSLCertTrustTest: same fix in @Test methods
    - AbstractOAuthCodeFlowTest: remove Thread.sleep-based logout wait loop
      (asserts nothing, is only useful for manual browser testing)
    
    Co-authored-by: Claude Sonnet 4.6 <[email protected]>
    
    * Address review: fix admin resource leak and restore assertions for realm 
checks
    
    * CAMEL-23480: address review: use @RegisterExtension on port fields to 
auto-release after test class
    
    * fix: add @RegisterExtension to OAuthCodeFlowVertxTest.SERVER_PORT for 
proper port release
    
    ---------
    
    Co-authored-by: Claude Sonnet 4.6 <[email protected]>
---
 .../camel/test/oauth/AbstractKeycloakTest.java     | 22 +++++++++++-------
 .../oauth/AbstractOAuthClientCredentialsTest.java  |  5 +++--
 .../test/oauth/AbstractOAuthCodeFlowTest.java      | 26 ++++------------------
 .../org/apache/camel/test/oauth/KeycloakAdmin.java |  2 +-
 .../oauth/OAuthClientCredentialsServletTest.java   | 21 +++++++++++++----
 .../oauth/OAuthClientCredentialsVertxTest.java     | 20 +++++++++++++----
 .../camel/test/oauth/OAuthCodeFlowServletTest.java | 23 ++++++++++++++++---
 .../camel/test/oauth/OAuthCodeFlowVertxTest.java   | 17 +++++++++++---
 .../apache/camel/test/oauth/SSLCertTrustTest.java  | 10 +++++++--
 9 files changed, 97 insertions(+), 49 deletions(-)

diff --git 
a/components/camel-oauth/src/test/java/org/apache/camel/test/oauth/AbstractKeycloakTest.java
 
b/components/camel-oauth/src/test/java/org/apache/camel/test/oauth/AbstractKeycloakTest.java
index 2585e9e54e6f..e83e503f73ae 100644
--- 
a/components/camel-oauth/src/test/java/org/apache/camel/test/oauth/AbstractKeycloakTest.java
+++ 
b/components/camel-oauth/src/test/java/org/apache/camel/test/oauth/AbstractKeycloakTest.java
@@ -24,7 +24,6 @@ import io.undertow.Undertow;
 import io.undertow.server.handlers.PathHandler;
 import io.undertow.servlet.Servlets;
 import org.apache.camel.component.servlet.CamelHttpTransportServlet;
-import org.apache.camel.test.AvailablePortFinder;
 import org.junit.jupiter.api.Assumptions;
 
 import static org.apache.camel.test.oauth.KeycloakAdmin.AdminParams;
@@ -34,10 +33,6 @@ import static 
org.apache.camel.test.oauth.KeycloakAdmin.UserParams;
 
 abstract class AbstractKeycloakTest {
 
-    static final AvailablePortFinder.Port SERVER_PORT = 
AvailablePortFinder.find();
-    static final int port = SERVER_PORT.getPort();
-    static final String APP_BASE_URL = "http://127.0.0.1:"; + port + "/";
-
     static final String KEYCLOAK_REALM = "camel";
     static final String KEYCLOAK_BASE_URL = "https://oauth.localtest.me/kc";;
     static final String KEYCLOAK_REALM_URL = KEYCLOAK_BASE_URL + "/realms/" + 
KEYCLOAK_REALM;
@@ -47,6 +42,17 @@ abstract class AbstractKeycloakTest {
     private KeycloakAdmin admin;
     private boolean removeRealm;
 
+    /**
+     * Returns the HTTP port used by this test class. Each concrete subclass 
must declare its own
+     * {@code static final AvailablePortFinder.Port} field and return its port 
number here, so that test classes running
+     * in the same JVM fork do not compete for the same port.
+     */
+    protected abstract int getPort();
+
+    protected String getAppBaseUrl() {
+        return "http://127.0.0.1:"; + getPort() + "/";
+    }
+
     protected KeycloakAdmin getKeycloakAdmin() {
         if (admin == null) {
             admin = new KeycloakAdmin(new AdminParams(KEYCLOAK_BASE_URL));
@@ -69,9 +75,9 @@ abstract class AbstractKeycloakTest {
                             .setLastName("Brown"))
                     .withClient(new ClientParams(TEST_CLIENT_ID)
                             .setClientSecret(TEST_CLIENT_SECRET)
-                            .setLogoutRedirectUri(APP_BASE_URL)
+                            .setLogoutRedirectUri(getAppBaseUrl())
                             .setServiceAccountsEnabled(true)
-                            .setRedirectUri(APP_BASE_URL + "auth"));
+                            .setRedirectUri(getAppBaseUrl() + "auth"));
             removeRealm = true;
         }
     }
@@ -82,7 +88,7 @@ abstract class AbstractKeycloakTest {
         }
     }
 
-    protected static Undertow createUndertowServer() throws ServletException {
+    protected static Undertow createUndertowServer(int port) throws 
ServletException {
         RestAssured.port = port;
 
         var deploymentInfo = Servlets.deployment()
diff --git 
a/components/camel-oauth/src/test/java/org/apache/camel/test/oauth/AbstractOAuthClientCredentialsTest.java
 
b/components/camel-oauth/src/test/java/org/apache/camel/test/oauth/AbstractOAuthClientCredentialsTest.java
index e0cc07e6a4b8..349778b3a409 100644
--- 
a/components/camel-oauth/src/test/java/org/apache/camel/test/oauth/AbstractOAuthClientCredentialsTest.java
+++ 
b/components/camel-oauth/src/test/java/org/apache/camel/test/oauth/AbstractOAuthClientCredentialsTest.java
@@ -33,8 +33,9 @@ public abstract class AbstractOAuthClientCredentialsTest 
extends AbstractKeycloa
     @Test
     public void testOAuthClientCredentials() throws Exception {
 
-        var admin = new KeycloakAdmin(new 
KeycloakAdmin.AdminParams(KEYCLOAK_BASE_URL));
-        Assumptions.assumeTrue(admin.isKeycloakRunning(), "Keycloak is not 
running");
+        try (var admin = new KeycloakAdmin(new 
KeycloakAdmin.AdminParams(KEYCLOAK_BASE_URL))) {
+            Assumptions.assumeTrue(admin.isKeycloakRunning(), "Keycloak is not 
running");
+        }
 
         try (CamelContext context = createCamelContext()) {
             addOAuthClientCredentialsRoutes(context);
diff --git 
a/components/camel-oauth/src/test/java/org/apache/camel/test/oauth/AbstractOAuthCodeFlowTest.java
 
b/components/camel-oauth/src/test/java/org/apache/camel/test/oauth/AbstractOAuthCodeFlowTest.java
index c02d6d4e790e..4c9853a0b04c 100644
--- 
a/components/camel-oauth/src/test/java/org/apache/camel/test/oauth/AbstractOAuthCodeFlowTest.java
+++ 
b/components/camel-oauth/src/test/java/org/apache/camel/test/oauth/AbstractOAuthCodeFlowTest.java
@@ -33,8 +33,9 @@ abstract class AbstractOAuthCodeFlowTest extends 
AbstractKeycloakTest {
     @Test
     void testCodeFlowAuth() throws Exception {
 
-        var admin = new KeycloakAdmin(new 
KeycloakAdmin.AdminParams(KEYCLOAK_BASE_URL));
-        Assumptions.assumeTrue(admin.isKeycloakRunning(), "Keycloak is not 
running");
+        try (var admin = new KeycloakAdmin(new 
KeycloakAdmin.AdminParams(KEYCLOAK_BASE_URL))) {
+            Assumptions.assumeTrue(admin.isKeycloakRunning(), "Keycloak is not 
running");
+        }
 
         try (CamelContext context = createCamelContext()) {
             addOAuthCodeFlowRoutes(context);
@@ -47,26 +48,7 @@ abstract class AbstractOAuthCodeFlowTest extends 
AbstractKeycloakTest {
             Assertions.assertEquals(1, 
keycloak.realm(KEYCLOAK_REALM).users().search("alice").size());
 
             LOG.info("Keycloak realm, client, and user available!");
-            LOG.info("Open: {}", APP_BASE_URL);
-
-            // Open WebApp in Browser (works on macOS)
-            // Runtime.getRuntime().exec("open " + APP_BASE_URL);
-
-            // Increase for manual testing
-            int maxLoopCount = 10; // 500ms per loop
-
-            for (int i = maxLoopCount; i > 0; i--) {
-                var options = context.getGlobalOptions();
-                if ("ok".equals(options.get("OAuthLogout"))) {
-                    LOG.info("OAuthLogout - ok");
-                    i = 0;
-                }
-                if (i % 4 == 0) {
-                    LOG.info("Waiting on logout: {}/{} - {}", maxLoopCount - 
i, maxLoopCount,
-                            APP_BASE_URL + "logout");
-                }
-                Thread.sleep(500L);
-            }
+            LOG.info("Open: {}", getAppBaseUrl());
         }
     }
 
diff --git 
a/components/camel-oauth/src/test/java/org/apache/camel/test/oauth/KeycloakAdmin.java
 
b/components/camel-oauth/src/test/java/org/apache/camel/test/oauth/KeycloakAdmin.java
index d2f8f2b50319..fce29ddfc39b 100644
--- 
a/components/camel-oauth/src/test/java/org/apache/camel/test/oauth/KeycloakAdmin.java
+++ 
b/components/camel-oauth/src/test/java/org/apache/camel/test/oauth/KeycloakAdmin.java
@@ -28,7 +28,7 @@ import 
org.keycloak.representations.idm.CredentialRepresentation;
 import org.keycloak.representations.idm.RealmRepresentation;
 import org.keycloak.representations.idm.UserRepresentation;
 
-class KeycloakAdmin {
+class KeycloakAdmin implements AutoCloseable {
 
     private static Keycloak keycloak;
     private String lastRealm;
diff --git 
a/components/camel-oauth/src/test/java/org/apache/camel/test/oauth/OAuthClientCredentialsServletTest.java
 
b/components/camel-oauth/src/test/java/org/apache/camel/test/oauth/OAuthClientCredentialsServletTest.java
index 2716cf68761f..35aaae951c32 100644
--- 
a/components/camel-oauth/src/test/java/org/apache/camel/test/oauth/OAuthClientCredentialsServletTest.java
+++ 
b/components/camel-oauth/src/test/java/org/apache/camel/test/oauth/OAuthClientCredentialsServletTest.java
@@ -25,10 +25,12 @@ import org.apache.camel.oauth.OAuthBearerTokenProcessor;
 import org.apache.camel.oauth.OAuthClientCredentialsProcessor;
 import org.apache.camel.oauth.OAuthFactory;
 import org.apache.camel.spi.PropertiesComponent;
+import org.apache.camel.test.AvailablePortFinder;
 import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.Assumptions;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
 import static org.apache.camel.oauth.OAuth.CAMEL_OAUTH_BASE_URI;
 import static org.apache.camel.oauth.OAuth.CAMEL_OAUTH_CLIENT_ID;
@@ -39,11 +41,25 @@ import static 
org.junit.jupiter.api.Assertions.assertNotNull;
 
 public class OAuthClientCredentialsServletTest extends 
AbstractOAuthClientCredentialsTest {
 
+    @RegisterExtension
+    static final AvailablePortFinder.Port SERVER_PORT = 
AvailablePortFinder.find();
+    static final int PORT = SERVER_PORT.getPort();
+
     static Undertow server;
 
+    @Override
+    protected int getPort() {
+        return PORT;
+    }
+
     @BeforeAll
     static void setUp() throws Exception {
-        server = createUndertowServer();
+        // Check Keycloak availability before starting Undertow, so the test 
class skips
+        // cleanly (TestAbortedException) rather than failing with 
BindException.
+        try (var admin = new KeycloakAdmin(new 
KeycloakAdmin.AdminParams(KEYCLOAK_BASE_URL))) {
+            Assumptions.assumeTrue(admin.isKeycloakRunning(), "Keycloak is not 
running");
+        }
+        server = createUndertowServer(PORT);
         server.start();
     }
 
@@ -55,9 +71,6 @@ public class OAuthClientCredentialsServletTest extends 
AbstractOAuthClientCreden
     @Test
     public void testOAuthSetup() throws Exception {
 
-        var admin = new KeycloakAdmin(new 
KeycloakAdmin.AdminParams(KEYCLOAK_BASE_URL));
-        Assumptions.assumeTrue(admin.isKeycloakRunning(), "Keycloak is not 
running");
-
         try (CamelContext context = createCamelContext()) {
             context.start();
 
diff --git 
a/components/camel-oauth/src/test/java/org/apache/camel/test/oauth/OAuthClientCredentialsVertxTest.java
 
b/components/camel-oauth/src/test/java/org/apache/camel/test/oauth/OAuthClientCredentialsVertxTest.java
index b23a2bbb7724..0e2e4b4d5fd1 100644
--- 
a/components/camel-oauth/src/test/java/org/apache/camel/test/oauth/OAuthClientCredentialsVertxTest.java
+++ 
b/components/camel-oauth/src/test/java/org/apache/camel/test/oauth/OAuthClientCredentialsVertxTest.java
@@ -27,8 +27,10 @@ import org.apache.camel.oauth.OAuthBearerTokenProcessor;
 import org.apache.camel.oauth.OAuthClientCredentialsProcessor;
 import org.apache.camel.oauth.OAuthFactory;
 import org.apache.camel.spi.PropertiesComponent;
+import org.apache.camel.test.AvailablePortFinder;
 import org.junit.jupiter.api.Assumptions;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
 import static org.apache.camel.oauth.OAuth.CAMEL_OAUTH_BASE_URI;
 import static org.apache.camel.oauth.OAuth.CAMEL_OAUTH_CLIENT_ID;
@@ -39,11 +41,21 @@ import static 
org.junit.jupiter.api.Assertions.assertNotNull;
 
 public class OAuthClientCredentialsVertxTest extends 
AbstractOAuthClientCredentialsTest {
 
+    @RegisterExtension
+    static final AvailablePortFinder.Port SERVER_PORT = 
AvailablePortFinder.find();
+    static final int PORT = SERVER_PORT.getPort();
+
+    @Override
+    protected int getPort() {
+        return PORT;
+    }
+
     @Test
     public void testOAuthSetup() throws Exception {
 
-        var admin = new KeycloakAdmin(new 
KeycloakAdmin.AdminParams(KEYCLOAK_BASE_URL));
-        Assumptions.assumeTrue(admin.isKeycloakRunning(), "Keycloak is not 
running");
+        try (var admin = new KeycloakAdmin(new 
KeycloakAdmin.AdminParams(KEYCLOAK_BASE_URL))) {
+            Assumptions.assumeTrue(admin.isKeycloakRunning(), "Keycloak is not 
running");
+        }
 
         try (CamelContext context = createCamelContext()) {
             context.start();
@@ -66,9 +78,9 @@ public class OAuthClientCredentialsVertxTest extends 
AbstractOAuthClientCredenti
     CamelContext createCamelContext() throws Exception {
 
         var conf = new VertxPlatformHttpServerConfiguration();
-        conf.setBindPort(port);
+        conf.setBindPort(PORT);
 
-        RestAssured.port = port;
+        RestAssured.port = PORT;
 
         var context = new DefaultCamelContext();
         context.addService(new VertxPlatformHttpServer(conf));
diff --git 
a/components/camel-oauth/src/test/java/org/apache/camel/test/oauth/OAuthCodeFlowServletTest.java
 
b/components/camel-oauth/src/test/java/org/apache/camel/test/oauth/OAuthCodeFlowServletTest.java
index 8efa9e9b83a6..54348bcde57d 100644
--- 
a/components/camel-oauth/src/test/java/org/apache/camel/test/oauth/OAuthCodeFlowServletTest.java
+++ 
b/components/camel-oauth/src/test/java/org/apache/camel/test/oauth/OAuthCodeFlowServletTest.java
@@ -24,8 +24,11 @@ import org.apache.camel.oauth.OAuthCodeFlowCallback;
 import org.apache.camel.oauth.OAuthCodeFlowProcessor;
 import org.apache.camel.oauth.OAuthLogoutProcessor;
 import org.apache.camel.spi.PropertiesComponent;
+import org.apache.camel.test.AvailablePortFinder;
 import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Assumptions;
 import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
 import static org.apache.camel.oauth.OAuth.CAMEL_OAUTH_BASE_URI;
 import static org.apache.camel.oauth.OAuth.CAMEL_OAUTH_CLIENT_ID;
@@ -38,11 +41,25 @@ import static 
org.apache.camel.oauth.OAuth.CAMEL_OAUTH_REDIRECT_URI;
  */
 class OAuthCodeFlowServletTest extends AbstractOAuthCodeFlowTest {
 
+    @RegisterExtension
+    static final AvailablePortFinder.Port SERVER_PORT = 
AvailablePortFinder.find();
+    static final int PORT = SERVER_PORT.getPort();
+
     static Undertow server;
 
+    @Override
+    protected int getPort() {
+        return PORT;
+    }
+
     @BeforeAll
     static void setUp() throws Exception {
-        server = createUndertowServer();
+        // Check Keycloak availability before starting Undertow, so the test 
class skips
+        // cleanly (TestAbortedException) rather than failing with 
BindException.
+        try (var admin = new KeycloakAdmin(new 
KeycloakAdmin.AdminParams(KEYCLOAK_BASE_URL))) {
+            Assumptions.assumeTrue(admin.isKeycloakRunning(), "Keycloak is not 
running");
+        }
+        server = createUndertowServer(PORT);
         server.start();
     }
 
@@ -60,8 +77,8 @@ class OAuthCodeFlowServletTest extends 
AbstractOAuthCodeFlowTest {
         props.addInitialProperty(CAMEL_OAUTH_BASE_URI, KEYCLOAK_REALM_URL);
         props.addInitialProperty(CAMEL_OAUTH_CLIENT_ID, TEST_CLIENT_ID);
         props.addInitialProperty(CAMEL_OAUTH_CLIENT_SECRET, 
TEST_CLIENT_SECRET);
-        props.addInitialProperty(CAMEL_OAUTH_REDIRECT_URI, APP_BASE_URL + 
"auth");
-        props.addInitialProperty(CAMEL_OAUTH_LOGOUT_REDIRECT_URI, 
APP_BASE_URL);
+        props.addInitialProperty(CAMEL_OAUTH_REDIRECT_URI, getAppBaseUrl() + 
"auth");
+        props.addInitialProperty(CAMEL_OAUTH_LOGOUT_REDIRECT_URI, 
getAppBaseUrl());
 
         return context;
     }
diff --git 
a/components/camel-oauth/src/test/java/org/apache/camel/test/oauth/OAuthCodeFlowVertxTest.java
 
b/components/camel-oauth/src/test/java/org/apache/camel/test/oauth/OAuthCodeFlowVertxTest.java
index 1404e0f4c649..d421b00764b1 100644
--- 
a/components/camel-oauth/src/test/java/org/apache/camel/test/oauth/OAuthCodeFlowVertxTest.java
+++ 
b/components/camel-oauth/src/test/java/org/apache/camel/test/oauth/OAuthCodeFlowVertxTest.java
@@ -25,6 +25,8 @@ import org.apache.camel.oauth.OAuthCodeFlowCallback;
 import org.apache.camel.oauth.OAuthCodeFlowProcessor;
 import org.apache.camel.oauth.OAuthLogoutProcessor;
 import org.apache.camel.spi.PropertiesComponent;
+import org.apache.camel.test.AvailablePortFinder;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
 import static org.apache.camel.oauth.OAuth.CAMEL_OAUTH_BASE_URI;
 import static org.apache.camel.oauth.OAuth.CAMEL_OAUTH_CLIENT_ID;
@@ -37,11 +39,20 @@ import static 
org.apache.camel.oauth.OAuth.CAMEL_OAUTH_REDIRECT_URI;
  */
 class OAuthCodeFlowVertxTest extends AbstractOAuthCodeFlowTest {
 
+    @RegisterExtension
+    static final AvailablePortFinder.Port SERVER_PORT = 
AvailablePortFinder.find();
+    static final int PORT = SERVER_PORT.getPort();
+
+    @Override
+    protected int getPort() {
+        return PORT;
+    }
+
     @Override
     CamelContext createCamelContext() throws Exception {
 
         var conf = new VertxPlatformHttpServerConfiguration();
-        conf.setBindPort(port);
+        conf.setBindPort(PORT);
 
         var context = new DefaultCamelContext();
         context.addService(new VertxPlatformHttpServer(conf));
@@ -50,8 +61,8 @@ class OAuthCodeFlowVertxTest extends 
AbstractOAuthCodeFlowTest {
         props.addInitialProperty(CAMEL_OAUTH_BASE_URI, KEYCLOAK_REALM_URL);
         props.addInitialProperty(CAMEL_OAUTH_CLIENT_ID, TEST_CLIENT_ID);
         props.addInitialProperty(CAMEL_OAUTH_CLIENT_SECRET, 
TEST_CLIENT_SECRET);
-        props.addInitialProperty(CAMEL_OAUTH_REDIRECT_URI, APP_BASE_URL + 
"auth");
-        props.addInitialProperty(CAMEL_OAUTH_LOGOUT_REDIRECT_URI, 
APP_BASE_URL);
+        props.addInitialProperty(CAMEL_OAUTH_REDIRECT_URI, getAppBaseUrl() + 
"auth");
+        props.addInitialProperty(CAMEL_OAUTH_LOGOUT_REDIRECT_URI, 
getAppBaseUrl());
 
         return context;
     }
diff --git 
a/components/camel-oauth/src/test/java/org/apache/camel/test/oauth/SSLCertTrustTest.java
 
b/components/camel-oauth/src/test/java/org/apache/camel/test/oauth/SSLCertTrustTest.java
index 07a6cf653eca..96a802a067b1 100644
--- 
a/components/camel-oauth/src/test/java/org/apache/camel/test/oauth/SSLCertTrustTest.java
+++ 
b/components/camel-oauth/src/test/java/org/apache/camel/test/oauth/SSLCertTrustTest.java
@@ -49,6 +49,11 @@ class SSLCertTrustTest extends AbstractKeycloakTest {
     private static Thread serverThread;
     private static int localHttpsPort;
 
+    @Override
+    protected int getPort() {
+        return localHttpsPort;
+    }
+
     @BeforeAll
     static void startLocalHttpsServer() throws Exception {
         // Load the self-signed keystore from test resources
@@ -101,8 +106,9 @@ class SSLCertTrustTest extends AbstractKeycloakTest {
 
     @Test
     void testCheckKeycloakCertificateTrust() {
-        var admin = new KeycloakAdmin(new 
KeycloakAdmin.AdminParams(KEYCLOAK_BASE_URL));
-        Assumptions.assumeTrue(admin.isKeycloakRunning(), "Keycloak is not 
running");
+        try (var admin = new KeycloakAdmin(new 
KeycloakAdmin.AdminParams(KEYCLOAK_BASE_URL))) {
+            Assumptions.assumeTrue(admin.isKeycloakRunning(), "Keycloak is not 
running");
+        }
         Assertions.assertDoesNotThrow(() -> connectToUrl(KEYCLOAK_BASE_URL), 
"Certificate should be trusted");
     }
 

Reply via email to