Try setting the expectation before you actually hit the endpoint with any messages. Hit the endpoint with your test logic. Then assert.
Does it work then? Regards. Sent from a mobile device On 5 Nov 2012 20:27, "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&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 >
