@Test
    public void testDeserializeByType() {
        Assert.assertTrue(0 == BeanSerializer.deserializeByType(null, int.class));
        Assert.assertTrue(0 == BeanSerializer.deserializeByType(null, long.class));
        Assert.assertFalse(BeanSerializer.deserializeByType(null, boolean.class));

        Assert.assertArrayEquals(new int[] { 123 }, BeanSerializer.deserializeByType(Arrays.asList(123), int[].class));
        Assert.assertFalse(BeanSerializer.deserializeByType(Arrays.asList(123), String.class) instanceof String);
        Assert.assertTrue(CommonUtils.listEquals(Arrays.asList(123),
            BeanSerializer.deserializeByType(new int[] { 123 }, List.class)));
        Assert.assertTrue(CommonUtils.listEquals(Arrays.asList("xxx"),
            BeanSerializer.deserializeByType(new String[] { "xxx" }, List.class)));

        Assert.assertEquals(TestJsonBean.Status.START,
            BeanSerializer.deserializeByType("START", TestJsonBean.Status.class));
        try {
            BeanSerializer.deserializeByType(new TestJsonBean(), TestJsonBean.Status.class);
            Assert.fail();
        } catch (Exception e) {
        }

        Date now = new Date();
        Assert.assertEquals(now, BeanSerializer.deserializeByType(now.getTime(), Date.class));
        Assert.assertEquals(DateUtils.dateToStr(now), DateUtils.dateToStr(
            BeanSerializer.deserializeByType(DateUtils.dateToStr(now), Date.class)));
        try {
            BeanSerializer.deserializeByType("xxxx", Date.class);
            Assert.fail();
        } catch (Exception e) {
        }
        try {
            BeanSerializer.deserializeByType(new TestJsonBean(), Date.class);
            Assert.fail();
        } catch (Exception e) {
        }
    }
<p>


@author <a href=mailto:zhanggeng@howtimeflies.org>GengZhang</a>
core/common/src/test/java/com/alipay/sofa/rpc/common/json/BeanSerializerTest.java