You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by developpef <sr...@orange.fr> on 2012/01/19 10:10:54 UTC

Testing headers in multiple messages

I recently saw the jira CAMEL-4159 but it is not what I expected : this issue
is intended to let a test expect for multiple headers in ONE message.
What I needed is the following : I know that a given endpoint will receive 3
messages in any order, and I need to test ONE header in each of these
messages.

I wrote :
getMockEndpoint("mock:zipSHP").expectedHeaderReceived("zippedFile",
"001.zip");
getMockEndpoint("mock:zipSHP").expectedHeaderReceived("zippedFile",
"002.zip");
getMockEndpoint("mock:zipSHP").expectedHeaderReceived("zippedFile",
"003.zip");

for the route :
for("file://filesToBeZipped/").to("bean:my.bean.ZipperBean").log("Zipped :
...");

The endpoint effectively received the three messages (the results of three
ZIP operations) but the test failed saying that the first message header was
"003.zip" and not the expected "001.zip".

Is there a way to test this kind of action?


--
View this message in context: http://camel.465427.n5.nabble.com/Testing-headers-in-multiple-messages-tp5157167p5157167.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Testing headers in multiple messages

Posted by developpef <sr...@orange.fr>.
FYI, I opened CAMEL-4919

-----
http://developpef.blogspot.com
--
View this message in context: http://camel.465427.n5.nabble.com/Testing-headers-in-multiple-messages-tp5157167p5157294.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Testing headers in multiple messages

Posted by developpef <sr...@orange.fr>.
Thank you for this hint. I will open a JIRA for this.

Yes I think that this point might be comparable to
expectedBodiesReceivedInAnyOrder.
I will try your solution, but I would prefer not to modify the "prodution
ready" route, even if it's not an important change.

-----
http://developpef.blogspot.com
--
View this message in context: http://camel.465427.n5.nabble.com/Testing-headers-in-multiple-messages-tp5157167p5157279.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Testing headers in multiple messages

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

btw you can always just check for the 3 headers manually afterwards.

You can get the receive exchanges from the mock endpoint. And then
loop that, and check that you got the 3 of them.


On Thu, Jan 19, 2012 at 11:05 AM, Claus Ibsen <cl...@gmail.com> wrote:
> Hi
>
> So you mock endpoint receives 3 messages in any order.
> And you just want to test that those 3 messages has all together those
> 3 different headers?
>
> We got that on the body, where you can say expectedBodiesReceivedInAnyOrder
>
> We may consider a similar for the headers.
>
>
> You can configure the file endpoint to sort the files before hand, so
> from("file://filesToBeZipped/?sortBy=file:name")...
>
> Then the headers should be in order.
>
> Fell free to create a JIRA ticket about the expectedHeadersReceivedInAnyOrder
> Link to JIRA from here
> http://camel.apache.org/support
>
>
> On Thu, Jan 19, 2012 at 10:10 AM, developpef <sr...@orange.fr> wrote:
>> I recently saw the jira CAMEL-4159 but it is not what I expected : this issue
>> is intended to let a test expect for multiple headers in ONE message.
>> What I needed is the following : I know that a given endpoint will receive 3
>> messages in any order, and I need to test ONE header in each of these
>> messages.
>>
>> I wrote :
>> getMockEndpoint("mock:zipSHP").expectedHeaderReceived("zippedFile",
>> "001.zip");
>> getMockEndpoint("mock:zipSHP").expectedHeaderReceived("zippedFile",
>> "002.zip");
>> getMockEndpoint("mock:zipSHP").expectedHeaderReceived("zippedFile",
>> "003.zip");
>>
>> for the route :
>> for("file://filesToBeZipped/").to("bean:my.bean.ZipperBean").log("Zipped :
>> ...");
>>
>> The endpoint effectively received the three messages (the results of three
>> ZIP operations) but the test failed saying that the first message header was
>> "003.zip" and not the expected "001.zip".
>>
>> Is there a way to test this kind of action?
>>
>>
>> --
>> View this message in context: http://camel.465427.n5.nabble.com/Testing-headers-in-multiple-messages-tp5157167p5157167.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>
>
> --
> Claus Ibsen
> -----------------
> FuseSource
> Email: cibsen@fusesource.com
> Web: http://fusesource.com
> Twitter: davsclaus, fusenews
> Blog: http://davsclaus.blogspot.com/
> Author of Camel in Action: http://www.manning.com/ibsen/



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

Re: Testing headers in multiple messages

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

So you mock endpoint receives 3 messages in any order.
And you just want to test that those 3 messages has all together those
3 different headers?

We got that on the body, where you can say expectedBodiesReceivedInAnyOrder

We may consider a similar for the headers.


You can configure the file endpoint to sort the files before hand, so
from("file://filesToBeZipped/?sortBy=file:name")...

Then the headers should be in order.

Fell free to create a JIRA ticket about the expectedHeadersReceivedInAnyOrder
Link to JIRA from here
http://camel.apache.org/support


On Thu, Jan 19, 2012 at 10:10 AM, developpef <sr...@orange.fr> wrote:
> I recently saw the jira CAMEL-4159 but it is not what I expected : this issue
> is intended to let a test expect for multiple headers in ONE message.
> What I needed is the following : I know that a given endpoint will receive 3
> messages in any order, and I need to test ONE header in each of these
> messages.
>
> I wrote :
> getMockEndpoint("mock:zipSHP").expectedHeaderReceived("zippedFile",
> "001.zip");
> getMockEndpoint("mock:zipSHP").expectedHeaderReceived("zippedFile",
> "002.zip");
> getMockEndpoint("mock:zipSHP").expectedHeaderReceived("zippedFile",
> "003.zip");
>
> for the route :
> for("file://filesToBeZipped/").to("bean:my.bean.ZipperBean").log("Zipped :
> ...");
>
> The endpoint effectively received the three messages (the results of three
> ZIP operations) but the test failed saying that the first message header was
> "003.zip" and not the expected "001.zip".
>
> Is there a way to test this kind of action?
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Testing-headers-in-multiple-messages-tp5157167p5157167.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



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