camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Tombs <>
Subject NotifyBuilder and MockEndpoint message count
Date Fri, 21 Jan 2011 14:59:10 GMT
Hello all,

While using the great testing utilities that camel provides, I have
noticed that NotifyBuilder and MockEndpoint provide options for a
minimum message received count (expectedMinimumMessageCount) and an
exact message received count (expectedMessageCount). However, as far
as I can tell from experience and glancing at the source code, the
exact versions are not reliable because the object will only delay
until the expected count is reached, then immedaitely return.

For example, consider the following sequence:
1) [test-thread] mock.expectedMessageCount(1)
2) [test-thread] mock.assertIsSatisfied()
3) [msg-thread] message 1 comes in
4) [test-thread] mock.assertIsSatisfied() wakes up an returns
5) [msg-thread] message 2 comes in

Of course, (4) and (5) can be in either order, so it's a race
condition: assertIsSatisfied() can return true or false.

Am I right about this? If so, is there any way to avoid the race condition?

Thanks in advance,

Wise men _still_ seek Him.

View raw message