@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());
}