OSGi and Testing
Does OSGi use JUNIT, and if NOT why NOT? I was faced today with this rather aggressive looking question.
Yes it does, and no it does not.
The OSGi test harness was developed before JUNIT was around, actually, before Extreme Programming made testing move up in the programmers popularity charts. Initially we used an even simpler scheme than JUNIT, test cases were just sending output to the console and compared it to a reference output and differences were flagged. However, as JUNIT became more and more popular, and rightly so, we decided to go with the flow and adopt/adapt.
The easy part was the adoption of the API, Test cases in OSGi parlance are now virtual indistinguishable from the JUNIT APIs. Unfortunately, we could not adopt the JUNIT harness because we have severe constraints on the target environment. Embedded does that to you. The original test harness we developed in 1999 already had an architecture where the UI was running in another process so that the requirements on the target could be kept to an absolute minimum.
We also provided support for running the test case in two different processes. Each test case can run partly in the Director (the GUI host) and partly in the target. This architecture significantly reduced the need for setup instructions before the test could be run, a major headache with larger test suites. For example, the test case for Initial Provisioning contains a full provisioning server in the Director.
We also had to add support for the management of bundles. At first sight, it looks like that bundles is what should be tested. However, this turns out to be such a fundamental part of the testing, that special support was needed. Actually, we used the OSGi bundle model intensely. A Test Case consists of a number (embedded) bundles.
The test suites can be run from a rather nice looking GUI (which is based on IFC, what Swing could have been, but that is a story for another time) but can also be run from a script or command line.

Overall, the test harness has so far withstood the test of time. It will be interesting to see if JUNIT one day will replace our test suite. Though I am always for standards, it will not be without pain to let it go.
Peter Kriens
posted by Peter @ Monday, June 27, 2005



