@Test
  public void setFailureReasonInResponseTest() throws Exception {
    HttpRequest request = createRequestWithHeaders(HttpMethod.GET, TestingUri.SetFailureReasonInResponse.toString());
    HttpUtil.setKeepAlive(request, false);

    EmbeddedChannel channel = createEmbeddedChannel();
    channel.writeInbound(request);

    HttpResponse response = channel.readOutbound();
    assertEquals(HttpResponseStatus.INTERNAL_SERVER_ERROR, response.status());
    assertEquals(TestingUri.SetFailureReasonInResponse.toString(),
        response.headers().get(NettyResponseChannel.FAILURE_REASON_HEADER));
    assertFalse("Channel not closed on the server", channel.isActive());

    request = createRequestWithHeaders(HttpMethod.GET, TestingUri.SetFailureReasonInResponseWithException.toString());
    HttpUtil.setKeepAlive(request, false);

    channel = createEmbeddedChannel();
    channel.writeInbound(request);

    response = channel.readOutbound();
    assertEquals(HttpResponseStatus.INTERNAL_SERVER_ERROR, response.status());
    assertFalse(response.headers().contains(NettyResponseChannel.FAILURE_REASON_HEADER));
    assertFalse("Channel not closed on the server", channel.isActive());
  }
Tests when setting internal send-failure-reason back to client.
@throws Exception
ambry-rest/src/test/java/com/github/ambry/rest/NettyResponseChannelTest.java