### Question:
HandshakeHandler extends Handler { @Override public Packet runPacketParser(PacketBuffer packetBuffer, Session session, PACKETS expecting) throws PacketParserException { if (expecting == PACKETS.HANDSHAKE_OPEN) { Packet packet = new HandshakePacket().getParser().parse(packetBuffer, null); packetBuffer.reset(); return packet; } else { throw new RuntimeException("Handshake Handler: Something is not implemented"); } } HandshakeHandler(); @Override Packet runPacketParser(PacketBuffer packetBuffer, Session session, PACKETS expecting); @Override CONNECTION_PHASE handlePacket(PacketBuffer packetBuffer, Session session);  }### Answer:
@Test public void testRunPacketParser() throws Exception { byte[] buffer = new byte[]{ (byte) PACKETS.HANDSHAKE_OPEN.ordinal(), 0, 2, 4, 8, 16, 32, 64, 2, 4, 8, 16, 32, 64, 2, 4, 8, 16, 32, 64, 2, 4, 8, 16, 32, 64, 2, 4, 8, 16, 32, 64, 0, 1 }; PacketBuffer packetBuffer = new PacketBuffer(); handler.initPacketBuffer(packetBuffer); packetBuffer.write(buffer); Session niceMock = EasyMock.createNiceMock(Session.class); expect(niceMock.getExpecting()).andReturn(PACKETS.HANDSHAKE_OPEN); replay(niceMock); Packet packet = handler.runPacketParser(packetBuffer, null, PACKETS.HANDSHAKE_OPEN); packetBuffer.resize(0, 500); assertEquals(0, packetBuffer.getOffset()); }