Examples of Animal


Examples of org.nutz.ioc.json.pojo.Animal

  public void test_array_and_refer() {
    Ioc ioc = I(J("fox", "name:'Fox'"),
          J"rabit",
            "name:'Rabit',enemies:[{refer:'fox:org.nutz.ioc.json.pojo.Animal'},null]"));

    Animal r = ioc.get(Animal.class, "rabit");
    Animal f = ioc.get(Animal.class, "fox");
    assertEquals(2, r.getEnemies().length);
    assertTrue(f == r.getEnemies()[0]);
    assertEquals("Fox", f.getName());
    assertEquals("Rabit", r.getName());
    assertNull(r.getEnemies()[1]);
  }
View Full Code Here

Examples of org.nutz.ioc.json.pojo.Animal

    assertNull(r.getEnemies()[1]);
  }

  @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());
  }
View Full Code Here

Examples of org.nutz.ioc.json.pojo.Animal

  @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());
  }
View Full Code Here

Examples of org.nutz.ioc.json.pojo.Animal

    assertEquals("ZZZ", f.getMisc().get(0).toString());
  }

  @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());
  }
View Full Code Here

Examples of org.nutz.ioc.json.pojo.Animal

    assertEquals("Animal.class", ((File) f.getMisc().get(0)).getName());
  }

  @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());
  }
View Full Code Here

Examples of org.nutz.ioc.json.pojo.Animal

    assertEquals("xxx", f.getEnemies()[0].getName());
  }

  @Test
  public void test_map() {
    Animal f = A("map : {asia:34, europe: 45}");
    assertEquals(34, f.getMap().get("asia").intValue());
    assertEquals(45, f.getMap().get("europe").intValue());

    f = A("relations: {a: {type:'org.nutz.ioc.json.pojo.Animal', fields: {name:'AAA'}}"
        + ",b: {type:'org.nutz.ioc.json.pojo.Animal', fields: {name:'BBB'}}}");
    assertEquals(2, f.getRelations().size());
    assertEquals("AAA", f.getRelations().get("a").getName());
    assertEquals("BBB", f.getRelations().get("b").getName());
  }
View Full Code Here

Examples of org.nutz.ioc.json.pojo.Animal

  }

  @Test
  public void test_java_simple() {
    Ioc ioc = I(J("fox", "name:{java: '@Name.toUpperCase()'}, age:{java:'@Name.length()'}"));
    Animal fox = ioc.get(Animal.class, "fox");
    assertEquals("FOX", fox.getName());
    assertEquals(3, fox.getAge());
  }
View Full Code Here

Examples of org.nutz.ioc.json.pojo.Animal

  @Test
  public void test_java_with_arguments() {
    Ioc ioc = I(J("fox", "name:'Fox',age:10"),
          J("wolf", "name:{java:'$fox.showName(\"_\", 2, \"W\")'},age:{java:'$fox.age'}"));
    Animal fox = ioc.get(Animal.class, "fox");
    Animal wolf = ioc.get(Animal.class, "wolf");
    assertEquals("Fox", fox.getName());
    assertEquals(fox.getAge(), wolf.getAge());
    assertEquals("__W", wolf.getName());
  }
View Full Code Here

Examples of org.nutz.ioc.json.pojo.Animal

  }

  @Test
  public void test_parent() {
    Ioc ioc = I(J("fox", "name:'P',age:10"), J("f2", "parent:'fox',fields:{age:5}"));
    Animal fox = ioc.get(Animal.class, "fox");
    assertEquals("P", fox.getName());
    assertEquals(10, fox.getAge());
    Animal f2 = ioc.get(Animal.class, "f2");
    assertEquals("P", f2.getName());
    assertEquals(5, f2.getAge());
  }
View Full Code Here

Examples of org.nutz.ioc.json.pojo.Animal

  }

  @Test
  public void test_muilt_parent() {
    Ioc ioc = I(J("fox", "name:'P',age:10"), J("f2", "parent:'fox'"), J("f3", "parent:'f2'"));
    Animal f3 = ioc.get(Animal.class, "f3");
    assertEquals(10, f3.getAge());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.