Class MockIntegrationContext

java.lang.Object
org.springframework.integration.test.context.MockIntegrationContext
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanFactoryAware

public class MockIntegrationContext
extends java.lang.Object
implements 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:
SpringIntegrationTest
  • Field Summary

    Fields 
    Modifier and Type Field Description
    static java.lang.String MOCK_INTEGRATION_CONTEXT_BEAN_NAME
    The bean name for the mock integration context.
  • Constructor Summary

    Constructors 
    Constructor Description
    MockIntegrationContext()  
  • Method Summary

    Modifier and Type Method Description
    void resetBeans​(java.lang.String... beanNames)
    Reinstate the mocked beans after execution test to their real state.
    void setBeanFactory​(org.springframework.beans.factory.BeanFactory beanFactory)  
    void substituteMessageHandlerFor​(java.lang.String consumerEndpointId, org.springframework.messaging.MessageHandler mockMessageHandler)  
    void substituteMessageHandlerFor​(java.lang.String consumerEndpointId, org.springframework.messaging.MessageHandler mockMessageHandler, boolean autoStartup)  
    void substituteMessageSourceFor​(java.lang.String pollingAdapterId, org.springframework.integration.core.MessageSource<?> mockMessageSource)
    Replace the real MessageSource in the SourcePollingChannelAdapter bean with provided MessageSource instance.
    void substituteMessageSourceFor​(java.lang.String pollingAdapterId, org.springframework.integration.core.MessageSource<?> mockMessageSource, boolean autoStartup)
    Replace the real MessageSource in the SourcePollingChannelAdapter bean with provided MessageSource instance.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • setBeanFactory

      public void setBeanFactory​(org.springframework.beans.factory.BeanFactory beanFactory) throws org.springframework.beans.BeansException
      Specified by:
      setBeanFactory in interface org.springframework.beans.factory.BeanFactoryAware
      Throws:
      org.springframework.beans.BeansException
    • resetBeans

      public void resetBeans​(java.lang.String... beanNames)
      Reinstate the mocked beans after execution test to their real state. Typically is used from the After method.
      Parameters:
      beanNames - the bean names to reset. If null, all the mocked beans are reset
    • substituteMessageSourceFor

      public void substituteMessageSourceFor​(java.lang.String pollingAdapterId, org.springframework.integration.core.MessageSource<?> mockMessageSource)
      Replace the real MessageSource in the SourcePollingChannelAdapter bean with provided MessageSource instance. Can be a mock object.
      Parameters:
      pollingAdapterId - the endpoint bean name
      mockMessageSource - the MessageSource to replace in the endpoint bean
      See Also:
      MockIntegration.mockMessageSource(T)
    • substituteMessageSourceFor

      public void substituteMessageSourceFor​(java.lang.String pollingAdapterId, org.springframework.integration.core.MessageSource<?> mockMessageSource, boolean autoStartup)
      Replace the real MessageSource in the SourcePollingChannelAdapter bean with provided MessageSource instance. Can be a mock object. The endpoint is not started when autoStartup == false.
      Parameters:
      pollingAdapterId - the endpoint bean name
      mockMessageSource - the MessageSource to replace in the endpoint bean
      autoStartup - start or not the endpoint after replacing its MessageSource
      See Also:
      MockIntegration.mockMessageSource(T)
    • substituteMessageHandlerFor

      public void substituteMessageHandlerFor​(java.lang.String consumerEndpointId, org.springframework.messaging.MessageHandler mockMessageHandler)
    • substituteMessageHandlerFor

      public void substituteMessageHandlerFor​(java.lang.String consumerEndpointId, org.springframework.messaging.MessageHandler mockMessageHandler, boolean autoStartup)