use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.DefaultFullHttpRequest in project jocean-http by isdom.
the class DefaultHttpTradeTestCase method testTradeForCallAbortAfterRequestPublish.
@Test
public final void testTradeForCallAbortAfterRequestPublish() {
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);
writeToInboundAndFlush(channel, request);
trade.close();
assertFalse(trade.isActive());
reqSubscriber.assertValueCount(1);
reqSubscriber.assertValue(RxNettys.<HttpObject>wrap4release(request));
reqSubscriber.assertCompleted();
reqSubscriber.assertNoErrors();
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.DefaultFullHttpRequest in project jocean-http by isdom.
the class DefaultHttpTradeTestCase method testTradeForCallAbortAndUseInboundRequest.
@Test
public final void testTradeForCallAbortAndUseInboundRequest() {
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);
writeToInboundAndFlush(channel, request);
trade.close();
assertTrue(!trade.isActive());
final TestSubscriber<DisposableWrapper<HttpObject>> reqSubscriber = new TestSubscriber<>();
trade.inbound().subscribe(reqSubscriber);
reqSubscriber.assertTerminalEvent();
reqSubscriber.assertError(Exception.class);
reqSubscriber.assertValueCount(0);
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.DefaultFullHttpRequest in project jocean-http by isdom.
the class NettysTestCase method test_httpobjs2fullreq_success2.
@Test
public final void test_httpobjs2fullreq_success2() throws Exception {
final DefaultFullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "/", Nettys4Test.buildByteBuf(REQ_CONTENT));
assertEquals(1, request.refCnt());
final FullHttpRequest fullreq = Nettys.httpobjs2fullreq(Arrays.<HttpObject>asList(request));
assertNotNull(fullreq);
assertEquals(REQ_CONTENT, new String(Nettys.dumpByteBufAsBytes(fullreq.content()), Charsets.UTF_8));
assertEquals(2, request.refCnt());
fullreq.release();
assertEquals(1, request.refCnt());
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.DefaultFullHttpRequest in project jocean-http by isdom.
the class RxNettysTestCase method test_BUILD_FULL_REQUEST_ForSingleFullRequest.
@Test
public final void test_BUILD_FULL_REQUEST_ForSingleFullRequest() throws IOException {
final DefaultFullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "/", Nettys4Test.buildByteBuf(REQ_CONTENT));
assertEquals(1, request.refCnt());
final FullHttpRequest fullreq = RxNettys.BUILD_FULL_REQUEST.call(new HttpObject[] { request });
assertNotNull(fullreq);
assertEquals(REQ_CONTENT, new String(Nettys.dumpByteBufAsBytes(fullreq.content()), Charsets.UTF_8));
assertEquals(2, request.refCnt());
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.DefaultFullHttpRequest in project jocean-http by isdom.
the class DefaultHttpServerBuilderTestCase method buildFullRequest.
private DefaultFullHttpRequest buildFullRequest(final byte[] bytes) {
final ByteBuf content = Unpooled.buffer(0);
content.writeBytes(bytes);
final DefaultFullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "/", content);
HttpUtil.setContentLength(request, content.readableBytes());
return request;
}
Aggregations