NettyResponseChannelTest.java 文件源码

java
阅读 32 收藏 0 点赞 0 评论 0

项目:ambry 作者:
/**
 * Tests that the underlying network channel is closed when {@link NettyResponseChannel#close()} is called.
 */
@Test
public void closeTest() {
  // request is keep-alive by default.
  HttpRequest request = createRequestWithHeaders(HttpMethod.GET, TestingUri.Close.toString());
  EmbeddedChannel channel = createEmbeddedChannel();
  channel.writeInbound(request);

  HttpResponse response = (HttpResponse) channel.readOutbound();
  assertEquals("Unexpected response status", HttpResponseStatus.INTERNAL_SERVER_ERROR, response.status());
  assertFalse("Inconsistent value for Connection header", HttpUtil.isKeepAlive(response));
  // drain the channel of content.
  while (channel.readOutbound() != null) {
  }
  assertFalse("Channel should be closed", channel.isOpen());
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号