I’m pleased to announce the 1.0.0.M1 release of SpringSource’s OSGi Test Stubs. These stubs offer a way to unit test complex OSGi Framework interactions without needing a full OSGi container.
As the dm Server team has been developing, we found that one of the biggest problem areas for testing for us was in BundleActivators. Our BundleActivators do quite a bit of publishing services to the service registry as well as consuming services using ServiceTrackers. These kinds of tasks involve many interwoven calls to BundleContexts, Bundles, ServiceRegistrations, and ServiceReferences. In the beginning, these activators were simple enough that not much unit testing was done on them, and we depended on integration tests to catch any bugs that were introduced. As time went on though, the activators became more complex and unit testing became a more pressing need. We started using EasyMock for these tests, but found that they were very complex, hard to maintain, and most importantly hard to understand.