### Question:
RequestPacketParser extends PacketParser { @Override public byte[] serialize() throws PacketParserException { RSA rsa = new RSA(); byte[] outputPacketBytes; try (ByteArrayOutputStream requestPacketOutputStream = new ByteArrayOutputStream()) { requestPacketOutputStream.write(owner.getType().toPacketType().ordinal()); OpenSSLRSAPEM.INTEGER nonce = owner.getNonce(); OpenSSLRSAPEM.INTEGER counter = OpenSSLRSAPEM.INTEGER.randomShort().abs(); ByteArrayOutputStream sessionInformationOutputStream = encryptSymmetricCipherParameters(rsa, nonce, counter); int size = appendRijndaelEncryptedSessionContent(sessionInformationOutputStream, nonce, counter); byte[] sessionContentBytes = sessionInformationOutputStream.toByteArray(); requestPacketOutputStream.write(OpenSSLRSAPEM.INTEGER.valueOf(size).getBytes(4)); requestPacketOutputStream.write(sessionContentBytes); outputPacketBytes = requestPacketOutputStream.toByteArray(); } catch (IOException e) { System.err.println("Failed to serialize a message packet"); return null; } return outputPacketBytes; } RequestPacketParser(RequestPacket requestPacket); @Override Packet parse(PacketBuffer packetBuffer, Remote remote); @Override byte[] serialize();  }### Answer:
@Test public void testSerialize() throws Exception { PublicKey recieverKey = new PublicKey(new File(ClassLoader.getSystemResource("test.pub").getFile())); PrivateKey senderKey = new PrivateKey(new File(ClassLoader.getSystemResource("test.pem").getFile())); String senderName = "Frankie"; String receiverName = "Johnny"; String message = "Hello There"; RequestPacket requestPacket = RequestPacket.newMessage(senderKey, recieverKey, senderName, receiverName) .setMessage(message); requestPacket.getNonce(); PacketParser parser = requestPacket.getParser(); assertNotNull(parser); byte[] serialize = parser.serialize(); PacketBuffer packetBuffer = new PacketBuffer(0, 100000); packetBuffer.write(serialize); communications.getListenerKey(); expectLastCall().andReturn(senderKey); replay(communications); RequestPacket parse = new RequestPacket(); parse.setReceiverKey(recieverKey); parse.setCommunications(communications); parse.getParser().parse(packetBuffer, new Remote(senderKey)); assertEquals(message, parse.getMessage()); assertEquals(senderName, parse.getSenderName()); assertEquals(receiverName, parse.getReceiverName()); }