You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by cgveld <j....@avisi.nl> on 2009/09/03 08:58:04 UTC
expectedHeaderReceived gives OK, but header is not present
Dear reader,
I created a custom processor that puts a property map on the header.
To check if everything works as planned I created a JUnit test.
In this JUnit test I check all the expected headers.
Also I check if the previous headers still exist.
This seemed to work out fine, until I noticed I didn't put the previous
headers there.
Therefor expectedHeaderReceived gives me an okay, while actually the header
is not there.
I also noticed it does give an error if I move the two headers that are not
there to the end.
In conclusion:
expectedHeaderReceived gives me an okay if there are more
expectedHeaderReceived calls that succeed after the ones that fail.
According to the API expectedHeaderReceived "Adds an expectation that the
given header name & value are received by this endpoint", but it seems only
the last one is really checked.
http://www.nabble.com/file/p25270770/LoadPropertiesRouteTest.java
LoadPropertiesRouteTest.java
http://www.nabble.com/file/p25270770/properties.xml properties.xml
--
View this message in context: http://www.nabble.com/expectedHeaderReceived-gives-OK%2C-but-header-is-not-present-tp25270770p25270770.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: expectedHeaderReceived gives OK, but header is not present
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
Well spotted. I have fixed the javadoc of the mock endpoint as it does
NOT add but set an expectation.
On Thu, Sep 3, 2009 at 6:32 PM, Claus Ibsen<cl...@gmail.com> wrote:
> Hi
>
> Try this one
>
> public void testHeaders() throws Exception {
> MockEndpoint resultEndpoint = getMockEndpoint("mock:result");
> resultEndpoint.message(0).header("header1").isEqualTo("value1");
> resultEndpoint.message(0).header("header2").isEqualTo("value2");
>
> template.sendBody("direct:test", null);
>
> resultEndpoint.assertIsNotSatisfied();
> }
>
>
> On Thu, Sep 3, 2009 at 5:13 PM, cgveld<j....@avisi.nl> wrote:
>>
>> Hello Claus,
>>
>> I'm sorry for the difficult example.
>> At first I thought the problem was in this process, but I was able to drill
>> it down to the next example.
>>
>> http://www.nabble.com/file/p25278205/HeadersRouteTest.java
>> HeadersRouteTest.java
>>
>> I would assume the method expectedHeaderReceived would test all headers.
>> But it seems it only tests the last one.
>>
>> With kind regards,
>>
>> Jeroen
>> --
>> View this message in context: http://www.nabble.com/expectedHeaderReceived-gives-OK%2C-but-header-is-not-present-tp25270770p25278205.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
>
--
Claus Ibsen
Apache Camel Committer
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Re: expectedHeaderReceived gives OK, but header is not present
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
Try this one
public void testHeaders() throws Exception {
MockEndpoint resultEndpoint = getMockEndpoint("mock:result");
resultEndpoint.message(0).header("header1").isEqualTo("value1");
resultEndpoint.message(0).header("header2").isEqualTo("value2");
template.sendBody("direct:test", null);
resultEndpoint.assertIsNotSatisfied();
}
On Thu, Sep 3, 2009 at 5:13 PM, cgveld<j....@avisi.nl> wrote:
>
> Hello Claus,
>
> I'm sorry for the difficult example.
> At first I thought the problem was in this process, but I was able to drill
> it down to the next example.
>
> http://www.nabble.com/file/p25278205/HeadersRouteTest.java
> HeadersRouteTest.java
>
> I would assume the method expectedHeaderReceived would test all headers.
> But it seems it only tests the last one.
>
> With kind regards,
>
> Jeroen
> --
> View this message in context: http://www.nabble.com/expectedHeaderReceived-gives-OK%2C-but-header-is-not-present-tp25270770p25278205.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>
--
Claus Ibsen
Apache Camel Committer
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Re: expectedHeaderReceived gives OK, but header is not present
Posted by cgveld <j....@avisi.nl>.
Hello Claus,
I'm sorry for the difficult example.
At first I thought the problem was in this process, but I was able to drill
it down to the next example.
http://www.nabble.com/file/p25278205/HeadersRouteTest.java
HeadersRouteTest.java
I would assume the method expectedHeaderReceived would test all headers.
But it seems it only tests the last one.
With kind regards,
Jeroen
--
View this message in context: http://www.nabble.com/expectedHeaderReceived-gives-OK%2C-but-header-is-not-present-tp25270770p25278205.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: expectedHeaderReceived gives OK, but header is not present
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
Try with a simpler example if you want to make it more clear what your
problem is.
In your own code with the XML stuff you *replace* all headers by
calling exchange.getIn().setHeaders.
If you want to *add* instead then use
exchange.getIn().getHeaders().putAll(otherMap);
On Thu, Sep 3, 2009 at 8:58 AM, cgveld<j....@avisi.nl> wrote:
>
> Dear reader,
>
> I created a custom processor that puts a property map on the header.
> To check if everything works as planned I created a JUnit test.
>
> In this JUnit test I check all the expected headers.
> Also I check if the previous headers still exist.
>
> This seemed to work out fine, until I noticed I didn't put the previous
> headers there.
> Therefor expectedHeaderReceived gives me an okay, while actually the header
> is not there.
>
> I also noticed it does give an error if I move the two headers that are not
> there to the end.
>
> In conclusion:
> expectedHeaderReceived gives me an okay if there are more
> expectedHeaderReceived calls that succeed after the ones that fail.
> According to the API expectedHeaderReceived "Adds an expectation that the
> given header name & value are received by this endpoint", but it seems only
> the last one is really checked.
>
> http://www.nabble.com/file/p25270770/LoadPropertiesRouteTest.java
> LoadPropertiesRouteTest.java
> http://www.nabble.com/file/p25270770/properties.xml properties.xml
> --
> View this message in context: http://www.nabble.com/expectedHeaderReceived-gives-OK%2C-but-header-is-not-present-tp25270770p25270770.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>
--
Claus Ibsen
Apache Camel Committer
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus