camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: Unit Testing Route
Date Mon, 29 Nov 2010 21:03:07 GMT
On Mon, Nov 29, 2010 at 7:01 PM, Claus Straube <claus.straube@catify.com> wrote:
>
> Hi,
>
> you can do this by intercepting your routes.
>
> public void testFoo() throws Exception {
>  RouteDefinition route = context.getRouteDefinitions().get("routeId");
> route.adviceWith(context, new RouteBuilder() {
>   public void configure() throws Exception {
>      interceptSendToEndpoint("seda:in")
>      .skipSendToOriginalEndpoint()
>      .to("mock:m1");
> }
> });
>
> Best regrads - Claus
>

Yeah I have been meant to added some more nicer syntax sugar for the
approach above with the adviceWith and intercept in the Camel Test
Kit.
We should have something so you can easily instruct Camel to not send
to X but send to mock:X instead (or what you want).
Also to more easily replace parts of routes, and whatnot.

So any ideas you may have in this area is welcome.


>
> Am Montag, den 29.11.2010, 09:39 +0100 schrieb "Olivier.Roger"
> <olivier.roger@bsb.com>:
>>
>> Hello Camel,
>>
>> I am using Camel for some time now and I was wondering how I could perform
>> unit test using the same camel context used in production but still being
>> able to test intermediate messages of the routes.
>>
>> For instance, with the simple routes A --> B and B --> C.
>> At the moment I use 4 properties A,B,B' and C. In prod, B == B' and in
>> test
>> A and C are direct: endpoint and B' and D are mock endpoint.
>>
>> This allows to sent easily message using the template object and validate
>> the result by making mock assertions.
>>
>> I wanted to know if there was a better solution than duplicating the
>> endpoint URI (B and B' here) for intermediate endpoints.
>>
>> Thanks in advance for your input!
>
>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Mime
View raw message