@Test
public void testWhitelistLookupConvertsClassTypes() throws Exception
{
ClassLoader thisLoader = ClassLoaderAdapterWhitelistLoaderLookupTest.class.getClassLoader();
AddonRegistry registry = LocalServices.getFurnace(getClass().getClassLoader())
.getAddonRegistry();
ClassLoader loader1 = registry.getAddon(AddonId.from("dep1", "1")).getClassLoader();
ClassLoader loader2 = registry.getAddon(AddonId.from("dep2", "1")).getClassLoader();
ClassLoader loader3 = registry.getAddon(AddonId.from("dep3", "1")).getClassLoader();
AddonRegistry enhancedRegistry = ClassLoaderAdapterBuilder.callingLoader(thisLoader)
.delegateLoader(loader2)
.whitelist(new HashSet<>(Arrays.asList(loader1, loader3))).enhance(registry);
Assert.assertNotSame(MockContextConsumer.class, registry.getServices(MockContextConsumer.class.getName()).get()
.getClass());
Imported<MockContextConsumer> importedByName = enhancedRegistry.getServices(MockContextConsumer.class.getName());
Assert.assertFalse(importedByName.isUnsatisfied());
MockContextConsumer consumerByName = importedByName.get();
Assert.assertSame(MockContextConsumer.class, consumerByName.getClass().getSuperclass());
Imported<MockContextConsumer> importedByClass = enhancedRegistry.getServices(MockContextConsumer.class);
Assert.assertFalse(importedByClass.isUnsatisfied());
MockContextConsumer consumerByClass = importedByClass.get();
Assert.assertNotSame(MockContextConsumer.class, consumerByClass.getClass());
}