Versions Compared

Key

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

Mock Component

Testing of distributed and asynchronous processing is notoriously difficult. The Mock Component provides a great tool for creating good integration test cases based on the Enterprise Integration Patterns using the various Components in Camel.

The Mock The mock: component provides a powerful declarative testing mechanism which is similar to jMock in that it allows declarative expectations to be created on an endpoint up frontany Camle Endpoint before a test begins. Then the test is ran which typically fires messages to one or more endpoints and finally the expectations can be asserted in a test case to ensure the system worked as expected.Testing of distributed and asynchronous processing is notoriously difficult. The MockEndpoint provides a great tool for creating great test cases depite using the various diverse Components in Camel.

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

URI format

Code Block
mock:someName

...