This recipe expands on the core testing capabilities described so far by detailing the steps needed to test Camel routes defined using the XML DSL in a Spring application. You will learn how to assemble a test harness that replaces parts of the application in order to test your routes outside a deployment environment, including the substitution of Spring ${..}
placeholders with test values.
The Java code for this recipe is located in the org.camelcookbook.examples.testing.spring
package. The Spring XML files are located under src/main/resources/META-INF/spring
.
To use Camel's Spring test support, you need to add a dependency for the camel-test-spring
library that provides the support classes for JUnit testing of Spring as well as a transitive dependency on JUnit itself.
Add the following to the dependencies
section of your Maven POM:
<dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-test-spring</artifactId...