use of org.apache.flink.shaded.netty4.io.netty.channel.embedded.EmbeddedChannel in project jackrabbit-oak by apache.
the class ResponseDecoderTest method shouldDropGetReferencesResponsesWithoutDelimiter.
@Test
public void shouldDropGetReferencesResponsesWithoutDelimiter() throws Exception {
byte[] data = "a".getBytes(Charsets.UTF_8);
ByteBuf buf = Unpooled.buffer();
buf.writeInt(data.length + 1);
buf.writeByte(Messages.HEADER_REFERENCES);
buf.writeBytes(data);
EmbeddedChannel channel = new EmbeddedChannel(new ResponseDecoder(folder.newFolder()));
channel.writeInbound(buf);
assertNull(channel.readInbound());
}
use of org.apache.flink.shaded.netty4.io.netty.channel.embedded.EmbeddedChannel in project jackrabbit-oak by apache.
the class ResponseDecoderTest method shouldDropInvalidGetSegmentResponses.
@Test
public void shouldDropInvalidGetSegmentResponses() throws Exception {
UUID uuid = new UUID(1, 2);
byte[] data = new byte[] { 3, 4, 5 };
ByteBuf buf = Unpooled.buffer();
buf.writeInt(data.length + 25);
buf.writeByte(Messages.HEADER_SEGMENT);
buf.writeLong(uuid.getMostSignificantBits());
buf.writeLong(uuid.getLeastSignificantBits());
buf.writeLong(hash(data) + 1);
buf.writeBytes(data);
EmbeddedChannel channel = new EmbeddedChannel(new ResponseDecoder(folder.newFolder()));
channel.writeInbound(buf);
assertNull(channel.readInbound());
}
use of org.apache.flink.shaded.netty4.io.netty.channel.embedded.EmbeddedChannel in project jackrabbit-oak by apache.
the class ResponseDecoderTest method shouldDecodeValidSingleElementGetReferencesResponses.
@Test
public void shouldDecodeValidSingleElementGetReferencesResponses() throws Exception {
byte[] data = "a:b".getBytes(Charsets.UTF_8);
ByteBuf buf = Unpooled.buffer();
buf.writeInt(data.length + 1);
buf.writeByte(Messages.HEADER_REFERENCES);
buf.writeBytes(data);
EmbeddedChannel channel = new EmbeddedChannel(new ResponseDecoder(folder.newFolder()));
channel.writeInbound(buf);
GetReferencesResponse response = (GetReferencesResponse) channel.readInbound();
assertEquals("a", response.getSegmentId());
assertTrue(elementsEqual(newArrayList("b"), response.getReferences()));
}
use of org.apache.flink.shaded.netty4.io.netty.channel.embedded.EmbeddedChannel in project jackrabbit-oak by apache.
the class ResponseDecoderTest method unrecognizedMessagesShouldBeDropped.
@Test
public void unrecognizedMessagesShouldBeDropped() throws Exception {
ByteBuf buf = Unpooled.buffer();
buf.writeInt(1);
buf.writeByte(-1);
EmbeddedChannel channel = new EmbeddedChannel(new ResponseDecoder(folder.newFolder()));
channel.writeInbound(buf);
assertNull(channel.readInbound());
}
use of org.apache.flink.shaded.netty4.io.netty.channel.embedded.EmbeddedChannel in project jocean-http by isdom.
the class DefaultHttpTradeTestCase method testTradeForCallAbortBeforeRequestPublish.
// TODO: fix
@Test
public final void testTradeForCallAbortBeforeRequestPublish() {
final DefaultFullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "/", Nettys4Test.buildByteBuf("testcontent"));
final EmbeddedChannel channel = new EmbeddedChannel();
final HttpTrade trade = new DefaultHttpTrade(channel);
final TestSubscriber<DisposableWrapper<HttpObject>> reqSubscriber = new TestSubscriber<>();
trade.inbound().subscribe(reqSubscriber);
trade.close();
assertTrue(!trade.isActive());
reqSubscriber.assertTerminalEvent();
reqSubscriber.assertError(Exception.class);
writeToInboundAndFlush(channel, request);
reqSubscriber.assertValueCount(0);
}
Aggregations