AddonId dep1Id = AddonId.from("dep1", "1");
AddonId dep2Id = AddonId.from("dep2", "2");
AddonId dep3Id = AddonId.from("dep3", "3");
AddonId dep4Id = AddonId.from("dep4", "4");
Addon dep1 = registry.getAddon(dep1Id);
Addon dep2 = registry.getAddon(dep2Id);
Addon dep3 = registry.getAddon(dep3Id);
Addon dep4 = registry.getAddon(dep4Id);
ClassLoader dep1Classloader = dep1.getClassLoader();
ClassLoader dep2Classloader = dep2.getClassLoader();
ClassLoader dep3Classloader = dep3.getClassLoader();
ClassLoader dep4Classloader = dep4.getClassLoader();
Addons.waitUntilStarted(dep1, 10, TimeUnit.SECONDS);
Addons.waitUntilStarted(dep2, 10, TimeUnit.SECONDS);
Addons.waitUntilStarted(dep3, 10, TimeUnit.SECONDS);
Addons.waitUntilStarted(dep4, 10, TimeUnit.SECONDS);
((MutableAddonRepository) repository).disable(dep4Id);
Addons.waitUntilStopped(dep1, 10, TimeUnit.SECONDS);
((MutableAddonRepository) repository).enable(dep4Id);
Addons.waitUntilStarted(dep1, 10, TimeUnit.SECONDS);
/*
* Verify existing references are updated.
*/
Assert.assertNotEquals(dep1Classloader, dep1.getClassLoader());
Assert.assertNotEquals(dep1Classloader.toString(), dep1.getClassLoader().toString());
Assert.assertNotEquals(dep2Classloader, dep2.getClassLoader());
Assert.assertNotEquals(dep2Classloader.toString(), dep2.getClassLoader().toString());
Assert.assertNotEquals(dep3Classloader, dep3.getClassLoader());
Assert.assertNotEquals(dep3Classloader.toString(), dep3.getClassLoader().toString());
Assert.assertNotEquals(dep4Classloader, dep4.getClassLoader());
Assert.assertNotEquals(dep4Classloader.toString(), dep4.getClassLoader().toString());
/*
* Now retrieving fresh references.
*/
Assert.assertNotEquals(dep1Classloader, registry.getAddon(dep1Id).getClassLoader());