Rev 92 | Rev 97 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 92 | Rev 93 | ||
---|---|---|---|
Line 28... | Line 28... | ||
28 | }
|
28 | }
|
29 | 29 | ||
30 | @Test |
30 | @Test |
31 | public void testFactory() { |
31 | public void testFactory() { |
32 | 32 | ||
33 |
|
33 | Container container = new MentaContainer(); |
34 | 34 | ||
- | 35 | Factory c1 = new ClassFactory(container, User.class).addInitValue("saoj"); |
|
- | 36 | ||
35 | Factory c2 = new ClassFactory(User.class).addPropertyValue("username", "soliveira"); |
37 | Factory c2 = new ClassFactory(container, User.class).addPropertyValue("username", "soliveira"); |
36 | 38 | ||
37 | User u1 = c1.getInstance(); |
39 | User u1 = c1.getInstance(); |
38 | 40 | ||
39 | User u2 = c2.getInstance(); |
41 | User u2 = c2.getInstance(); |
40 | 42 | ||
Line 114... | Line 116... | ||
114 | }
|
116 | }
|
115 | 117 | ||
116 | @Test |
118 | @Test |
117 | public void testPrimitivePropertyValue1() { |
119 | public void testPrimitivePropertyValue1() { |
118 | 120 | ||
- | 121 | Container container = new MentaContainer(); |
|
- | 122 | ||
119 | Factory f = new ClassFactory(TestObj2.class).addPropertyValue("integer", 20); |
123 | Factory f = new ClassFactory(container, TestObj2.class).addPropertyValue("integer", 20); |
120 | 124 | ||
121 | TestObj2 o = f.getInstance(); |
125 | TestObj2 o = f.getInstance(); |
122 | 126 | ||
123 | Assert.assertEquals(20, o.x); |
127 | Assert.assertEquals(20, o.x); |
124 | }
|
128 | }
|
125 | 129 | ||
126 | @Test |
130 | @Test |
127 | public void testPrimitivePropertyValue2() { |
131 | public void testPrimitivePropertyValue2() { |
128 | 132 | ||
- | 133 | Container container = new MentaContainer(); |
|
- | 134 | ||
129 | Factory f = new ClassFactory(TestObj2.class).addPropertyValue("integer", new Integer(20)); |
135 | Factory f = new ClassFactory(container, TestObj2.class).addPropertyValue("integer", new Integer(20)); |
130 | 136 | ||
131 | TestObj2 o = f.getInstance(); |
137 | TestObj2 o = f.getInstance(); |
132 | 138 | ||
133 | Assert.assertEquals(20, o.x); |
139 | Assert.assertEquals(20, o.x); |
134 | }
|
140 | }
|
Line 145... | Line 151... | ||
145 | }
|
151 | }
|
146 | 152 | ||
147 | @Test |
153 | @Test |
148 | public void testPrimitivePropertyValue3() { |
154 | public void testPrimitivePropertyValue3() { |
149 | 155 | ||
- | 156 | Container container = new MentaContainer(); |
|
- | 157 | ||
150 | Factory f = new ClassFactory(TestObj2_1.class).addPropertyValue("integer", 20); |
158 | Factory f = new ClassFactory(container, TestObj2_1.class).addPropertyValue("integer", 20); |
151 | 159 | ||
152 | TestObj2_1 o = f.getInstance(); |
160 | TestObj2_1 o = f.getInstance(); |
153 | 161 | ||
154 | Assert.assertEquals(20, o.x); |
162 | Assert.assertEquals(20, o.x); |
155 | }
|
163 | }
|
156 | 164 | ||
157 | @Test |
165 | @Test |
158 | public void testPrimitivePropertyValue4() { |
166 | public void testPrimitivePropertyValue4() { |
159 | 167 | ||
- | 168 | Container container = new MentaContainer(); |
|
- | 169 | ||
160 | Factory f = new ClassFactory(TestObj2_1.class).addPropertyValue("integer", new Integer(20)); |
170 | Factory f = new ClassFactory(container, TestObj2_1.class).addPropertyValue("integer", new Integer(20)); |
161 | 171 | ||
162 | TestObj2_1 o = f.getInstance(); |
172 | TestObj2_1 o = f.getInstance(); |
163 | 173 | ||
164 | Assert.assertEquals(20, o.x); |
174 | Assert.assertEquals(20, o.x); |
165 | }
|
175 | }
|
Line 175... | Line 185... | ||
175 | }
|
185 | }
|
176 | 186 | ||
177 | @Test |
187 | @Test |
178 | public void testPrimitiveInitValue1() { |
188 | public void testPrimitiveInitValue1() { |
179 | 189 | ||
- | 190 | Container container = new MentaContainer(); |
|
- | 191 | ||
180 | Factory f = new ClassFactory(TestObj3.class).addInitValue(20); |
192 | Factory f = new ClassFactory(container, TestObj3.class).addInitValue(20); |
181 | 193 | ||
182 | TestObj3 o = f.getInstance(); |
194 | TestObj3 o = f.getInstance(); |
183 | 195 | ||
184 | Assert.assertEquals(20, o.x); |
196 | Assert.assertEquals(20, o.x); |
185 | }
|
197 | }
|
Line 194... | Line 206... | ||
194 | }
|
206 | }
|
195 | 207 | ||
196 | @Test |
208 | @Test |
197 | public void testPrimitiveInitValue2() { |
209 | public void testPrimitiveInitValue2() { |
198 | 210 | ||
- | 211 | Container container = new MentaContainer(); |
|
- | 212 | ||
199 | Factory f = new ClassFactory(TestObj3_1.class).addInitValue(20); |
213 | Factory f = new ClassFactory(container, TestObj3_1.class).addInitValue(20); |
200 | 214 | ||
201 | TestObj3_1 o = f.getInstance(); |
215 | TestObj3_1 o = f.getInstance(); |
202 | 216 | ||
203 | Assert.assertEquals(20, o.x); |
217 | Assert.assertEquals(20, o.x); |
204 | }
|
218 | }
|
Line 215... | Line 229... | ||
215 | }
|
229 | }
|
216 | 230 | ||
217 | @Test |
231 | @Test |
218 | public void testPrimitiveInitValue3() { |
232 | public void testPrimitiveInitValue3() { |
219 | 233 | ||
- | 234 | Container container = new MentaContainer(); |
|
- | 235 | ||
220 | Factory f = new ClassFactory(TestObj3_2.class).addInitValue(20).addInitPrimitive(30L); |
236 | Factory f = new ClassFactory(container, TestObj3_2.class).addInitValue(20).addInitPrimitive(30L); |
221 | 237 | ||
222 | TestObj3_2 o = f.getInstance(); |
238 | TestObj3_2 o = f.getInstance(); |
223 | 239 | ||
224 | Assert.assertEquals(20, o.x); |
240 | Assert.assertEquals(20, o.x); |
225 | Assert.assertEquals(30L, o.l); |
241 | Assert.assertEquals(30L, o.l); |
Line 241... | Line 257... | ||
241 | }
|
257 | }
|
242 | 258 | ||
243 | @Test |
259 | @Test |
244 | public void testMixInitValues() { |
260 | public void testMixInitValues() { |
245 | 261 | ||
- | 262 | Container container = new MentaContainer(); |
|
- | 263 | ||
246 | Factory f = new ClassFactory(TestObj4.class).addInitPrimitive(20).addInitValue("hello").addInitValue(20L).addInitPrimitive(20L); |
264 | Factory f = new ClassFactory(container, TestObj4.class).addInitPrimitive(20).addInitValue("hello").addInitValue(20L).addInitPrimitive(20L); |
247 | 265 | ||
248 | TestObj4 o = f.getInstance(); |
266 | TestObj4 o = f.getInstance(); |
249 | 267 | ||
250 | Assert.assertEquals(20, o.x); |
268 | Assert.assertEquals(20, o.x); |
251 | Assert.assertEquals("hello", o.s); |
269 | Assert.assertEquals("hello", o.s); |