public void testModuleRegistered() throws Exception {
assertNotNull("BundleContext injected", bundleContext);
ServiceReference sref = bundleContext.getServiceReference(PackageAdmin.class.getName());
PackageAdmin pa = (PackageAdmin) bundleContext.getService(sref);
assertNotNull("PackageAdmin not null", pa);
Bundle[] bundles = pa.getBundles("example-module-reg", null);
assertNotNull("Bundles not null", bundles);
assertEquals("One bundle", 1, bundles.length);
Bundle bundle = bundles[0];
assertEquals("Bundle INSTALLED", Bundle.INSTALLED, bundle.getState());
Class<?> clazz = bundle.loadClass(SimpleService.class.getName());
assertNotNull("Loaded class", clazz);
assertEquals("Bundle RESOLVED", Bundle.RESOLVED, bundle.getState());
ExportedPackage[] exportedPackages = pa.getExportedPackages(bundle);
assertNotNull("ExportedPackages not null", exportedPackages);
assertEquals("One ExportedPackage", 1, exportedPackages.length);
ExportedPackage exportedPackage = exportedPackages[0];
assertEquals(SimpleService.class.getPackage().getName(), exportedPackage.getName());