You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Andreas Feldmann <an...@gmail.com> on 2012/01/19 11:38:00 UTC

Testing: MockEndpoint has sometimes a Message and sometimes not

Hallo everbody,

currently I am using JUnit-tests for testing purposes.

In my project I have a route with a software-proxy (Jetty) and then some
webservices. That part is working very well. The software-proxy/webservices
respond with the according messages, when I use SOAP-UI.

Now I tried to construct a test-route in a JUnit-test.

It looks like that:

from(SEDA_TEST).
setHeader("CamelHttpMethod", constant("POST")).
to("https4://localhost:8090/services/MYSERVICE?q=ssl").
to("seda:mock");
				
from("seda:mock").
streamCaching().
convertBodyTo(String.class, "UTF-8").
to(MOCK_ENDPOINT);

I have constructed several tests where I send a message with:

template.sendBody(SEDA_TEST, testFileAsString);

And then I check the MOCK_ENDPOINT via "expectedMessagesMatches", if my
expected response is available.

This works fine with some tests. But some tests fail very often, because the
response is empty. The problem confuses me even more, because the
"production-route" logs every time a message with the correct response as a
file.

So why do I get a empty message back from
"to("https4://localhost:8090/services/MYSERVICE?q=ssl")."?

I also have to mention, that sometimes there is message and sometimes the
message is empty.

What do you think?

Thanks for any suggestions!

Best regards,

Andreas Feldmann



--
View this message in context: http://camel.465427.n5.nabble.com/Testing-MockEndpoint-has-sometimes-a-Message-and-sometimes-not-tp5157327p5157327.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Testing: MockEndpoint has sometimes a Message and sometimes not

Posted by Claus Ibsen <cl...@gmail.com>.
I suggest to convert the result of http4 to a String before sending to
the seda queue.

For example if processing the messages happens much later, and the
http connection has been closed, and the input stream is closed and
returns no data.


On Thu, Jan 19, 2012 at 11:38 AM, Andreas Feldmann
<an...@gmail.com> wrote:
> Hallo everbody,
>
> currently I am using JUnit-tests for testing purposes.
>
> In my project I have a route with a software-proxy (Jetty) and then some
> webservices. That part is working very well. The software-proxy/webservices
> respond with the according messages, when I use SOAP-UI.
>
> Now I tried to construct a test-route in a JUnit-test.
>
> It looks like that:
>
> from(SEDA_TEST).
> setHeader("CamelHttpMethod", constant("POST")).
> to("https4://localhost:8090/services/MYSERVICE?q=ssl").
> to("seda:mock");
>
> from("seda:mock").
> streamCaching().
> convertBodyTo(String.class, "UTF-8").
> to(MOCK_ENDPOINT);
>
> I have constructed several tests where I send a message with:
>
> template.sendBody(SEDA_TEST, testFileAsString);
>
> And then I check the MOCK_ENDPOINT via "expectedMessagesMatches", if my
> expected response is available.
>
> This works fine with some tests. But some tests fail very often, because the
> response is empty. The problem confuses me even more, because the
> "production-route" logs every time a message with the correct response as a
> file.
>
> So why do I get a empty message back from
> "to("https4://localhost:8090/services/MYSERVICE?q=ssl")."?
>
> I also have to mention, that sometimes there is message and sometimes the
> message is empty.
>
> What do you think?
>
> Thanks for any suggestions!
>
> Best regards,
>
> Andreas Feldmann
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Testing-MockEndpoint-has-sometimes-a-Message-and-sometimes-not-tp5157327p5157327.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/