Search in sources :

Example 1 with IocTO00

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

the class SimpleJsonIocTest method test_2darray_iocvalue.

@Test
public void test_2darray_iocvalue() {
    Ioc ioc = I("obj:{args:[[['a','b'],['c','d']]]}");
    IocTO00 obj = ioc.get(IocTO00.class, "obj");
    assertEquals(2, obj.getStrss().length);
    assertEquals(2, obj.getStrss()[0].length);
    assertEquals("a", obj.getStrss()[0][0]);
    assertEquals("b", obj.getStrss()[0][1]);
    assertEquals("c", obj.getStrss()[1][0]);
    assertEquals("d", obj.getStrss()[1][1]);
}
Also used : IocTO00(org.nutz.ioc.json.pojo.IocTO00) Ioc(org.nutz.ioc.Ioc) NutIoc(org.nutz.ioc.impl.NutIoc) Test(org.junit.Test)

Example 2 with IocTO00

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

the class SimpleJsonIocTest method test_2darray_by_map_iocvalue.

@Test
public void test_2darray_by_map_iocvalue() {
    Map<String, Map<String, Object>> map = new HashMap<String, Map<String, Object>>();
    Map<String, Object> objMap = new HashMap<String, Object>();
    String[][] strss = new String[2][2];
    strss[0][0] = "a";
    strss[0][1] = "b";
    strss[1][0] = "c";
    strss[1][1] = "d";
    objMap.put("args", new Object[] { strss });
    map.put("obj", objMap);
    Ioc ioc = new NutIoc(new MapLoader(map));
    IocTO00 obj = ioc.get(IocTO00.class, "obj");
    assertEquals(2, obj.getStrss().length);
    assertEquals(2, obj.getStrss()[0].length);
    assertEquals("a", obj.getStrss()[0][0]);
    assertEquals("b", obj.getStrss()[0][1]);
    assertEquals("c", obj.getStrss()[1][0]);
    assertEquals("d", obj.getStrss()[1][1]);
    ioc.depose();
}
Also used : NutIoc(org.nutz.ioc.impl.NutIoc) IocTO00(org.nutz.ioc.json.pojo.IocTO00) MapLoader(org.nutz.ioc.loader.map.MapLoader) HashMap(java.util.HashMap) Ioc(org.nutz.ioc.Ioc) NutIoc(org.nutz.ioc.impl.NutIoc) HashMap(java.util.HashMap) Map(java.util.Map) NutMap(org.nutz.lang.util.NutMap) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 Ioc (org.nutz.ioc.Ioc)2 NutIoc (org.nutz.ioc.impl.NutIoc)2 IocTO00 (org.nutz.ioc.json.pojo.IocTO00)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 MapLoader (org.nutz.ioc.loader.map.MapLoader)1 NutMap (org.nutz.lang.util.NutMap)1