Make sure you set you expectations on the mocks first in your unit
test. Before any messages gets routed etc.


On Mon, Nov 5, 2012 at 9:27 PM, David Karlsen <[email protected]> wrote:
> I'm confused about how expectedBodiesReceived behaves.
>
> I have a route where I mock a jms endpoint (the endpoint is sent to in
> an onException route as follows:
>
>  <camel:onException>
>
> <camel:exception>java.lang.Exception</camel:exception>
>                                 <camel:handled>
>                                         <camel:constant>true</camel:constant>
>                                 </camel:handled>
>                                 <camel:to
> id="inboundFromRtsErrorQueue"
> uri="jms:queue:{{rts.online.mq.reservationsReceiveErrorQueue}}?connectionFactory=#rtsConnectionFactory&amp;destinationResolver=#rtsDestinationResolver"
> />
>
>
> I then override the sending to inboundFromRtsErrorQueue by id in the
> setup of my testclass.
>
> Everything works ok:
>
>
>         mockInboundFromRtsErrorQueue.setExpectedMessageCount( 1 );
>         Exchange failedExchange =
> mockInboundFromRtsErrorQueue.getExchanges().get( 0 );
>         Assert.assertEquals( payload, failedExchange.getIn().getBody() );
>         //mockInboundFromRtsErrorQueue.expectedBodiesReceived( payload
> ); //strangely this does not pass - but the above does
>         mockInboundFromRtsErrorQueue.assertIsSatisfied();
>
>
> but I'm surprised that if I comment in the second-last line it will
> fail. Why? As line no 2&3 does exactly the same??
>
> --
> --
> David J. M. Karlsen - http://www.linkedin.com/in/davidkarlsen



-- 
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