Auto-mocking of endpoints
In the recipes that have involved mock testing so far, it has been necessary to provide a mock:
endpoint URI directly into a route, either explicitly or through dependency injection. Camel's test support classes provide a mechanism for automatically mocking endpoints that allow you to more easily test routes with embedded URIs. This recipe will show you how to exercise this functionality.
Getting ready
The Java code for this recipe is located in the org.camelcookbook.examples.testing.automocking
package. The Spring route used here is located under src/main/resources/META-INF/spring/fixedEndpoints-context.xml
.
How to do it...
Consider the following route, with fixed endpoints:
<from uri="activemq:in"/> <transform> <simple>Modified: ${body}</simple> </transform> <log message="Set message to ${body}"/> <to uri="activemq:out"/>
In order to set up a mock endpoint on the to(..)
node without changing the route, perform the following...