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
@@ -49,7 +49,7 @@ public class ReactiveStreamsConsumer extends AbstractEndpoint implements Integra
|
||||
|
||||
private final MessageChannel inputChannel;
|
||||
|
||||
private final MessageHandler messageHandler;
|
||||
private final MessageHandler handler;
|
||||
|
||||
private final Publisher<Message<Object>> publisher;
|
||||
|
||||
@@ -83,10 +83,13 @@ public class ReactiveStreamsConsumer extends AbstractEndpoint implements Integra
|
||||
this.subscriber = subscriber;
|
||||
this.lifecycleDelegate = subscriber instanceof Lifecycle ? (Lifecycle) subscriber : null;
|
||||
if (subscriber instanceof MessageHandlerSubscriber) {
|
||||
this.messageHandler = ((MessageHandlerSubscriber) subscriber).messageHandler;
|
||||
this.handler = ((MessageHandlerSubscriber) subscriber).messageHandler;
|
||||
}
|
||||
else if (subscriber instanceof MessageHandler) {
|
||||
this.handler = (MessageHandler) subscriber;
|
||||
}
|
||||
else {
|
||||
this.messageHandler = this.subscriber::onNext;
|
||||
this.handler = this.subscriber::onNext;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,11 +104,11 @@ public class ReactiveStreamsConsumer extends AbstractEndpoint implements Integra
|
||||
|
||||
@Override
|
||||
public MessageChannel getOutputChannel() {
|
||||
if (this.messageHandler instanceof MessageProducer) {
|
||||
return ((MessageProducer) this.messageHandler).getOutputChannel();
|
||||
if (this.handler instanceof MessageProducer) {
|
||||
return ((MessageProducer) this.handler).getOutputChannel();
|
||||
}
|
||||
else if (this.messageHandler instanceof MessageRouter) {
|
||||
return ((MessageRouter) this.messageHandler).getDefaultOutputChannel();
|
||||
else if (this.handler instanceof MessageRouter) {
|
||||
return ((MessageRouter) this.handler).getDefaultOutputChannel();
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
@@ -114,7 +117,7 @@ public class ReactiveStreamsConsumer extends AbstractEndpoint implements Integra
|
||||
|
||||
@Override
|
||||
public MessageHandler getHandler() {
|
||||
return this.messageHandler;
|
||||
return this.handler;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user