If you are using OSGi then give Pax Exam a try

James Strachan, Technical Director at Progress Software, blogging about Pax Exam:

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.