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