}
@Test
public void testAddonsSharedIfSubgraphEquivalent() throws IOException, InterruptedException, TimeoutException
{
Furnace furnace = FurnaceFactory.getInstance();
AddonRepository left = furnace.addRepository(AddonRepositoryMode.MUTABLE, repodir1);
AddonRepository right = furnace.addRepository(AddonRepositoryMode.MUTABLE, repodir2);
AddonDependencyResolver resolver = new MavenAddonDependencyResolver();
AddonManager manager = new AddonManagerImpl(furnace, resolver);
AddonId no_dep = AddonId.from("test:no_dep", "1.0.0.Final");
AddonId one_dep = AddonId.from("test:one_dep", "1.0.0.Final");
AddonId one_dep_a = AddonId.from("test:one_dep_a", "1.0.0.Final");
AddonId no_dep2 = AddonId.from("test:no_dep", "2.0.0.Final");
Assert.assertFalse(left.isDeployed(one_dep_a));
Assert.assertFalse(left.isDeployed(no_dep));
Assert.assertFalse(left.isDeployed(no_dep2));
Assert.assertFalse(left.isDeployed(one_dep));
Assert.assertFalse(right.isDeployed(one_dep_a));
Assert.assertFalse(right.isDeployed(no_dep));
Assert.assertFalse(right.isDeployed(no_dep2));
Assert.assertFalse(right.isDeployed(one_dep));
manager.install(no_dep, left).perform();
manager.deploy(one_dep, left).perform();
manager.deploy(one_dep_a, right).perform();
manager.deploy(no_dep2, right).perform();
Assert.assertFalse(left.isDeployed(one_dep_a));
Assert.assertFalse(right.isDeployed(one_dep));
Assert.assertFalse(right.isDeployed(no_dep));
Assert.assertFalse(left.isDeployed(no_dep2));
Assert.assertTrue(left.isDeployed(no_dep));
Assert.assertTrue(left.isDeployed(one_dep));
Assert.assertTrue(right.isDeployed(one_dep_a));
Assert.assertTrue(right.isDeployed(no_dep2));
ConfigurationScanListener listener = new ConfigurationScanListener();
ListenerRegistration<ContainerLifecycleListener> registration = furnace.addContainerLifecycleListener(listener);
furnace.startAsync();
while (!listener.isConfigurationScanned())
Thread.sleep(100);
AddonRegistry registry = furnace.getAddonRegistry();
Addons.waitUntilStarted(registry.getAddon(one_dep_a), 10, TimeUnit.SECONDS);
AddonRegistry leftRegistry = furnace.getAddonRegistry(left);
Assert.assertNotNull(leftRegistry.getAddon(no_dep));
Assert.assertTrue(registry.getAddon(no_dep).getStatus().isMissing());
Assert.assertNotNull(registry.getAddon(no_dep2));
Assert.assertTrue(leftRegistry.getAddon(no_dep2).getStatus().isMissing());
registration.removeListener();
furnace.stop();
}