@SuppressWarnings("rawtypes") @Test public void testGetProviderMetadata() throws Exception { MetadataBundleListener listener = new MetadataBundleListener(); 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")).anyTimes(); expect((Class) bundle.loadClass("org.jclouds.providers.JcloudsTestBlobStoreProviderMetadata")).andReturn( JcloudsTestBlobStoreProviderMetadata.class).anyTimes(); expect((Class) bundle.loadClass("org.jclouds.providers.JcloudsTestComputeProviderMetadata")).andReturn( JcloudsTestComputeProviderMetadata.class).anyTimes(); expect((Class) bundle.loadClass("org.jclouds.providers.JcloudsTestYetAnotherComputeProviderMetadata")).andReturn( JcloudsTestYetAnotherComputeProviderMetadata.class).anyTimes(); replay(bundle); List<ProviderMetadata> providerMetadataList = Lists.newArrayList(listener.listProviderMetadata(bundle)); assertNotNull(providerMetadataList); assertEquals(3, providerMetadataList.size()); assertTrue(providerMetadataList.contains(new JcloudsTestBlobStoreProviderMetadata())); assertTrue(providerMetadataList.contains(new JcloudsTestComputeProviderMetadata())); assertTrue(providerMetadataList.contains(new JcloudsTestYetAnotherComputeProviderMetadata())); verify(bundle); }
public Iterable<ProviderMetadata> listProviderMetadata(Bundle bundle) { Iterable<String> classNames = stringsForResourceInBundle( "/META-INF/services/org.jclouds.providers.ProviderMetadata", bundle); return instantiateAvailableClasses(bundle, classNames, ProviderMetadata.class); }
MetadataBundleListener implements BundleListener { public Iterable<ProviderMetadata> listProviderMetadata(Bundle bundle) { Iterable<String> classNames = stringsForResourceInBundle( "/META-INF/services/org.jclouds.providers.ProviderMetadata", bundle); return instantiateAvailableClasses(bundle, classNames, ProviderMetadata.class); } }
MetadataBundleListener implements BundleListener { public Iterable<ProviderMetadata> listProviderMetadata(Bundle bundle) { Iterable<String> classNames = stringsForResourceInBundle( "/META-INF/services/org.jclouds.providers.ProviderMetadata", bundle); return instantiateAvailableClasses(bundle, classNames, ProviderMetadata.class); }  }
MetadataBundleListener implements BundleListener { public Iterable<ProviderMetadata> listProviderMetadata(Bundle bundle) { Iterable<String> classNames = stringsForResourceInBundle( "/META-INF/services/org.jclouds.providers.ProviderMetadata", bundle); return instantiateAvailableClasses(bundle, classNames, ProviderMetadata.class); }  synchronized void start(BundleContext bundleContext); void stop(BundleContext bundleContext); @Override synchronized void bundleChanged(BundleEvent event); Iterable<ProviderMetadata> listProviderMetadata(Bundle bundle); Iterable<ApiMetadata> listApiMetadata(Bundle bundle); synchronized void addProviderListener(ProviderListener listener); synchronized void removeProviderListener(ProviderListener listener); synchronized void addApiListenerListener(ApiListener listener); synchronized void removeApiListenerListener(ApiListener listener); }
MetadataBundleListener implements BundleListener { public Iterable<ProviderMetadata> listProviderMetadata(Bundle bundle) { Iterable<String> classNames = stringsForResourceInBundle( "/META-INF/services/org.jclouds.providers.ProviderMetadata", bundle); return instantiateAvailableClasses(bundle, classNames, ProviderMetadata.class); }  synchronized void start(BundleContext bundleContext); void stop(BundleContext bundleContext); @Override synchronized void bundleChanged(BundleEvent event); Iterable<ProviderMetadata> listProviderMetadata(Bundle bundle); Iterable<ApiMetadata> listApiMetadata(Bundle bundle); synchronized void addProviderListener(ProviderListener listener); synchronized void removeProviderListener(ProviderListener listener); synchronized void addApiListenerListener(ApiListener listener); synchronized void removeApiListenerListener(ApiListener listener);  }