camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tarjei Huse <tar...@scanmine.com>
Subject Re: camel test kit
Date Fri, 27 Jan 2012 08:42:22 GMT
On 01/27/2012 09:25 AM, Claus Ibsen wrote:
> Hi
>
> Can you be more specific how this is related to C
> This is not really Camel specific, but about timing issues from unit
> tests running on CI servers.
>
>
> On Fri, Jan 27, 2012 at 9:03 AM, Filippo Balicchia <fbalicchia@gmail.com> wrote:
>> Hi,
>>
>> When use camelTestSuport is possible to avoid the use of Thread.sleep
>> for gives Camel to React and and route ?
>> Suppose that  test is running on CI where cpu  it is particularly
>> busy, with thread.sleep
>> there is a risk that the test should not fail even if

This is what you use the MockEndpoint.assertSatisfied() methods for. You
await a reaction at the end of the route. If it is not possible to await
the end of the route because it ends in a dead end (f.x. a db value is
updated) then inject an extra listener that you can wait for.

Tip if you got multiple tests running in the same jvm then it is often a
good idea to call
MockEndpoint.resetMocks(this.context());

As spring has a tendency to reuse too much of the context.

A bit sample code to get you started:

RouteDefinition rdef = context().getRouteDefinition(routeName);
rdef.adviceWith(context(), new AdviceWithRouteBuilder() {
            @Override
            public void configure() throws Exception {
                weaveByType(RecipientListDefinition.class)
                //weaveByToString(".*RecipientList.*")
                .before().log(("[MOCK] message for ${header.dest}
sending to mock")).to("mock:myMock");
            }
        });

T
>>
>>
>> Cheers
>>
>> --Filippo
>
>


-- 
Regards / Med vennlig hilsen
Tarjei Huse
Mobil: 920 63 413


Mime
View raw message