camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dennis Bohnstedt Hansen <>
Subject Re: CamelCdiRunner loads all routes in each test case (sometimes)
Date Fri, 14 Oct 2016 10:44:00 GMT

Thanks for you quick answer!

>> 3) If Weld and Camel versions are the same - where do i look for the
> Not sure I understand the question here :(

This refered to the fact, that i had two different behaviours in the two
projects - and i could'nt figure out which was the correct behaviour and
WHY they were different. You answer gave me a clue though. It turned out,
that one of my projects was a WAR project and the other was a JAR project,
and that beans.xml was not loaded on the WAR file (since it was located
/webapp/WEB-INF/beans.xml and therefor not picked up by the classloader).

This gave me a "solution" to my problem, even though it's not perfect.
Unfortunately you can't override src/main/resources/beans.xml with a
src/test/resources/beans.xml in Weld (, but i was able to exclude the
package containing my RouteBuildes by adding an exclution to my beans.xml,
and having a "marker class" ( in

<beans ...>
        <!-- Exclude routes from beans scan...! -->
        <weld:exclude name="my.routebuilder.package.**" >
            <weld:if-class-available name="ExcludeRouteBuildersFromTest"/>

> That being said, we may want to improve CamelCdiRunner to meet your need,
provided that it does not hinder the original intent, that is simplicity
and convention over configuration.

I think that would be a very good idea. The problem with the current
default, is that if all routes a loaded, you have to handle all endpoints
in every class. "Unfortunately" you are helped by the fact that the
folowing code, actually mocks and skips ALL endpoints in the CamelContext,
not just endpoints in the current route being adviced, but i'm thinkin that
thats a bug that will be fixed at some point:

context.getRouteDefinition("MyRouteId").adviceWith(context, new
AdviceWithRouteBuilder() {
    public void configure() throws Exception {

But you would also have to replace "from endpoints" of all routes in every
test, if they communicate with resources that are not available in you unit
tests - and you can't advice with the same replaceFromWith(...), in
different classes, since advices with @Observable conflict when all routes
are loaded.

... But thanks again!


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message