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();
((MutableAddonRepository) dep4.getRepository()).disable(dep4Id);
Addons.waitUntilStopped(dep4, 10, TimeUnit.SECONDS);
Addons.waitUntilStarted(dep1, 10, TimeUnit.SECONDS);
Assert.assertNotNull(dep1.getClassLoader());
Assert.assertNotEquals(dep1Classloader, dep1.getClassLoader());
dep1Classloader = dep1.getClassLoader();
Assert.assertNotNull(dep2.getClassLoader());
Assert.assertNotEquals(dep2Classloader, dep2.getClassLoader());
dep2Classloader = dep2.getClassLoader();
Assert.assertNotNull(dep3.getClassLoader());
Assert.assertNotEquals(dep3Classloader, dep3.getClassLoader());
dep3Classloader = dep3.getClassLoader();
((MutableAddonRepository) repository).enable(dep4Id);
Addons.waitUntilStarted(dep4, 10, TimeUnit.SECONDS);
Thread.sleep(1000);
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());
}