### Question:
TerminationManager implements InboundHandler { @Override public void onReceivePacket(final Packet packet, final PipelineContext ctx) { if (packet instanceof FullPacket) { final FullPacket fp = (FullPacket) packet; for (final Frame frame : fp.getPayload().getFrames()) { if (frame instanceof ConnectionCloseFrame) { ctx.setState(State.Closing); connection.closeByPeer(); ctx.setState(State.Closed); } } } resetIdleTimer(); ctx.next(packet); } TerminationManager(
      final InternalConnection connection,
      final Timer timer,
      final long idleTimeout,
      final TimeUnit idleUnit); @Override void onReceivePacket(final Packet packet, final PipelineContext ctx);  }### Answer:
@Test public void testConnectionCloseFrame() { final Packet packet = packet(new ConnectionCloseFrame(456, FrameType.PADDING, "Test")); manager.onReceivePacket(packet, ctx); verify(connection).closeByPeer(); verify(ctx).setState(State.Closing); verify(ctx).setState(State.Closed); verify(ctx).next(packet); }
@Test public void idleTimeout() throws Exception { assertTrue(timer.timeouts.isEmpty()); manager.onReceivePacket(packet(PingFrame.INSTANCE), ctx); assertFalse(timer.timeouts.isEmpty()); timer.trigger(); verify(connection).close(eq(TransportError.NO_ERROR), eq(FrameType.PADDING), anyString()); }