You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by jpalmer1026 <pa...@gmail.com> on 2011/04/05 17:52:54 UTC

assertMockEndpointsSatisfied Question

Hi,

I'm trying to use the assertMockEndpointsSatisfied() method to assert that
all the expectations of the Mock endpoints are valid. In my test, I'm
passing in 2 messages to a topic and calling mock.expectedMessageCount(3)
and the test is passing (I can actually pass in any arbitrary number to
expectedMessageCount() method and the test will still pass). My code is as
follows:

@Test
    public void testQuote() throws Exception {
        MockEndpoint mock = getMockEndpoint("mock:quote");
        mock.expectedMessageCount(3);
        mock.expectedBodiesReceivedInAnyOrder("test 1", "test 2");

        template.sendBody("jms:topic:quote", "test 1");
        template.sendBody("jms:topic:quote", "test 2");

        assertMockEndpointsSatisfied();
    }

Does anyone have any ideas what might be causing this to fail?

--
View this message in context: http://camel.465427.n5.nabble.com/assertMockEndpointsSatisfied-Question-tp4284338p4284338.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: assertMockEndpointsSatisfied Question

Posted by jpalmer1026 <pa...@gmail.com>.
Thanks Claus. Much appreciated!

--
View this message in context: http://camel.465427.n5.nabble.com/assertMockEndpointsSatisfied-Question-tp4284338p4284597.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: assertMockEndpointsSatisfied Question

Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Apr 5, 2011 at 5:52 PM, jpalmer1026 <pa...@gmail.com> wrote:
> Hi,
>
> I'm trying to use the assertMockEndpointsSatisfied() method to assert that
> all the expectations of the Mock endpoints are valid. In my test, I'm
> passing in 2 messages to a topic and calling mock.expectedMessageCount(3)
> and the test is passing (I can actually pass in any arbitrary number to
> expectedMessageCount() method and the test will still pass). My code is as
> follows:
>
> @Test
>    public void testQuote() throws Exception {
>        MockEndpoint mock = getMockEndpoint("mock:quote");
>        mock.expectedMessageCount(3);
>        mock.expectedBodiesReceivedInAnyOrder("test 1", "test 2");
>

You use both message count, and expected bodies. So what happens is
the latter overrides the first.
So the mock expects 2 messages having bodies as either "test 1" or "test 2".

So use only either one, eg remove message count 3


>        template.sendBody("jms:topic:quote", "test 1");
>        template.sendBody("jms:topic:quote", "test 2");
>
>        assertMockEndpointsSatisfied();
>    }
>
> Does anyone have any ideas what might be causing this to fail?
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/assertMockEndpointsSatisfied-Question-tp4284338p4284338.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
CamelOne 2011: http://fusesource.com/camelone2011/
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/