public void testRegistrationByNameAndClassWithResolving() throws Exception { DefaultPicoContainer pico = new DefaultPicoContainer(); pico.addComponent(List.class, new ArrayList()); pico.addComponent("one", Webster.class); pico.addComponent("two", SimpleTouchable.class); assertEquals("Wrong number of comps in the internals", 3, pico.getComponents().size()); assertNotNull("Object one the same", pico.getComponent("one")); assertNotNull("Object two the same", pico.getComponent("two")); assertNull("Lookup of unknown key should return null", pico.getComponent("unknown")); }
// TODO - move public void testRegistrationByName() throws Exception { DefaultPicoContainer pico = new DefaultPicoContainer(); Webster one = new Webster(new ArrayList()); Touchable two = new SimpleTouchable(); pico.addComponent("one", one); pico.addComponent("two", two); assertEquals("Wrong number of comps in the internals", 2, pico.getComponents().size()); assertEquals("Looking up one Touchable", one, pico.getComponent("one")); assertEquals("Looking up two Touchable", two, pico.getComponent("two")); assertTrue("Object one the same", one == pico.getComponent("one")); assertTrue("Object two the same", two == pico.getComponent("two")); assertEquals("Lookup of unknown key should return null", null, pico.getComponent("unknown")); }