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]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 18, “Mock dependency” to their pom.xml to use this component.

Example 18. 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 49, “Mock options” describes the options for a mock endpoint.

Table 49. Mock options

OptionDescription
reportGroupSpecifies a size to use for a throughput logger for reporting.