Name
Mock — provides a declarative framework for testing routes
Overview
Mock endpoints provide a powerful declarative testing mechanism similar to jMock. It allows declarative expectations to be created on any Mock endpoint before a test begins. When the test is run, which typically fires messages to one or more endpoints, the expectations can be asserted in a test case to ensure the system worked as expected.
This allows you to test things like:
The correct number of messages are received on each endpoint
The correct payloads are received
The messages arrive on an endpoint in the right order
![]() | Note |
---|---|
The Test endpoint is a mock endpoint that uses a second endpoint to provide the list of expected message bodies and automatically sets up the mock endpoint assertions. |
Dependencies
Maven users will need to add the dependency shown in Example 9.1 to their
pom.xml
to use this component.
Example 9.1. Mock dependency
<dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-test</artifactId> <version>x.x.x</version> <!-- use the same version as your Camel core version --> </dependency>
URI format
Mock endpoints have the following URI format:
mock:someName
[?options
]
someName
can be any string that uniquely identifies the
endpoint.
Options
Table 9.1 describes the options for a mock endpoint.
Table 9.1. Mock options
Option | Description |
---|---|
reportGroup | Specifies a size to use for a throughput logger for reporting. |