The point of this wiki is to show you how to execute integration tests using Apache Camel.
More precisely, doing this you will be able to launch an existing route from beginning to end (With or without your real database) or intercept the exchange between each part of the route and test if your headers or body are correct or not.
The project I have been doing this on uses classic Spring with xml configuration and DBUnit to mock a test database. Hope this will give you a few leads.
Parameter/Function | Details |
---|---|
Exchange | The exchange is used inside the camel processor to pass objects between parts of your route |
CamelContext | The camel context is used in the test to manually start and stop the context. |
ProducerTemplate | Allows you to send messages in your route, setting the complete exchange manually or sending dummy headers/body |
AdviceWith | Helps you redefine an existing route with the current context |
WeaveById | Used inside the advice with configuration, tells pieces of your route how to behave (Can also use weaveByToString) |
MockEndpoint | The mockendpoint is a point you define for your test. In your weaveById, you can tell your route to its usual processing and go into a mockEnpoint rather than following the usual route. This way you can check the message count, the exchange status ... |
Some definitions given here are not perfectly accurate, but they will help you understand the code above. Here are a few links for more detailed information :
About the use of AdviceWith and weaveById (Or other ways to trigger routes), have a look at the official apache-camel documentation : see this link
About the use of ProducerTemplate, see the official documentation again : see this link
To really understand what camel is all about : Entreprise Integration Patterns detailed documentation
This particular way of testing is pretty hard to find, even on stack overflow. This is pretty specific but don't hesitate to ask for more details, maybe I'll be able to help.