You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Scott Cranton <sc...@cranton.com> on 2013/01/31 12:32:47 UTC

Camel Unit Test EndpointInject versus getMockEndpoint

In creating unit tests for my Camel routes, I've tried to be
consistent with the Camel project's conventions figuring those are the
best practices, or at least the most tested path. I've noticed that
the vast majority of Camel unit tests use the
CamelTestSupport.getMockEndpoint(...) convenience method versus using
@EndpointInject(uri="mock:myMock").

Is this purely personal style or are there some subtle scenarios where
@EndpointInject endpoints within Unit Tests don't work as expected?

I ask to help me write better unit tests, and not start a bracing
style flame war thread... :-)

Thanks,
Scott

Re: Camel Unit Test EndpointInject versus getMockEndpoint

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Jan 31, 2013 at 12:32 PM, Scott Cranton <sc...@cranton.com> wrote:
> In creating unit tests for my Camel routes, I've tried to be
> consistent with the Camel project's conventions figuring those are the
> best practices, or at least the most tested path. I've noticed that
> the vast majority of Camel unit tests use the
> CamelTestSupport.getMockEndpoint(...) convenience method versus using
> @EndpointInject(uri="mock:myMock").
>
> Is this purely personal style or are there some subtle scenarios where
> @EndpointInject endpoints within Unit Tests don't work as expected?
>
> I ask to help me write better unit tests, and not start a bracing
> style flame war thread... :-)
>

It depends on your style.

The @ inject stuff is needed if you do not use CamelTestSupport, but for example
use spring testing.

Then you would usually need a way of get a reference to the mock
endpoint, so you can set its assertions.
And hence you can use those @ annotations for that.

When using CamelTestSupports its often faster and easier to just use
its API with methods like
getMockEndpoint("foo") etc.



> Thanks,
> Scott



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen