1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
49
50 protected void setUp() throws Exception {
51 super.setUp();
52
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
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
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
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
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
114
115 public void testRegisterComponentImplementationClassClassString() {
116 }
117
118
119
120
121 public void testRegisterComponentInstanceComponentI() {
122 }
123
124
125
126
127 public void testRegisterComponentInstanceComponentIString() {
128 }
129
130
131
132
133 public void testRetrieveComponentInstanceClass() {
134 testObject = defaultContainer.retrieveComponentInstance(testClass);
135 assertEquals(testObject.getClass().getName(), testClass.getName());
136 }
137
138
139
140
141 public void testRetrieveComponentInstanceString() {
142 testObject = defaultContainer.retrieveComponentInstance(sTestClassType);
143 assertEquals(testObject.getClass().getName(), sTestClassType);
144 }
145
146
147
148
149 public void testRetrieveComponentInstancesString() {
150
151 }
152
153
154
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 }