Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

...

You can append query options to the URI in the following format, ?option=value&option=value&...

Options

Div
classconfluenceTableSmall

Option

Default

Description

reportGroup

null

A size to use a throughput logger for reporting

retainFirst

 

Camel 2.10: To only keep first X number of messages in memory.

retainLast

 

Camel 2.10: To only keep last X number of messages in memory.

Wiki Markup
{div:class=confluenceTableSmall} || Option || Default || Description || | {{reportGroup}} | {{null}} | A size to use a [throughput logger|Log] for reporting | | {{retainFirst}} | | *Camel 2.10:* To only keep first X number of messages in memory. | | {{retainLast}} | | *Camel 2.10:* To only keep last X number of messages in memory. | {div}

Simple Example

Here's a simple example of Mock endpoint in use. First, the endpoint is resolved on the context. Then we set an expectation, and then, after the test has run, we assert that our expectations have been met.

...

You can see from the javadoc of MockEndpoint the various helper methods you can use to set expectations. The main methods are as follows:

Div
classconfluenceTableSmall

Method

Description

expectedMessageCount(int)

To define the expected message count on the endpoint.

expectedMinimumMessageCount(int)

To define the minimum number of expected messages on the endpoint.

expectedBodiesReceived(...)

To define the expected bodies that should be received (in order).

expectedHeaderReceived(...)

To define the expected header that should be received

expectsAscending(Expression)

To add an expectation that messages are received in order, using the given Expression to compare messages.

expectsDescending(Expression)

To add an expectation that messages are received in order, using the given Expression to compare messages.

expectsNoDuplicates(Expression)

To add an expectation that no duplicate messages are received; using an Expression to calculate a unique identifier for each message. This could be something like the JMSMessageID if using JMS, or some unique reference number within the message.

Wiki Markup
{div:class=confluenceTableSmall} || Method || Description || | [expectedMessageCount(int)|http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/component/mock/MockEndpoint.html#expectedMessageCount(int)] | To define the expected message count on the endpoint. | | [expectedMinimumMessageCount(int)|http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/component/mock/MockEndpoint.html#expectedMinimumMessageCount(int)] | To define the minimum number of expected messages on the endpoint. | | [expectedBodiesReceived(...)|http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/component/mock/MockEndpoint.html#expectedBodiesReceived(java.lang.Object...)] | To define the expected bodies that should be received (in order). | | [expectedHeaderReceived(...)|http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/component/mock/MockEndpoint.html#expectedHeaderReceived(java.lang.String,%20java.lang.String)] | To define the expected header that should be received | | [expectsAscending(Expression)|http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/component/mock/MockEndpoint.html#expectsAscending(org.apache.camel.Expression)] | To add an expectation that messages are received in order, using the given [Expression] to compare messages. | | [expectsDescending(Expression)|http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/component/mock/MockEndpoint.html#expectsDescending(org.apache.camel.Expression)] | To add an expectation that messages are received in order, using the given [Expression] to compare messages. | | [expectsNoDuplicates(Expression)|http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/component/mock/MockEndpoint.html#expectsNoDuplicates(org.apache.camel.Expression)] | To add an expectation that no duplicate messages are received; using an [Expression] to calculate a unique identifier for each message. This could be something like the {{JMSMessageID}} if using JMS, or some unique reference number within the message. | {div}

Here's another example:

Code Block
resultEndpoint.expectedBodiesReceived("firstMessageBody", "secondMessageBody", "thirdMessageBody");

...