[HEADS-UP] - ContextTestSupport and isUseRouteBuilder()

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[HEADS-UP] - ContextTestSupport and isUseRouteBuilder()

Claus Ibsen
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