Jetty9 - Test code cleanup.
This commit is contained in:
parent
523f1a8295
commit
0ddbdda280
|
@ -13,10 +13,6 @@
|
|||
|
||||
package org.eclipse.jetty.server;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.matchers.JUnitMatchers.containsString;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
@ -24,7 +20,6 @@ import java.net.Socket;
|
|||
import java.net.SocketException;
|
||||
import java.util.concurrent.Exchanger;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.net.ssl.SSLException;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
@ -37,6 +32,10 @@ import org.eclipse.jetty.util.IO;
|
|||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.matchers.JUnitMatchers.containsString;
|
||||
|
||||
public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
|
||||
{
|
||||
protected static final int MAX_IDLE_TIME=500;
|
||||
|
@ -115,7 +114,7 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
|
|||
@Test
|
||||
public void testMaxIdleWithRequest10NoClientClose() throws Exception
|
||||
{
|
||||
final Exchanger<EndPoint> endpoint = new Exchanger<EndPoint>();
|
||||
final Exchanger<EndPoint> exchanger = new Exchanger<>();
|
||||
configureServer(new HelloWorldHandler()
|
||||
{
|
||||
@Override
|
||||
|
@ -124,10 +123,12 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
|
|||
{
|
||||
try
|
||||
{
|
||||
endpoint.exchange(baseRequest.getHttpChannel().getConnection().getEndPoint());
|
||||
exchanger.exchange(baseRequest.getHttpChannel().getConnection().getEndPoint());
|
||||
}
|
||||
catch (Exception e)
|
||||
{}
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
super.handle(target, baseRequest, request, response);
|
||||
}
|
||||
|
||||
|
@ -148,9 +149,9 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
|
|||
os.flush();
|
||||
|
||||
// Get the server side endpoint
|
||||
EndPoint endp = endpoint.exchange(null,10,TimeUnit.SECONDS);
|
||||
if (endp instanceof SslConnection.DecryptedEndPoint)
|
||||
endp=((SslConnection.DecryptedEndPoint)endp).getConnection().getEndPoint();
|
||||
EndPoint endPoint = exchanger.exchange(null,10,TimeUnit.SECONDS);
|
||||
if (endPoint instanceof SslConnection.DecryptedEndPoint)
|
||||
endPoint=endPoint.getConnection().getEndPoint();
|
||||
|
||||
// read the response
|
||||
String result=IO.toString(is);
|
||||
|
@ -182,13 +183,13 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
|
|||
// expected
|
||||
}
|
||||
// check the server side is closed
|
||||
Assert.assertFalse(endp.isOpen());
|
||||
Assert.assertFalse(endPoint.isOpen());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMaxIdleWithRequest10ClientIgnoresClose() throws Exception
|
||||
{
|
||||
final Exchanger<EndPoint> endpoint = new Exchanger<EndPoint>();
|
||||
final Exchanger<EndPoint> exchanger = new Exchanger<>();
|
||||
configureServer(new HelloWorldHandler()
|
||||
{
|
||||
@Override
|
||||
|
@ -197,10 +198,12 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
|
|||
{
|
||||
try
|
||||
{
|
||||
endpoint.exchange(baseRequest.getHttpChannel().getConnection().getEndPoint());
|
||||
exchanger.exchange(baseRequest.getHttpChannel().getConnection().getEndPoint());
|
||||
}
|
||||
catch (Exception e)
|
||||
{}
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
super.handle(target, baseRequest, request, response);
|
||||
}
|
||||
|
||||
|
@ -221,9 +224,9 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
|
|||
os.flush();
|
||||
|
||||
// Get the server side endpoint
|
||||
EndPoint endp = endpoint.exchange(null,10,TimeUnit.SECONDS);
|
||||
if (endp instanceof SslConnection.DecryptedEndPoint)
|
||||
endp=((SslConnection.DecryptedEndPoint)endp).getConnection().getEndPoint();
|
||||
EndPoint endPoint = exchanger.exchange(null,10,TimeUnit.SECONDS);
|
||||
if (endPoint instanceof SslConnection.DecryptedEndPoint)
|
||||
endPoint=endPoint.getConnection().getEndPoint();
|
||||
|
||||
// read the response
|
||||
String result=IO.toString(is);
|
||||
|
@ -251,13 +254,13 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
|
|||
// expected
|
||||
}
|
||||
// check the server side is closed
|
||||
Assert.assertFalse(endp.isOpen());
|
||||
Assert.assertFalse(endPoint.isOpen());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMaxIdleWithRequest11NoClientClose() throws Exception
|
||||
{
|
||||
final Exchanger<EndPoint> endpoint = new Exchanger<EndPoint>();
|
||||
final Exchanger<EndPoint> exchanger = new Exchanger<>();
|
||||
configureServer(new EchoHandler()
|
||||
{
|
||||
@Override
|
||||
|
@ -266,10 +269,12 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
|
|||
{
|
||||
try
|
||||
{
|
||||
endpoint.exchange(baseRequest.getHttpChannel().getConnection().getEndPoint());
|
||||
exchanger.exchange(baseRequest.getHttpChannel().getConnection().getEndPoint());
|
||||
}
|
||||
catch (Exception e)
|
||||
{}
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
super.handle(target, baseRequest, request, response);
|
||||
}
|
||||
|
||||
|
@ -295,7 +300,7 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
|
|||
os.flush();
|
||||
|
||||
// Get the server side endpoint
|
||||
EndPoint endp = endpoint.exchange(null,10,TimeUnit.SECONDS);
|
||||
EndPoint endPoint = exchanger.exchange(null,10,TimeUnit.SECONDS);
|
||||
|
||||
// read the response
|
||||
IO.toString(is);
|
||||
|
@ -326,7 +331,7 @@ public abstract class ConnectorTimeoutTest extends HttpServerTestFixture
|
|||
}
|
||||
|
||||
// check the server side is closed
|
||||
Assert.assertFalse(endp.isOpen());
|
||||
Assert.assertFalse(endPoint.isOpen());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog
|
||||
#org.eclipse.jetty.LEVEL=WARN
|
Loading…
Reference in New Issue