mock
default MockEndpointBuilderFactory.MockEndpointBuilder mock(String path)
Mock (camel-mock)
The mock component is used for testing routes and mediation rules
using mocks. A Mock endpoint which provides a literate, fluent API
for testing routes using a JMock style API. The mock endpoint have
two set of methods expectedXXX or expectsXXX - To set pre conditions,
before the test is executed assertXXX - To assert assertions, after
the test has been executed Its important to know the difference
between the two set. The former is used to set expectations before
the test is being started (eg before the mock receives messages). The
latter is used after the test has been executed, to verify the
expectations; or other assertions which you can perform after the
test has been completed. Beware: If you want to expect a mock does
not receive any messages, by calling setExpectedMessageCount(int)
with 0, then take extra care, as 0 matches when the tests starts, so
you need to set a assert period time to let the test run for a while
to make sure there are still no messages arrived; for that use
setAssertPeriod(long) . An alternative is to use NotifyBuilder, and
use the notifier to know when Camel is done routing some messages,
before you call the assertIsSatisfied() method on the mocks. This
allows you to not use a fixed assert period, to speedup testing
times. Important: If using expectedMessageCount(int) and also
expectedBodiesReceived(java.util.List) or
expectedHeaderReceived(String,Object) then the latter overrides the
number of expected message based on the number of values provided in
the bodies/headers.
Category: core,testing
Since: 1.0
Maven coordinates: org.apache.camel:camel-mock
Syntax: mock:name
Path parameter: name (required)
Name of mock endpoint