use port 0 instead of random port

git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@3011 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
Greg Wilkins 2011-04-13 01:29:18 +00:00
parent c226f9c5a8
commit 65aa81c018
15 changed files with 35 additions and 65 deletions

View File

@ -1,6 +1,7 @@
jetty-7.4.0-SNAPSHOT
+ 342504 Scanner Listener
+ JETTY-1362 Set root cause of UnavailableException
+ Various test harness cleanups to avoid random failures
jetty-7.4.0.RC0
+ 324110 Added test harnesses for merging of QueryStrings.

View File

@ -113,9 +113,6 @@ public abstract class AbstractConnector extends HttpBuffers implements Connector
}
/* ------------------------------------------------------------ */
/*
* @see org.eclipse.jetty.http.HttpListener#getHttpServer()
*/
public ThreadPool getThreadPool()
{
return _threadPool;
@ -144,18 +141,12 @@ public abstract class AbstractConnector extends HttpBuffers implements Connector
}
/* ------------------------------------------------------------ */
/*
* @see org.eclipse.jetty.server.server.HttpListener#setPort(int)
*/
public void setPort(int port)
{
_port = port;
}
/* ------------------------------------------------------------ */
/*
* @see org.eclipse.jetty.server.server.HttpListener#getPort()
*/
public int getPort()
{
return _port;

View File

@ -42,18 +42,17 @@ public abstract class AbstractClientCrossContextSessionTest
@Test
public void testCrossContextDispatch() throws Exception
{
Random random = new Random(System.nanoTime());
String contextA = "/contextA";
String contextB = "/contextB";
String servletMapping = "/server";
int port = random.nextInt(50000) + 10000;
AbstractTestServer server = createServer(port);
AbstractTestServer server = createServer(0);
ServletContextHandler ctxA = server.addContext(contextA);
ctxA.addServlet(TestServletA.class, servletMapping);
ServletContextHandler ctxB = server.addContext(contextB);
ctxB.addServlet(TestServletB.class, servletMapping);
server.start();
int port = server.getPort();
try
{
HttpClient client = new HttpClient();

View File

@ -41,15 +41,14 @@ public abstract class AbstractImmortalSessionTest
@Test
public void testImmortalSession() throws Exception
{
Random random = new Random(System.nanoTime());
String contextPath = "";
String servletMapping = "/server";
int port = random.nextInt(50000) + 10000;
int scavengePeriod = 2;
AbstractTestServer server = createServer(port, -1, scavengePeriod);
AbstractTestServer server = createServer(0, -1, scavengePeriod);
server.addContext(contextPath).addServlet(TestServlet.class, servletMapping);
server.start();
int port=server.getPort();
try
{
HttpClient client = new HttpClient();

View File

@ -42,20 +42,18 @@ public abstract class AbstractInvalidationSessionTest
@Test
public void testInvalidation() throws Exception
{
Random random = new Random(System.nanoTime());
String contextPath = "";
String servletMapping = "/server";
int port1 = random.nextInt(50000) + 10000;
AbstractTestServer server1 = createServer(port1);
AbstractTestServer server1 = createServer(0);
server1.addContext(contextPath).addServlet(TestServlet.class, servletMapping);
server1.start();
int port1 = server1.getPort();
try
{
int port2 = random.nextInt(50000) + 10000;
AbstractTestServer server2 = createServer(port2);
AbstractTestServer server2 = createServer(0);
server2.addContext(contextPath).addServlet(TestServlet.class, servletMapping);
server2.start();
int port2=server2.getPort();
try
{
HttpClient client = new HttpClient();

View File

@ -39,8 +39,6 @@ public abstract class AbstractLastAccessTimeTest
@Test
public void testLastAccessTime() throws Exception
{
Random random = new Random(System.nanoTime());
String contextPath = "";
String servletMapping = "/server";
int maxInactivePeriod = 8;

View File

@ -50,20 +50,18 @@ public abstract class AbstractLightLoadTest
{
if ( _stress )
{
Random random = new Random( System.nanoTime() );
String contextPath = "";
String servletMapping = "/server";
int port1 = random.nextInt( 50000 ) + 10000;
AbstractTestServer server1 = createServer( port1 );
AbstractTestServer server1 = createServer( 0 );
server1.addContext( contextPath ).addServlet( TestServlet.class, servletMapping );
server1.start();
int port1 = server1.getPort();
try
{
int port2 = random.nextInt( 50000 ) + 10000;
AbstractTestServer server2 = createServer( port2 );
AbstractTestServer server2 = createServer( 0 );
server2.addContext( contextPath ).addServlet( TestServlet.class, servletMapping );
server2.start();
int port2=server2.getPort();
try
{
HttpClient client = new HttpClient();

View File

@ -52,21 +52,20 @@ public abstract class AbstractLocalSessionScavengingTest
@Test
public void testLocalSessionsScavenging() throws Exception
{
Random random = new Random(System.nanoTime());
String contextPath = "";
String servletMapping = "/server";
int port1 = random.nextInt(50000) + 10000;
int inactivePeriod = 1;
int scavengePeriod = 2;
AbstractTestServer server1 = createServer(port1, inactivePeriod, scavengePeriod);
AbstractTestServer server1 = createServer(0, inactivePeriod, scavengePeriod);
server1.addContext(contextPath).addServlet(TestServlet.class, servletMapping);
server1.start();
int port1 = server1.getPort();
try
{
int port2 = random.nextInt(50000) + 10000;
AbstractTestServer server2 = createServer(port2, inactivePeriod, scavengePeriod * 3);
AbstractTestServer server2 = createServer(0, inactivePeriod, scavengePeriod * 3);
server2.addContext(contextPath).addServlet(TestServlet.class, servletMapping);
server2.start();
int port2 = server2.getPort();
try
{
HttpClient client = new HttpClient();

View File

@ -51,16 +51,14 @@ public abstract class AbstractNewSessionTest
@Test
public void testNewSession() throws Exception
{
Random random = new Random(System.nanoTime());
String contextPath = "";
String servletMapping = "/server";
int port = random.nextInt(50000) + 10000;
int scavengePeriod = 3;
AbstractTestServer server = createServer(port, 1, scavengePeriod);
AbstractTestServer server = createServer(0, 1, scavengePeriod);
ServletContextHandler context = server.addContext(contextPath);
context.addServlet(TestServlet.class, servletMapping);
server.start();
int port=server.getPort();
try
{
HttpClient client = new HttpClient();

View File

@ -45,8 +45,6 @@ public abstract class AbstractOrphanedSessionTest
@Test
public void testOrphanedSession() throws Exception
{
Random random = new Random(System.nanoTime());
// Disable scavenging for the first server, so that we simulate its "crash".
String contextPath = "";
String servletMapping = "/server";

View File

@ -40,14 +40,12 @@ public abstract class AbstractReentrantRequestSessionTest
@Test
public void testReentrantRequestSession() throws Exception
{
Random random = new Random(System.nanoTime());
String contextPath = "";
String servletMapping = "/server";
int port = random.nextInt(50000) + 10000;
AbstractTestServer server = createServer(port);
AbstractTestServer server = createServer(0);
server.addContext(contextPath).addServlet(TestServlet.class, servletMapping);
server.start();
int port = server.getPort();
try
{
HttpClient client = new HttpClient();

View File

@ -25,16 +25,14 @@ public abstract class AbstractRemoveSessionTest
@Test
public void testRemoveSession() throws Exception
{
Random random = new Random(System.nanoTime());
String contextPath = "";
String servletMapping = "/server";
int port = random.nextInt(50000) + 10000;
int scavengePeriod = 3;
AbstractTestServer server = createServer(port, 1, scavengePeriod);
AbstractTestServer server = createServer(0, 1, scavengePeriod);
ServletContextHandler context = server.addContext(contextPath);
context.addServlet(TestServlet.class, servletMapping);
server.start();
int port = server.getPort();
try
{
HttpClient client = new HttpClient();

View File

@ -44,18 +44,16 @@ public abstract class AbstractServerCrossContextSessionTest
@Test
public void testCrossContextDispatch() throws Exception
{
Random random = new Random(System.nanoTime());
String contextA = "/contextA";
String contextB = "/contextB";
String servletMapping = "/server";
int port = random.nextInt(50000) + 10000;
AbstractTestServer server = createServer(port);
AbstractTestServer server = createServer(0);
ServletContextHandler ctxA = server.addContext(contextA);
ctxA.addServlet(TestServletA.class, servletMapping);
ServletContextHandler ctxB = server.addContext(contextB);
ctxB.addServlet(TestServletB.class, servletMapping);
server.start();
int port=server.getPort();
try
{
HttpClient client = new HttpClient();

View File

@ -40,20 +40,18 @@ public abstract class AbstractSessionMigrationTest
@Test
public void testSessionMigration() throws Exception
{
Random random = new Random(System.nanoTime());
String contextPath = "";
String servletMapping = "/server";
int port1 = random.nextInt(50000) + 10000;
AbstractTestServer server1 = createServer(port1);
AbstractTestServer server1 = createServer(0);
server1.addContext(contextPath).addServlet(TestServlet.class, servletMapping);
server1.start();
int port1=server1.getPort();
try
{
int port2 = random.nextInt(50000) + 10000;
AbstractTestServer server2 = createServer(port2);
AbstractTestServer server2 = createServer(0);
server2.addContext(contextPath).addServlet(TestServlet.class, servletMapping);
server2.start();
int port2=server2.getPort();
try
{
HttpClient client = new HttpClient();

View File

@ -87,18 +87,17 @@ public abstract class AbstractWebAppObjectInSessionTest
targetFile = new File(packageDirs, resourceName);
//copy(sourceFile, targetFile);
IO.copy(resource.getInputStream(), new FileOutputStream(targetFile));
Random random = new Random(System.nanoTime());
int port1 = random.nextInt(50000) + 10000;
AbstractTestServer server1 = createServer(port1);
AbstractTestServer server1 = createServer(0);
server1.addWebAppContext(warDir.getCanonicalPath(), contextPath).addServlet(WebAppObjectInSessionServlet.class.getName(), servletMapping);
server1.start();
int port1 = server1.getPort();
try
{
int port2 = random.nextInt(50000) + 10000;
AbstractTestServer server2 = createServer(port2);
AbstractTestServer server2 = createServer(0);
server2.addWebAppContext(warDir.getCanonicalPath(), contextPath).addServlet(WebAppObjectInSessionServlet.class.getName(), servletMapping);
server2.start();
int port2 = server2.getPort();
try
{
HttpClient client = new HttpClient();