BeanUtil { public static void setBeanProperty(Object bean, String property, Object value) throws PropertyAccessException { try { PropertyUtils.setProperty(bean, property, value); } catch (IllegalArgumentException e) { throw new PropertyAccessException(e); } catch (IllegalAccessException e) { throw new PropertyAccessException(e); } catch (InvocationTargetException e) { throw new PropertyAccessException(e.getTargetException()); } catch (NoSuchMethodException e) { throw new PropertyAccessException(e); } }  static void setBeanProperty(Object bean, String property,
            Object value); static Object getBeanProperty(Object bean, String property); static Class<?> getBeanPropertyType(Object bean, String property);  }
@Test public void testSetBeanProperty01() throws Exception { BeanUtil_BeanStub01 bean = new BeanUtil_BeanStub01(); try { BeanUtil.setBeanProperty(bean, "param1", "PARAM1"); fail(); } catch (PropertyAccessException e) { assertEquals(Exception.class.getName(), e.getCause().getClass() .getName()); } }
@Test public void testSetBeanProperty02() throws Exception { BeanUtil_BeanStub01 bean = new BeanUtil_BeanStub01(); try { BeanUtil.setBeanProperty(bean, "param3", "PARAM3"); fail(); } catch (PropertyAccessException e) { assertEquals(NoSuchMethodException.class.getName(), e.getCause() .getClass().getName()); } }
@Test public void testSetBeanProperty03() throws Exception { try { BeanUtil.setBeanProperty(null, "param1", "PARAM1"); fail(); } catch (PropertyAccessException e) { assertEquals(IllegalArgumentException.class.getName(), e.getCause() .getClass().getName()); } }
@Test public void testSetBeanProperty04() throws Exception { BeanUtil_BeanStub01 bean = new BeanUtil_BeanStub01(); try { BeanUtil.setBeanProperty(bean, null, "PARAM1"); fail(); } catch (PropertyAccessException e) { assertEquals(IllegalArgumentException.class.getName(), e.getCause() .getClass().getName()); } }
@Test public void testSetBeanProperty05() throws Exception { BeanUtil_BeanStub01 bean = new BeanUtil_BeanStub01(); BeanUtil.setBeanProperty(bean, "param2", "PARAM2"); assertEquals("PARAM2", ReflectionTestUtils.getField(bean, "param2")); }
@Test public void testSetBeanProperty06() throws Exception { BeanUtil_BeanStub01 bean = new BeanUtil_BeanStub01(); bean.setParam2("PARAM2"); BeanUtil.setBeanProperty(bean, "param2", null); assertNull(ReflectionTestUtils.getField(bean, "param2")); }
@Test public void testSetBeanProperty07() throws Exception { BeanUtil_BeanStub01 bean = new BeanUtil_BeanStub01(); try { BeanUtil.setBeanProperty(bean, "", "PARAM"); fail(); } catch (PropertyAccessException e) { assertEquals(NoSuchMethodException.class.getName(), e.getCause() .getClass().getName()); } }