简体   繁体   English

Apache骆驼单元测试用例

[英]Apache camel unit test cases

Am new to Apache camel, working with it from last 2 weeks. 最近两周以来,Apache骆驼才开始使用。

I have written a single route for FTP download and then unzipping the downloaded files from FTP and then parsing the csv files to a bean objects. 我编写了一条用于FTP下载的单一路由,然后从FTP解压缩下载的文件,然后将csv文件解析为bean对象。

Now i have to write unit test cases for this route, so i divided them in parts like 1 for FT,1 for Unzipping and 1 for parsing to bean, am through with writing a FTP test successfully, but for the next two tasks am not clear on how to proceed for unzipping and parsing to bean unit test, can anyone please help me on this? 现在,我必须为该路由编写单元测试用例,因此我将它们分为多个部分,例如1用于FT,1用于解压缩和1用于解析到bean,可以成功编写FTP测试,但是接下来的两个任务不是明确说明如何进行解压缩和解析到bean单元测试,有人可以帮我吗?

Thanks for the help 谢谢您的帮助

take a look at Camel AdviceWith for testing the route flow using mock endpoints to assert its setup properly... 看看Camel AdviceWith ,使用模拟端点测试路由流以正确声明其设置...

public void testAdvised() throws Exception {
    // advice the first route using the inlined route builder
    context.getRouteDefinitions().get(0).adviceWith(context, new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            // intercept sending to mock:foo and do something else
            interceptSendToEndpoint("mock:foo")
                    .skipSendToOriginalEndpoint()
                    .to("log:foo")
                    .to("mock:advised");
        }
    });

    getMockEndpoint("mock:foo").expectedMessageCount(0);
    getMockEndpoint("mock:advised").expectedMessageCount(1);
    getMockEndpoint("mock:result").expectedMessageCount(1);

    template.sendBody("direct:start", "Hello World");

    assertMockEndpointsSatisfied();
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM