Refactored tests.

This commit is contained in:
Simone Bordet 2016-06-20 23:10:22 +02:00
parent 7ef22c8ebd
commit d073780dde
3 changed files with 6 additions and 55 deletions

View File

@ -18,15 +18,10 @@
package org.eclipse.jetty.http.client;
import java.io.IOException;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.function.Predicate;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.HttpClientTransport;
import org.eclipse.jetty.client.HttpDestination;
@ -44,8 +39,6 @@ import org.eclipse.jetty.http2.client.http.HttpChannelOverHTTP2;
import org.eclipse.jetty.http2.client.http.HttpClientTransportOverHTTP2;
import org.eclipse.jetty.http2.client.http.HttpConnectionOverHTTP2;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.eclipse.jetty.util.Promise;
import org.eclipse.jetty.util.thread.QueuedThreadPool;
import org.junit.Assert;
@ -61,14 +54,7 @@ public class HttpChannelAssociationTest extends AbstractTest
@Test
public void testAssociationFailedAbortsRequest() throws Exception
{
startServer(new AbstractHandler()
{
@Override
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
baseRequest.setHandled(true);
}
});
startServer(new EmptyServerHandler());
client = new HttpClient(newHttpClientTransport(transport, exchange -> false), sslContextFactory);
QueuedThreadPool clientThreads = new QueuedThreadPool();
@ -90,14 +76,7 @@ public class HttpChannelAssociationTest extends AbstractTest
@Test
public void testIdleTimeoutJustBeforeAssociation() throws Exception
{
startServer(new AbstractHandler()
{
@Override
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
baseRequest.setHandled(true);
}
});
startServer(new EmptyServerHandler());
long idleTimeout = 1000;
client = new HttpClient(newHttpClientTransport(transport, exchange ->

View File

@ -116,14 +116,7 @@ public class HttpClientIdleTimeoutTest extends AbstractTest
@Test
public void testIdleClientIdleTimeout() throws Exception
{
start(new AbstractHandler()
{
@Override
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
baseRequest.setHandled(true);
}
});
start(new EmptyServerHandler());
client.stop();
client.setIdleTimeout(idleTimeout);
client.start();
@ -143,14 +136,7 @@ public class HttpClientIdleTimeoutTest extends AbstractTest
@Test
public void testIdleServerIdleTimeout() throws Exception
{
start(new AbstractHandler()
{
@Override
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
baseRequest.setHandled(true);
}
});
start(new EmptyServerHandler());
connector.setIdleTimeout(idleTimeout);
ContentResponse response1 = client.newRequest(newURI()).send();

View File

@ -300,14 +300,7 @@ public class HttpClientTest extends AbstractTest
// Only run this test for transports over TLS.
Assume.assumeTrue(EnumSet.of(Transport.HTTPS, Transport.H2).contains(transport));
startServer(new AbstractHandler()
{
@Override
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
baseRequest.setHandled(true);
}
});
startServer(new EmptyServerHandler());
// Use a default SslContextFactory, requests should fail because the server certificate is unknown.
client = newHttpClient(provideClientTransport(transport), new SslContextFactory());
@ -410,14 +403,7 @@ public class HttpClientTest extends AbstractTest
@Test
public void testConnectionListener() throws Exception
{
start(new AbstractHandler()
{
@Override
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
baseRequest.setHandled(true);
}
});
start(new EmptyServerHandler());
CountDownLatch openLatch = new CountDownLatch(1);
CountDownLatch closeLatch = new CountDownLatch(1);