spring-integration
spring-integration copied to clipboard
JmsChannelFactoryBean instanciating it's own jmsTemplate prevents mocking for test [INT-2679]
Sylvain Mougenot opened INT-2679 and commented
Using jms:outbound-channel-adapter it's not possible to mock jmsTemplate (for test purposes) because JmsChannelFactoryBean instanciate it's own.
private final JmsTemplate jmsTemplate = new DynamicJmsTemplate();
It would be nice if we could inject the jmsTemplate.
Affects: 2.1.3
Artem Bilan commented
Hello
Maybe this will be enough:
Field jmsTemplateField = ReflectionUtils.findField(AbstractJmsChannel.class, "jmsTemplate");
jmsTemplateField.setAccessible(true);
JmsTemplate jmsTemplate = Mockito.mock(JmsTemplate.class);
...
ReflectionUtils.setField(jmsTemplateField , jmsChannel, jmsTemplate );
?