}
@Test
public void testServiceWithExpectedObjectsDifferentClassLoaders() throws Exception
{
AddonRegistry addonRegistry = SimpleContainer.getFurnace(this.getClass().getClassLoader()).getAddonRegistry();
AddonId depOneId = AddonId.from("test:dep1", "1");
AddonId depTwoId = AddonId.from("test:dep2", "2");
Addon depOne = addonRegistry.getAddon(depOneId);
Addon depTwo = addonRegistry.getAddon(depTwoId);
ServiceRegistry depOneServiceRegistry = depOne.getServiceRegistry();
ServiceRegistry depTwoServiceRegistry = depTwo.getServiceRegistry();
Assert.assertFalse(depOneServiceRegistry.hasService(Aa.class));
Assert.assertFalse(depOneServiceRegistry.hasService(Aa.class.getName()));
Assert.assertFalse(depTwoServiceRegistry.hasService(Aa.class));
Assert.assertFalse(depTwoServiceRegistry.hasService(Aa.class.getName()));
Assert.assertFalse(depOneServiceRegistry.hasService(loadClass(BB.class, depTwo.getClassLoader())));
Assert.assertTrue(depOneServiceRegistry.hasService(BB.class.getName()));
Assert.assertTrue(depTwoServiceRegistry.hasService(loadClass(BB.class, depTwo.getClassLoader())));
Assert.assertTrue(depTwoServiceRegistry.hasService(BB.class.getName()));
Assert.assertNotNull(depTwoServiceRegistry.getExportedInstance(BB.class.getName()));
Imported<BB> services = addonRegistry.getServices(BB.class);
Assert.assertFalse("Imported<BB> should have been satisfied", services.isUnsatisfied());
Assert.assertFalse("Imported<BB> should not have been ambiguous", services.isAmbiguous());
Iterator<BB> iterator2 = services.iterator();
Assert.assertTrue(iterator2.hasNext());
Assert.assertThat(iterator2.next(), is(instanceOf(BB.class)));