View Javadoc
1   /*
2    * Created on May 23, 2004
3    * 
4    * This library is free software; you can redistribute it and/or
5    * modify it under the terms of the GNU Lesser General Public
6    * License as published by the Free Software Foundation; either
7    * version 2.1 of the License, or (at your option) any later version.
8    * 
9    * This library is distributed in the hope that it will be useful,
10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12   * Lesser General Public License for more details.
13   * 
14   * Full GNU LGPL license terms : http://www.gnu.org/copyleft/lesser.txt
15   * 
16   * Project : iky-container
17   * Package : net.wmind.container.model
18   * Author : mchaplin@users.sourceforge.net
19   * 
20   */
21  package net.mchaplin.ioc.test;
22  
23  import junit.framework.TestCase;
24  import net.mchaplin.ioc.DefaultContainer;
25  
26  import org.apache.commons.logging.Log;
27  import org.apache.commons.logging.LogFactory;
28  
29  
30  /***
31   * Unit Tests for net.wmind.container.DefaultContainer
32   * 
33   * @author matthieu
34   *
35   * $Header: 
36   * $Revision: 
37   * $Date:
38   */
39  public class DefaultContainerTest extends TestCase {
40  
41      private transient Log logger = LogFactory.getLog(DefaultContainerTest.class);
42      private DefaultContainer defaultContainer = null;
43      private final static String sTestClassType = "java.lang.String";
44      private Class testClass = null;
45      private Object testObject = null;
46      
47      /*
48       * @see TestCase#setUp()
49       */
50      protected void setUp() throws Exception {
51          super.setUp();
52          //PersistentConfiguration ctx = new PersistentConfiguration();
53          defaultContainer = new DefaultContainer("test");
54          try {
55              testClass = Class.forName(sTestClassType);
56              defaultContainer.registerComponentImplementation(testClass);
57          } catch (ClassNotFoundException e) {
58              e.printStackTrace();
59          }
60      }
61  
62      /***
63       * Constructor for DefaultContainerTest.
64       * @param arg0
65       */
66      public DefaultContainerTest(String arg0) {
67          super(arg0);
68      }
69  
70      /*
71       * Class under test for void registerComponentImplementation(Class)
72       */
73      public void testRegisterComponentImplementationClass() {
74          defaultContainer.registerComponentImplementation(testClass);
75          testObject = defaultContainer.retrieveComponentInstance(testClass);
76          logger.debug("testObject type : "+testObject.getClass());
77          assertEquals(sTestClassType, testObject.getClass().getName());
78      }
79  
80      /*
81       * Class under test for void registerComponentImplementation(Class, String)
82       */
83      public void testRegisterComponentImplementationClassString() {
84         
85          defaultContainer.registerComponentImplementation(testClass, sTestClassType);
86          testObject = defaultContainer.retrieveComponentInstance(testClass);
87          logger.debug("testObject type : "+testObject.getClass());
88          assertEquals(sTestClassType, testObject.getClass().getName());
89      }
90  
91      /*
92       * Class under test for void registerComponentImplementation(Class)
93       */
94      public void testRegisterComponentImplementationClassboolean() {
95          defaultContainer.registerComponentImplementation(testClass);
96          testObject = defaultContainer.retrieveComponentInstance(testClass);
97          logger.debug("testObject type : "+testObject.getClass());
98          assertEquals(sTestClassType, testObject.getClass().getName());
99      }
100 
101     /*
102      * Class under test for void registerComponentImplementation(Class, String)
103      */
104     public void testRegisterComponentImplementationClassbooleanString() {
105         defaultContainer.registerComponentImplementation(testClass, sTestClassType);
106         testObject = defaultContainer.retrieveComponentInstance(testClass);
107         logger.debug("testObject type : "+testObject.getClass());
108         assertEquals(sTestClassType, testObject.getClass().getName());
109     }
110 
111 
112     /*
113      * Class under test for void registerComponentImplementation(Class, Class, String)
114      */
115     public void testRegisterComponentImplementationClassClassString() {
116     }
117 
118     /*
119      * Class under test for void registerComponentInstance(ComponentI)
120      */
121     public void testRegisterComponentInstanceComponentI() {
122     }
123 
124     /*
125      * Class under test for void registerComponentInstance(ComponentI, String)
126      */
127     public void testRegisterComponentInstanceComponentIString() {
128     }
129 
130     /*
131      * Class under test for void retrieveComponentInstance(Class)
132      */
133     public void testRetrieveComponentInstanceClass() {
134         testObject = defaultContainer.retrieveComponentInstance(testClass);
135         assertEquals(testObject.getClass().getName(), testClass.getName());
136     }
137 
138     /*
139      * Class under test for void retrieveComponentInstance(String)
140      */
141     public void testRetrieveComponentInstanceString() {
142         testObject = defaultContainer.retrieveComponentInstance(sTestClassType);
143         assertEquals(testObject.getClass().getName(), sTestClassType);
144     }
145 
146     /*
147      * Class under test for List retrieveComponentInstances(String)
148      */
149     public void testRetrieveComponentInstancesString() {
150 
151     }
152 
153     /*
154      * Class under test for void retrieveComponentInstances()
155      */
156     public void testRetrieveComponentInstances() {
157     }
158 
159     public void testMakeComponentAvailable() {
160     }
161 
162     public void testUnregisterComponentInstance() {
163     }
164 
165     public void testPrintState() {
166     }
167 
168 }