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 |
Constructor and Description |
---|
MockIntegrationContext() |
Modifier and Type | Method and Description |
---|---|
void |
instead(String pollingAdapterId,
MessageSource<?> mockMessageSource)
Replace the real
MessageSource in the SourcePollingChannelAdapter bean
with provided MessageSource instance. |
void |
instead(String pollingAdapterId,
MessageSource<?> mockMessageSource,
boolean autoStartup)
Replace the real
MessageSource in the SourcePollingChannelAdapter bean
with provided MessageSource instance. |
void |
resetBeans(String... beanNames)
Reinstate the mocked beans after execution test to their real state.
|
void |
setBeanFactory(BeanFactory beanFactory) |
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 instead(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 instead(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)