There are a number of examples on the camel testing page. However I can
provide perhaps some information. Mock endpoints are just recorders of
information the previous poster used in example. Normally an endpoint
doesn't keep track of what exchanges go through it but mock ones do. You
can also mock an endpoint in an existing route with adviceWith() in a unit
test. This will insert an interceptor into the route before the endpoint
that will record the data going through. If you do mockEndpointsAndSkip()
the component mocking will not get executed.

See the following pages for more info then come back if you have further
questions:
http://camel.apache.org/advicewith.html
http://camel.apache.org/camel-test.html



*Robert Simmons Jr. MSc. - Lead Java Architect @ EA*
*Author of: Hardcore Java (2003) and Maintainable Java (2012)*
*LinkedIn: **http://www.linkedin.com/pub/robert-simmons/40/852/a39
<http://www.linkedin.com/pub/robert-simmons/40/852/a39>*


On Fri, Jan 17, 2014 at 8:24 AM, Henryk Konsek <hekon...@gmail.com> wrote:

> > I don't really understand yet how mock endpoints work, I am seeking a
> simple
> > example to help get me over this.
>
> You can test your processor with Mock endpoint by using the latter to
> catch exchange processed by the former.
>
> // Fixtures
> from("direct:test").process(new testProc()).to("mock:test");
>
> // Given
> MockEndpoint resultEndpoint = getMockEndpoint("mock:test");
> resultEndpoint.expectedMessageCount(1);
> resultEndpoint.message(0).header("myHeader").isEqualTo("Yay");
>
> // When
> template.sendBody("direct:test", "Test");
>
> // Then
> resultEndpoint.assertIsSatisfied();
>
> Cheers.
>
> --
> Henryk Konsek
> http://henryk-konsek.blogspot.com
>

Reply via email to