@Test
  public void operationsAfterCloseTest() throws Exception {
    NettyMultipartRequest request = createRequest(null, null);
    request.prepare();
    closeRequestAndValidate(request);
    // close should be idempotent.
    request.close();

    try {
      request.readInto(new ByteBufferAsyncWritableChannel(), null).get();
      fail("Reading should have failed because request is closed");
    } catch (ExecutionException e) {
      assertEquals("Unexpected exception", ClosedChannelException.class, Utils.getRootCause(e).getClass());
    }

    try {
      request.prepare();
      fail("Preparing should have failed because request is closed");
    } catch (RestServiceException e) {
      assertEquals("Unexpected RestServiceErrorCode", RestServiceErrorCode.RequestChannelClosed, e.getErrorCode());
    }

    try {
      request.addContent(new DefaultHttpContent(Unpooled.wrappedBuffer(TestUtils.getRandomBytes(10))));
      fail("Content addition should have failed because request is closed");
    } catch (RestServiceException e) {
      assertEquals("Unexpected RestServiceErrorCode", RestServiceErrorCode.RequestChannelClosed, e.getErrorCode());
    }
  }
Tests the expected behavior of operations after {@link NettyMultipartRequest#close()} has been called.
@throws Exception
ambry-rest/src/test/java/com/github/ambry/rest/NettyMultipartRequestTest.java