This sample demonstrates how Citrus is able to interact with Apache Camel. Read more about this in reference guide
Apache Camel project implements the enterprise integration patterns for building mediation and routing rules in your enterprise application. With the Citrus Camel support you are able to directly interact with the Apache Camel components and route definitions. You can call Camel routes and receive synchronous response messages. You can also simulate the Camel route endpoint with receiving messages and providing simulated response messages.
So we need a Camel route to test.
The Camel route reads from a JMS queue and forwards the message to a SOAP web service endpoint. In a test scenario we need to send messages to the JMS destination and wait for messages on the SOAP server endpoint. Lets add configuration for this in Citrus:
The components above are used in a Citrus test case.
As you can see Citrus is both JMS message producer and SOAP server at the same time in a single test. The Apache Camel route in the middle will read the JMS message and forward it to the SOAP server endpoint where Citrus receives the message for validation purpose. This way we make sure the Camel route is working as expected.
The sample application uses Maven as build tool. So you can compile, package and test the sample with Maven.
mvn clean install -Dembedded=true
This executes the complete Maven build lifecycle.
During the build you will see Citrus performing some integration tests.
Execute all Citrus tests by calling
You can also pick a single test by calling
mvn integration-test -Ptest=TodoListIT
You should see Citrus performing several tests with lots of debugging output in your terminal. And of course green tests at the very end of the build.
Of course you can also start the Citrus tests from your favorite IDE. Just start the Citrus test using the TestNG IDE integration in IntelliJ, Eclipse or Netbeans.