Versions Compared

Key

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

...

This allows you to test various things like:

  • the correct number of messages are received on each endpoint
  • that the correct payloads are received, in the right order
  • that messages arrive on an endpoint in order, using some Expression to create an order testing function
  • that messages arrive match some kind of Predicate such as that specific headers have certain values, or that parts of the messages match some predicate such as by evaluating an XPath or XQuery Expression

...

You can see from the javadoc of MockEndpoint the various helper methods you can use to set expectations. The main 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)

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.

Here's another example:

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

...