Hi Babak,

Thanks a lot for your reply, it confirms what I suspected from looking
through the source. I can see that when you setExpectedMessageCount(0),
there is no countdown latch, resulting in the mock being asserted on pretty
much straight away.

I don't really like the MockEndpoint.setSleepForEmptyTest() idea as it's
pretty much analogous to sticking an arbitrary Thread.sleep() into the code.

The NotifyBuilder example seems to work a lot nicer however, thanks a lot
for your suggestion. I now have:

       // wait for the message to pass through the route before running the
assertions.
        // JMS msgs are processed asynchronously creating a race condition
for the test.
        NotifyBuilder notify = new
NotifyBuilder(context).whenDone(1).create();
        notify.matches(500, TimeUnit.MILLISECONDS);

        sftpMockEndpoint.assertIsSatisfied();

And this is working as expected.

I'm a little surprised that there is not much mention of this potential race
condition when using the Camel testing framework - neither within the online
documentation nor within the Camel in Action book. It seems to be a pretty
big omission within what is otherwise an excellent and well documented
framework.

Thanks for your help.
John



--
View this message in context: 
http://camel.465427.n5.nabble.com/mock-expectedMessageCount-0-resulting-in-a-false-positive-tp5723952p5724031.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to