|
22 | 22 | import java.nio.ByteBuffer;
|
23 | 23 | import java.nio.channels.ByteChannel;
|
24 | 24 | import java.nio.channels.Channels;
|
| 25 | +import java.time.Duration; |
25 | 26 | import java.util.concurrent.BlockingDeque;
|
26 | 27 | import java.util.concurrent.LinkedBlockingDeque;
|
27 | 28 | import java.util.concurrent.TimeUnit;
|
28 | 29 | import java.util.concurrent.atomic.AtomicBoolean;
|
29 | 30 |
|
| 31 | +import org.awaitility.Awaitility; |
30 | 32 | import org.junit.jupiter.api.BeforeEach;
|
31 | 33 | import org.junit.jupiter.api.Test;
|
32 | 34 | import org.junit.jupiter.api.extension.ExtendWith;
|
@@ -236,13 +238,14 @@ void httpConnectionsAreClosedAfterLongPollTimeout() throws Exception {
|
236 | 238 | this.server.setLongPollTimeout(100);
|
237 | 239 | MockHttpConnection h1 = new MockHttpConnection();
|
238 | 240 | this.server.handle(h1);
|
| 241 | + Awaitility.await().atMost(Duration.ofSeconds(30)).until(h1.getServletResponse()::getStatus, |
| 242 | + (status) -> status == 204); |
239 | 243 | MockHttpConnection h2 = new MockHttpConnection();
|
240 | 244 | this.server.handle(h2);
|
241 |
| - Thread.sleep(400); |
| 245 | + Awaitility.await().atMost(Duration.ofSeconds(30)).until(h2.getServletResponse()::getStatus, |
| 246 | + (status) -> status == 204); |
242 | 247 | this.serverChannel.disconnect();
|
243 | 248 | this.server.getServerThread().join();
|
244 |
| - assertThat(h1.getServletResponse().getStatus()).isEqualTo(204); |
245 |
| - assertThat(h2.getServletResponse().getStatus()).isEqualTo(204); |
246 | 249 | }
|
247 | 250 |
|
248 | 251 | @Test
|
|
0 commit comments