Build-time integration testing OSGi bundles in ServiceMix

I have just added a new project to GitHub under FuseByExample/smx-integration-testing that you can use to verify at build time that your bundles and features will deploy and run as expected in a specific version of ServiceMix. The intention is that you can use it to kick start testing in your own projects.

To do this I hooked up the process described by Ioannis Canellos in Advanced integration testing with Pax Exam Karaf to start up and deploy your project artifacts into an embedded FuseSource distribution of ServiceMix (4.4.1-fuse-01.13 at time of writing), using the maven-failsafe-plugin for integration testing.

The result is a build that compiles and assembles your bundle or features project, unit tests it, packages it up for installation and then integration tests the binary using pax-exam-karaf and JUnit.

If your bundle fails either to install into the embedded ServiceMix container, or fails any of the criteria defined in your integration test, the build will fail and the build artifact won’t end up being installed to your Maven repo.

The sample demonstrates:

  • the wiring required to assemble this approach in Maven
  • the separation of test artifacts for a SpringDM bundle into both unit and integration tests; abstracting out the OSGi bits for unit testing while ensuring ${} placeholders work, and
  • shows a number of ways to exercise the code in your bundle via:
    • straight Camel route testing
    • using the OSGi BundleContext to verify that a bundle is installed and active
    • checking that a SpringDM OSGi service is deployed via the @Inject mechanism

The documentation in the README file goes into full detail as to how this is achieved.

Enjoy!


Posted

in

, , ,

by

Tags:

Comments

One response to “Build-time integration testing OSGi bundles in ServiceMix”

  1. jamie Avatar
    jamie

    How ironic. I was just talking about how awesome this would be to have automated in jenkins.
    Good job!