apache camel - What does 'moveFailed' really do? -
i want create file input behaves follows:
- process exchange
- attempt copy input file shared drive
- if step (2) fails (e.g. share down) move local file instead
following doc 'movefailed' parameter allows "set different target directory when moving files after processing (configured via move defined above) failed". sounds movefailed cover step (3).
the following test, fails...what doing wrong ? using 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: 1 output assertmockendpointssatisfied(); // assert: renamed failed, hence input file moved 'movefailed' directory file[] failedcount2 = movefaileddir.listfiles(); assertequals("no file appeared in 'movefailed' directory", failedcount1.length + 1, failedcount2.length); } }
your test wrong. autocreate option default true, means directories created if needed.
Comments
Post a Comment