Additional annotations
The Camel test kit also provides additional annotations, in order to simplify the code of your tests.
Instead of using the getMockEndpoint()
method to get the mocked endpoints, you can use the @EndpointInject
annotation:
@EndpointInject(uri = "mock:direct:france") protected MockEndpoint franceEndpoint;
Now, we can directly use the franceEndpoint
mock endpoint in the test methods:
@Test public void aTest() throws Exception { … franceEndpoint.expectedBodiesReceived("<foo/>"); … franceEndpoint.assertIsSatisfied(); }
Similarly, instead of defining the endpoint URI on the producer template, you can use the @Producer
annotation to define where the producer template sends the message:
@Produce(uri = "direct:input"); protected ProducerTemplate template;
We can now directly use the producer template without specifying the endpoint:
@Test public void aTest() throws Exception { … template.sendBodyAndHeader("<message/>", "foo", "bar"); }