[英]Using alternate endpoints when testing Apache Camel + SpringBoot
I have a simple Apache Camel RouteBuilder
class that roughly looks like: 我有一个简单的Apache Camel
RouteBuilder
类,大致类似于:
from("an FTP server")
// log stuff
.to("direct:split");
from("direct:split")
// split CSV and aggregate the messages into separate files
.to("direct:save");
from("direct:save")
// save the files to a different FTP server
.end();
In tests that I'm going to write though, I want to use pretty much test the direct:split
endpoint only -- I'll load the CSV and save the new CSVs locally, and then write tests to compare the output with what I'd expect the output to be. 在我要编写的测试中,我只想使用
direct:split
终结点做很多测试—我将加载CSV并将新的CSV保存在本地,然后编写测试以将输出与我的输出进行比较期望输出是。 Would I just rewrite the RouteBuilder
in my tests? 我
RouteBuilder
在测试中重写RouteBuilder
? Or would I somehow pull in the direct:split
endpoint, and then just specify different starting and ending locations? 还是我会以某种方式引入
direct:split
端点,然后仅指定不同的开始和结束位置?
You could make some "sub" routes such as: 您可以创建一些“子”路线,例如:
from("direct:split")
// make two subroutes
.to("direct:splitSubRouteOne")
.to("direct:splitSubRouteTwo");
from("direct:splitSubRouteOne")
// split CSV and aggregate the messages into separate files
// etc
;
from("direct:splitSubRouteTwo")
.to("direct:save");
Then you can test just the portion that you want (presumably) by sending to "direct:splitSubRouteOne" which will test that piece, but not the second piece. 然后,您可以发送到“ direct:splitSubRouteOne”,仅测试您想要的部分(大概),该部分将测试该部分,而不测试第二部分。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.