use of org.apache.flink.shaded.netty4.io.netty.buffer.ByteBuf in project neo4j by neo4j.
the class NetworkFlushableChannelNetty4Test method shouldNotCountBytesAlreadyInBuffer.
@Test
public void shouldNotCountBytesAlreadyInBuffer() throws Exception {
// Given
int sizeLimit = 100;
ByteBuf buffer = Unpooled.buffer();
int padding = Long.BYTES;
buffer.writeLong(0);
NetworkFlushableChannelNetty4 channel = new NetworkFlushableChannelNetty4(buffer, sizeLimit);
// When
for (int i = 0; i < sizeLimit - padding; i++) {
channel.put((byte) 0);
}
// again, when
for (int i = 0; i < padding; i++) {
channel.put((byte) 0);
}
// finally, when we pass the limit
try {
channel.put((byte) 0);
fail("Should not allow more bytes than what the limit dictates");
} catch (MessageTooBigException e) {
// then
}
}
use of org.apache.flink.shaded.netty4.io.netty.buffer.ByteBuf in project netty by netty.
the class Http2MultiplexCodecTest method inboundDataFrameShouldEmitWindowUpdateFrame.
@Test
public void inboundDataFrameShouldEmitWindowUpdateFrame() {
LastInboundHandler inboundHandler = streamActiveAndWriteHeaders(streamId);
ByteBuf tenBytes = bb("0123456789");
parentChannel.pipeline().fireChannelRead(new DefaultHttp2DataFrame(tenBytes, true).streamId(streamId));
parentChannel.pipeline().flush();
Http2WindowUpdateFrame windowUpdate = parentChannel.readOutbound();
assertNotNull(windowUpdate);
assertEquals(streamId, windowUpdate.streamId());
assertEquals(10, windowUpdate.windowSizeIncrement());
// headers and data frame
verifyFramesMultiplexedToCorrectChannel(streamId, inboundHandler, 2);
}
use of org.apache.flink.shaded.netty4.io.netty.buffer.ByteBuf in project netty by netty.
the class Http2ServerDowngraderTest method testUpgradeNonEmptyFullResponse.
@Test
public void testUpgradeNonEmptyFullResponse() throws Exception {
EmbeddedChannel ch = new EmbeddedChannel(new Http2ServerDowngrader());
ByteBuf hello = Unpooled.copiedBuffer("hello world", CharsetUtil.UTF_8);
assertTrue(ch.writeOutbound(new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK, hello)));
Http2HeadersFrame headersFrame = ch.readOutbound();
assertThat(headersFrame.headers().status().toString(), is("200"));
assertFalse(headersFrame.isEndStream());
Http2DataFrame dataFrame = ch.readOutbound();
try {
assertThat(dataFrame.content().toString(CharsetUtil.UTF_8), is("hello world"));
assertTrue(dataFrame.isEndStream());
} finally {
dataFrame.release();
}
assertThat(ch.readOutbound(), is(nullValue()));
assertFalse(ch.finish());
}
use of org.apache.flink.shaded.netty4.io.netty.buffer.ByteBuf in project netty by netty.
the class Http2ServerDowngraderTest method testUpgradeDataEndWithTrailers.
@Test
public void testUpgradeDataEndWithTrailers() throws Exception {
EmbeddedChannel ch = new EmbeddedChannel(new Http2ServerDowngrader());
ByteBuf hello = Unpooled.copiedBuffer("hello world", CharsetUtil.UTF_8);
LastHttpContent trailers = new DefaultLastHttpContent(hello, true);
HttpHeaders headers = trailers.trailingHeaders();
headers.set("key", "value");
assertTrue(ch.writeOutbound(trailers));
Http2DataFrame dataFrame = ch.readOutbound();
try {
assertThat(dataFrame.content().toString(CharsetUtil.UTF_8), is("hello world"));
assertFalse(dataFrame.isEndStream());
} finally {
dataFrame.release();
}
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.buffer.ByteBuf in project netty by netty.
the class Http2ServerDowngraderTest method testUpgradeDataEnd.
@Test
public void testUpgradeDataEnd() throws Exception {
EmbeddedChannel ch = new EmbeddedChannel(new Http2ServerDowngrader());
ByteBuf hello = Unpooled.copiedBuffer("hello world", CharsetUtil.UTF_8);
LastHttpContent end = new DefaultLastHttpContent(hello, true);
assertTrue(ch.writeOutbound(end));
Http2DataFrame dataFrame = ch.readOutbound();
try {
assertThat(dataFrame.content().toString(CharsetUtil.UTF_8), is("hello world"));
assertTrue(dataFrame.isEndStream());
} finally {
dataFrame.release();
}
assertThat(ch.readOutbound(), is(nullValue()));
assertFalse(ch.finish());
}
Aggregations