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()); }
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()); }
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()); }