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,- ComponentSourceAware,- ExpressionCapable,- Orderable,- MessageProducer,- HeaderPropagationAware,- IntegrationPattern,- NamedComponent,- IntegrationManagement,- TrackableComponent,- MessageHandler,- reactor.core.CoreSubscriber<Message<?>>
The 
AbstractMessageProducingHandler extension for the mocking purpose in tests.
 
 The provided Consumers and Functions 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 SummaryNested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagementIntegrationManagement.ManagementOverrides
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected booleanFields inherited from class org.springframework.integration.handler.AbstractMessageProducingHandlermessagingTemplateFields inherited from class org.springframework.integration.context.IntegrationObjectSupportEXPRESSION_PARSER, loggerFields inherited from interface org.springframework.integration.support.management.IntegrationManagementMETER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAMEFields inherited from interface org.springframework.core.OrderedHIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedMockMessageHandler(org.mockito.ArgumentCaptor<Message<?>> messageArgumentCaptor) 
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidhandleMessageInternal(Message<?> message) handleNext(Consumer<Message<?>> nextMessageConsumer) Add theConsumerto the stack to handle the next incoming message.handleNextAndReply(Function<Message<?>, ?> nextMessageFunction) Add theFunctionto the stack to handle the next incoming message and produce reply for it.Methods inherited from class org.springframework.integration.handler.AbstractMessageProducingHandleraddNotPropagatedHeaders, createOutputMessage, getNotPropagatedHeaders, getOutputChannel, isAsync, messageBuilderForReply, onInit, produceOutput, resolveErrorChannel, sendErrorMessage, sendOutput, sendOutputs, setAsync, setNotPropagatedHeaders, setOutputChannel, setOutputChannelName, setSendTimeout, setupMessageProcessor, shouldCopyRequestHeaders, shouldSplitOutput, updateNotPropagatedHeadersMethods inherited from class org.springframework.integration.handler.AbstractMessageHandlerhandleMessage, onComplete, onError, onNext, onSubscribe, setObservationConventionMethods inherited from class org.springframework.integration.handler.MessageHandlerSupportbuildSendTimer, destroy, getComponentType, getIntegrationPatternType, getManagedName, getManagedType, getMetricsCaptor, getObservationRegistry, getOrder, getOverrides, isLoggingEnabled, isObserved, registerMetricsCaptor, registerObservationRegistry, sendTimer, setLoggingEnabled, setManagedName, setManagedType, setOrder, setShouldTrack, shouldTrackMethods inherited from class org.springframework.integration.context.IntegrationObjectSupportafterPropertiesSet, extractTypeIfPossible, generateId, getApplicationContext, getApplicationContextId, getBeanDescription, getBeanFactory, getBeanName, getChannelResolver, getComponentDescription, getComponentName, getComponentSource, getConversionService, getExpression, getIntegrationProperties, getMessageBuilderFactory, getTaskScheduler, isInitialized, setApplicationContext, setBeanFactory, setBeanName, setChannelResolver, setComponentDescription, setComponentName, setComponentSource, setConversionService, setMessageBuilderFactory, setPrimaryExpression, setTaskScheduler, toStringMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface reactor.core.CoreSubscribercurrentContextMethods inherited from interface org.springframework.integration.support.management.IntegrationManagementgetThisAsMethods inherited from interface org.springframework.integration.support.context.NamedComponentgetBeanName, getComponentName
- 
Field Details- 
messageFunctions
- 
lastFunction
- 
hasRepliesprotected boolean hasReplies
 
- 
- 
Constructor Details- 
MockMessageHandler
 
- 
- 
Method Details- 
handleNextAdd theConsumerto the stack to handle the next incoming message.- Parameters:
- nextMessageConsumer- the Consumer to handle the next incoming message.
- Returns:
- this
 
- 
handleNextAndReplyAdd theFunctionto 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:
- handleMessageInternalin class- AbstractMessageHandler
 
 
-