org.jboss.kernel.spi.registry.KernelRegistry registry = bootstrap().getRegistry();
SimpleRegistryFactory factory1 = new SimpleRegistryFactory();
Object testObject1 = new Object();
factory1.entries.put("Name1", testObject1);
KernelRegistryEntry factoryEntry1 = makeEntry(factory1);
registry.registerEntry("Factory1", factoryEntry1);
SimpleRegistryFactory factory2 = new SimpleRegistryFactory();
Object testObject2 = new Object();
Object testObject3 = new Object();
factory2.entries.put("Name1", testObject2);
factory2.entries.put("Name2", testObject3);
KernelRegistryEntry factoryEntry2 = makeEntry(factory2);
registry.registerEntry("Factory2", factoryEntry2);
KernelRegistryEntry result = registry.getEntry("Name1");
assertNotNull(result);
Object target = result.getTarget();
assertNotNull(target);
assertTrue("Should be the object from the first factory", testObject1 == target);
result = registry.getEntry("Name2");
assertNotNull(result);
target = result.getTarget();
assertNotNull(target);
assertTrue("Should be the object from the second factory", testObject3 == target);
registry.unregisterEntry("Factory1");
result = registry.getEntry("Name1");
assertNotNull(result);
target = result.getTarget();
assertNotNull(target);
assertTrue("Should be the object from the second factory", testObject2 == target);
registry.registerEntry("Factory1", factoryEntry1);
result = registry.getEntry("Name1");
assertNotNull(result);
target = result.getTarget();
assertNotNull(target);
assertTrue("Should be the object from the second factory", testObject2 == target);
registry.unregisterEntry("Factory1");
registry.unregisterEntry("Factory2");