I am trying to implement some tests for the flow configuration. I have JMS inbound channel adapter as an entry point of the flow and outbound file channel adapter(with attached ExpressionEvaluatingRequestHandlerAdvice) as a last endpoint.
Here is a sample code:
@Bean
public IntegrationFlow fileProcessingFlow() {
DefaultMessageListenerContainer dmlc = new DefaultMessageListenerContainer();
dmlc.setConnectionFactory(connectionFactory);
dmlc.setDestination(jmsQueue);
return IntegrationFlows.from(Jms.messageDrivenChannelAdapter(dmlc))
.<String, File>transform(p -> new File(p))
.handle(headerEnricherService)
.<Boolean>route("T(SomeEnum).INVALID.equals(headers['headerName'])", mapping -> mapping
.subFlowMapping(Boolean.TRUE, sf -> sf.handle(serviceRef, "handleInvalidFile"))
.subFlowMapping(Boolean.FALSE, sf -> sf
.handle(serviceRef, "handleValidFile")
.handle(anotherServiceRef)))
.filter(additionalFilterRef)
.handle(Files.outboundAdapter("'output/dir/path'")
.autoCreateDirectory(true)
.deleteSourceFiles(true),
c -> c.advice(fileCopyAdvice()))
.get();
}
I was using this article to implement code above - https://spring.io/blog/2014/11/25/spring-integration-java-dsl-line-by-line-tutorial . However, I was not able to find information about testing of that code.
I've got several questions regarding code above:
- Where can I find test example(s) for the similarly defined flow? Or at least, some tutorial or articles on the subject?
- What would be the best way to mock JMS connection?
- How can I get references to the channels, when they are not explicitly defined in the flow config? Preferably, I would like to autowire channel in my test config and then to send a sample message to it. Something like
jmsInputChannel.send(testMessage);
- Is there any way to use MessageHistory in the test?
Thank you.