This is an automated email from the ASF dual-hosted git repository.
gaul pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jclouds.git
The following commit(s) were added to refs/heads/master by this push:
new e49ce2e Remove tests which rely on an isolated ClassLoader
e49ce2e is described below
commit e49ce2e835d9ca8d4176bc7a67f81dad8f9f13f0
Author: Andrew Gaul <[email protected]>
AuthorDate: Sat Jul 10 11:47:03 2021 +0900
Remove tests which rely on an isolated ClassLoader
Java 9 returns jdk.internal.loader.ClassLoaders$AppClassLoader instead
of URLClassLoader so we cannot create an isolated ClassLoader.
---
.../jclouds/osgi/MetadataBundleListenerTest.java | 76 ----------------------
1 file changed, 76 deletions(-)
diff --git
a/core/src/test/java/org/jclouds/osgi/MetadataBundleListenerTest.java
b/core/src/test/java/org/jclouds/osgi/MetadataBundleListenerTest.java
index 536f6b5..6a9732f 100644
--- a/core/src/test/java/org/jclouds/osgi/MetadataBundleListenerTest.java
+++ b/core/src/test/java/org/jclouds/osgi/MetadataBundleListenerTest.java
@@ -23,13 +23,9 @@ import static org.easymock.EasyMock.expectLastCall;
import static org.easymock.EasyMock.replay;
import static org.easymock.EasyMock.verify;
import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
import java.util.List;
import org.jclouds.apis.ApiMetadata;
@@ -48,15 +44,6 @@ import com.google.common.collect.Lists;
public class MetadataBundleListenerTest {
- @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")));
- }
-
@SuppressWarnings("rawtypes")
@Test
public void testGetProviderMetadata() throws Exception {
@@ -114,31 +101,6 @@ public class MetadataBundleListenerTest {
@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 testGetApiMetadata() throws Exception {
MetadataBundleListener listener = new MetadataBundleListener();
Bundle bundle = createMock(Bundle.class);
@@ -192,42 +154,4 @@ public class MetadataBundleListenerTest {
listener.bundleChanged(event);
verify(bundle, apiListener);
}
-
- @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);
- }
-
- /**
- * Creates a different {@link ClassLoader}.
- *
- * @return
- */
- private ClassLoader createIsolatedClassLoader() throws
MalformedURLException {
- URLClassLoader testClassLoader = (URLClassLoader)
getClass().getClassLoader();
- URL[] urls = testClassLoader.getURLs();
- URLClassLoader loader = new URLClassLoader(urls, null);
- return loader;
- }
}