use of org.nutz.ioc.Ioc in project nutz by nutzam.
the class SimpleJsonIocTest method test_refer_self.
@Test
public void test_refer_self() {
Ioc ioc = I(J("fox", "name:'Fox',another:{refer:'fox'}"));
Animal f = ioc.get(Animal.class, "fox");
assertEquals("Fox", f.getName());
assertTrue(f == f.getAnother());
}
use of org.nutz.ioc.Ioc in project nutz by nutzam.
the class SimpleJsonIocTest method test_get_ioc_self.
@Test
public void test_get_ioc_self() {
Ioc ioc = I(J("iocV", "type:'org.nutz.ioc.json.pojo.IocSelf',fields:{ioc:{refer : '$iOc'}}"));
assertEquals(ioc, ioc.get(IocSelf.class, "iocV").getIoc());
}
use of org.nutz.ioc.Ioc in project nutz by nutzam.
the class SimpleJsonIocTest method test_muilt_parent.
@Test
public void test_muilt_parent() {
Ioc ioc = I(J("fox", "name:'P',age:10"), J("f2", "parent:'fox'"), J("f3", "parent:'f2'"));
Animal f3 = ioc.get(Animal.class, "f3");
assertEquals(10, f3.getAge());
}
use of org.nutz.ioc.Ioc in project nutz by nutzam.
the class SimpleJsonIocTest method test_parent.
@Test
public void test_parent() {
Ioc ioc = I(J("fox", "name:'P',age:10"), J("f2", "parent:'fox',fields:{age:5}"));
Animal fox = ioc.get(Animal.class, "fox");
assertEquals("P", fox.getName());
assertEquals(10, fox.getAge());
Animal f2 = ioc.get(Animal.class, "f2");
assertEquals("P", f2.getName());
assertEquals(5, f2.getAge());
}
use of org.nutz.ioc.Ioc in project nutz by nutzam.
the class SimpleJsonIocTest method test_null_json_file.
@Test
public void test_null_json_file() {
IocLoader loader = new JsonLoader("org/nutz/ioc/json/empty.js");
Ioc ioc = new NutIoc(loader);
assertEquals(0, ioc.getNames().length);
ioc.depose();
}
Aggregations