### Question:
BeanUtils { public static <T> T populate(final Properties properties, final Class<T> clazz) { T obj = null; try { obj = clazz.newInstance(); return populate(properties, obj); } catch (Throwable e) { log.warn("Error occurs !", e); } return obj; }  static T populate(final Properties properties, final Class<T> clazz); static T populate(final KeyValue properties, final Class<T> clazz); static Class<?> getMethodClass(Class<?> clazz, String methodName); static void setProperties(Class<?> clazz, Object obj, String methodName,
        Object value); static T populate(final Properties properties, final T obj); static T populate(final KeyValue properties, final T obj);  }### Answer:
@Test public void testPopulate_ExistObj() { CustomizedConfig config = new CustomizedConfig(); config.setOmsConsumerId("NewConsumerId"); Assert.assertEquals(config.getOmsConsumerId(), "NewConsumerId"); config = BeanUtils.populate(properties, config); Assert.assertEquals(config.getRmqMaxRedeliveryTimes(), 120); Assert.assertEquals(config.getStringTest(), "kaka"); Assert.assertEquals(config.getRmqConsumerGroup(), "Default_Consumer_Group"); Assert.assertEquals(config.getRmqMessageConsumeTimeout(), 101); Assert.assertEquals(config.getLongTest(), 1234567890L); Assert.assertEquals(config.getDoubleTest(), 10.234, 0.000001); }
@Test public void testPopulate() { CustomizedConfig config = BeanUtils.populate(properties, CustomizedConfig.class); Assert.assertEquals(config.getRmqMaxRedeliveryTimes(), 120); Assert.assertEquals(config.getStringTest(), "kaka"); Assert.assertEquals(config.getRmqConsumerGroup(), "Default_Consumer_Group"); Assert.assertEquals(config.getRmqMessageConsumeTimeout(), 101); Assert.assertEquals(config.getLongTest(), 1234567890L); Assert.assertEquals(config.getDoubleTest(), 10.234, 0.000001); }
@Test public void testPopulate_ExistObj() { CustomizedConfig config = new CustomizedConfig(); config.setConsumerId("NewConsumerId"); Assert.assertEquals(config.getConsumerId(), "NewConsumerId"); config = BeanUtils.populate(properties, config); Assert.assertEquals(config.getRmqMaxRedeliveryTimes(), 120); Assert.assertEquals(config.getStringTest(), "kaka"); Assert.assertEquals(config.getRmqConsumerGroup(), "Default_Consumer_Group"); Assert.assertEquals(config.getRmqMessageConsumeTimeout(), 101); Assert.assertEquals(config.getLongTest(), 1234567890L); Assert.assertEquals(config.getDoubleTest(), 10.234, 0.000001); }