use of org.nutz.ioc.impl.NutIoc in project nutz by nutzam.
the class DefaultValueTypes method test_el.
@Test
public void test_el() {
IocContext context = new ScopeContext("abc");
String json = "{obj:{type:'org.nutz.ioc.val.DefaultValueTypes', fields:{name:{el:'sys[\"os.arch\"]'}}}}";
System.out.println(Json.toJson(Json.fromJson(json)));
Ioc2 ioc = new NutIoc(new MapLoader(json), context, "abc");
DefaultValueTypes self = ioc.get(DefaultValueTypes.class, "obj");
assertEquals(System.getProperties().get("os.arch"), self.name);
}
use of org.nutz.ioc.impl.NutIoc in project nutz by nutzam.
the class IocCustomizedValueTypeTest method test_simple_customized.
@Test
public void test_simple_customized() {
String json = "{xb:{name:{cc:'XiaoBai'}}}";
Ioc2 ioc = new NutIoc(new MapLoader(json));
ioc.addValueProxyMaker(new ValueProxyMaker() {
public ValueProxy make(IocMaking ing, IocValue iv) {
if ("cc".equalsIgnoreCase(iv.getType())) {
return new StaticValue("CC:" + iv.getValue());
}
return null;
}
public String[] supportedTypes() {
return Lang.array("cc");
}
});
Pet pet = ioc.get(Pet.class, "xb");
assertEquals("CC:XiaoBai", pet.getName());
ioc.depose();
}
use of org.nutz.ioc.impl.NutIoc 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.impl.NutIoc in project nutz by nutzam.
the class Utils method I.
static Ioc2 I(String... ss) {
String json = "{";
json += Lang.concat(',', ss);
json += "}";
return new NutIoc(new MapLoader(json));
}
use of org.nutz.ioc.impl.NutIoc in project nutz by nutzam.
the class AnnotationIocLoaderTest method test_ioc_inject_by_setter.
@Test
public void test_ioc_inject_by_setter() throws ObjectLoadException {
AnnotationIocLoader loader = new AnnotationIocLoader(getClass().getPackage().getName());
Logs.get().error(loader.load(null, "issue1060"));
NutIoc ioc = new NutIoc(loader);
// 放个假的
ioc.getIocContext().save("app", "dao", new ObjectProxy(new NutDao()));
ioc.get(Issue1060.class);
ioc.depose();
}
Aggregations