Friday 17 April 2009

If you are using OSGi then give Pax Exam a try

Pax Exam is a great piece of work! It makes it super easy to write JUnit4 tests which can then be run in multiple OSGi containers like Felix & Equinox using the exact bundles you require - plus it lets you inject BundleListener and so forth. Here's the tutorial which should get you started pretty quick.

I recently added an OSGi integration test to Apache Camel, here's the test case if you're interested. Notice how the versions of the bundles added to Felix and Equinox are not mentioned in this test case - they are inherited from the pom.xml from Maven.

The depends-maven-plugin from ServiceMix Kernel (soon to be Apache Karaf) generates the file target/classes/META-INF/maven/dependencies.properties which Pax Exam can then use to resolve the version dependencies of groupId/artifactIds. This lets you keep all your version information in your pom.xml and avoid having to update all your test cases whenever your pom.xml changes - keeping things nice and DRY!

Great stuff Pax-folks, keep up the good work!

1 comment: