Index: tests/reliability/run/run.normal.mode.settings.xml =================================================================== --- tests/reliability/run/run.normal.mode.settings.xml (revision 601425) +++ tests/reliability/run/run.normal.mode.settings.xml (working copy) @@ -517,7 +517,7 @@ - + Index: tests/reliability/run/exclude.linux_x86_64 =================================================================== --- tests/reliability/run/exclude.linux_x86_64 (revision 601425) +++ tests/reliability/run/exclude.linux_x86_64 (working copy) @@ -2,7 +2,6 @@ ## 20071030 test run failures api.kernel.thread.VolatileVariableTest.DekkerTest api.net.DatagramTest -api.net.HttpConnectionTest api.net.SingleConnectTest api.nio.buffers.ByteBufferallocateTest api.nio.channels.filechannel.MappedByteBufferForceTest Index: tests/reliability/src/java/org/apache/harmony/test/reliability/api/net/HttpConnectionTest.java =================================================================== --- tests/reliability/src/java/org/apache/harmony/test/reliability/api/net/HttpConnectionTest.java (revision 601425) +++ tests/reliability/src/java/org/apache/harmony/test/reliability/api/net/HttpConnectionTest.java (working copy) @@ -24,12 +24,17 @@ import java.io.BufferedReader; import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.InetSocketAddress; import java.net.MalformedURLException; import java.net.Proxy; import java.net.URL; +import java.net.Socket; +import java.net.SocketException; +import java.net.ServerSocket; import java.util.regex.Pattern; import org.apache.harmony.test.reliability.share.Test; @@ -37,7 +42,7 @@ /* * Goal: Test HttpURLConnection functionality * - * passed parameters: + * passed optional parameters: * parameter[0] - urls for web pages you want to get, all urls are to be listed consequently * via ";" with no blanks or tabs * E.g http://harmony.apache.org/;http://issues.apache.org/jira/browse/HARMONY @@ -49,13 +54,17 @@ * * No crash, hang or fail is excpected. * - * Note: All input parameters are to be set properly as test could fail due to wrong - * set proxy or Url address. + * If no parameters are set then internal stab http server is started for testing. * */ public class HttpConnectionTest extends Test{ + static volatile boolean failed = false; String[] testedUrlStrings = null; Proxy prx = null; + final static int STARTING_PORT_NUMBER = 8100; + final static int numberOfTriesToOpenPort = 2000; + final static int numberOfAcceptedRequests = 1000; + static int portStarted = 0; public static void main(String[] params){ System.exit(new HttpConnectionTest().test(params)); @@ -63,8 +72,25 @@ public int test(String[] params){ parseParams(params); + + ServerRunner2 sPort = null; + for (int i = 0; i < numberOfTriesToOpenPort; i++) + { + sPort = new ServerRunner2(STARTING_PORT_NUMBER + i); + if (sPort.started) + { + break; + } + } + if (!sPort.isAlive()) + { + return fail("Failed to start any server"); + } + portStarted = sPort.port; + if (testedUrlStrings == null){ - return fail("Urls to test are not set"); + testedUrlStrings = new String[1]; + testedUrlStrings[0] = "http://localhost:" + portStarted + "/"; } for (int i=0; i