use of org.nutz.ioc.json.pojo.Animal in project nutz by nutzam.
the class SimpleJsonIocTest method test_env_list.
@Test
public void test_env_list() {
Animal f = A("name:{env:['java.tmp.file', '/wendal']},misc:[{env:['!PATH', '/' , 'os.name', '/zozoh']}]");
assertTrue(f.getName().length() > 0);
assertTrue(f.getName().contains("/wendal"));
assertTrue(f.getMisc().get(0).toString().endsWith("/zozoh"));
System.out.println(f.getName());
System.out.println(f.getMisc().get(0));
f = A("name:{env:['!JAVA_HOME:/opt/jdk6', '/bin/java']}");
assertTrue(f.getName().contains("/bin/java"));
assertTrue(f.getName().length() > "/bin/java".length());
f = A("name:{env:['!ERR_JAVA_HOME:/opt/jdk6', '/bin/java']}");
assertTrue(f.getName().contains("/bin/java"));
assertTrue(f.getName().length() > "/bin/java".length());
assertEquals("/opt/jdk6/bin/java", f.getName());
}
use of org.nutz.ioc.json.pojo.Animal in project nutz by nutzam.
the class SimpleJsonIocTest method test_inner.
@Test
public void test_inner() {
Animal f = A("enemies: [ {type:'org.nutz.ioc.json.pojo.Animal', fields: {name:'xxx'}} ]");
assertEquals("xxx", f.getEnemies()[0].getName());
}
use of org.nutz.ioc.json.pojo.Animal in project nutz by nutzam.
the class SimpleJsonIocTest method test_refer.
@Test
public void test_refer() {
Ioc ioc = I(J("fox", "type:'org.nutz.ioc.json.pojo.Animal',fields:{name:'Fox'}"), J("rabit", "name:'Rabit',enemies:[{refer:'fox'},{refer:'fox'}]"));
Animal r = ioc.get(Animal.class, "rabit");
Animal f = ioc.get(Animal.class, "fox");
assertEquals(2, r.getEnemies().length);
assertTrue(f == r.getEnemies()[0]);
assertTrue(f == r.getEnemies()[1]);
assertEquals("Fox", f.getName());
assertEquals("Rabit", r.getName());
}
use of org.nutz.ioc.json.pojo.Animal in project nutz by nutzam.
the class SimpleJsonIocTest method test_singleon.
@Test
public void test_singleon() {
Ioc ioc = I(J("fox", "name:'Fox'"));
Animal f = ioc.get(Animal.class, "fox");
Animal f2 = ioc.get(Animal.class, "fox");
assertTrue(f == f2);
ioc = I(J("fox", "singleton:false, fields: {name:'Fox'}"));
Animal f3 = ioc.get(Animal.class, "fox");
Animal f4 = ioc.get(Animal.class, "fox");
assertFalse(f3 == f4);
}
use of org.nutz.ioc.json.pojo.Animal in project nutz by nutzam.
the class SimpleJsonIocTest method test_env.
@Test
public void test_env() {
Animal f = A("name:{env:'PATH'},misc:[{env:'PATH'}]");
assertTrue(f.getName().length() > 0);
assertEquals(f.getName(), f.getMisc().get(0).toString());
}
Aggregations