@Test
  public void closeTest() throws RestServiceException {
    Channel channel = new MockChannel();
    NettyRequest nettyRequest = createNettyRequest(HttpMethod.POST, "/", null, channel);
    Queue<HttpContent> httpContents = new LinkedBlockingQueue<HttpContent>();
    for (int i = 0; i < 5; i++) {
      ByteBuffer content = ByteBuffer.wrap(TestUtils.getRandomBytes(1024));
      HttpContent httpContent = new DefaultHttpContent(Unpooled.wrappedBuffer(content));
      nettyRequest.addContent(httpContent);
      httpContents.add(httpContent);
    }
    closeRequestAndValidate(nettyRequest, channel);
    while (httpContents.peek() != null) {
      assertEquals("Reference count of http content has changed", 1, httpContents.poll().refCnt());
    }
  }
Tests that {@link NettyRequest#close()} leaves any added {@link HttpContent} the way it was before it was added.
(i.e no reference count changes).
@throws RestServiceException
ambry-rest/src/test/java/com/github/ambry/rest/NettyRequestTest.java