use of io.micronaut.http.server.HttpServerConfiguration in project micronaut-core by micronaut-projects.
the class HttpRequestTest method testForEach2.
public void testForEach2() {
final DefaultFullHttpRequest nettyRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, io.netty.handler.codec.http.HttpMethod.GET, "/test");
nettyRequest.headers().add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
nettyRequest.headers().add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML);
HttpRequest<?> request = new NettyHttpRequest(nettyRequest, new DetachedMockFactory().Mock(ChannelHandlerContext.class), ConversionService.SHARED, new HttpServerConfiguration());
final HttpHeaders headers = request.getHeaders();
headers.forEach((name, values) -> {
assertEquals(HttpHeaders.CONTENT_TYPE, name);
assertEquals(2, values.size());
assertTrue(values.contains(MediaType.APPLICATION_JSON));
assertTrue(values.contains(MediaType.APPLICATION_XML));
});
AtomicInteger integer = new AtomicInteger(0);
headers.forEachValue((s, s2) -> integer.incrementAndGet());
assertEquals(2, integer.get());
}
use of io.micronaut.http.server.HttpServerConfiguration in project micronaut-core by micronaut-projects.
the class HttpRequestTest method testForEach.
public void testForEach() {
final DefaultFullHttpRequest nettyRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, io.netty.handler.codec.http.HttpMethod.GET, "/test");
nettyRequest.headers().add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
HttpRequest<?> request = new NettyHttpRequest(nettyRequest, new DetachedMockFactory().Mock(ChannelHandlerContext.class), ConversionService.SHARED, new HttpServerConfiguration());
final HttpHeaders headers = request.getHeaders();
headers.forEach((name, values) -> {
assertEquals(HttpHeaders.CONTENT_TYPE, name);
assertEquals(1, values.size());
assertEquals(MediaType.APPLICATION_JSON, values.iterator().next());
});
}
Aggregations