Unit testing OSGi Blueprint with Apache Camel made easier

Apache Camel 2.10 is currently in development, and recently Guillaume Nodet added a new camel-test-blueprint component, to make unit testing Camel with OSGi blueprint much easier.

I have then polished the camel-test-blueprint to make it easier to use, and also fix a few glitches etc. So what's the story then? Well camel-test-blueprint, works exactly as the regular camel-test you may be familiar with already.

So all you have to do is to extend the CamelTestSupport class, and override the getBlueprintDescriptor method, and return the path for your OSGi blueprint XML file. Then the rest is the usual story, to add test methods.

The Camel documentation has been updated, and you can find details here.

This is a great step forward for Camel end users who are on the OSGi blueprint wagon, as its becoming easier to develop and unit test along the way. All you have to do is to right click from your editor and run the unit tests as shown in the screenshot below.

JUnit testing Camel with OSGi Blueprint

The Camel Maven archetype camel-archetype-blueprint has been updated and include the test kit out of the box with a sample code. I used this archetype to generate a new project, imported the project into Fuse IDE / Eclipse, and then I opened the unit test source code file, and right clicked -> run as -> JUnit test. This is all standard functionality of Eclipse.

The camel-test-blueprint component will be part of Apache Camel 2.10 release, and as well in the upcoming Fuse Mediation Router 2.9 release (our distribution of Apache Camel).

No comments: