Versions Compared

Key

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

...

You can see from the javadoc of MockEndpoint the various helper methods you can use . You can use other methods such asto set expectations. The mail methods available are as follows

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)

expectsAscending(Expression)

to add an expectation that messages are received in order using the given expression as an ordering Expression

expectsDescending(Expression)

to add an expectation that messages are received in order using the given expression as an ordering Expression

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.

...

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

Adding assertions to messages

In addition you can use the message(int messageIndex) method to add assertions about a specific message that is received.

For example to add expectations of the headers or body of the first message (using zero based indexing like java.util.List), you can use this codeOr you could add an expectation on the headers or content of a specific message. For example

Code Block
resultEndpoint.message(0).header("foo").isEqualTo("bar");

There are some examples of the Mock endpoint in use in the camel-corecore core processor tests.

Include Page
CAMEL:Endpoint See Also
CAMEL:Endpoint See Also