Camel Component: Test - 6.3

Talend ESB Mediation Developer Guide

EnrichVersion
6.3
EnrichProdName
Talend Data Fabric
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Open Studio for ESB
Talend Real-Time Big Data Platform
task
Design and Development
EnrichPlatform
Talend ESB

Testing of distributed and asynchronous processing is notoriously difficult. The Camel Component: Mock, Camel Component: Test and DataSet endpoints work great with the Camel Testing Framework to simplify your unit and integration testing using Enterprise Integration Patterns and Camel's large range of Components together with the powerful Bean Integration.

The test component extends the Camel Component: Mock component to support pulling messages from another endpoint on startup to set the expected message bodies on the underlying Camel Component: Mock endpoint. That is, you use the test endpoint in a route and messages arriving on it will be implicitly compared to some expected messages extracted from some other location.

So you can use, for example, an expected set of message bodies as files. This will then set up a properly configured Camel Component: Mock endpoint, which is only valid if the received messages match the number of expected messages and their message payloads are equal.

URI format

test:expectedMessagesEndpointUri

where expectedMessagesEndpointUri refers to some other Component URI that the expected message bodies are pulled from before starting the test.

URI Options

Name

Default Value

Description

timeout

2000

Camel 2.12: The timeout to use when polling for message bodies from the URI.

Example

For example, you could write a test case as follows:

from("seda:someEndpoint").
   to("test:file://data/expectedOutput?noop=true");

If your test then invokes the MockEndpoint.assertIsSatisfied(camelContext) method, your test case will perform the necessary assertions.

To see how you can set other expectations on the test endpoint, see Camel Component: Mock component.