ConnectionLimitingHandler extends ChannelInboundHandlerAdapter { public int maxNumConnections() { return maxNumConnections; } ConnectionLimitingHandler(int maxNumConnections); @Override void channelRead(ChannelHandlerContext ctx, Object msg); int maxNumConnections(); int numConnections(); Set<Channel> children(); static int validateMaxNumConnections(int maxNumConnections);  }
@Test void testMaxNumConnectionsRange() { final ConnectionLimitingHandler handler = new ConnectionLimitingHandler(Integer.MAX_VALUE); assertThat(handler.maxNumConnections()).isEqualTo(Integer.MAX_VALUE); assertThatThrownBy(() -> new ConnectionLimitingHandler(0)) .isInstanceOf(IllegalArgumentException.class); assertThatThrownBy(() -> new ConnectionLimitingHandler(-1)) .isInstanceOf(IllegalArgumentException.class); }