private static Function<Integer, Mono<InputStream>> zipkinServerStream(String zipkinUrl, Mono<HttpClient> client) { return lookbackSeconds -> client .flatMap(c -> c .get(zipkinQuery(zipkinUrl, lookbackSeconds)) .flatMap(resp -> resp.receive() .aggregate() .asInputStream())); }
@Test public void hoverflyProxy() { Mono<HttpClientResponse> remote = HttpClient.create(o -> o.httpProxy(ops -> ops .address(new InetSocketAddress("localhost", hoverflyRule.getProxyPort())) )) .get("http://www.my-test.com/api/bookings/1", HttpClientRequest::sendHeaders); Mono<String> page = remote .flatMapMany(r -> r.receive() .retain() .asString() .limitRate(1)) .reduce(String::concat); StepVerifier.create(page) .expectNextMatches(s -> s.contains("bookingId")) .expectComplete() .verify(Duration.ofSeconds(30)); } }