@Test
    public void encode() throws Exception {
        SimpleMapSerializer simpleMapSerializer = new SimpleMapSerializer();
        Map<String, String> map = null;
        byte[] bs = simpleMapSerializer.encode(map);
        Assert.assertEquals(bs, null);

        map = new HashMap<String, String>();
        bs = simpleMapSerializer.encode(map);
        Assert.assertEquals(bs, null);

        map.put("1", "2");
        map.put("", "x");
        map.put("a", "");
        map.put("b", null);
        bs = simpleMapSerializer.encode(map);
        Assert.assertEquals(28, bs.length);

        Map<String, String> map1 = simpleMapSerializer.decode(bs);
        Assert.assertNotNull(map1);
        Assert.assertEquals(3, map1.size());
        Assert.assertEquals("2", map1.get("1"));
        Assert.assertEquals("x", map1.get(""));
        Assert.assertEquals("", map1.get("a"));
        Assert.assertNull(map1.get("b"));

        map1 = simpleMapSerializer.decode(null);
        Assert.assertNotNull(map1);
        Assert.assertEquals(0, map1.size());

        map1 = simpleMapSerializer.decode(new byte[0]);
        Assert.assertNotNull(map1);
        Assert.assertEquals(0, map1.size());
    }
@author <a href="mailto:zhanggeng.zg@antfin.com">GengZhang</a>
remoting/remoting-bolt/src/test/java/com/alipay/sofa/rpc/codec/bolt/SimpleMapSerializerTest.java