testing - 如何测试在 spring-integration 中使用 channel 的热文件夹?

标签 testing jakarta-ee spring-integration channel

在 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/

相关文章:

Java:测试算法:所有可能的组合

java - Spring Integration 轮询器有时会运行一次然后停止

testing - karma-eslint 预处理器不工作

java - 如何在 Eclipse 中获取调试 View ?

java - 用于模拟的示例Java Web应用程序(包括数据库脚本等)

java - JMS 替代方案

java - JDBC Appender 不写入异常堆栈跟踪

java - Spring 重试: NeverRetryLogic Not working as I expected with ExceptionClassifierRetryPolicy

java - Spring 集成 LastModifiedFileListFilter 不起作用

ruby-on-rails - Rails 4 'permit' 和 'count by one' 错误