Book Image

Mastering Apache Camel

By : Bilgin Ismet Ibryam, Jean Baptiste Onofre, Jean-Baptiste Onofré
5 (1)
Book Image

Mastering Apache Camel

5 (1)
By: Bilgin Ismet Ibryam, Jean Baptiste Onofre, Jean-Baptiste Onofré

Overview of this book

Table of Contents (15 chapters)
Mastering Apache Camel
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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"); 

}