JprotobufRpcMethodInfo extends RpcMethodInfo { @Override public Object inputDecode(byte[] input) throws IOException { if (inputCodec != null) { return inputCodec.decode(input); } return null; } JprotobufRpcMethodInfo(Method method); @Override byte[] inputEncode(Object input); @Override void inputWriteToStream(Object input, CodedOutputStream stream); @Override Object outputDecode(byte[] output); @Override Object outputDecode(ByteBuf output); @Override Object outputDecode(DynamicCompositeByteBuf output); @Override Object inputDecode(byte[] input); @Override Object inputDecode(ByteBuf input); @Override Object inputDecode(DynamicCompositeByteBuf input); @Override byte[] outputEncode(Object output); @Override void outputWriteToStream(Object output, CodedOutputStream stream); @Override int getInputSerializedSize(Object input); @Override int getOutputSerializedSize(Object output);  }
@Test public void testInputDecode() throws Exception { Method method = EchoService.class.getMethod("echo", EchoRequest.class); JprotobufRpcMethodInfo rpcMethodInfo = new JprotobufRpcMethodInfo(method); Echo.EchoRequest request = Echo.EchoRequest.newBuilder().setMessage("hello").build(); byte[] bytes = request.toByteArray(); EchoRequest request1 = (EchoRequest) rpcMethodInfo.inputDecode(bytes); Assert.assertTrue(request1.getMessage().equals(request.getMessage())); }
@Test public void testInputDecode2() throws Exception { Method method = EchoService.class.getMethod("echo", EchoRequest.class); JprotobufRpcMethodInfo rpcMethodInfo = new JprotobufRpcMethodInfo(method); Echo.EchoRequest request = Echo.EchoRequest.newBuilder().setMessage("hello").build(); byte[] bytes = request.toByteArray(); ByteBuf byteBuf = Unpooled.wrappedBuffer(bytes); EchoRequest request1 = (EchoRequest) rpcMethodInfo.inputDecode(byteBuf); Assert.assertTrue(request1.getMessage().equals(request.getMessage())); }
@Test public void testInputDecode3() throws Exception { Method method = EchoService.class.getMethod("echo", EchoRequest.class); JprotobufRpcMethodInfo rpcMethodInfo = new JprotobufRpcMethodInfo(method); Echo.EchoRequest request = Echo.EchoRequest.newBuilder().setMessage("hello").build(); byte[] bytes = request.toByteArray(); ByteBuf byteBuf = Unpooled.wrappedBuffer(bytes); DynamicCompositeByteBuf compositeByteBuf = new DynamicCompositeByteBuf(byteBuf); EchoRequest request1 = (EchoRequest) rpcMethodInfo.inputDecode(compositeByteBuf); Assert.assertTrue(request1.getMessage().equals(request.getMessage())); }