use of org.apache.flink.shaded.netty4.io.netty.channel.embedded.EmbeddedChannel in project jocean-http by isdom.
the class DefaultHttpTradeTestCase method testTradeForFullRequestSourceAndDumpFullRequests.
@Test
public final void testTradeForFullRequestSourceAndDumpFullRequests() throws IOException {
final DefaultFullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "/", Nettys4Test.buildByteBuf(REQ_CONTENT));
final EmbeddedChannel channel = new EmbeddedChannel();
final HttpTrade trade = new DefaultHttpTrade(channel);
writeToInboundAndFlush(channel, request);
// expected refCnt, request -- 1 + HttpMessageHolder -- 1, total refcnt is 2
// TODO, why 4 & 5 refCnt ?
callByteBufHolderBuilderOnceAndAssertDumpContentAndRefCnt(trade.inbound().compose(RxNettys.message2fullreq(trade)).toBlocking().single().unwrap(), REQ_CONTENT.getBytes(Charsets.UTF_8), 4);
callByteBufHolderBuilderOnceAndAssertDumpContentAndRefCnt(trade.inbound().compose(RxNettys.message2fullreq(trade)).toBlocking().single().unwrap(), REQ_CONTENT.getBytes(Charsets.UTF_8), 5);
}
use of org.apache.flink.shaded.netty4.io.netty.channel.embedded.EmbeddedChannel in project jocean-http by isdom.
the class DefaultHttpTradeTestCase method testTradeForRequestAndLastContentSourceAndDumpFullRequests.
@Test
public final void testTradeForRequestAndLastContentSourceAndDumpFullRequests() throws IOException {
final DefaultHttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "/");
final LastHttpContent lastcontent = new DefaultLastHttpContent(Nettys4Test.buildByteBuf(REQ_CONTENT));
final EmbeddedChannel channel = new EmbeddedChannel();
final HttpTrade trade = new DefaultHttpTrade(channel);
writeToInboundAndFlush(channel, request);
writeToInboundAndFlush(channel, lastcontent);
// final Func0<FullHttpRequest> fullRequestBuilder =
// trade.inboundHolder().fullOf(RxNettys.BUILD_FULL_REQUEST);
// expected refCnt, request -- 1 + HttpMessageHolder -- 1, total refcnt is 2
// TODO, why 4 & 5 refCnt ?
callByteBufHolderBuilderOnceAndAssertDumpContentAndRefCnt(trade.inbound().compose(RxNettys.message2fullreq(trade)).toBlocking().single().unwrap(), REQ_CONTENT.getBytes(Charsets.UTF_8), 4);
callByteBufHolderBuilderOnceAndAssertDumpContentAndRefCnt(trade.inbound().compose(RxNettys.message2fullreq(trade)).toBlocking().single().unwrap(), REQ_CONTENT.getBytes(Charsets.UTF_8), 5);
}
use of org.apache.flink.shaded.netty4.io.netty.channel.embedded.EmbeddedChannel in project alliance by codice.
the class RawUdpDataToMTSPacketDecoderTest method testCorruptedData.
@SuppressWarnings("unchecked")
@Test
public void testCorruptedData() throws Exception {
RawUdpDataToMTSPacketDecoder.MTSParser mtsParser = mock(RawUdpDataToMTSPacketDecoder.MTSParser.class);
ResettableMTSSource resettable = mock(ResettableMTSSource.class);
Mockito.when(mtsParser.parse(Mockito.any())).thenReturn(resettable);
MTSPacket mtsPacket = mock(MTSPacket.class);
Mockito.when(resettable.nextPacket()).thenThrow(RuntimeException.class).thenReturn(mtsPacket);
int packetCount = 2;
List<DatagramPacket> datagramPackets = toDatagrams(flatten(createTsPackets(packetCount)));
PacketBuffer packetBuffer = mock(PacketBuffer.class);
RawUdpDataToMTSPacketDecoder rawUdpDataToMTSPacketDecoder = new RawUdpDataToMTSPacketDecoder(packetBuffer, mock(UdpStreamProcessor.class));
rawUdpDataToMTSPacketDecoder.setMtsParser(mtsParser);
EmbeddedChannel channel = new EmbeddedChannel(rawUdpDataToMTSPacketDecoder);
datagramPackets.forEach(channel::writeInbound);
List<Object> outputList = NettyUtility.read(channel);
assertThat(outputList, hasSize(packetCount - 1));
}
use of org.apache.flink.shaded.netty4.io.netty.channel.embedded.EmbeddedChannel in project alliance by codice.
the class RawUdpDataToMTSPacketDecoderTest method test.
@Test
public void test() throws Exception {
int packetCount = 100;
List<DatagramPacket> datagramPackets = toDatagrams(flatten(createTsPackets(packetCount)));
PacketBuffer packetBuffer = mock(PacketBuffer.class);
EmbeddedChannel channel = new EmbeddedChannel(new RawUdpDataToMTSPacketDecoder(packetBuffer, mock(UdpStreamProcessor.class)));
datagramPackets.forEach(channel::writeInbound);
List<Object> outputList = NettyUtility.read(channel);
assertThat(outputList, hasSize(packetCount));
}
use of org.apache.flink.shaded.netty4.io.netty.channel.embedded.EmbeddedChannel in project sidewinder by srotya.
the class TestGraphiteDecoder method testHandler.
@Test
public void testHandler() throws IOException {
EmbeddedChannel ch = new EmbeddedChannel(new StringDecoder(), new GraphiteDecoder("test", engine, null));
ch.writeInbound(Unpooled.copiedBuffer("app1.server1.jvm.heap.max 233123 1497720452", Charset.defaultCharset()));
ch.readInbound();
verify(engine, times(1)).writeDataPoint("test", "heap", "max", Arrays.asList("app1", "server1", "jvm"), ((long) 1497720452) * 1000, 233123);
ch.close();
}
Aggregations