@Test public void testSanity() throws MalformedURLException, ClassNotFoundException { // We are checking here that the class loader we create and use in this test series is indeed different and // isolated from our tests classloader. ClassLoader loader = createIsolatedClassLoader(); assertFalse(ProviderMetadata.class.isAssignableFrom(loader .loadClass("org.jclouds.providers.JcloudsTestComputeProviderMetadata"))); }
@Test public void testSanity() throws MalformedURLException, ClassNotFoundException { // We are checking here that the class loader we create and use in this test series is indeed different and // isolated from our tests classloader. ClassLoader loader = createIsolatedClassLoader(); assertFalse(ProviderMetadata.class.isAssignableFrom(loader .loadClass("org.jclouds.providers.JcloudsTestComputeProviderMetadata"))); }
@Test public void testGetProviderMetadataFromMultipleClassLoaders() throws Exception { ClassLoader isolatedClassLoader = createIsolatedClassLoader(); 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(bundle.loadClass("org.jclouds.providers.JcloudsTestBlobStoreProviderMetadata")).andReturn( isolatedClassLoader.loadClass(JcloudsTestBlobStoreProviderMetadata.class.getName())).anyTimes(); expect(bundle.loadClass("org.jclouds.providers.JcloudsTestComputeProviderMetadata")).andReturn( JcloudsTestComputeProviderMetadata.class).anyTimes(); expect(bundle.loadClass("org.jclouds.providers.JcloudsTestYetAnotherComputeProviderMetadata")).andReturn( JcloudsTestYetAnotherComputeProviderMetadata.class).anyTimes(); replay(bundle); List<ProviderMetadata> providerMetadataList = Lists.newArrayList(listener.listProviderMetadata(bundle)); assertNotNull(providerMetadataList); assertEquals(2, providerMetadataList.size()); assertFalse(providerMetadataList.contains(new JcloudsTestBlobStoreProviderMetadata())); assertTrue(providerMetadataList.contains(new JcloudsTestComputeProviderMetadata())); assertTrue(providerMetadataList.contains(new JcloudsTestYetAnotherComputeProviderMetadata())); verify(bundle); }
@Test public void testGetApiMetadataFromMultipleClassLoaders() throws Exception { ClassLoader isolatedClassLoader = createIsolatedClassLoader(); MetadataBundleListener listener = new MetadataBundleListener(); Bundle bundle = createMock(Bundle.class); expect(bundle.getEntry("/META-INF/services/org.jclouds.apis.ApiMetadata")).andReturn( getClass().getResource("/META-INF/services/org.jclouds.apis.ApiMetadata")).anyTimes(); expect(bundle.loadClass("org.jclouds.apis.JcloudsTestBlobStoreApiMetadata")).andReturn( isolatedClassLoader.loadClass(JcloudsTestBlobStoreApiMetadata.class.getName())).anyTimes(); expect(bundle.loadClass("org.jclouds.apis.JcloudsTestComputeApiMetadata")).andReturn( JcloudsTestComputeApiMetadata.class).anyTimes(); expect(bundle.loadClass("org.jclouds.apis.JcloudsTestYetAnotherComputeApiMetadata")).andReturn( JcloudsTestYetAnotherComputeApiMetadata.class).anyTimes(); replay(bundle); List<ApiMetadata> apiMetadataList = Lists.newArrayList(listener.listApiMetadata(bundle)); assertNotNull(apiMetadataList); assertEquals(2, apiMetadataList.size()); assertFalse(apiMetadataList.contains(new JcloudsTestBlobStoreApiMetadata())); assertTrue(apiMetadataList.contains(new JcloudsTestComputeApiMetadata())); assertTrue(apiMetadataList.contains(new JcloudsTestYetAnotherComputeApiMetadata())); verify(bundle); }
@SuppressWarnings("rawtypes") @Test public void testGetProviderMetadataFromMultipleClassLoaders() throws Exception { ClassLoader isolatedClassLoader = createIsolatedClassLoader(); 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( isolatedClassLoader.loadClass(JcloudsTestBlobStoreProviderMetadata.class.getName())).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(2, providerMetadataList.size()); assertFalse(providerMetadataList.contains(new JcloudsTestBlobStoreProviderMetadata())); assertTrue(providerMetadataList.contains(new JcloudsTestComputeProviderMetadata())); assertTrue(providerMetadataList.contains(new JcloudsTestYetAnotherComputeProviderMetadata())); verify(bundle); }
@SuppressWarnings("rawtypes") @Test public void testGetApiMetadataFromMultipleClassLoaders() throws Exception { ClassLoader isolatedClassLoader = createIsolatedClassLoader(); MetadataBundleListener listener = new MetadataBundleListener(); Bundle bundle = createMock(Bundle.class); expect(bundle.getEntry("/META-INF/services/org.jclouds.apis.ApiMetadata")).andReturn( getClass().getResource("/META-INF/services/org.jclouds.apis.ApiMetadata")).anyTimes(); expect((Class) bundle.loadClass("org.jclouds.apis.JcloudsTestBlobStoreApiMetadata")).andReturn( isolatedClassLoader.loadClass(JcloudsTestBlobStoreApiMetadata.class.getName())).anyTimes(); expect((Class) bundle.loadClass("org.jclouds.apis.JcloudsTestComputeApiMetadata")).andReturn( JcloudsTestComputeApiMetadata.class).anyTimes(); expect((Class) bundle.loadClass("org.jclouds.apis.JcloudsTestYetAnotherComputeApiMetadata")).andReturn( JcloudsTestYetAnotherComputeApiMetadata.class).anyTimes(); replay(bundle); List<ApiMetadata> apiMetadataList = Lists.newArrayList(listener.listApiMetadata(bundle)); assertNotNull(apiMetadataList); assertEquals(2, apiMetadataList.size()); assertFalse(apiMetadataList.contains(new JcloudsTestBlobStoreApiMetadata())); assertTrue(apiMetadataList.contains(new JcloudsTestComputeApiMetadata())); assertTrue(apiMetadataList.contains(new JcloudsTestYetAnotherComputeApiMetadata())); verify(bundle); }