INT-4537: Fix RSConsumer for MockIntegrationCtx
JIRA: https://jira.spring.io/browse/INT-4537 Fixes spring-projects/spring-integration#2582 * Rename `ReactiveStreamsConsumer.messageHandler` property to the `handler` for consistency with other `IntegrationConsumer` s * Do not wrap `Subscriber` into the `MessageHandler` if that one is already a `MessageHandler` * Fix `MockIntegrationContext` for the logic around `ReactiveStreamsConsumer` where it is not enough just replace a `handler`, but we also need to do that with the `subscriber`. Luckily the `MockMessageHandler` is also a Reactive `Subscriber` * Clean up `MockIntegrationContext.beans` in the end of `resetBeans()` * Improve `testing.adoc` **Cherry-pick to 5.0.x**
This commit is contained in:
committed by
Gary Russell
parent
9e9fa2cf58
commit
2df71fba30
@@ -265,6 +265,21 @@ public void testMockMessageSource() {
|
||||
----
|
||||
====
|
||||
|
||||
NOTE: The `mySourceEndpoint` refers here to the bean name of the `SourcePollingChannelAdapter` for which we replace the real `MessageSource` with our mock.
|
||||
Similarly the `MockIntegrationContext.substituteMessageHandlerFor()` expects a bean name for the `IntegrationConsumer`, which wraps a `MessageHandler` as an endpoint.
|
||||
|
||||
After test is performed you can restore the state of endpoint beans to the real configuration using `MockIntegrationContext.resetBeans()`:
|
||||
|
||||
====
|
||||
[source,java]
|
||||
----
|
||||
@After
|
||||
public void tearDown() {
|
||||
this.mockIntegrationContext.resetBeans();
|
||||
}
|
||||
----
|
||||
====
|
||||
|
||||
See the https://docs.spring.io/spring-integration/api/org/springframework/integration/test/context/MockIntegrationContext.html[Javadoc] for more information.
|
||||
|
||||
[[testing-mocks]]
|
||||
@@ -272,7 +287,7 @@ See the https://docs.spring.io/spring-integration/api/org/springframework/integr
|
||||
|
||||
The `org.springframework.integration.test.mock` package offers tools and utilities for mocking, stubbing, and verification of activity on Spring Integration components.
|
||||
The mocking functionality is fully based on and compatible with the well known Mockito Framework.
|
||||
(The current Mockito transitive dependency is on version 2.5.x.)
|
||||
(The current Mockito transitive dependency is on version 2.5.x or higher.)
|
||||
|
||||
==== MockIntegration
|
||||
|
||||
|
||||
Reference in New Issue
Block a user