SessionClosing extends AbstractSessionState { @Override public void tryWrite(ByteBuf byteBuf) { throw new UnsupportedOperationException("No write, Session closing"); } SessionClosing(Session session); @Override void tryWrite(ByteBuf byteBuf); @Override String name(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }
@Test(expected = UnsupportedOperationException.class) public void testTryWrite() { ByteBuf byteBuf = new UnpooledByteBufAllocator(false).buffer(); byteBuf.setBytes(0, "+OK\r\n".getBytes()); seesionClosing.tryWrite(byteBuf); ReferenceCountUtil.release(byteBuf); }