Search in sources :

Example 1 with Ioc

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());
}
Also used : Animal(org.nutz.ioc.json.pojo.Animal) Ioc(org.nutz.ioc.Ioc) NutIoc(org.nutz.ioc.impl.NutIoc) Test(org.junit.Test)

Example 2 with Ioc

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());
}
Also used : Ioc(org.nutz.ioc.Ioc) NutIoc(org.nutz.ioc.impl.NutIoc) Test(org.junit.Test)

Example 3 with Ioc

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());
}
Also used : Animal(org.nutz.ioc.json.pojo.Animal) Ioc(org.nutz.ioc.Ioc) NutIoc(org.nutz.ioc.impl.NutIoc) Test(org.junit.Test)

Example 4 with Ioc

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());
}
Also used : Animal(org.nutz.ioc.json.pojo.Animal) Ioc(org.nutz.ioc.Ioc) NutIoc(org.nutz.ioc.impl.NutIoc) Test(org.junit.Test)

Example 5 with Ioc

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();
}
Also used : NutIoc(org.nutz.ioc.impl.NutIoc) IocLoader(org.nutz.ioc.IocLoader) JsonLoader(org.nutz.ioc.loader.json.JsonLoader) Ioc(org.nutz.ioc.Ioc) NutIoc(org.nutz.ioc.impl.NutIoc) Test(org.junit.Test)

Aggregations

Ioc (org.nutz.ioc.Ioc)35 NutIoc (org.nutz.ioc.impl.NutIoc)29 Test (org.junit.Test)27 Animal (org.nutz.ioc.json.pojo.Animal)15 JsonLoader (org.nutz.ioc.loader.json.JsonLoader)6 Ioc2 (org.nutz.ioc.Ioc2)3 IocContext (org.nutz.ioc.IocContext)2 IocLoader (org.nutz.ioc.IocLoader)2 IocTO00 (org.nutz.ioc.json.pojo.IocTO00)2 MapLoader (org.nutz.ioc.loader.map.MapLoader)2 Stopwatch (org.nutz.lang.Stopwatch)2 LoadingException (org.nutz.mvc.LoadingException)2 File (java.io.File)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Properties (java.util.Properties)1 HttpSession (javax.servlet.http.HttpSession)1 User (net.wendal.nutzdemo.bean.User)1 Dao (org.nutz.dao.Dao)1 ComboContext (org.nutz.ioc.impl.ComboContext)1