Fixed test after #1804.

This commit is contained in:
Simone Bordet 2017-09-11 17:03:22 +02:00
parent b078c910a7
commit c402f8d5fa
1 changed files with 5 additions and 13 deletions

View File

@ -20,6 +20,7 @@ package org.eclipse.jetty.client;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.nio.ByteBuffer;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
@ -28,6 +29,7 @@ import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.client.util.DeferredContentProvider;
import org.eclipse.jetty.server.Request; import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.handler.AbstractHandler; import org.eclipse.jetty.server.handler.AbstractHandler;
import org.eclipse.jetty.util.ssl.SslContextFactory; import org.eclipse.jetty.util.ssl.SslContextFactory;
@ -156,28 +158,18 @@ public class HttpResponseAbortTest extends AbstractHttpClientServerTest
} }
}); });
final CountDownLatch abortLatch = new CountDownLatch(1); final DeferredContentProvider contentProvider = new DeferredContentProvider(ByteBuffer.allocate(1));
final AtomicInteger completes = new AtomicInteger(); final AtomicInteger completes = new AtomicInteger();
final CountDownLatch completeLatch = new CountDownLatch(1); final CountDownLatch completeLatch = new CountDownLatch(1);
client.newRequest("localhost", connector.getLocalPort()) client.newRequest("localhost", connector.getLocalPort())
.scheme(scheme) .scheme(scheme)
.onRequestSuccess(request -> .content(contentProvider)
{
try
{
abortLatch.await(5, TimeUnit.SECONDS);
}
catch (InterruptedException x)
{
x.printStackTrace();
}
})
.onResponseContent((response, content) -> .onResponseContent((response, content) ->
{ {
try try
{ {
response.abort(new Exception()); response.abort(new Exception());
abortLatch.countDown(); contentProvider.close();
// Delay to let the request side to finish its processing. // Delay to let the request side to finish its processing.
Thread.sleep(1000); Thread.sleep(1000);
} }