Testing routes with fixed endpoints using AOP
When working with Camel you may at some point need to test a route that has endpoint URIs hardcoded into it. This tends to be more typical when testing Spring or Blueprint routes.
Consider the following route defined in /META-INF/spring/fixedEndpoints-context.xml
:
<route id="modifyPayloadBetweenQueues"> <from uri="activemq:in"/> <transform> <simple>Modified: ${body}</simple> </transform> <to uri="activemq:out"/> </route>
The route endpoints here make use of the ActiveMQ Component to consume from one queue and publish to another. We would like to test this logic as described in the Testing routes defined in Spring recipe, in a pure unit test without making any changes to the route.
Camel provides you with a built-in form of Aspect-Oriented Programming (AOP) in the form of the adviceWith(..)
Java DSL. This feature allows you to modify routing logic, once it has been loaded into the Camel context...