Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Say RouteC is not applicable to our test scenario and generates a lot of noise during test. It would be nice to be able to exclude this route from this specific test. The SpringTestSupport class has been modified to allow this. It provides two methods (excludedRoute and excludedRoutes) that may be overridden to exclude a single class or an array of classes.

Code Block
languagejava
@Component 
public class MyRouteRouteAandRouteBOnlyTest extends SpringRouteBuilderSpringTestSupport {
  @Override 
  publicprotected voidClass configureexcludeRoute() throws Exception {
    from("direct:start") .to("mock:result");
return RouteC.class; 
  }
}

javapublic class RouteAandRouteBOnlyTest extends SpringTestSupport { @Override protected Class excludeRoute() { return RouteC.class; } }java

In order to hook into the camelContext initialization by spring to exclude the MyExcludedRouteBuilder.class we need to intercept the spring context creation. When overriding createApplicationContext to create the spring context, we call the getRouteExcludingApplicationContext() method to provide a special parent spring context that takes care of the exclusion.

...