@Test
public void testConvertPrimitive() throws Exception {

    assertThat(ClassUtils.convertPrimitive(char.class, ""), equalTo('\0'));
    assertThat(ClassUtils.convertPrimitive(char.class, null), equalTo(null));
    assertThat(ClassUtils.convertPrimitive(char.class, "6"), equalTo('6'));
    assertThat(ClassUtils.convertPrimitive(boolean.class, ""), equalTo(Boolean.FALSE));
    assertThat(ClassUtils.convertPrimitive(boolean.class, null), equalTo(null));
    assertThat(ClassUtils.convertPrimitive(boolean.class, "true"), equalTo(Boolean.TRUE));
    assertThat(ClassUtils.convertPrimitive(byte.class, ""), equalTo(null));
    assertThat(ClassUtils.convertPrimitive(byte.class, null), equalTo(null));
    assertThat(ClassUtils.convertPrimitive(byte.class, "127"), equalTo(Byte.MAX_VALUE));
    assertThat(ClassUtils.convertPrimitive(short.class, ""), equalTo(null));
    assertThat(ClassUtils.convertPrimitive(short.class, null), equalTo(null));
    assertThat(ClassUtils.convertPrimitive(short.class, "32767"), equalTo(Short.MAX_VALUE));
    assertThat(ClassUtils.convertPrimitive(int.class, ""), equalTo(null));
    assertThat(ClassUtils.convertPrimitive(int.class, null), equalTo(null));
    assertThat(ClassUtils.convertPrimitive(int.class, "6"), equalTo(6));
    assertThat(ClassUtils.convertPrimitive(long.class, ""), equalTo(null));
    assertThat(ClassUtils.convertPrimitive(long.class, null), equalTo(null));
    assertThat(ClassUtils.convertPrimitive(long.class, "6"), equalTo(new Long(6)));
    assertThat(ClassUtils.convertPrimitive(float.class, ""), equalTo(null));
    assertThat(ClassUtils.convertPrimitive(float.class, null), equalTo(null));
    assertThat(ClassUtils.convertPrimitive(float.class, "1.1"), equalTo(new Float(1.1)));
    assertThat(ClassUtils.convertPrimitive(double.class, ""), equalTo(null));
    assertThat(ClassUtils.convertPrimitive(double.class, null), equalTo(null));
    assertThat(ClassUtils.convertPrimitive(double.class, "10.1"), equalTo(new Double(10.1)));
}