FrameworkUtils { public static String[] getBundleExportedPackages(Bundle bundle, PackageAdmin packageAdmin) throws IllegalArgumentException { if (bundle == null) { throw new IllegalArgumentException("Argument bundle cannot be null"); } if (packageAdmin == null) { throw new IllegalArgumentException("Argument packageAdmin cannot be null"); } String[] exportedPackages; ExportedPackage[] exported = packageAdmin.getExportedPackages(bundle); if (exported != null) { exportedPackages = new String[exported.length]; for (int i = 0; i < exported.length; i++) { exportedPackages[i] = exported[i].getName() + ";" + exported[i].getVersion().toString(); } } else { exportedPackages = new String[0]; } return exportedPackages; } private  FrameworkUtils(); static Bundle resolveBundle(BundleContext bundleContext, long bundleId); static long[] getBundleIds(Bundle[] bundles); static long[] getBundleIds(List<Bundle> bundles); static ServiceReference resolveService(BundleContext bundleContext, long serviceId); static long[] getServiceIds(ServiceReference[] serviceReferences); static String[] getBundleExportedPackages(Bundle bundle, PackageAdmin packageAdmin); static long[] getFragmentIds(Bundle bundle, PackageAdmin packageAdmin); static long[] getHostIds(Bundle fragment, PackageAdmin packageAdmin); static String[] getBundleImportedPackages(BundleContext localBundleContext, Bundle bundle,
            PackageAdmin packageAdmin); static long[] getRegisteredServiceIds(Bundle bundle); static long[] getServicesInUseByBundle(Bundle bundle); static boolean isBundlePendingRemoval(Bundle bundle, PackageAdmin packageAdmin); static boolean isBundleRequiredByOthers(Bundle bundle, PackageAdmin packageAdmin); @SuppressWarnings("unchecked") static long[] getBundleDependencies(BundleContext localBundleContext, 
                                               Bundle bundle,
                                               PackageAdmin packageAdmin); static long[] getDependentBundles(Bundle bundle, PackageAdmin packageAdmin); static String getBundleState(Bundle bundle); static boolean arrayContains(Object[] array, Object value); static List<String> extractHeaderDeclaration(String headerStatement);  }
@Test public void testGetBundleExportedPackages() throws Exception { Bundle bundle = mock(Bundle.class); PackageAdmin admin = mock(PackageAdmin.class); assertEquals(0, getBundleExportedPackages(bundle, admin).length); ExportedPackage exported = mock(ExportedPackage.class); when(exported.getName()).thenReturn("org.apache.aries.jmx"); when(exported.getVersion()).thenReturn(new Version("1.0.0")); when(admin.getExportedPackages(bundle)).thenReturn(new ExportedPackage[] { exported }); assertArrayEquals(new String[] { "org.apache.aries.jmx;1.0.0"} , getBundleExportedPackages(bundle, admin)); }