use of org.nutz.ioc.json.pojo.Animal in project nutz by nutzam.
the class SimpleJsonIocTest method test_sys.
@Test
public void test_sys() {
Properties properties = System.getProperties();
properties.put("sysA", "XX");
properties.put("sysP", "ZZZ");
Animal f = A("name:{sys:'sysA'},misc:[{sys:'sysP'}]");
assertEquals("XX", f.getName());
assertEquals("ZZZ", f.getMisc().get(0).toString());
}
use of org.nutz.ioc.json.pojo.Animal in project nutz by nutzam.
the class SimpleJsonIocTest method test_file.
@Test
public void test_file() {
Animal f = A("misc:[{file:'org/nutz/ioc/json/pojo/Animal.class'}]");
assertEquals("Animal.class", ((File) f.getMisc().get(0)).getName());
}
use of org.nutz.ioc.json.pojo.Animal in project nutz by nutzam.
the class EvensJsonIocTest method test_events_for_un_singleton.
@Test
public void test_events_for_un_singleton() {
String s = "singleton:false, fields: {name:'Fox'},";
s = s + "\nevents:{";
s = s + "\n fetch: 'onFetch',";
s = s + "\n create: 'onCreate',";
s = s + "\n depose: 'onDepose'";
s = s + "\n}";
Ioc ioc = I(J("fox", s));
Animal f = ioc.get(Animal.class, "fox");
assertEquals(1, f.getCreateTime());
assertEquals(1, f.getFetchTime());
assertEquals(0, f.getDeposeTime());
ioc.get(Animal.class, "fox");
assertEquals(1, f.getCreateTime());
assertEquals(1, f.getFetchTime());
assertEquals(0, f.getDeposeTime());
ioc.reset();
assertEquals(1, f.getCreateTime());
assertEquals(1, f.getFetchTime());
assertEquals(0, f.getDeposeTime());
}
use of org.nutz.ioc.json.pojo.Animal in project nutz by nutzam.
the class EvensJsonIocTest method test_init_with_field.
@Test
public void test_init_with_field() {
String s = "fields: {name:'Fox'},";
s = s + "\nevents:{";
s = s + "\n create: 'org.nutz.ioc.json.pojo.WhenCreateFox'";
s = s + "\n}";
Ioc ioc = I(J("fox", s));
Animal fox = ioc.get(Animal.class, "fox");
assertEquals("$Fox", fox.getName());
}
use of org.nutz.ioc.json.pojo.Animal in project nutz by nutzam.
the class EvensJsonIocTest method test_events_for_singleton.
@Test
public void test_events_for_singleton() {
String s = "fields: {name:'Fox'},";
s = s + "\nevents:{";
s = s + "\n fetch: 'onFetch',";
s = s + "\n create: 'onCreate',";
s = s + "\n depose: 'onDepose'";
s = s + "\n}";
Ioc ioc = I(J("fox", s));
Animal f = ioc.get(Animal.class, "fox");
assertEquals(1, f.getCreateTime());
assertEquals(1, f.getFetchTime());
assertEquals(0, f.getDeposeTime());
ioc.get(Animal.class, "fox");
assertEquals(1, f.getCreateTime());
assertEquals(2, f.getFetchTime());
assertEquals(0, f.getDeposeTime());
ioc.reset();
assertEquals(1, f.getCreateTime());
assertEquals(2, f.getFetchTime());
assertEquals(1, f.getDeposeTime());
}
Aggregations