MentaContainer

Compare Revisions

Ignore whitespace Rev 142 → Rev 143

/trunk/src/test/java/org/mentacontainer/impl/GenericFactoryTest.java
4,7 → 4,7
 
import org.junit.Test;
import org.mentacontainer.Container;
import org.mentacontainer.Creator;
import org.mentacontainer.Factory;
 
public class GenericFactoryTest {
25,7 → 25,7
Container c = new MentaContainer();
// giveMeSomething => method that will be called to return object
Creator<String> generic = new GenericFactory<String>(factory, "giveMeSomething");
Factory<String> generic = new GenericFactory<String>(factory, "giveMeSomething");
c.ioc("myFactory", generic);
/trunk/src/test/java/org/mentacontainer/impl/WrapperFactoryTest.java
4,7 → 4,7
 
import org.junit.Test;
import org.mentacontainer.Container;
import org.mentacontainer.Creator;
import org.mentacontainer.Factory;
 
public class WrapperFactoryTest {
13,7 → 13,7
String s = new String("saoj");
Creator<String> ic = new WrapperFactory<String>(s);
Factory<String> ic = new WrapperFactory<String>(s);
Container c = new MentaContainer();
/trunk/src/test/java/org/mentacontainer/impl/ClassFactoryTest.java
3,7 → 3,7
import junit.framework.Assert;
 
import org.junit.Test;
import org.mentacontainer.Creator;
import org.mentacontainer.Factory;
 
public class ClassFactoryTest {
31,13 → 31,13
MentaContainer container = new MentaContainer();
Creator<User> c1 = new ClassFactory<User>(container, User.class).addInitValue("saoj");
Factory<User> c1 = new ClassFactory<User>(container, User.class).addInitValue("saoj");
Creator<User> c2 = new ClassFactory<User>(container, User.class).addPropertyValue("username", "soliveira");
Factory<User> c2 = new ClassFactory<User>(container, User.class).addPropertyValue("username", "soliveira");
User u1 = c1.createInstance();
User u1 = c1.getInstance();
User u2 = c2.createInstance();
User u2 = c2.getInstance();
Assert.assertTrue(u1 != u2);
66,10 → 66,10
c.ioc("myString", String.class).addInitValue("hello");
Creator<TestObj1> c1 = new ClassFactory<TestObj1>(c, TestObj1.class).addConstructorDependency("myString").addInitValue(20).addInitValue(30000L)
Factory<TestObj1> c1 = new ClassFactory<TestObj1>(c, TestObj1.class).addConstructorDependency("myString").addInitValue(20).addInitValue(30000L)
.addInitValue(new User("saoj"));
TestObj1 o = c1.createInstance();
TestObj1 o = c1.getInstance();
Assert.assertEquals("hello", o.s);
Assert.assertEquals(20, o.i);
95,9 → 95,9
c.ioc("myString", String.class).addInitValue("hello");
Creator<TestObj1_1> c1 = new ClassFactory<TestObj1_1>(c, TestObj1_1.class).addPropertyDependency("s", "myString").addPropertyValue("i", 30);
Factory<TestObj1_1> c1 = new ClassFactory<TestObj1_1>(c, TestObj1_1.class).addPropertyDependency("s", "myString").addPropertyValue("i", 30);
TestObj1_1 o = c1.createInstance();
TestObj1_1 o = c1.getInstance();
Assert.assertEquals("hello", o.s);
Assert.assertEquals(30, o.i);
119,9 → 119,9
MentaContainer container = new MentaContainer();
Creator<TestObj2> f = new ClassFactory<TestObj2>(container, TestObj2.class).addPropertyValue("integer", 20);
Factory<TestObj2> f = new ClassFactory<TestObj2>(container, TestObj2.class).addPropertyValue("integer", 20);
TestObj2 o = f.createInstance();
TestObj2 o = f.getInstance();
Assert.assertEquals(20, o.x);
}
131,9 → 131,9
MentaContainer container = new MentaContainer();
Creator<TestObj2> f = new ClassFactory<TestObj2>(container, TestObj2.class).addPropertyValue("integer", new Integer(20));
Factory<TestObj2> f = new ClassFactory<TestObj2>(container, TestObj2.class).addPropertyValue("integer", new Integer(20));
TestObj2 o = f.createInstance();
TestObj2 o = f.getInstance();
Assert.assertEquals(20, o.x);
}
154,9 → 154,9
MentaContainer container = new MentaContainer();
Creator<TestObj2_1> f = new ClassFactory<TestObj2_1>(container, TestObj2_1.class).addPropertyValue("integer", 20);
Factory<TestObj2_1> f = new ClassFactory<TestObj2_1>(container, TestObj2_1.class).addPropertyValue("integer", 20);
TestObj2_1 o = f.createInstance();
TestObj2_1 o = f.getInstance();
Assert.assertEquals(20, o.x);
}
166,9 → 166,9
MentaContainer container = new MentaContainer();
Creator<TestObj2_1>f = new ClassFactory<TestObj2_1>(container, TestObj2_1.class).addPropertyValue("integer", new Integer(20));
Factory<TestObj2_1>f = new ClassFactory<TestObj2_1>(container, TestObj2_1.class).addPropertyValue("integer", new Integer(20));
TestObj2_1 o = f.createInstance();
TestObj2_1 o = f.getInstance();
Assert.assertEquals(20, o.x);
}
188,9 → 188,9
MentaContainer container = new MentaContainer();
Creator<TestObj3> f = new ClassFactory<TestObj3>(container, TestObj3.class).addInitValue(20);
Factory<TestObj3> f = new ClassFactory<TestObj3>(container, TestObj3.class).addInitValue(20);
TestObj3 o = f.createInstance();
TestObj3 o = f.getInstance();
Assert.assertEquals(20, o.x);
}
209,9 → 209,9
MentaContainer container = new MentaContainer();
Creator<TestObj3_1> f = new ClassFactory<TestObj3_1>(container, TestObj3_1.class).addInitValue(20);
Factory<TestObj3_1> f = new ClassFactory<TestObj3_1>(container, TestObj3_1.class).addInitValue(20);
TestObj3_1 o = f.createInstance();
TestObj3_1 o = f.getInstance();
Assert.assertEquals(20, o.x);
}
232,9 → 232,9
MentaContainer container = new MentaContainer();
Creator<TestObj3_2> f = new ClassFactory<TestObj3_2>(container, TestObj3_2.class).addInitValue(20).addInitPrimitive(30L);
Factory<TestObj3_2> f = new ClassFactory<TestObj3_2>(container, TestObj3_2.class).addInitValue(20).addInitPrimitive(30L);
TestObj3_2 o = f.createInstance();
TestObj3_2 o = f.getInstance();
Assert.assertEquals(20, o.x);
Assert.assertEquals(30L, o.l);
260,9 → 260,9
MentaContainer container = new MentaContainer();
Creator<TestObj4> f = new ClassFactory<TestObj4>(container, TestObj4.class).addInitPrimitive(20).addInitValue("hello").addInitValue(20L).addInitPrimitive(20L);
Factory<TestObj4> f = new ClassFactory<TestObj4>(container, TestObj4.class).addInitPrimitive(20).addInitValue("hello").addInitValue(20L).addInitPrimitive(20L);
TestObj4 o = f.createInstance();
TestObj4 o = f.getInstance();
Assert.assertEquals(20, o.x);
Assert.assertEquals("hello", o.s);
280,9 → 280,9
MentaContainer container = new MentaContainer();
Creator<TestObj22> f = new ClassFactory<TestObj22>(container, TestObj22.class);
Factory<TestObj22> f = new ClassFactory<TestObj22>(container, TestObj22.class);
TestObj22 o = f.createInstance();
TestObj22 o = f.getInstance();
Assert.assertNotNull(o);