Apache camel 什么是';移动失败';真的吗?

Apache camel 什么是';移动失败';真的吗?,apache-camel,fuseesb,Apache Camel,Fuseesb,我想创建一个行为如下的文件输入: 处理交换 尝试将输入文件复制到共享驱动器 如果步骤(2)失败(例如共享已关闭),则改为移动到本地文件 在“moveFailed”参数之后,允许“在处理(通过上面定义的移动配置)失败后移动文件时设置不同的目标目录”。所以这听起来像是moveFailed涵盖了步骤(3) 但是,下面的测试失败了……我做错了什么?我使用的是camel 2.10.0.fuse package sandbox.camel; import java.io.File; import

我想创建一个行为如下的文件输入:

  • 处理交换
  • 尝试将输入文件复制到共享驱动器
  • 如果步骤(2)失败(例如共享已关闭),则改为移动到本地文件
  • 在“moveFailed”参数之后,允许“在处理(通过上面定义的移动配置)失败后移动文件时设置不同的目标目录”。所以这听起来像是moveFailed涵盖了步骤(3)

    但是,下面的测试失败了……我做错了什么?我使用的是camel 2.10.0.fuse

    package sandbox.camel;
    
    import java.io.File;    
    import org.apache.camel.Endpoint;
    import org.apache.camel.builder.RouteBuilder;
    import org.apache.camel.component.mock.MockEndpoint;
    import org.junit.Test;
    
    public class MoveFailedTest extends org.apache.camel.test.junit4.CamelTestSupport {
    
        private String failedDir = "move-failed";
    
        @Override
        protected RouteBuilder createRouteBuilder() throws Exception {
            return new RouteBuilder() {
    
    
    
                @Override
                public void configure() throws Exception {
                    from("file:tmp/prepare").to("file:tmp/input");
                    from("file:tmp/input?move=/doesnotexist&moveFailed=" + failedDir).to("file:tmp/output");
                }
            };
        }        
    
        @Test
        public void test_move() throws Exception {
    
            // arrange
            File moveFailedDir = new File("tmp/input/" + failedDir);
            moveFailedDir.mkdirs();
            File[] failedCount1 = moveFailedDir.listFiles();
            failedCount1 = failedCount1 == null ? new File[0] : failedCount1;
            String messagePayload = "Hello";
    
            Endpoint input = getMandatoryEndpoint("file:tmp/prepare");
            MockEndpoint output = getMockEndpoint("mock:file:tmp/output");
            output.setMinimumExpectedMessageCount(1);
            output.expectedBodiesReceived(messagePayload);
    
            // act
            template.asyncSendBody(input, messagePayload);
            Thread.sleep(3000);
    
            // assert: only 1 output
            assertMockEndpointsSatisfied();
            // assert: renamed failed, hence input file was moved to 'movefailed' directory
            File[] failedCount2 = moveFailedDir.listFiles();
            assertEquals("No file appeared in 'movefailed' directory", failedCount1.length + 1, failedCount2.length);
        }
    
    }
    

    你的测试很可能是错的。自动创建选项默认为true,这意味着在需要时创建目录