From 37eb7909be7a7dfaa4c55b7122bb008d766b9181 Mon Sep 17 00:00:00 2001 From: Ludovic Orban Date: Mon, 2 Aug 2021 13:28:10 +0200 Subject: [PATCH] #6327 enable HttpClientStreamTest.testUploadWithDeferredContentProviderFromInputStream Signed-off-by: Ludovic Orban --- .../http/client/HttpClientStreamTest.java | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/tests/test-http-client-transport/src/test/java/org/eclipse/jetty/http/client/HttpClientStreamTest.java b/tests/test-http-client-transport/src/test/java/org/eclipse/jetty/http/client/HttpClientStreamTest.java index 70639327ceb..a4f3b800895 100644 --- a/tests/test-http-client-transport/src/test/java/org/eclipse/jetty/http/client/HttpClientStreamTest.java +++ b/tests/test-http-client-transport/src/test/java/org/eclipse/jetty/http/client/HttpClientStreamTest.java @@ -58,7 +58,6 @@ import org.eclipse.jetty.server.handler.AbstractHandler; import org.eclipse.jetty.toolchain.test.MavenTestingUtils; import org.eclipse.jetty.util.Callback; import org.eclipse.jetty.util.IO; -import org.junit.jupiter.api.condition.DisabledIfSystemProperty; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ArgumentsSource; @@ -666,7 +665,6 @@ public class HttpClientStreamTest extends AbstractTest @ParameterizedTest @ArgumentsSource(TransportProvider.class) - @DisabledIfSystemProperty(named = "env", matches = "ci") // TODO: SLOW, needs review public void testUploadWithDeferredContentProviderFromInputStream(Transport transport) throws Exception { init(transport); @@ -680,8 +678,17 @@ public class HttpClientStreamTest extends AbstractTest } }); - CountDownLatch latch = new CountDownLatch(1); - try (AsyncRequestContent content = new AsyncRequestContent()) + CountDownLatch demandLatch = new CountDownLatch(2); + CountDownLatch requestLatch = new CountDownLatch(1); + try (AsyncRequestContent content = new AsyncRequestContent() + { + @Override + public void demand() + { + demandLatch.countDown(); + super.demand(); + } + }) { scenario.client.newRequest(scenario.newURI()) .scheme(scenario.getScheme()) @@ -689,11 +696,11 @@ public class HttpClientStreamTest extends AbstractTest .send(result -> { if (result.isSucceeded() && result.getResponse().getStatus() == 200) - latch.countDown(); + requestLatch.countDown(); }); // Make sure we provide the content *after* the request has been "sent". - Thread.sleep(1000); + assertTrue(demandLatch.await(5, TimeUnit.SECONDS)); try (ByteArrayInputStream input = new ByteArrayInputStream(new byte[1024])) { @@ -705,7 +712,7 @@ public class HttpClientStreamTest extends AbstractTest } } } - assertTrue(latch.await(5, TimeUnit.SECONDS)); + assertTrue(requestLatch.await(5, TimeUnit.SECONDS)); } @ParameterizedTest