You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by Claus Ibsen <ci...@silverbullet.dk> on 2008/10/06 09:45:38 UTC

[HEADS-UP] - ContextTestSupport and isUseRouteBuilder()

Hi

It has bugged me for a while that ContextTestSupport didn't easily support having multiple route builders in a single unit test class.

So I tended to create new unit test classes having only 1 route builder.
However sometimes you would like it to be in the same class but using a slightly different route per test method.

And I would like to setup the route in the test method directly.

So I have changed setup() in ContextTestSupport to support this.

If you overwrite this method in your unit test class:
   public boolean isUseRouteBuilder() {
        return false;
    }

Then you can add your routes in your test method:
public void testAggregateOutBatchSize() throws Exception {
        context.addRoutes(new RouteBuilder() {
        });
// and you must start camel context afterwards
     startCamelContext();

// and do you usually testing here

The change in ContextTestSupport is that it will not startCamelContest if isUseRouteBuilder() returns false.




Med venlig hilsen

Claus Ibsen
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk