Refactored tests.
This commit is contained in:
parent
7ef22c8ebd
commit
d073780dde
|
@ -18,15 +18,10 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.http.client;
|
package org.eclipse.jetty.http.client;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.function.Predicate;
|
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.HttpClient;
|
||||||
import org.eclipse.jetty.client.HttpClientTransport;
|
import org.eclipse.jetty.client.HttpClientTransport;
|
||||||
import org.eclipse.jetty.client.HttpDestination;
|
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.HttpClientTransportOverHTTP2;
|
||||||
import org.eclipse.jetty.http2.client.http.HttpConnectionOverHTTP2;
|
import org.eclipse.jetty.http2.client.http.HttpConnectionOverHTTP2;
|
||||||
import org.eclipse.jetty.io.EndPoint;
|
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.Promise;
|
||||||
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
|
@ -61,14 +54,7 @@ public class HttpChannelAssociationTest extends AbstractTest
|
||||||
@Test
|
@Test
|
||||||
public void testAssociationFailedAbortsRequest() throws Exception
|
public void testAssociationFailedAbortsRequest() throws Exception
|
||||||
{
|
{
|
||||||
startServer(new AbstractHandler()
|
startServer(new EmptyServerHandler());
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
|
||||||
{
|
|
||||||
baseRequest.setHandled(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
client = new HttpClient(newHttpClientTransport(transport, exchange -> false), sslContextFactory);
|
client = new HttpClient(newHttpClientTransport(transport, exchange -> false), sslContextFactory);
|
||||||
QueuedThreadPool clientThreads = new QueuedThreadPool();
|
QueuedThreadPool clientThreads = new QueuedThreadPool();
|
||||||
|
@ -90,14 +76,7 @@ public class HttpChannelAssociationTest extends AbstractTest
|
||||||
@Test
|
@Test
|
||||||
public void testIdleTimeoutJustBeforeAssociation() throws Exception
|
public void testIdleTimeoutJustBeforeAssociation() throws Exception
|
||||||
{
|
{
|
||||||
startServer(new AbstractHandler()
|
startServer(new EmptyServerHandler());
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
|
||||||
{
|
|
||||||
baseRequest.setHandled(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
long idleTimeout = 1000;
|
long idleTimeout = 1000;
|
||||||
client = new HttpClient(newHttpClientTransport(transport, exchange ->
|
client = new HttpClient(newHttpClientTransport(transport, exchange ->
|
||||||
|
|
|
@ -116,14 +116,7 @@ public class HttpClientIdleTimeoutTest extends AbstractTest
|
||||||
@Test
|
@Test
|
||||||
public void testIdleClientIdleTimeout() throws Exception
|
public void testIdleClientIdleTimeout() throws Exception
|
||||||
{
|
{
|
||||||
start(new AbstractHandler()
|
start(new EmptyServerHandler());
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
|
||||||
{
|
|
||||||
baseRequest.setHandled(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
client.stop();
|
client.stop();
|
||||||
client.setIdleTimeout(idleTimeout);
|
client.setIdleTimeout(idleTimeout);
|
||||||
client.start();
|
client.start();
|
||||||
|
@ -143,14 +136,7 @@ public class HttpClientIdleTimeoutTest extends AbstractTest
|
||||||
@Test
|
@Test
|
||||||
public void testIdleServerIdleTimeout() throws Exception
|
public void testIdleServerIdleTimeout() throws Exception
|
||||||
{
|
{
|
||||||
start(new AbstractHandler()
|
start(new EmptyServerHandler());
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
|
||||||
{
|
|
||||||
baseRequest.setHandled(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
connector.setIdleTimeout(idleTimeout);
|
connector.setIdleTimeout(idleTimeout);
|
||||||
|
|
||||||
ContentResponse response1 = client.newRequest(newURI()).send();
|
ContentResponse response1 = client.newRequest(newURI()).send();
|
||||||
|
|
|
@ -300,14 +300,7 @@ public class HttpClientTest extends AbstractTest
|
||||||
// Only run this test for transports over TLS.
|
// Only run this test for transports over TLS.
|
||||||
Assume.assumeTrue(EnumSet.of(Transport.HTTPS, Transport.H2).contains(transport));
|
Assume.assumeTrue(EnumSet.of(Transport.HTTPS, Transport.H2).contains(transport));
|
||||||
|
|
||||||
startServer(new AbstractHandler()
|
startServer(new EmptyServerHandler());
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
|
||||||
{
|
|
||||||
baseRequest.setHandled(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Use a default SslContextFactory, requests should fail because the server certificate is unknown.
|
// Use a default SslContextFactory, requests should fail because the server certificate is unknown.
|
||||||
client = newHttpClient(provideClientTransport(transport), new SslContextFactory());
|
client = newHttpClient(provideClientTransport(transport), new SslContextFactory());
|
||||||
|
@ -410,14 +403,7 @@ public class HttpClientTest extends AbstractTest
|
||||||
@Test
|
@Test
|
||||||
public void testConnectionListener() throws Exception
|
public void testConnectionListener() throws Exception
|
||||||
{
|
{
|
||||||
start(new AbstractHandler()
|
start(new EmptyServerHandler());
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
|
|
||||||
{
|
|
||||||
baseRequest.setHandled(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
CountDownLatch openLatch = new CountDownLatch(1);
|
CountDownLatch openLatch = new CountDownLatch(1);
|
||||||
CountDownLatch closeLatch = new CountDownLatch(1);
|
CountDownLatch closeLatch = new CountDownLatch(1);
|
||||||
|
|
Loading…
Reference in New Issue