001    package org.picocontainer.containers;
002    
003    import static org.junit.Assert.assertSame;
004    import static org.junit.Assert.assertEquals;
005    
006    import org.junit.Test;
007    import org.picocontainer.DefaultPicoContainer;
008    
009    /**
010     * test capabilities of system properties providing container. 
011     * @author Konstantin Pribluda
012     *
013     */
014    public class SystemPropertiesPicoContainerTestCase {
015    
016            
017            /**
018             * all the content of system properties shall be made available
019             *  through this contaienr. 
020             */
021            @Test public void testThatAllSystemPropertiesAreCopied() {
022                    SystemPropertiesPicoContainer container = new SystemPropertiesPicoContainer();          
023                    for(Object key: System.getProperties().keySet()) {
024                            assertSame(System.getProperties().get(key),container.getComponent(key));
025                    }
026            }
027    
028        @Test public void testRepresentationOfContainerTree() {
029            SystemPropertiesPicoContainer parent = new SystemPropertiesPicoContainer();
030            parent.setName("parent");
031            DefaultPicoContainer child = new DefaultPicoContainer(parent);
032            child.setName("child");
033                    child.addComponent("hello", "goodbye");
034            child.addComponent("bonjour", "aurevior");
035            int num = System.getProperties().size(); 
036            assertEquals("child:2<I<D<parent:"+num+"<|", child.toString());
037        }
038    
039    
040    }