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 c5cfe2f04896 CAMEL-24019: Fix flaky VertxWebsocketHandshakeHeadersTest 
(#24619)
c5cfe2f04896 is described below

commit c5cfe2f04896aa559f4d029130fc8f7f6fbbcd5b
Author: Guillaume Nodet <[email protected]>
AuthorDate: Sun Jul 12 10:14:52 2026 +0200

    CAMEL-24019: Fix flaky VertxWebsocketHandshakeHeadersTest (#24619)
    
    CAMEL-24019: Fix flaky VertxWebsocketHandshakeHeadersTest
    
    Move MockEndpoint expectations before context.start() and replace 
CountDownLatch
    with MockEndpoint.assertIsSatisfied(context, 30, TimeUnit.SECONDS) to 
eliminate
    race condition where messages arrive before mock expectations are 
configured.
    
    Co-authored-by: Claude Opus 4.6 <[email protected]>
---
 .../websocket/VertxWebsocketHandshakeHeadersTest.java      | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git 
a/components/camel-vertx/camel-vertx-websocket/src/test/java/org/apache/camel/component/vertx/websocket/VertxWebsocketHandshakeHeadersTest.java
 
b/components/camel-vertx/camel-vertx-websocket/src/test/java/org/apache/camel/component/vertx/websocket/VertxWebsocketHandshakeHeadersTest.java
index d11a82177d78..42c79289d3d1 100644
--- 
a/components/camel-vertx/camel-vertx-websocket/src/test/java/org/apache/camel/component/vertx/websocket/VertxWebsocketHandshakeHeadersTest.java
+++ 
b/components/camel-vertx/camel-vertx-websocket/src/test/java/org/apache/camel/component/vertx/websocket/VertxWebsocketHandshakeHeadersTest.java
@@ -137,7 +137,6 @@ public class VertxWebsocketHandshakeHeadersTest extends 
VertxWebSocketTestSuppor
 
     @Test
     public void testHandshakeHeadersAsConsumer() throws Exception {
-        CountDownLatch latch = new CountDownLatch(1);
         Vertx vertx = Vertx.vertx();
         Router router = Router.router(vertx);
         Route route = router.route("/ws");
@@ -177,7 +176,7 @@ public class VertxWebsocketHandshakeHeadersTest extends 
VertxWebSocketTestSuppor
                             // Send a text message to consumer
                             ServerWebSocket webSocket = toWebSocket.result();
                             webSocket.writeTextMessage("Hello World");
-                            
webSocket.writeTextMessage("Ping").onComplete(event -> latch.countDown());
+                            webSocket.writeTextMessage("Ping");
                         } else {
                             // the upgrade failed
                             context.fail(toWebSocket.cause());
@@ -205,13 +204,14 @@ public class VertxWebsocketHandshakeHeadersTest extends 
VertxWebSocketTestSuppor
             }
         });
 
+        // Set up mock expectations BEFORE starting the context to avoid race 
conditions
+        // where messages arrive before expectations are configured
+        MockEndpoint mockEndpoint = context.getEndpoint("mock:result", 
MockEndpoint.class);
+        mockEndpoint.expectedBodiesReceivedInAnyOrder("Hello World", "Ping");
+
         context.start();
         try {
-            assertTrue(latch.await(10, TimeUnit.SECONDS));
-
-            MockEndpoint mockEndpoint = context.getEndpoint("mock:result", 
MockEndpoint.class);
-            mockEndpoint.expectedBodiesReceivedInAnyOrder("Hello World", 
"Ping");
-            mockEndpoint.assertIsSatisfied();
+            MockEndpoint.assertIsSatisfied(context, 30, TimeUnit.SECONDS);
         } finally {
             try {
                 host.stop();

Reply via email to