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 e1d72c68e143 Fix CxfTimeoutTest flakiness: check cause chain for 
HttpTimeoutException
e1d72c68e143 is described below

commit e1d72c68e1431eeac2e4d9c84e2736290182db9b
Author: Guillaume Nodet <[email protected]>
AuthorDate: Mon Jul 20 19:14:39 2026 +0200

    Fix CxfTimeoutTest flakiness: check cause chain for HttpTimeoutException
    
    CXF may propagate HttpTimeoutException directly or wrap it in a Fault
    ("Could not send Message.") depending on where in the interceptor chain
    the timeout is caught. The test assertion only checked the top-level
    exception, causing intermittent failures (~2.6% for
    testInvokingFromCamelRoute) when CXF wraps the timeout exception.
    
    Modified sendTimeOutMessage() to accept HttpTimeoutException at any level
    in the cause chain using AssertJ's satisfiesAnyOf/hasRootCauseInstanceOf.
    Added assertj-core test dependency to camel-cxf-spring-soap.
    
    Co-Authored-By: Claude Opus 4.6 <[email protected]>
---
 components/camel-cxf/camel-cxf-spring-soap/pom.xml    |  5 +++++
 .../apache/camel/component/cxf/CxfTimeoutTest.java    | 19 +++++++++++--------
 2 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/components/camel-cxf/camel-cxf-spring-soap/pom.xml 
b/components/camel-cxf/camel-cxf-spring-soap/pom.xml
index 3198c8f4c26c..4f7d6ddf3747 100644
--- a/components/camel-cxf/camel-cxf-spring-soap/pom.xml
+++ b/components/camel-cxf/camel-cxf-spring-soap/pom.xml
@@ -59,6 +59,11 @@
         </dependency>
 
         <!--  Test Dependencies -->
+        <dependency>
+            <groupId>org.assertj</groupId>
+            <artifactId>assertj-core</artifactId>
+            <scope>test</scope>
+        </dependency>
         <dependency>
             <groupId>org.apache.camel</groupId>
             <artifactId>camel-cxf-common</artifactId>
diff --git 
a/components/camel-cxf/camel-cxf-spring-soap/src/test/java/org/apache/camel/component/cxf/CxfTimeoutTest.java
 
b/components/camel-cxf/camel-cxf-spring-soap/src/test/java/org/apache/camel/component/cxf/CxfTimeoutTest.java
index 0762cec09426..4599221ee1f2 100644
--- 
a/components/camel-cxf/camel-cxf-spring-soap/src/test/java/org/apache/camel/component/cxf/CxfTimeoutTest.java
+++ 
b/components/camel-cxf/camel-cxf-spring-soap/src/test/java/org/apache/camel/component/cxf/CxfTimeoutTest.java
@@ -40,10 +40,7 @@ import org.junit.jupiter.api.parallel.Isolated;
 import org.springframework.context.support.AbstractXmlApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.assertj.core.api.Assertions.assertThat;
 
 @Isolated
 public class CxfTimeoutTest extends CamelSpringTestSupport {
@@ -78,8 +75,8 @@ public class CxfTimeoutTest extends CamelSpringTestSupport {
     public void testInvokingJaxWsServerWithCxfEndpointWithConfigurer() throws 
Exception {
         Exchange reply = 
sendJaxWsMessage("cxf://bean:springEndpoint?cxfConfigurer=#myConfigurer");
         // we don't expect the exception here
-        assertFalse(reply.isFailed(), "We don't expect the exception here");
-        assertEquals("Greet Hello World!", 
reply.getMessage().getBody(String.class), "Get a wrong response");
+        assertThat(reply.isFailed()).as("We don't expect the exception 
here").isFalse();
+        assertThat(reply.getMessage().getBody(String.class)).as("response 
body").isEqualTo("Greet Hello World!");
     }
 
     @Test
@@ -95,8 +92,14 @@ public class CxfTimeoutTest extends CamelSpringTestSupport {
     protected void sendTimeOutMessage(String endpointUri) throws Exception {
         Exchange reply = sendJaxWsMessage(endpointUri);
         Exception e = reply.getException();
-        assertNotNull(e, "We should get the exception cause here");
-        assertTrue(e instanceof HttpTimeoutException, "We should get a http 
time out exception here");
+        assertThat(e).as("exchange exception").isNotNull();
+        // CXF may either propagate HttpTimeoutException directly or wrap it 
in a
+        // Fault ("Could not send Message.") depending on where in the 
interceptor
+        // chain the timeout is caught. Both cases indicate the timeout was 
applied
+        // correctly, so check the entire cause chain.
+        assertThat(e).satisfiesAnyOf(
+                ex -> assertThat(ex).isInstanceOf(HttpTimeoutException.class),
+                ex -> 
assertThat(ex).hasRootCauseInstanceOf(HttpTimeoutException.class));
     }
 
     protected Exchange sendJaxWsMessage(String endpointUri) throws 
InterruptedException {

Reply via email to