在 spring-integretion 项目中,我有一个热文件夹,它检测何时将 csv 放在文件夹中并做一些额外的事情,我有一个与 channel 连接的入站 channel 适配器。
入站 channel 适配器 -> channel 。 检测其放置的 csv 何时接收其连接的 mns 服务激活器 我要做的只是测试它在创建文件时接收 mns 的 channel
我正在使用这个教程 https://www.javacodegeeks.com/2013/05/spring-integration-file-polling-and-tests.html 它非常有用,但我可以创建上下文
Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@57a4d5ee] to prepare test instance [proyect.integration.hotFolderTest@5af5def9] java.lang.IllegalStateException: Failed to load ApplicationContext
最佳答案
您需要在此事上显示更多堆栈跟踪,因为目前尚不清楚您真正的问题是什么。
另外,如果能分享一些您目前拥有的代码以及您希望在测试用例中执行的操作,那将是极好的。
要验证 channel 中是否存在消息,您可以配置 ChannelInterceptor
并实现其 preSend()
.
但是我们也建议像 @SpringIntegrationTest
这样的东西与 MockIntegration
特征。这样你就可以用一些 MockIntegration.mockMessageHandler()
替换你真正的服务激活器。并对其进行验证。
您需要配置一个 noAutoStartup
在提到的注释上,在准备模拟并调用 this.mockIntegrationContext.substituteMessageHandlerFor()
之前不要轮询目录.
在引用手册中查看更多信息:https://docs.spring.io/spring-integration/docs/current/reference/html/testing.html#test-context
关于testing - 如何测试在 spring-integration 中使用 channel 的热文件夹?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54223633/