在 Mule 服务器下运行 below flow 时,位于 C:\vikas\file 位置的 Message.xml 文件成功移动到 C:\vikas\file\error 位置。
<flow name="Demo" doc:name="Demo">
<file:inbound-endpoint path="C:\vikas\file\"
responseTimeout="10000" doc:name="File" />
<file:outbound-endpoint path="C:\vikas\file\error"
outputPattern="#[function:datestamp:dd-MM-yy]_#[function:systime].xml"
responseTimeout="10000" doc:name="ErrorQueue" />
</flow>
但是,在运行 JUnit 测试时,913d4c34-c754-11e2-8cfb-696bc9376bf8.dat 文件会在 C:/vikas/file 位置创建。为什么 Message.xml 没有复制到 C:\vikas\file\error 位置?如何解决?
@Test
public void testFile() throws Exception {
String fileInputPath = "file://C:/vikas/file";
String payload = IOUtils.getResourceAsString(
"Message.xml", this.getClass());
client.dispatch(fileInputPath, payload, null);
MuleMessage result = client.request(
"file://C:/vikas/file/error", 5000);
}
最佳答案
我在 client.dispatch() 方法后添加 Thread.sleep 后修复了它。
@Test
public void testFile() throws Exception {
String fileInputPath = "file://C:/vikas/file";
String payload = IOUtils.getResourceAsString(
"Message.xml", this.getClass());
client.dispatch(fileInputPath, payload, null);
Thread.sleep(685000);
MuleMessage result = client.request(
"file://C:/vikas/file/error", 5000);
}
由于调度是异步方法,Mule需要一些等待时间来完成文件移动过程。
关于file - Mule:JUnit 测试不适用于文件端点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16784336/