public void testGetBeanMapNoReadMethod() throws Exception { MyWriteBar bar = new MyWriteBar(); bar.setBar("Sams"); Map beans = ognlUtil.getBeanMap(bar); assertEquals(2, beans.size()); assertEquals(new Integer("1"), beans.get("id")); assertEquals("There is no read method for bar", beans.get("bar")); }
public void testNoExceptionForUnmatchedGetterAndSetterWithThrowPropertyException() { Map<String, Object> props = new HashMap<String, Object>(); props.put("myIntegerProperty", new Integer(1234)); TestObject testObject = new TestObject(); // this used to fail in OGNL versions < 2.7 ognlUtil.setProperties(props, testObject, true); assertEquals(1234, props.get("myIntegerProperty")); }
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")); }