Just realized that the behavior you see is consistent with the documentation
[1] which clearly states that the onCompletion logic runs *concurrently* and
*not* in the main thread (I did not know that).

While you run your test method shouldCopyFromSourceToDestination() it runs
inside the JVM *main* thread so that while you do:

verify(main).stop(); 

inside the *main* thread the onCompletion block should have been *already*
run concurrently to make Mockito happy. You make this happen in that you do
sleep a bit inside the *main* thread. If you don't sleep long enough then
the chance is given that by one run your test passes and by another run it
doesn't pass anymore, so that sleeping *long enough* to catch the worst
Thread-Scheduling order & duration of JVM would be a good idea.

[1] http://camel.apache.org/oncompletion.html

Babak

--
View this message in context: 
http://camel.465427.n5.nabble.com/File-consumer-waiting-for-it-to-start-tp5455062p5456788.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to