public void testWrappedInstanceAccessors() { SpringBeanWrapper beanWrapper; Object object; beanWrapper = new SpringBeanWrapper(beanFactory.assignBeanWrapper(object = new Object())); assertEquals(object, beanWrapper.getWrappedInstance()); beanWrapper.setWrappedInstance(object = new Object()); assertEquals(object, beanWrapper.getWrappedInstance()); try { beanWrapper.setWrappedInstance(null); fail("Object is null"); } catch (IllegalArgumentException e) { } }
public void testPropertyAccessors() { SpringBeanWrapper beanWrapper; MockObject object; HashMap map; String value; beanWrapper = new SpringBeanWrapper(beanFactory.assignBeanWrapper(object = new MockObject())); assertNull(beanWrapper.getPropertyValue("string")); assertNull(object.getString()); beanWrapper.setPropertyValue("string", (value = "value")); assertEquals(value, beanWrapper.getPropertyValue("string")); assertEquals(value, object.getString()); map = new HashMap(); map.put("string", (value = "map")); beanWrapper.setPropertyValues(map); assertEquals(value, beanWrapper.getPropertyValue("string")); assertEquals(value, object.getString()); try { beanWrapper.getPropertyValue("method-does-not-exist"); fail("Failed to detect non-existant property"); } catch (Exception e) { } map = new HashMap(); map.put("method-does-not-exist", "value"); try { beanWrapper.setPropertyValues(map); fail("Failed to detect non-existant property"); } catch (Exception e) { } }