-
Book Overview & Buying
-
Table Of Contents
Apache Camel Developer's Cookbook
By :
The ability to verify message flow using mock endpoints was built into the Camel framework from its inception. The Mock Component in the camel-core library provides you with a testing DSL that allows you to verify which messages have reached various named mock: endpoints defined in your route. This recipe will describe how to make use of this mock DSL.
To use this recipe you should first have a route test set up as described in the Testing routes defined in Java recipe.
The Java code for this recipe is located in the org.camelcookbook.examples.testing.mockreply package.
To use mock endpoints, perform the following steps:
Within your route, use a mock: endpoint URI in any Camel DSL statement that produces a message to an endpoint, such as to(..) or wireTap(..):
from("direct:start")
.choice()
.when().simple("${body} contains 'Camel'")
.setHeader("verified").constant(true)
.to("mock:camel")
.otherwise...