MentaContainer

Compare Revisions

Ignore whitespace Rev 93 → Rev 92

/trunk/src/test/java/org/mentacontainer/impl/ClassFactoryTest.java
30,12 → 30,10
@Test
public void testFactory() {
Container container = new MentaContainer();
Factory c1 = new ClassFactory(User.class).addInitValue("saoj");
Factory c1 = new ClassFactory(container, User.class).addInitValue("saoj");
Factory c2 = new ClassFactory(User.class).addPropertyValue("username", "soliveira");
Factory c2 = new ClassFactory(container, User.class).addPropertyValue("username", "soliveira");
User u1 = c1.getInstance();
User u2 = c2.getInstance();
118,10 → 116,8
@Test
public void testPrimitivePropertyValue1() {
Container container = new MentaContainer();
Factory f = new ClassFactory(TestObj2.class).addPropertyValue("integer", 20);
Factory f = new ClassFactory(container, TestObj2.class).addPropertyValue("integer", 20);
TestObj2 o = f.getInstance();
Assert.assertEquals(20, o.x);
130,10 → 126,8
@Test
public void testPrimitivePropertyValue2() {
Container container = new MentaContainer();
Factory f = new ClassFactory(TestObj2.class).addPropertyValue("integer", new Integer(20));
Factory f = new ClassFactory(container, TestObj2.class).addPropertyValue("integer", new Integer(20));
TestObj2 o = f.getInstance();
Assert.assertEquals(20, o.x);
153,10 → 147,8
@Test
public void testPrimitivePropertyValue3() {
Container container = new MentaContainer();
Factory f = new ClassFactory(TestObj2_1.class).addPropertyValue("integer", 20);
Factory f = new ClassFactory(container, TestObj2_1.class).addPropertyValue("integer", 20);
TestObj2_1 o = f.getInstance();
Assert.assertEquals(20, o.x);
165,10 → 157,8
@Test
public void testPrimitivePropertyValue4() {
Container container = new MentaContainer();
Factory f = new ClassFactory(TestObj2_1.class).addPropertyValue("integer", new Integer(20));
Factory f = new ClassFactory(container, TestObj2_1.class).addPropertyValue("integer", new Integer(20));
TestObj2_1 o = f.getInstance();
Assert.assertEquals(20, o.x);
187,10 → 177,8
@Test
public void testPrimitiveInitValue1() {
Container container = new MentaContainer();
Factory f = new ClassFactory(TestObj3.class).addInitValue(20);
Factory f = new ClassFactory(container, TestObj3.class).addInitValue(20);
TestObj3 o = f.getInstance();
Assert.assertEquals(20, o.x);
207,10 → 195,8
@Test
public void testPrimitiveInitValue2() {
Container container = new MentaContainer();
Factory f = new ClassFactory(container, TestObj3_1.class).addInitValue(20);
Factory f = new ClassFactory(TestObj3_1.class).addInitValue(20);
TestObj3_1 o = f.getInstance();
231,10 → 217,8
@Test
public void testPrimitiveInitValue3() {
Container container = new MentaContainer();
Factory f = new ClassFactory(TestObj3_2.class).addInitValue(20).addInitPrimitive(30L);
Factory f = new ClassFactory(container, TestObj3_2.class).addInitValue(20).addInitPrimitive(30L);
TestObj3_2 o = f.getInstance();
Assert.assertEquals(20, o.x);
259,10 → 243,8
@Test
public void testMixInitValues() {
Container container = new MentaContainer();
Factory f = new ClassFactory(TestObj4.class).addInitPrimitive(20).addInitValue("hello").addInitValue(20L).addInitPrimitive(20L);
Factory f = new ClassFactory(container, TestObj4.class).addInitPrimitive(20).addInitValue("hello").addInitValue(20L).addInitPrimitive(20L);
TestObj4 o = f.getInstance();
Assert.assertEquals(20, o.x);