2 Replies Latest reply on Feb 24, 2009 1:35 PM by Milton Becker Junior

    How to load several routes in different classes in unit tests?

    Milton Becker Junior Newbie

      Hi there,


      Is it possible to load several camel routes in unit tests?


      For example, I have the following route:


      public class CompleteRoute extends RouteBuilder {


          public static final String jettyURL = "";


          public void configure() throws Exception {

               from("jetty:" + jettyURL)






      This route, as you can see, calls an endpoint of another route, the TransformRoute:


      public class TransformRoute extends RouteBuilder {


           public static final String DIRECT_TRANSFORM = "direct:transform";


           public void configure() throws Exception {






      Then i did an unit test for CompleteRoute:


      public class CompleteRouteTest extends ContextTestSupport {


           private static final String MOCK_RESULT = "mock:result";

           MockEndpoint resultEndPoint;



           protected void setUp() throws Exception {


                resultEndPoint = resolveMandatoryEndpoint(MOCK_RESULT, MockEndpoint.class);




           protected RouteBuilder createRouteBuilder() throws Exception {

                return new CompleteRoute() {


                     public void configure() throws Exception {






           public void testCompleteRouteOK() throws Exception {

                String expectedBody = ReadFile.getFileContents("src/main/resources/msg_ok.xml");

                String sentBody = ReadFile.getFileContents("src/test/resources/xml_test.xml");





                Object request = template.requestBody(CompleteRoute.jettyURL, sentBody);

                template.sendBody(MOCK_RESULT, request);






      When I run it, it loads the Jetty component just fine, but it won't load the TranformRoute, so I get the following error:


      "DirectProducer WARN  No getConsumers() available on Producer[direct:transform] for Exchange[]"


      Any clues? Any help would be much appreciated


      PS: if I run it with mvn camel:run it works just fine


      Edited by: milton on Feb 24, 2009 3:03 PM