Search in sources :

Example 1 with Animal

use of org.nutz.ioc.json.pojo.Animal 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 Animal

use of org.nutz.ioc.json.pojo.Animal in project nutz by nutzam.

the class SimpleJsonIocTest method test_normal.

@Test
public void test_normal() {
    Animal a = A("age:23,name:'monkey',race:'MAMMAL'");
    assertEquals(23, a.getAge());
    assertEquals("monkey", a.getName());
    assertEquals(AnimalRace.MAMMAL, a.getRace());
}
Also used : Animal(org.nutz.ioc.json.pojo.Animal) Test(org.junit.Test)

Example 3 with Animal

use of org.nutz.ioc.json.pojo.Animal 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 Animal

use of org.nutz.ioc.json.pojo.Animal 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 Animal

use of org.nutz.ioc.json.pojo.Animal in project nutz by nutzam.

the class SimpleJsonIocTest method test_java_simple.

@Test
public void test_java_simple() {
    Ioc ioc = I(J("fox", "name:{java: '@Name.toUpperCase()'}, age:{java:'@Name.length()'}"));
    Animal fox = ioc.get(Animal.class, "fox");
    assertEquals("FOX", fox.getName());
    assertEquals(3, fox.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)

Aggregations

Test (org.junit.Test)25 Animal (org.nutz.ioc.json.pojo.Animal)25 Ioc (org.nutz.ioc.Ioc)15 NutIoc (org.nutz.ioc.impl.NutIoc)15 Properties (java.util.Properties)1 Ioc2 (org.nutz.ioc.Ioc2)1 ObjectProxy (org.nutz.ioc.ObjectProxy)1 ScopeContext (org.nutz.ioc.impl.ScopeContext)1 JsonLoader (org.nutz.ioc.loader.json.JsonLoader)1