Doesn't this code look suspicious (look at actual bodies):

public void expectedBodiesReceived(final List<?> bodies) {
        expectedMessageCount(bodies.size());
        this.expectedBodyValues = bodies;
        this.actualBodyValues = new ArrayList<Object>();

        expects(new Runnable() {
            public void run() {
                for (int i = 0; i < expectedBodyValues.size(); i++) {
                    Exchange exchange = getReceivedExchange(i);
                    assertTrue("No exchange received for counter: " +
i, exchange != null);

                    Object expectedBody = expectedBodyValues.get(i);
                    Object actualBody = null;
                    if (i < actualBodyValues.size()) {
                        actualBody = actualBodyValues.get(i);
                    }
                    actualBody = extractActualValue(exchange,
actualBody, expectedBody);

                    assertEquals("Body of message: " + i,
expectedBody, actualBody);
                }
            }
        });
    }

2012/11/5 David Karlsen <[email protected]>:
> Same:
>
> Body of message: 0. Expected: <<?xml version="1.0...
>
> If I had the order like before (defining the asserts after the test)
> it read body of message: null
>
> 2012/11/5 Raul Kripalani <[email protected]>:
>> 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&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
>>>
>
>
>
> --
> --
> David J. M. Karlsen - http://www.linkedin.com/in/davidkarlsen



-- 
--
David J. M. Karlsen - http://www.linkedin.com/in/davidkarlsen

Reply via email to