Testing headers in multiple messages

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Testing headers in multiple messages

developpef
This post was updated on .
Hello everyone,

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?
Reply | Threaded
Open this post in threaded view
|

Re: Testing headers in multiple messages

Claus Ibsen-2
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 <[hidden email]> 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: [hidden email]
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/
Reply | Threaded
Open this post in threaded view
|

Re: Testing headers in multiple messages

developpef
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.
Reply | Threaded
Open this post in threaded view
|

Re: Testing headers in multiple messages

developpef
FYI, I opened CAMEL-4919
Reply | Threaded
Open this post in threaded view
|

Re: Testing headers in multiple messages

Claus Ibsen-2
In reply to this post by Claus Ibsen-2
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 <[hidden email]> 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 <[hidden email]> 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: [hidden email]
> 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: [hidden email]
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/