@Test public void simpleClientPooling() { ConnectionProvider p = ConnectionProvider.fixed("test", 1); AtomicReference<Channel> ch1 = new AtomicReference<>(); AtomicReference<Channel> ch2 = new AtomicReference<>(); HttpResponseStatus r = HttpClient.create(p) .doOnResponse((res, c) -> ch1.set(c.channel())) .wiretap(true) .get() .uri("http://google.com/unsupportedURI") .responseSingle((res, buf) -> buf.thenReturn(res.status())) .block(Duration.ofSeconds(30)); HttpClient.create(p) .doOnResponse((res, c) -> ch2.set(c.channel())) .wiretap(true) .get() .uri("http://google.com/unsupportedURI") .responseSingle((res, buf) -> buf.thenReturn(res.status())) .block(Duration.ofSeconds(30)); AtomicBoolean same = new AtomicBoolean(); same.set(ch1.get() == ch2.get()); Assert.assertTrue(same.get()); Assert.assertEquals(r, HttpResponseStatus.NOT_FOUND); p.dispose(); }
.responseSingle((r, buf) -> buf.thenReturn(r.status().code())) .log() .block(Duration.ofSeconds(30));