Ejemplo n.º 1
0
  public void testNullProperties() {
    Foo foo = new Foo();
    foo.setALong(88);

    Map context = Ognl.createDefaultContext(foo);

    ognlUtil.setProperties(null, foo, context);
    assertEquals(88, foo.getALong());

    Map props = new HashMap();
    props.put("aLong", "99");
    ognlUtil.setProperties(props, foo, context);
    assertEquals(99, foo.getALong());
  }
Ejemplo n.º 2
0
  public void testStringToLong() {
    Foo foo = new Foo();

    Map context = Ognl.createDefaultContext(foo);

    Map props = new HashMap();
    props.put("aLong", "123");

    ognlUtil.setProperties(props, foo, context);
    assertEquals(123, foo.getALong());

    props.put("aLong", new String[] {"123"});

    foo.setALong(0);
    ognlUtil.setProperties(props, foo, context);
    assertEquals(123, foo.getALong());
  }
Ejemplo n.º 3
0
  public void testOgnlHandlesCrapAtTheEndOfANumber() {
    Foo foo = new Foo();
    Map<String, Object> context = Ognl.createDefaultContext(foo);

    Map<String, Object> props = new HashMap<String, Object>();
    props.put("aLong", "123a");

    ognlUtil.setProperties(props, foo, context);
    assertEquals(0, foo.getALong());
  }