gnodet commented on code in PR #22980:
URL: https://github.com/apache/camel/pull/22980#discussion_r3194031159
##########
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:
Good point, thanks! Switched to
`assertThat(exception).hasRootCauseInstanceOf(ShutdownSignalException.class)` —
uses `hasRootCauseInstanceOf` rather than `hasCauseInstanceOf` since the
`ShutdownSignalException` is the deepest cause in both the direct and wrapped
scenarios. This also gives the full stack trace on failure as you suggested.
_Claude Code on behalf of Guillaume Nodet_
--
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]