AmqpOutboundEndpoint not replaceable during integration tests? #3670
-
I'm working on a project that's using Amqp/RabbitMQ and spring integration heavily. We've got all of the units tested and a few end-to-end tests and we've reached the point where we'd like to integration test our flows themselves. The flows we're most interested in testing have pub/sub channels with an oubound message to a MQTT topic plus an additional message out to an amqp endpoint; both using Amqp/Rabbit spring-integration-core:5.5.2
The outbound endpoints are defined as above and the application functions as intended. However when I try to replace the bean during an integration test
I get an error when the integration test runs saying it's the wrong type.
Am I doing something improperly or have I found a bug? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
It is a bug, but not on the framework side.
This is not an endpoint to consume messages from the channel. This is a handler to process messages in that endpoint. Your mistake that you indeed try to replace a Consider to change your https://docs.spring.io/spring-integration/docs/current/reference/html/overview.html#finding-class-names-for-java-and-dsl-configuration |
Beta Was this translation helpful? Give feedback.
It is a bug, but not on the framework side.
It is just a misunderstanding of Spring Integration concepts:
This is not an endpoint to consume messages from the channel. This is a handler to process messages in that endpoint.
The goal of that
MockIntegrationContext
is still keep your flow as is, but replace message handlers exactly in the endpoints, so we don't do heavy logic with low-level resource.Your mistake that you indeed try to replace a
MessageHandler
bean with the mock. While that error and docs states clearly that we have to call exactly an endpoint and replace exactly itsMessageHandler
with our mock.