### Question:
RpcProtocolTool implements Tool { @Override public int run(InputStream in, PrintStream out, PrintStream err, List<String> args) throws Exception { if (args.size() != 1) { err.println("Usage: uri"); return 1; } URI uri = URI.create(args.get(0)); try (Transceiver transceiver = Ipc.createTransceiver(uri)) { HandshakeRequest rq = HandshakeRequest.newBuilder().setClientHash(new MD5(new byte[16])) .setServerHash(new MD5(new byte[16])).setClientProtocol(null).setMeta(new LinkedHashMap<>()).build(); DatumWriter<HandshakeRequest> handshakeWriter = new SpecificDatumWriter<>(HandshakeRequest.class); ByteBufferOutputStream byteBufferOutputStream = new ByteBufferOutputStream(); BinaryEncoder encoder = EncoderFactory.get().binaryEncoder(byteBufferOutputStream, null); handshakeWriter.write(rq, encoder); encoder.flush(); List<ByteBuffer> response = transceiver.transceive(byteBufferOutputStream.getBufferList()); ByteBufferInputStream byteBufferInputStream = new ByteBufferInputStream(response); DatumReader<HandshakeResponse> handshakeReader = new SpecificDatumReader<>(HandshakeResponse.class); HandshakeResponse handshakeResponse = handshakeReader.read(null, DecoderFactory.get().binaryDecoder(byteBufferInputStream, null)); Protocol p = Protocol.parse(handshakeResponse.getServerProtocol()); out.println(p.toString(true)); } return 0; }  @Override String getName(); @Override String getShortDescription(); @Override int run(InputStream in, PrintStream out, PrintStream err, List<String> args);  }### Answer:
@Test public void testRpcProtocol() throws Exception { ByteArrayOutputStream baos2 = new ByteArrayOutputStream(); PrintStream p2 = new PrintStream(baos2, true, "UTF-8"); RpcProtocolTool testObject = new RpcProtocolTool(); testObject.run(null, p2, System.err, Collections.singletonList(uriScheme + ": p2.flush(); assertEquals("Expected the simple.avpr protocol to be echoed to standout", simpleProtocol, Protocol.parse(baos2.toString("UTF-8"))); }