public static DefaultFullRequest.Builder newGet(String path) { return newGet().path(path); }
@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 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 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()); }