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


##########
components/camel-spring-parent/camel-spring-rabbitmq/src/test/java/org/apache/camel/component/springrabbit/integration/RabbitMQProducerInvalidExchangeIT.java:
##########
@@ -50,7 +50,13 @@ public void testProducer() {
 
         final CamelExecutionException exception = 
Assertions.assertThrows(CamelExecutionException.class,
                 () -> template.sendBody("direct:start", "Hello World"));
-        Assertions.assertInstanceOf(ShutdownSignalException.class, 
exception.getCause());
+        // Spring AMQP may wrap ShutdownSignalException in AmqpException 
depending on timing
+        Throwable cause = exception.getCause();
+        while (cause != null && !(cause instanceof ShutdownSignalException)) {
+            cause = cause.getCause();
+        }
+        Assertions.assertInstanceOf(ShutdownSignalException.class, cause,
+                "Expected ShutdownSignalException in cause chain, but got: " + 
exception.getCause());

Review Comment:
   I think we could use 
https://javadoc.io/doc/org.assertj/assertj-core/3.27.7/org/assertj/core/api/AbstractThrowableAssert.html#hasCauseInstanceOf(java.lang.Class)
   
   it will allow to have shorter code and also a better error message with the 
full stack trace.
   Especially given that it sounds like a stab in the dark that the 
AMQPEXception is wrapping the shutdownexception. At least, if i tis not the 
case, i twill help to investigate more.



-- 
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