Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-15402

Spring components extending RouteBuilder not added to CamelContext during tests

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Won't Fix
    • 3.4.2
    • None
    • None
    • Spring Boot 2.3.2, JUnit5 that comes with the former, Java 11, Maven 3.6

      First time I spotted the issue was Dec 2017 in Camel 2.20 so it's not in some freshly changed part of the project. 

    • Unknown

    Description

      Having written a couple of tests for pieces of routes within a Camel application, I have noticed that testing routes defined by components annotated with @Consume("direct:xyz") work quite well, but components that extend the class org.apache.camel.builder.RouteBuilder suffer from the following issue.

      The component scanning by Spring encounters these components fine. If they are autowired in the test, then those fields have a value as expected. But when the test route has to invoke it, then delivery fails throwing a DirectConsumerNotAvailableException.

      The work-around is to invoke camelContext.addRoutes(autowiredInstance) in the test, which should not be necessary and clutters up the test code.

      Demonstration of the issue:
      https://github.com/BertKoor/camelCase/blob/master/src/test/java/nl/ordina/bertkoor/camelcase/service/CamelHealthServiceClientTest.java 

      Attachments

        Activity

          People

            Unassigned Unassigned
            bertkoor Bert Koorengevel
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: