public class MockIntegrationContext extends Object implements BeanFactoryAware
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.
SpringIntegrationTest
Modifier and Type | Field and Description |
---|---|
static String |
MOCK_INTEGRATION_CONTEXT_BEAN_NAME
The bean name for the mock integration context.
|
Constructor and Description |
---|
MockIntegrationContext() |
Modifier and Type | Method and Description |
---|---|
void |
resetBeans(String... beanNames)
Reinstate the mocked beans after execution test to their real state.
|
void |
setBeanFactory(BeanFactory beanFactory) |
void |
substituteMessageHandlerFor(String consumerEndpointId,
MessageHandler mockMessageHandler) |
void |
substituteMessageHandlerFor(String consumerEndpointId,
MessageHandler mockMessageHandler,
boolean autoStartup) |
void |
substituteMessageSourceFor(String pollingAdapterId,
MessageSource<?> mockMessageSource)
Replace the real
MessageSource in the SourcePollingChannelAdapter bean
with provided MessageSource instance. |
void |
substituteMessageSourceFor(String pollingAdapterId,
MessageSource<?> mockMessageSource,
boolean autoStartup)
Replace the real
MessageSource in the SourcePollingChannelAdapter bean
with provided MessageSource instance. |
public static final String MOCK_INTEGRATION_CONTEXT_BEAN_NAME
public void setBeanFactory(BeanFactory beanFactory) throws BeansException
setBeanFactory
in interface BeanFactoryAware
BeansException
public void resetBeans(String... beanNames)
After
method.beanNames
- the bean names to reset.
If null
, all the mocked beans are resetpublic void substituteMessageSourceFor(String pollingAdapterId, MessageSource<?> mockMessageSource)
MessageSource
in the SourcePollingChannelAdapter
bean
with provided MessageSource
instance.
Can be a mock object.pollingAdapterId
- the endpoint bean namemockMessageSource
- the MessageSource
to replace in the endpoint beanMockIntegration.mockMessageSource(T)
public void substituteMessageSourceFor(String pollingAdapterId, MessageSource<?> mockMessageSource, boolean autoStartup)
MessageSource
in the SourcePollingChannelAdapter
bean
with provided MessageSource
instance.
Can be a mock object.
The endpoint is not started when autoStartup == false
.pollingAdapterId
- the endpoint bean namemockMessageSource
- the MessageSource
to replace in the endpoint beanautoStartup
- start or not the endpoint after replacing its MessageSource
MockIntegration.mockMessageSource(T)
public void substituteMessageHandlerFor(String consumerEndpointId, MessageHandler mockMessageHandler)
public void substituteMessageHandlerFor(String consumerEndpointId, MessageHandler mockMessageHandler, boolean autoStartup)