Class MockMessageHandler
java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.handler.MessageHandlerSupport
org.springframework.integration.handler.AbstractMessageHandler
org.springframework.integration.handler.AbstractMessageProducingHandler
org.springframework.integration.test.mock.MockMessageHandler
- All Implemented Interfaces:
org.reactivestreams.Subscriber<Message<?>>
,Aware
,BeanFactoryAware
,BeanNameAware
,DisposableBean
,InitializingBean
,ApplicationContextAware
,Ordered
,ExpressionCapable
,Orderable
,MessageProducer
,HeaderPropagationAware
,IntegrationPattern
,NamedComponent
,IntegrationManagement
,TrackableComponent
,MessageHandler
,reactor.core.CoreSubscriber<Message<?>>
The
AbstractMessageProducingHandler
extension for the mocking purpose in tests.
The provided Consumer
s and Function
s are applied to the incoming
messages one at a time until the last, which is applied for all subsequent messages.
The similar behavior exists in the
Mockito.doReturn(Object toBeReturned, Object... toBeReturnedNext)
.
Typically is used as a chain of stub actions:
MockIntegration.mockMessageHandler()
.handleNext(...)
.handleNext(...)
.handleNextAndReply(...)
.handleNextAndReply(...)
.handleNext(...)
.handleNextAndReply(...);
- Since:
- 5.0
- Author:
- Artem Bilan, Christian Tzolov
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagement
IntegrationManagement.ManagementOverrides
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
Fields inherited from class org.springframework.integration.handler.AbstractMessageProducingHandler
messagingTemplate
Fields inherited from class org.springframework.integration.context.IntegrationObjectSupport
EXPRESSION_PARSER, logger
Fields inherited from interface org.springframework.integration.support.management.IntegrationManagement
METER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAME
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
ModifierConstructorDescriptionprotected
MockMessageHandler
(org.mockito.ArgumentCaptor<Message<?>> messageArgumentCaptor) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
handleMessageInternal
(Message<?> message) handleNext
(Consumer<Message<?>> nextMessageConsumer) Add theConsumer
to the stack to handle the next incoming message.handleNextAndReply
(Function<Message<?>, ?> nextMessageFunction) Add theFunction
to the stack to handle the next incoming message and produce reply for it.Methods inherited from class org.springframework.integration.handler.AbstractMessageProducingHandler
addNotPropagatedHeaders, createOutputMessage, getNotPropagatedHeaders, getOutputChannel, isAsync, messageBuilderForReply, onInit, produceOutput, resolveErrorChannel, sendErrorMessage, sendOutput, sendOutputs, setAsync, setNotPropagatedHeaders, setOutputChannel, setOutputChannelName, setSendTimeout, setupMessageProcessor, shouldCopyRequestHeaders, shouldSplitOutput, updateNotPropagatedHeaders
Methods inherited from class org.springframework.integration.handler.AbstractMessageHandler
handleMessage, onComplete, onError, onNext, onSubscribe, setObservationConvention
Methods inherited from class org.springframework.integration.handler.MessageHandlerSupport
buildSendTimer, destroy, getComponentType, getIntegrationPatternType, getManagedName, getManagedType, getMetricsCaptor, getObservationRegistry, getOrder, getOverrides, isLoggingEnabled, isObserved, registerMetricsCaptor, registerObservationRegistry, sendTimer, setLoggingEnabled, setManagedName, setManagedType, setOrder, setShouldTrack, shouldTrack
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentName, getConversionService, getExpression, getIntegrationProperties, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentName, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface reactor.core.CoreSubscriber
currentContext
Methods inherited from interface org.springframework.integration.support.management.IntegrationManagement
getThisAs
Methods inherited from interface org.springframework.integration.support.context.NamedComponent
getBeanName, getComponentName
-
Field Details
-
messageFunctions
-
lastFunction
-
hasReplies
protected boolean hasReplies
-
-
Constructor Details
-
MockMessageHandler
-
-
Method Details
-
handleNext
Add theConsumer
to the stack to handle the next incoming message.- Parameters:
nextMessageConsumer
- the Consumer to handle the next incoming message.- Returns:
- this
-
handleNextAndReply
Add theFunction
to the stack to handle the next incoming message and produce reply for it.- Parameters:
nextMessageFunction
- the Function to handle the next incoming message.- Returns:
- this
-
handleMessageInternal
- Specified by:
handleMessageInternal
in classAbstractMessageHandler
-