java - Camel testing with Thread.sleep() -
in "camel in action" book found test example:
@test public void testmovefile() throws exception { // create new file in inbox folder name hello.txt , containing hello world body template.sendbodyandheader("file://target/inbox", "hello world", exchange.file_name, "hello.txt"); // wait while let file moved thread.sleep(2000); // test file moved file target = new file("target/outbox/hello.txt"); asserttrue("file should have been moved", target.exists()); // test content correct string content = context.gettypeconverter().convertto(string.class, target); assertequals("hello world", content); }
obviously integration test - test more 1 unit, but:
- are tests (with thread.sleep) considered practice?
- can better, leaving integration test approach ?
well chicken , egg. in camel in action book, later introduce notifybuilder allows test without thread sleep. see chapter 6, section 6.4.2.
there details notifybuilder on camel web site http://camel.apache.org/notifybuilder.html
Comments
Post a Comment