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: ...

Get Apache Camel Developer's Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.