@Test public void testPost() throws Exception { DirectProvider ep = new DirectProvider(); Topology topology = ep.newTopology(); String url = "http://httpbin.org/post"; TStream<String> stream = topology.strings(url); TStream<String> rc = HttpStreams.<String, String>requestsWithBody( stream, HttpClients::noAuthentication, t -> HttpPost.METHOD_NAME, t-> t, t-> new ByteArrayEntity(t.getBytes()), HttpResponders.inputOn200()); Tester tester = topology.getTester(); Condition<List<String>> endCondition = tester.streamContents(rc, url); tester.complete(ep, new JsonObject(), endCondition, 10, TimeUnit.SECONDS); assertTrue(endCondition.valid()); }
@Test public void testPut() throws Exception { DirectProvider ep = new DirectProvider(); Topology topology = ep.newTopology(); String url = "http://httpbin.org/put"; TStream<String> stream = topology.strings(url); TStream<String> rc = HttpStreams.<String, String>requestsWithBody( stream, HttpClients::noAuthentication, t -> HttpPut.METHOD_NAME, t-> t, t-> new ByteArrayEntity(t.getBytes()), HttpResponders.inputOn200()); Tester tester = topology.getTester(); Condition<List<String>> endCondition = tester.streamContents(rc, url); tester.complete(ep, new JsonObject(), endCondition, 10, TimeUnit.SECONDS); assertTrue(endCondition.valid()); }
@Test public void testDelete() throws Exception { DirectProvider ep = new DirectProvider(); Topology topology = ep.newTopology(); String url = "http://httpbin.org/delete"; TStream<String> stream = topology.strings(url); TStream<String> rc = HttpStreams.<String, String>requests( stream, HttpClients::noAuthentication, t -> HttpDelete.METHOD_NAME, t-> t, HttpResponders.inputOn200()); Tester tester = topology.getTester(); Condition<List<String>> endCondition = tester.streamContents(rc, url); tester.complete(ep, new JsonObject(), endCondition, 10, TimeUnit.SECONDS); assertTrue(endCondition.valid()); }
@Test public void testGet() throws Exception { DirectProvider ep = new DirectProvider(); Topology topology = ep.newTopology(); String url = "http://httpbin.org/get"; TStream<String> rc = HttpStreams.<String,String>requests( topology.strings(url), HttpClients::noAuthentication, t-> HttpGet.METHOD_NAME, t->t, HttpResponders.inputOn200()); Tester tester = topology.getTester(); Condition<List<String>> endCondition = tester.streamContents(rc, url); tester.complete(ep, new JsonObject(), endCondition, 10, TimeUnit.SECONDS); assertTrue(endCondition.valid()); }