On Sun, Nov 4, 2012 at 10:09 AM, Henri Tremblay
<[email protected]> wrote:
> Hi,
>
> I've started to play with Camel and loving it. However, I'm still having
> problems with the testing.
>
> I want to do an integration test of a complete message processing. Here's
> the flow, please focus on the solution, not on the fact that the
> architecture is a nonsense, that part isn't really my fault (but I can use
> any useful ideas)
>
> Here it goes:
>
>    1. Message received from JMS
>    2. Stored in DB
>    3. Read from DB with a consumer
>    4. Sent to a direct route
>    5. Status changed
>    6. Sent to another system in REST
>    7. The other system will change the status in DB and create new DB
>    entries
>    8. Read from DB with another consumer the new DB entries
>    9. Sent to the same direct route
>    10. Sent them to the same system in REST
>
> My questions are
>
>    - I want to check the message when entering in both direct route. How
>    calls like expectedMessageCount are working? Is it ordered? So I should put
>    an expectedMessageCount(1) for the first call and another for the second a
>    bit below in my test

expected message count just checks that X number of messages was
received on the mock.
You can read the javadoc of the methods to learn more about them.

If you use the same mock in both routes, then you can set expectation
that a message with content A is received
before message with content B etc.

I suggest to dig in the links from Christian and if you got the time
then David V. did a webinar recently about unit testing with Camel.
Its called "Are you Camel routes ready for production".
http://fusesource.com/resources/video-archived-webinars/



>    - I want to be able to check the status changed at point 5 before it is
>    changed again at step 7. How can I do that?
>    - What's the ordering of things like
>    expectedMessageCount, expectedBodyReceived? When they are specified in a
>    row, they always apply to the same message? Is message(0) working the same
>    way?
>

Check the javaddoc, for example expectedBodyReceived expects X
messages received in the order,
having the body value you specify, eg

expectedBodyReceived("foo", "bar");

would expect 2 messages, and the 1st has "foo" in message body, the
2nd has "bar" in message body etc.


> If it can help understanding the questions, I'm an EasyMock dude. So I'm
> trying to map the Camel expectation to their equivalent EasyMock behavior.
>
> Any help?
>
> Thanks,
> Henri



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: [email protected]
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Reply via email to