@Test
    public void encodeAndDecode() {
        boolean error = false;
        try {
            serializer.encode(null, null);
        } catch (Exception e) {
            error = true;
        }
        Assert.assertTrue(error);

        EchoStrReq req = EchoStrReq.newBuilder().setS("xxxx").build();
        AbstractByteBuf byteBuf = serializer.encode(req, null);
        EchoStrReq req2 = (EchoStrReq) serializer.decode(byteBuf, EchoStrReq.class, null);
        Assert.assertEquals(req.getS(), req2.getS());

        AbstractByteBuf data = serializer.encode("xxx", null);
        String dst = (String) serializer.decode(data, String.class, null);
        Assert.assertEquals("xxx", dst);

        error = false;
        try {
            serializer.encode(new Date(), null);
        } catch (Exception e) {
            error = true;
        }
        Assert.assertTrue(error);

        error = false;
        try {
            serializer.decode(data, null, null);
        } catch (Exception e) {
            error = true;
        }
        Assert.assertTrue(error);

        error = false;
        try {
            serializer.decode(data, "", null);
        } catch (Exception e) {
            error = true;
        }
        Assert.assertTrue(error);
    }
@author <a href="mailto:zhanggeng.zg@antfin.com">GengZhang</a>
codec/codec-protobuf/src/test/java/com/alipay/sofa/rpc/codec/protobuf/ProtobufSerializerTest.java