Skip to content

Commit

Permalink
Polish
Browse files Browse the repository at this point in the history
  • Loading branch information
violetagg committed Jun 3, 2024
1 parent 3f5c884 commit 0039b2c
Showing 1 changed file with 28 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 0039b2c

Please sign in to comment.