Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Include Page
Testing Summary Include
Testing Summary Include

The test component extends the Mock component to support pulling messages from another endpoint on startup to set the expected message bodies on the underlying 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.

...

Maven users will need to add the following dependency to their pom.xml for this component when using Camel 2.8 or older:

Code Block
xml
xml
<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-spring</artifactId>
    <version>x.x.x</version>
    <!-- use the same version as your Camel core version -->
</dependency>

From Camel 2.9 onwards : the Test component is provided directly in the camel-core.

URI format

Code Block
test:expectedMessagesEndpointUri

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

...

Div
classconfluenceTableSmall
2000 can be If enabled the \n\r delimiters (new lines) a \n|\r17 split delimiter split is enabled. By default the delimiter is new line based. The delimiter can be a regular expression.

Name

Default Value

Description

timeout

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

anyOrderfalseCamel 2.17: Whether the expected messages should arrive in the same order, or in any order.
delimiter\n|\rCamel 2.17: The delimiter to use when split=true. The delimiter can be a regular expression.
splitfalseCamel 2.17: If true the messages loaded from the test endpoint will be split using the delimiter so each line is an expected message.
For example to use
file endpoint to load a file where each line is an expected message. delimiter

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:

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

...