[
https://issues.apache.org/jira/browse/CAMEL-15402?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Bert Koorengevel updated CAMEL-15402:
-------------------------------------
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]
was:
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 feels unnescessary 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]
> Spring components extending RouteBuilder not added to CamelContext during
> tests
> -------------------------------------------------------------------------------
>
> Key: CAMEL-15402
> URL: https://issues.apache.org/jira/browse/CAMEL-15402
> Project: Camel
> Issue Type: Bug
> Components: camel-spring-boot, camel-test
> Affects Versions: 3.4.2
> Environment: 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.
> Reporter: Bert Koorengevel
> Priority: Minor
>
> 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]
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)