Bundles { public static ImmutableSet<String> stringsForResourceInBundle(String resourcePath, Bundle bundle) { checkNotNull(resourcePath, "resourcePath"); checkNotNull(bundle, "bundle"); URL resource = bundle.getEntry(resourcePath); if (resource == null) return ImmutableSet.of(); try { return ImmutableSet.copyOf(splitOrEmptyAndClose(resource.openStream())); } catch (IOException e) { } catch (RuntimeException ex) { } return ImmutableSet.of(); } private  Bundles(); static ImmutableSet<T> instantiateAvailableClasses(Bundle bundle, Iterable<String> classNames,
         Class<T> type); static ImmutableSet<String> stringsForResourceInBundle(String resourcePath, Bundle bundle);  }
@Test public void testStringsForResourcesInBundleWhenNoResources() throws Exception { Bundle bundle = createMock(Bundle.class); expect(bundle.getEntry("/META-INF/services/org.jclouds.apis.ApiMetadata")).andReturn(null); replay(bundle); assertEquals(Bundles.stringsForResourceInBundle("/META-INF/services/org.jclouds.apis.ApiMetadata", bundle), ImmutableSet.of()); verify(bundle); }
@Test public void testStringsForResourcesInBundleWhenResourcePresent() throws Exception { Bundle bundle = createMock(Bundle.class); expect(bundle.getEntry("/META-INF/services/org.jclouds.providers.ProviderMetadata")).andReturn( getClass().getResource("/META-INF/services/org.jclouds.providers.ProviderMetadata")); replay(bundle); assertEquals(Bundles.stringsForResourceInBundle("/META-INF/services/org.jclouds.providers.ProviderMetadata", bundle), ImmutableSet.of("org.jclouds.providers.JcloudsTestBlobStoreProviderMetadata", "org.jclouds.providers.JcloudsTestComputeProviderMetadata", "org.jclouds.providers.JcloudsTestYetAnotherComputeProviderMetadata")); verify(bundle); }