FrameworkUtils { public static long[] getServiceIds(ServiceReference[] serviceReferences) { long result[] = (serviceReferences == null) ? new long[0] : new long[serviceReferences.length]; for (int i = 0; i < result.length; i++) { result[i] = (Long) serviceReferences[i].getProperty(Constants.SERVICE_ID); } return result; } 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 testGetServiceIds() throws Exception { assertEquals(0, getServiceIds(null).length); assertEquals(0, getServiceIds(new ServiceReference[0]).length); ServiceReference s1 = mock(ServiceReference.class); when(s1.getProperty(Constants.SERVICE_ID)).thenReturn(new Long(15)); ServiceReference s2 = mock(ServiceReference.class); when(s2.getProperty(Constants.SERVICE_ID)).thenReturn(new Long(5)); ServiceReference s3 = mock(ServiceReference.class); when(s3.getProperty(Constants.SERVICE_ID)).thenReturn(new Long(25)); assertArrayEquals(new long[] { 15, 5, 25 }, getServiceIds(new ServiceReference[] {s1, s2, s3} ) ); }