柑橘 waitFor().file 无法读取文件

citrus waitFor().file fails to read a file

我正在尝试在我的 Citrutest 中使用 waitFor() 来等待磁盘上的输出文件被我正在测试的进程写入。我用过这个代码

outputFile = new File “/esbfiles/blesbt/bl03orders.99160221.14289.xml");
waitFor().file(outputFile).seconds(65L).interval(1000L);

几秒钟后,文件按预期出现在文件夹中。我是 运行 测试代码的用户具有读取文件的权限。然而,waitFor() 以超时结束。

09:46:44 09:46:44,818 DEBUG dition.FileCondition| Checking file path '/esbfiles/blesbt/bl03orders.99160221.14289.xml'
09:46:44 09:46:44,818 WARN  dition.FileCondition| Failed to access file resource 'class path resource [esbfiles/blesbt/bl03orders.99160221.14289.xml] cannot be resolved to URL because it does not exist'

可能是什么问题?我不能检查类路径外的文件吗?

这实际上是 Citrus 中的一个错误。 Citrus 使用文件路径而不是文件对象,并与 Spring 的 PathMatchingResourcePatternResolver 结合使用,这导致 Citrus 搜索类路径资源而不是使用绝对文件路径作为外部文件系统资源。

您可以通过提供绝对文件路径而不是像这样的文件对象来解决此问题:

waitFor().file(“file:/esbfiles/blesbt/bl03orders.99160221.14289.xml")
         .seconds(65L)
         .interval(1000L); 

关于损坏的文件对象转换的问题已经打开:https://github.com/christophd/citrus/issues/303

感谢指点!