From 0039b2c7dbce66234d06fd7ec23174839ad2ca21 Mon Sep 17 00:00:00 2001 From: Violeta Georgieva Date: Mon, 3 Jun 2024 13:29:47 +0300 Subject: [PATCH] Polish --- .../HttpServerOutboundCompleteTest.java | 56 +++++++++---------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/reactor-netty-http/src/test/java/reactor/netty/http/server/HttpServerOutboundCompleteTest.java b/reactor-netty-http/src/test/java/reactor/netty/http/server/HttpServerOutboundCompleteTest.java index 7838d1a3c4..2b680d64ab 100644 --- a/reactor-netty-http/src/test/java/reactor/netty/http/server/HttpServerOutboundCompleteTest.java +++ b/reactor-netty-http/src/test/java/reactor/netty/http/server/HttpServerOutboundCompleteTest.java @@ -233,38 +233,16 @@ void httpGetRespondsSendObject(HttpProtocol protocol) throws Exception { assertThat(recorder.onTerminateIsReceived.get()).isEqualTo(1); } - @ParameterizedTest - @EnumSource(value = HttpProtocol.class, names = {"HTTP11", "H2C"}) - void httpPostRespondsSend(HttpProtocol protocol) throws Exception { - CountDownLatch latch = new CountDownLatch(8); - EventsRecorder recorder = new EventsRecorder(latch); - disposableServer = createServer(recorder, protocol, - r -> r.post("/1", (req, res) -> res.send().doOnEach(recorder).doOnCancel(recorder)) - .post("/2", (req, res) -> req.receive().then(res.send().doOnEach(recorder).doOnCancel(recorder)))); - - sendPostRequest(disposableServer.port(), protocol) - .as(StepVerifier::create) - .expectNext(Collections.emptyList()) - .expectComplete() - .verify(Duration.ofSeconds(5)); - - assertThat(latch.await(5, TimeUnit.SECONDS)).isTrue(); - assertThat(recorder.bufferIsReleased.get()).isEqualTo(2); - assertThat(recorder.fullResponseIsSent.get()).isEqualTo(2); - assertThat(recorder.onCompleteIsReceived.get()).isEqualTo(2); - assertThat(recorder.onTerminateIsReceived.get()).isEqualTo(2); - } - @Test - void httpPipeliningGetRespondsSendObject() throws Exception { + void httpPipeliningGetRespondsSendMono() throws Exception { String oldValue = System.getProperty("reactor.netty.http.server.lastFlushWhenNoRead", "false"); System.setProperty("reactor.netty.http.server.lastFlushWhenNoRead", "true"); try { CountDownLatch latch = new CountDownLatch(64); EventsRecorder recorder = new EventsRecorder(latch); disposableServer = createServer(recorder, HttpProtocol.HTTP11, - r -> r.get("/1", (req, res) -> res.sendObject(Unpooled.wrappedBuffer(REPEAT.getBytes(Charset.defaultCharset()))) - .then().doOnEach(recorder).doOnCancel(recorder))); + r -> r.get("/1", (req, res) -> res.sendString(Mono.just(REPEAT).delayElement(Duration.ofMillis(10)) + .doOnEach(recorder).doOnCancel(recorder)))); Connection client = TcpClient.create() @@ -307,15 +285,15 @@ void httpPipeliningGetRespondsSendObject() throws Exception { } @Test - void httpPipeliningGetRespondsSendMono() throws Exception { + void httpPipeliningGetRespondsSendObject() throws Exception { String oldValue = System.getProperty("reactor.netty.http.server.lastFlushWhenNoRead", "false"); System.setProperty("reactor.netty.http.server.lastFlushWhenNoRead", "true"); try { CountDownLatch latch = new CountDownLatch(64); EventsRecorder recorder = new EventsRecorder(latch); disposableServer = createServer(recorder, HttpProtocol.HTTP11, - r -> r.get("/1", (req, res) -> res.sendString(Mono.just(REPEAT).delayElement(Duration.ofMillis(10)) - .doOnEach(recorder).doOnCancel(recorder)))); + r -> r.get("/1", (req, res) -> res.sendObject(Unpooled.wrappedBuffer(REPEAT.getBytes(Charset.defaultCharset()))) + .then().doOnEach(recorder).doOnCancel(recorder))); Connection client = TcpClient.create() @@ -357,6 +335,28 @@ void httpPipeliningGetRespondsSendMono() throws Exception { } } + @ParameterizedTest + @EnumSource(value = HttpProtocol.class, names = {"HTTP11", "H2C"}) + void httpPostRespondsSend(HttpProtocol protocol) throws Exception { + CountDownLatch latch = new CountDownLatch(8); + EventsRecorder recorder = new EventsRecorder(latch); + disposableServer = createServer(recorder, protocol, + r -> r.post("/1", (req, res) -> res.send().doOnEach(recorder).doOnCancel(recorder)) + .post("/2", (req, res) -> req.receive().then(res.send().doOnEach(recorder).doOnCancel(recorder)))); + + sendPostRequest(disposableServer.port(), protocol) + .as(StepVerifier::create) + .expectNext(Collections.emptyList()) + .expectComplete() + .verify(Duration.ofSeconds(5)); + + assertThat(latch.await(5, TimeUnit.SECONDS)).isTrue(); + assertThat(recorder.bufferIsReleased.get()).isEqualTo(2); + assertThat(recorder.fullResponseIsSent.get()).isEqualTo(2); + assertThat(recorder.onCompleteIsReceived.get()).isEqualTo(2); + assertThat(recorder.onTerminateIsReceived.get()).isEqualTo(2); + } + @ParameterizedTest @EnumSource(value = HttpProtocol.class, names = {"HTTP11", "H2C"}) void httpPostRespondsSendFlux(HttpProtocol protocol) throws Exception {