Simple way to test requiring OSGI without lots of artefacts and dependencies

384 views Asked by At

OSGI Testing frameworks - some observations.

I am in the middle of writing a system that makes use of OSGI. However all of the popular testing frameworks (Spring-OSGI, PaxExam) require a lot of artefacts for even the simplest test.

Wishlist / Goals

Ideally i would like a single Test that uses TinyBundle to assemble bundles and gives them to the framework. The framework will then do the heavy lifting of starting the container, deploying, running each test, updating the ui to show results etc.

On the surface it would appear that PAX-EXAM would satisfy this but it has additional requirements, which I have not been able to solve, within Eclipse. My problems are:

  • Each bundle requires a separate project.
  • Each project gets a manifest.mf in the $project/meta-inf/.

Ideally i would like to bundle all my manifests and "internal" classes in separate sub packages of the test rather than having them scattered about in their respective projects.

I have found packaging everything into the one project just does not work when the tests execute even if the bundles provisioned are identical in content. However if i split everything into separate projects stuff just works.

Maven

I wish to avoid maven as this implies that a more complex system that would end up requiring building, deploying into the repo which in the end even when automated just slows things down even more. This would conflict with my use of Infinitest which automagically detects changed classes and just executes the right tests.

Eclipse Project Plugin launch configurations.

This approach requires one to pick the bundles to deploy prior to executing the junit test. This of course only works if one has separate projects with a one to one mapping per bundle. Again this goes against my attempts to consolidate all test dependeny bundles under one project.

How, Can it be done ???

  • How can i achieve this ?
  • Is this practically possible ?
  • Whats the simplest alternative ?
1

There are 1 answers

3
Marcel Offermans On

One alternative, which also leverages Pax Exam, is what we did in an OSGi testing framework (that tests OSGi framework implementations). Rather than duplicating the whole explanation of how it works, you can find that here:

http://opensource.luminis.net/wiki/display/OSGITEST/OSGi+testing+framework

It does not use Maven, and writing new tests is explained here:

http://opensource.luminis.net/wiki/display/OSGITEST/Writing+a+framework+test

Maybe some of the solutions can inspire you. All in all, there are many test frameworks out there for OSGi (just like there are for non-OSGi) but so far there has one been any one that "makes the rest obsolete".