public static DefaultFullRequest.Builder newGet(String path) { return newGet().path(path); }
public static DefaultFullRequest.Builder newPost(String path) { return newPost().path(path); } }
public static DefaultFullRequest.Builder newPost() { return newDefaultBuilder().method(HttpMethod.POST); }
@Test public void testNoClients() { request = RequestBuilders.newGet("https://www.google.com/").build(); when(config.clientConfigs()).thenReturn(new ArrayList<ClientConfig>()); subject = new ProxyHandler(factory, config, addressHelper); EmbeddedChannel channel = new EmbeddedChannel(new TestHandler(subject)); channel.writeInbound("doesn't matter"); assertTrue(channel.finish()); DefaultFullResponse result = channel.readOutbound(); assertEquals(result.status().code(), 503); } }
@Test public void testFullRequestWithBody() throws Exception { outputReceived = new CountDownLatch(1); ByteBuf body = ByteBufUtil.writeUtf8(UnpooledByteBufAllocator.DEFAULT, "body"); FullRequest requestIn = RequestBuilders.newPost("/").host("localhost").body(body).build(); channel.writeOutbound(requestIn); channel.runPendingTasks(); // blocks Uninterruptibles.awaitUninterruptibly(outputReceived); Http2Request requestOut = (Http2Request) requests.remove(0); assertTrue(requestOut != null); assertTrue(requestOut.payload instanceof Http2Headers); assertEquals("POST", ((Http2Headers) requestOut.payload).method().toString()); assertEquals("/", ((Http2Headers) requestOut.payload).path()); assertFalse(requestOut.eos); Http2Request contentOut = (Http2Request) requests.remove(0); assertTrue(contentOut != null); assertTrue(contentOut.payload instanceof Http2DataFrame); assertEquals(body, ((Http2DataFrame) contentOut.payload).content()); assertTrue(contentOut.eos); }
public static DefaultFullRequest.Builder newGet() { return newDefaultBuilder().method(HttpMethod.GET).body(Unpooled.EMPTY_BUFFER); }
@Test public void testFullRequest() throws Exception { outputReceived = new CountDownLatch(1); FullRequest requestIn = RequestBuilders.newGet("/").host("localhost").build(); channel.writeOutbound(requestIn); channel.runPendingTasks(); // blocks Uninterruptibles.awaitUninterruptibly(outputReceived); Http2Request requestOut = (Http2Request) requests.remove(0); assertTrue(requestOut != null); assertTrue(requestOut.payload instanceof Http2Headers); assertEquals("GET", ((Http2Headers) requestOut.payload).method().toString()); assertEquals("/", ((Http2Headers) requestOut.payload).path()); assertTrue(requestOut.eos); }
@Test public void testFullRequestWithBody() throws Exception { outputReceived = new CountDownLatch(1); ByteBuf body = ByteBufUtil.writeUtf8(UnpooledByteBufAllocator.DEFAULT, "body"); FullRequest requestIn = RequestBuilders.newPost("/").body(body).build(); channel.writeOutbound(requestIn); channel.runPendingTasks(); // blocks Uninterruptibles.awaitUninterruptibly(outputReceived); FullHttpRequest requestOut = (FullHttpRequest) requests.remove(0); assertTrue(requestOut != null); assertEquals(HTTP_1_1, requestOut.protocolVersion()); assertEquals(HttpMethod.POST, requestOut.method()); assertEquals("/", requestOut.uri()); assertFalse(requestOut.content() == null); assertEquals(body, requestOut.content()); }
@Test public void testFullRequest() throws Exception { outputReceived = new CountDownLatch(1); FullRequest requestIn = RequestBuilders.newGet("/").build(); channel.writeOutbound(requestIn); channel.runPendingTasks(); // blocks Uninterruptibles.awaitUninterruptibly(outputReceived); FullHttpRequest requestOut = (FullHttpRequest) requests.remove(0); assertTrue(requestOut != null); assertEquals(HTTP_1_1, requestOut.protocolVersion()); assertEquals(HttpMethod.GET, requestOut.method()); assertEquals("/", requestOut.uri()); assertFalse(requestOut.content() == null); assertEquals(0, requestOut.content().readableBytes()); }