我正在嘗試爲流配置實施一些測試。我將JMS入站通道適配器作爲流和出站文件通道適配器(附帶ExpressionEvaluatingRequestHandlerAdvice)的入口點作爲最後一個端點。流量集成測試(Java DSL配置)
這裏是一個示例代碼:
@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();
}
我用這篇文章來實現上面的代碼 - https://spring.io/blog/2014/11/25/spring-integration-java-dsl-line-by-line-tutorial。但是,我無法找到有關測試代碼的信息。
我有關於上面的代碼中幾個問題:
- 我在哪裏可以找到一個類似定義流程的測試實例(S)?或者至少,有關該主題的一些教程或文章?
- 什麼是模擬JMS連接的最佳方式?
- 如何在流配置中未明確定義通道時引用通道?優選地,我想在我的測試配置中自動裝入通道,然後向其發送示例消息。類似於
jmsInputChannel.send(testMessage);
- 有什麼方法可以在測試中使用MessageHistory?
謝謝。
嗨Artem。非常感謝您的詳細回覆。 – Alex