Quantcast

Camel route testing

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Camel route testing

dhruv.sachdeva
This post was updated on .
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);
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Camel route from testting

Christian Mueller
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" <[hidden email]>:

> 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.
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Camel route from testting

Claus Ibsen-2
In reply to this post by dhruv.sachdeva
On Mon, Jan 7, 2013 at 6:48 AM, dhruv.sachdeva
<[hidden email]> 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: [hidden email]
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
Loading...