camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <>
Subject Re: Camel Unit Test EndpointInject versus getMockEndpoint
Date Thu, 31 Jan 2013 12:39:48 GMT
On Thu, Jan 31, 2013 at 12:32 PM, Scott Cranton <> 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
Twitter: davsclaus
Author of Camel in Action:

View raw message