use of org.apache.flink.shaded.netty4.io.netty.channel.embedded.EmbeddedChannel in project netty by netty.
the class Http2ServerDowngraderTest method testUpgradeEmptyEnd.
@Test
public void testUpgradeEmptyEnd() throws Exception {
EmbeddedChannel ch = new EmbeddedChannel(new Http2ServerDowngrader());
LastHttpContent end = LastHttpContent.EMPTY_LAST_CONTENT;
assertTrue(ch.writeOutbound(end));
Http2DataFrame emptyFrame = ch.readOutbound();
try {
assertThat(emptyFrame.content().readableBytes(), is(0));
assertTrue(emptyFrame.isEndStream());
} finally {
emptyFrame.release();
}
assertThat(ch.readOutbound(), is(nullValue()));
assertFalse(ch.finish());
}
use of org.apache.flink.shaded.netty4.io.netty.channel.embedded.EmbeddedChannel in project netty by netty.
the class Http2ServerDowngraderTest method testUpgradeEmptyFullResponse.
@Test
public void testUpgradeEmptyFullResponse() throws Exception {
EmbeddedChannel ch = new EmbeddedChannel(new Http2ServerDowngrader());
assertTrue(ch.writeOutbound(new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK)));
Http2HeadersFrame headersFrame = ch.readOutbound();
assertThat(headersFrame.headers().status().toString(), is("200"));
assertTrue(headersFrame.isEndStream());
assertThat(ch.readOutbound(), is(nullValue()));
assertFalse(ch.finish());
}
use of org.apache.flink.shaded.netty4.io.netty.channel.embedded.EmbeddedChannel in project netty by netty.
the class Http2ServerDowngraderTest method testUpgradeTrailers.
@Test
public void testUpgradeTrailers() throws Exception {
EmbeddedChannel ch = new EmbeddedChannel(new Http2ServerDowngrader());
LastHttpContent trailers = new DefaultLastHttpContent(Unpooled.EMPTY_BUFFER, true);
HttpHeaders headers = trailers.trailingHeaders();
headers.set("key", "value");
assertTrue(ch.writeOutbound(trailers));
Http2HeadersFrame headerFrame = ch.readOutbound();
assertThat(headerFrame.headers().get("key").toString(), is("value"));
assertTrue(headerFrame.isEndStream());
assertThat(ch.readOutbound(), is(nullValue()));
assertFalse(ch.finish());
}
use of org.apache.flink.shaded.netty4.io.netty.channel.embedded.EmbeddedChannel in project netty by netty.
the class Http2ServerDowngraderTest method testUpgradeHeaders.
@Test
public void testUpgradeHeaders() throws Exception {
EmbeddedChannel ch = new EmbeddedChannel(new Http2ServerDowngrader());
HttpResponse response = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
assertTrue(ch.writeOutbound(response));
Http2HeadersFrame headersFrame = ch.readOutbound();
assertThat(headersFrame.headers().status().toString(), is("200"));
assertFalse(headersFrame.isEndStream());
assertThat(ch.readOutbound(), is(nullValue()));
assertFalse(ch.finish());
}
use of org.apache.flink.shaded.netty4.io.netty.channel.embedded.EmbeddedChannel in project netty by netty.
the class Http2FrameCodecTest method setUp.
@Before
public void setUp() throws Exception {
frameWriter = spy(new VerifiableHttp2FrameWriter());
framingCodec = new Http2FrameCodec(true, frameWriter, new Http2FrameLogger(LogLevel.TRACE), new Http2Settings());
frameListener = ((DefaultHttp2ConnectionDecoder) framingCodec.connectionHandler().decoder()).internalFrameListener();
inboundHandler = new LastInboundHandler();
channel = new EmbeddedChannel();
channel.connect(new InetSocketAddress(0));
channel.pipeline().addLast(framingCodec);
channel.pipeline().addLast(inboundHandler);
http2HandlerCtx = channel.pipeline().context(framingCodec.connectionHandler());
// Handshake
verify(frameWriter).writeSettings(eq(http2HandlerCtx), anyHttp2Settings(), anyChannelPromise());
verifyNoMoreInteractions(frameWriter);
channel.writeInbound(Http2CodecUtil.connectionPrefaceBuf());
frameListener.onSettingsRead(http2HandlerCtx, new Http2Settings());
verify(frameWriter).writeSettingsAck(eq(http2HandlerCtx), anyChannelPromise());
frameListener.onSettingsAckRead(http2HandlerCtx);
}
Aggregations