apupier commented on code in PR #24954:
URL: https://github.com/apache/camel/pull/24954#discussion_r3615075434


##########
components/camel-cxf/camel-cxf-spring-soap/src/test/java/org/apache/camel/component/cxf/CxfTimeoutTest.java:
##########
@@ -96,7 +96,23 @@ 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");
+        // 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.
+        assertTrue(hasHttpTimeoutException(e),
+                "Expected HttpTimeoutException (direct or as cause) but got "
+                                               + e.getClass().getName() + ": " 
+ e.getMessage());
+    }
+
+    private static boolean hasHttpTimeoutException(Throwable t) {
+        while (t != null) {
+            if (t instanceof HttpTimeoutException) {
+                return true;
+            }
+            t = t.getCause();
+        }
+        return false;

Review Comment:
   Can use assertj assertThat().hasCause() directly



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to