我需要为Apache骆驼路线编写JUNIT

时间:2018-11-30 09:40:04

标签: junit apache-camel spring-camel camel-ftp

我的骆驼路线如下

public class IncomingBatchFileRoute extends RouteBuilder {

    @Value(CCS_PROCESSING_INCOMING_DIRECTORY)
    private String source;


    @Override
    public void configure() throws Exception {
        from(sourceLocation)).autoStartup(false).to("encryptionEndPoint");
    }

}

我需要为上述骆驼路线写一个JUNIT,这是我的新手,并创建了如下结构

public class IncomingBatchFileRouteTest extends CamelTestSupport{


    @Override
    public RoutesBuilder createRouteBuilder() throws Exception {
        return new IncomingBatchFileRoute();
    }

    @Test
    public void sampleMockTest() {

    }
}

不确定如何完成它。请您为此提供帮助

1 个答案:

答案 0 :(得分:0)

您需要模拟您的加密端点,并使用生产者模板开始路由

@Produce(uri = CCS_PROCESSING_INCOMING_DIRECTORY)
protected ProducerTemplate template;

@EndpointInject(uri = "encryptionEndPoint")
protected MockEndpoint resultEndpoint;

@Test
public void sampleMockTest() {

  // GIVEN
  this.resultEndpoint.expectedMessageCount(1);

  // WHEN
  this.template.sendBody("Hey");

  // THEN
  this.resultEndpoint.assertIsSatisfied();
}