You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "dhruv.sachdeva" <dh...@jktech.com> on 2013/01/07 06:48:31 UTC

Camel route from testting

Hi 

I need to write unit test cases for some camel routes using (Version 1.6)

Can anyone please suggest if it is possible to mock components(processor and
idempotentConsumer) inside the route? If yes, please suggest the approach.


Below is the route snippet

        from("direct:someuri").process(someClassObject).
       
idempotentConsumer(header("someHeadername"),socratesMessageIdRepository(bean(JpaTemplate.class)))./*process(exceptionProcessor)*/
        to(someQueues);



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-route-from-testting-tp5725027.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel route from testting

Posted by Christian Müller <ch...@gmail.com>.
I don't think it's possible without touching your existing route or repeat
the route definition.
If you use Spring, you can switch the implementation for your tests by
providing a test application context. But you need some little changes in
you route (use a bean instance instead of a class instance, ...).

Do you really still use the 1.6 version? In newer versions you can use
adviceWith to intercept some processing steps.

Sent from a mobile device
Am 07.01.2013 08:05 schrieb "dhruv.sachdeva" <dh...@jktech.com>:

> Hi
>
> I need to write unit test cases for some camel routes using (Version 1.6)
>
> Can anyone please suggest if it is possible to mock components(processor
> and
> idempotentConsumer) inside the route? If yes, please suggest the approach.
>
>
> Below is the route snippet
>
>         from("direct:someuri").process(someClassObject).
>
>
> idempotentConsumer(header("someHeadername"),socratesMessageIdRepository(bean(JpaTemplate.class)))./*process(exceptionProcessor)*/
>         to(someQueues);
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Camel-route-from-testting-tp5725027.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: Camel route from testting

Posted by Claus Ibsen <cl...@gmail.com>.
On Mon, Jan 7, 2013 at 6:48 AM, dhruv.sachdeva
<dh...@jktech.com> wrote:
> Hi
>
> I need to write unit test cases for some camel routes using (Version 1.6)
>
> Can anyone please suggest if it is possible to mock components(processor and
> idempotentConsumer) inside the route? If yes, please suggest the approach.
>
>
> Below is the route snippet
>
>         from("direct:someuri").process(someClassObject).
>
> idempotentConsumer(header("someHeadername"),socratesMessageIdRepository(bean(JpaTemplate.class)))./*process(exceptionProcessor)*/
>         to(someQueues);
>

This is just java code, so you can extend the route builder, and
change the instances of
- someClassObject
- exceptionProcessor
- someQueues

To whatever you want, such as mock endpoints, and custom processors or whatever.
Or allow your existing route builder class, to have getter/setter's
etc so you can re-configure them before testing.

Replacing or changing the idempotentConsumer is not so easy.



>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-route-from-testting-tp5725027.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
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