### Question:
PacketBufferManager implements InboundHandler, OutboundHandler { @Override public void onReceivePacket(final Packet packet, final PipelineContext ctx) { requireNonNull(packet); requireNonNull(ctx); if (packet instanceof FullPacket) { if (packet instanceof HandshakePacket) { initialBuffer.clear(); } else if (packet instanceof ShortPacket) { handshakeBuffer.clear(); } final FullPacket fp = (FullPacket) packet; ackQueue.add(fp, ackDelay.time()); log.debug("Acked packet {}", fp.getPacketNumber()); handleAcks(packet); if (shouldFlush(packet)) { log.debug("Directly acking packet"); final EncryptionLevel level = getEncryptionLevel(packet); flushAcks(level, ctx); } } ctx.next(packet); } PacketBufferManager(
      final AckDelay ackDelay,
      final FrameSender frameSender,
      final Timer timer,
      final Ticker ticker); void resend(); @Override void beforeSendPacket(final Packet packet, final PipelineContext ctx); @Override void onReceivePacket(final Packet packet, final PipelineContext ctx);  }### Answer:
@Test public void dontAckOnlyAcks() { final Packet ackPacket = packet(1, new AckFrame(123, new AckBlock(7, 8))); buffer.onReceivePacket(ackPacket, ctx); verify(ctx, never()).send(any(Frame.class)); assertBufferEmpty(); final Packet pingPacket = packet(2, PingFrame.INSTANCE); buffer.onReceivePacket(pingPacket, ctx); final AckFrame actual = (AckFrame) verifySent(); assertEquals(new AckBlock(1, 2), actual.getBlocks().get(0)); }
@Test public void ackOnPing() { final Packet pingPacket = packet(2, PingFrame.INSTANCE); buffer.onReceivePacket(pingPacket, ctx); final AckFrame actual = (AckFrame) verifySent(); assertEquals(67, actual.getAckDelay()); assertEquals(new AckBlock(2, 2), actual.getBlocks().get(0)); }