Exemplo n.º 1
0
  public void testDeepSetting() {
    Foo foo = new Foo();
    foo.setBar(new Bar());

    Map<String, Object> context = Ognl.createDefaultContext(foo);

    Map<String, Object> props = new HashMap();
    props.put("bar.title", "i am barbaz");
    ognlUtil.setProperties(props, foo, context);

    assertEquals(foo.getBar().getTitle(), "i am barbaz");
  }
Exemplo n.º 2
0
  public void testGetBeanMap() throws Exception {
    Bar bar = new Bar();
    bar.setTitle("I have beer");

    Foo foo = new Foo();
    foo.setALong(123);
    foo.setNumber(44);
    foo.setBar(bar);
    foo.setTitle("Hello Santa");
    foo.setUseful(true);

    // just do some of the 15 tests
    Map beans = ognlUtil.getBeanMap(foo);
    assertNotNull(beans);
    assertEquals(19, beans.size());
    assertEquals("Hello Santa", beans.get("title"));
    assertEquals(new Long("123"), beans.get("ALong"));
    assertEquals(new Integer("44"), beans.get("number"));
    assertEquals(bar, beans.get("bar"));
    assertEquals(Boolean.TRUE, beans.get("useful"));
  }