use of org.nutz.ioc.loader.json.JsonLoader 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();
}
use of org.nutz.ioc.loader.json.JsonLoader in project nutz by nutzam.
the class AopJsonIocTest method test_simple.
@Test
public void test_simple() {
Nutzs.cd();
IocLoader il = new JsonLoader("org/nutz/ioc/json/aop.js");
Ioc ioc = new NutIoc(il);
StringBuilder sb = ioc.get(StringBuilder.class, "sb");
Mammal fox = ioc.get(Mammal.class, "fox");
assertEquals("Fox", fox.getName());
assertEquals("B:getName0;A:getName0;", sb.toString());
sb.delete(0, sb.length());
fox.getName();
fox.getName();
assertEquals("B:getName0;A:getName0;B:getName0;A:getName0;", sb.toString());
ioc.depose();
}
use of org.nutz.ioc.loader.json.JsonLoader in project nutz by nutzam.
the class Nutzs method getIoc.
public static Ioc getIoc(String key) {
Ioc nut = nuts.get(key);
if (null == nut) {
synchronized (Nutzs.class) {
nut = nuts.get(key);
try {
if (null == nut) {
nut = new NutIoc(new JsonLoader(key));
nuts.put(key, nut);
}
} catch (Exception e) {
throw Lang.wrapThrow(e);
}
}
}
return nut;
}
use of org.nutz.ioc.loader.json.JsonLoader in project nutz by nutzam.
the class PlugsTest method test_get_plugin_from_ioc.
@Test
public void test_get_plugin_from_ioc() {
Ioc ioc = new NutIoc(new JsonLoader("org/nutz/plugin/plugin.js"));
PluginManager<Log> manager = new IocPluginManager<Log>(ioc, "pluB", "pluA", "pluC");
assertNotNull(manager.get());
assertTrue(manager.get() instanceof SystemLogAdapter);
ioc.depose();
}
use of org.nutz.ioc.loader.json.JsonLoader in project nutz by nutzam.
the class JsonAopConfigrationTest method test_jsonAop.
@Test
public void test_jsonAop() {
Nutzs.cd();
Ioc ioc = new NutIoc(new JsonLoader("org/nutz/ioc/aop/config/impl/jsonfile-aop.js"));
Assert.assertTrue(ioc.getNames().length > 0);
for (String name : ioc.getNames()) {
ioc.get(null, name);
}
MyMI mi = ioc.get(MyMI.class, "myMI");
assertTrue(mi.getTime() == 0);
Pet2 pet2 = ioc.get(Pet2.class, "pet2");
pet2.sing();
assertTrue(mi.getTime() == 1);
pet2.sing();
assertTrue(mi.getTime() == 2);
ioc.depose();
}
Aggregations