BeanPropertyAccessor { public abstract void setPropertyValue(Object bean, String property, Object value) throws NoSuchPropertyException; protected  BeanPropertyAccessor(); static BeanPropertyAccessor forClass(Class<?> clazz); abstract Object getPropertyValue(Object bean, String property); abstract void setPropertyValue(Object bean, String property,
                                          Object value);  }
@Test public void testSetPropertyValue() { MyObject bean = new MyObject(); BeanPropertyAccessor accessor = BeanPropertyAccessor.forClass(MyObject.class); accessor.setPropertyValue(bean, "primitiveInt", Integer.valueOf(TEST_PINT)); assertEquals("invalid primitive int", TEST_PINT, bean.getPrimitiveInt()); accessor.setPropertyValue(bean, "primitiveDouble", Double.valueOf(TEST_PDOUBLE)); assertEquals("invalid primitive double", TEST_PDOUBLE, bean.getPrimitiveDouble(), 0.0); accessor.setPropertyValue(bean, "wrapperInteger", TEST_WINT); assertEquals("invalid wrapper int", TEST_WINT, bean.getWrapperInteger()); accessor.setPropertyValue(bean, "wrapperDouble", TEST_WDOUBLE); assertEquals("invalid wrapper double", TEST_WDOUBLE, bean.getWrapperDouble()); accessor.setPropertyValue(bean, "string", TEST_STRING); assertEquals("invalid string", TEST_STRING, bean.getString()); }