Class MockIntegrationContext
java.lang.Object
org.springframework.integration.test.context.MockIntegrationContext
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanFactoryAware,org.springframework.beans.factory.config.BeanPostProcessor,org.springframework.beans.factory.SmartInitializingSingleton
public class MockIntegrationContext
extends Object
implements org.springframework.beans.factory.config.BeanPostProcessor, org.springframework.beans.factory.SmartInitializingSingleton, org.springframework.beans.factory.BeanFactoryAware
A
BeanFactoryAware component with an API to customize real beans
in the application context from test code.
The bean for this class is registered automatically via the SpringIntegrationTest
annotation and can be autowired into test class.
- Since:
- 5.0
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe bean name for the mock integration context. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidpostProcessBeforeInitialization(Object bean, String beanName) voidresetBeans(String... beanNames) Reinstate the mocked beans after execution test to their real state.voidsetBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory) voidsubstituteMessageHandlerFor(String consumerEndpointId, org.springframework.messaging.MessageHandler mockMessageHandler) voidsubstituteMessageHandlerFor(String consumerEndpointId, org.springframework.messaging.MessageHandler mockMessageHandler, boolean autoStartup) voidsubstituteMessageSourceFor(String pollingAdapterId, org.springframework.integration.core.MessageSource<?> mockMessageSource) Replace the realMessageSourcein theSourcePollingChannelAdapterbean with providedMessageSourceinstance.voidsubstituteMessageSourceFor(String pollingAdapterId, org.springframework.integration.core.MessageSource<?> mockMessageSource, boolean autoStartup) Replace the realMessageSourcein theSourcePollingChannelAdapterbean with providedMessageSourceinstance.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.beans.factory.config.BeanPostProcessor
postProcessAfterInitialization
-
Field Details
-
MOCK_INTEGRATION_CONTEXT_BEAN_NAME
The bean name for the mock integration context.- See Also:
-
-
Constructor Details
-
MockIntegrationContext
public MockIntegrationContext()
-
-
Method Details
-
setBeanFactory
public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory) throws org.springframework.beans.BeansException - Specified by:
setBeanFactoryin interfaceorg.springframework.beans.factory.BeanFactoryAware- Throws:
org.springframework.beans.BeansException
-
postProcessBeforeInitialization
public Object postProcessBeforeInitialization(Object bean, String beanName) throws org.springframework.beans.BeansException - Specified by:
postProcessBeforeInitializationin interfaceorg.springframework.beans.factory.config.BeanPostProcessor- Throws:
org.springframework.beans.BeansException
-
afterSingletonsInstantiated
public void afterSingletonsInstantiated()- Specified by:
afterSingletonsInstantiatedin interfaceorg.springframework.beans.factory.SmartInitializingSingleton
-
resetBeans
Reinstate the mocked beans after execution test to their real state. Typically, this method is used from JUnit clean up methods.- Parameters:
beanNames- the bean names to reset. Ifnull, all the mocked beans are reset
-
substituteMessageSourceFor
public void substituteMessageSourceFor(String pollingAdapterId, org.springframework.integration.core.MessageSource<?> mockMessageSource) Replace the realMessageSourcein theSourcePollingChannelAdapterbean with providedMessageSourceinstance. Can be a mock object.- Parameters:
pollingAdapterId- the endpoint bean namemockMessageSource- theMessageSourceto replace in the endpoint bean- See Also:
-
substituteMessageSourceFor
public void substituteMessageSourceFor(String pollingAdapterId, org.springframework.integration.core.MessageSource<?> mockMessageSource, boolean autoStartup) Replace the realMessageSourcein theSourcePollingChannelAdapterbean with providedMessageSourceinstance. Can be a mock object. The endpoint is not started whenautoStartup == false.- Parameters:
pollingAdapterId- the endpoint bean namemockMessageSource- theMessageSourceto replace in the endpoint beanautoStartup- start or not the endpoint after replacing itsMessageSource- See Also:
-
substituteMessageHandlerFor
public void substituteMessageHandlerFor(String consumerEndpointId, org.springframework.messaging.MessageHandler mockMessageHandler) -
substituteMessageHandlerFor
public void substituteMessageHandlerFor(String consumerEndpointId, org.springframework.messaging.MessageHandler mockMessageHandler, boolean autoStartup)
-