use of org.apache.flink.shaded.netty4.io.netty.channel.embedded.EmbeddedChannel in project netty by netty.
the class JsonObjectDecoderTest method testMaxObjectLength.
@Test(expected = TooLongFrameException.class)
public void testMaxObjectLength() {
EmbeddedChannel ch = new EmbeddedChannel(new JsonObjectDecoder(6));
try {
ch.writeInbound(Unpooled.copiedBuffer("[2,4,5]", CharsetUtil.UTF_8));
} finally {
assertFalse(ch.finish());
}
fail();
}
use of org.apache.flink.shaded.netty4.io.netty.channel.embedded.EmbeddedChannel in project netty by netty.
the class JsonObjectDecoderTest method testNonJsonContent1.
@Test(expected = CorruptedFrameException.class)
public void testNonJsonContent1() {
EmbeddedChannel ch = new EmbeddedChannel(new JsonObjectDecoder());
try {
ch.writeInbound(Unpooled.copiedBuffer(" b [1,2,3]", CharsetUtil.UTF_8));
} finally {
assertFalse(ch.finish());
}
fail();
}
use of org.apache.flink.shaded.netty4.io.netty.channel.embedded.EmbeddedChannel in project netty by netty.
the class WebSocketServerProtocolHandlerTest method testHttpUpgradeRequest.
@Test
public void testHttpUpgradeRequest() throws Exception {
EmbeddedChannel ch = createChannel(new MockOutboundHandler());
ChannelHandlerContext handshakerCtx = ch.pipeline().context(WebSocketServerProtocolHandshakeHandler.class);
writeUpgradeRequest(ch);
FullHttpResponse response = responses.remove();
assertEquals(SWITCHING_PROTOCOLS, response.status());
response.release();
assertNotNull(WebSocketServerProtocolHandler.getHandshaker(handshakerCtx.channel()));
}
use of org.apache.flink.shaded.netty4.io.netty.channel.embedded.EmbeddedChannel in project netty by netty.
the class HttpClientCodecTest method testFailsNotOnRequestResponse.
@Test
public void testFailsNotOnRequestResponse() {
HttpClientCodec codec = new HttpClientCodec(4096, 8192, 8192, true);
EmbeddedChannel ch = new EmbeddedChannel(codec);
ch.writeOutbound(new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "http://localhost/"));
ch.writeInbound(Unpooled.copiedBuffer(RESPONSE, CharsetUtil.ISO_8859_1));
ch.finish();
for (; ; ) {
Object msg = ch.readOutbound();
if (msg == null) {
break;
}
release(msg);
}
for (; ; ) {
Object msg = ch.readInbound();
if (msg == null) {
break;
}
release(msg);
}
}
use of org.apache.flink.shaded.netty4.io.netty.channel.embedded.EmbeddedChannel in project neo4j by neo4j.
the class TxPullResponseEncodeDecodeTest method shouldEncodeAndDecodePullResponseMessage.
@Test
public void shouldEncodeAndDecodePullResponseMessage() {
// given
EmbeddedChannel channel = new EmbeddedChannel(new TxPullResponseEncoder(), new TxPullResponseDecoder());
TxPullResponse sent = new TxPullResponse(new StoreId(1, 2, 3, 4), newCommittedTransactionRepresentation());
// when
channel.writeOutbound(sent);
channel.writeInbound(new Object[] { channel.readOutbound() });
// then
TxPullResponse received = (TxPullResponse) channel.readInbound();
assertNotSame(sent, received);
assertEquals(sent, received);
}
Aggregations