Skip to content

Commit

Permalink
FormSubmissionTest#largeForm is flaky (#392)
Browse files Browse the repository at this point in the history
  • Loading branch information
basil authored Jun 21, 2024
1 parent 44a8b75 commit d66e39d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/test/java/winstone/FormSubmissionTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package winstone;

import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertEquals;

import java.net.HttpURLConnection;
Expand All @@ -9,6 +10,8 @@
import java.net.http.HttpResponse;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import org.awaitility.Awaitility;
import org.eclipse.jetty.server.ServerConnector;
import org.junit.Test;
import org.jvnet.hudson.test.Issue;
Expand All @@ -33,8 +36,12 @@ public void largeForm() throws Exception {
HttpRequest request = HttpRequest.newBuilder(new URI("http://127.0.0.2:" + port + "/AcceptFormServlet"))
.POST(HttpRequest.BodyPublishers.ofString("x=" + ".".repeat(size)))
.build();
HttpResponse<String> response =
HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
HttpResponse<String> response = Awaitility.await()
.pollInterval(100, TimeUnit.MILLISECONDS)
.atMost(5, TimeUnit.SECONDS)
.until(
() -> HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString()),
notNullValue());
assertEquals(HttpURLConnection.HTTP_OK, response.statusCode());
assertEquals(
"correct response at size " + size,
Expand Down

0 comments on commit d66e39d

Please sign in to comment.