/**
* Tests setting of different available {@link ResponseStatus} codes and sees that they are recognized and converted
* in {@link NettyResponseChannel}.
* <p/>
* If this test fails, a case for conversion probably needs to be added in {@link NettyResponseChannel}.
*/
@Test
public void setStatusTest() {
// ask for every status to be set
for (ResponseStatus expectedResponseStatus : ResponseStatus.values()) {
HttpRequest request = createRequestWithHeaders(HttpMethod.GET, TestingUri.SetStatus.toString());
request.headers().set(MockNettyMessageProcessor.STATUS_HEADER_NAME, expectedResponseStatus);
HttpUtil.setKeepAlive(request, false);
EmbeddedChannel channel = createEmbeddedChannel();
channel.writeInbound(request);
// pull but discard response
channel.readOutbound();
assertFalse("Channel not closed on the server", channel.isActive());
}
// check if all the ResponseStatus codes were recognized.
String metricName = MetricRegistry.name(NettyResponseChannel.class, "UnknownResponseStatusCount");
long metricCount = MockNettyMessageProcessor.METRIC_REGISTRY.getCounters().get(metricName).getCount();
assertEquals("Some of the ResponseStatus codes were not recognized", 0, metricCount);
}
NettyResponseChannelTest.java 文件源码
java
阅读 33
收藏 0
点赞 0
评论 0
项目:ambry
作者:
评论列表
文章目录