camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Willem Jiang <willem.ji...@gmail.com>
Subject Re: Unit testing each route in a large camel context
Date Fri, 04 Apr 2014 02:48:37 GMT
You can take a look at the camel-example-cafe in the camel examples directory, there are some
trick to inject the mock endpoint.
At the mean time, you can leverage camel properties component to replace the direct endpoint
with the mock endpoint.

--  
Willem Jiang

Red Hat, Inc.
Web: http://www.redhat.com
Blog: http://willemjiang.blogspot.com (English)
http://jnn.iteye.com (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem



On April 4, 2014 at 10:25:51 AM, Gnanaguru S (gnanagurus@gmail.com) wrote:
> Riders,
>  
> I have a came context like the below one. I am going to do unit testing for
> each and every route. I am still wondering why no body has asked this
> question early. ( May be I didnt find it )
> How can I do unit testing for each and every route ?
>  
> Camel context:
>  
>  
>  
>  
>  
>  
>  
>  
>  
>  
>  
>  
>  
>  
>  
>  
>  
>  
>  
>  
>  
>  
>  
>  
>  
> My current test strategy:
>  
> 1. I have four different camelcontext xml's under my test resources
> 2. I have created four different test classes using JUnit ( Supported by
> camel)
> 3. If I take one route, I will mock the direct:B to mock:direct:B.
> 4. Apply assertions to the mock endpoints.
>  
> Alternative test strategy:
>  
> 1. Instead of creating four different XML's, I can just keep one camel
> context xml and add property placeholders.
> 2. By changing the endpoints in the property placeholers, so that I can
> logically disable the remaining routes. Because direct endpoints cannot have
> more than one consumer and mock endpoint cannot have consumer at all.
>  
> But of all this, Is there any other simplied way to do the testing ? For
> large projects having large number of routes, Is there a way I can test
> individual routes from the same camelcontext files ? Instead of having
> multiple xml's.
>  
> I will great appreciate your help. Also I am planning to develop an article
> based on this conversation. Please drop in your ideas and comments.
>  
> Camel is a wonderful framework with wonderful test endpoint like Mock. Mock
> is very powerful in terms of asssertions, but wondering what are the other
> ways to utilize it well in large camel context.
>  
> Cheers,
> Guru
> gnanaguru.com
>  
>  
>  
> --
> View this message in context: http://camel.465427.n5.nabble.com/Unit-testing-each-route-in-a-large-camel-context-tp5749750.html
 
> Sent from the Camel - Users mailing list archive at Nabble.com.
>  


Mime
View raw message