harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From regi...@apache.org
Subject svn commit: r764728 - /harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/internal/net/www/protocol/http/HttpURLConnectionTest.java
Date Tue, 14 Apr 2009 09:54:29 GMT
Author: regisxu
Date: Tue Apr 14 09:54:29 2009
New Revision: 764728

URL: http://svn.apache.org/viewvc?rev=764728&view=rev
Log:
Apply patch for HARMONY-6120: [classlib][luni] - use Jetty as test http server in org.apache.harmony.luni.tests.internal.net.www.protocol.http.HttpURLConnectionTest

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/internal/net/www/protocol/http/HttpURLConnectionTest.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/internal/net/www/protocol/http/HttpURLConnectionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/internal/net/www/protocol/http/HttpURLConnectionTest.java?rev=764728&r1=764727&r2=764728&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/internal/net/www/protocol/http/HttpURLConnectionTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/internal/net/www/protocol/http/HttpURLConnectionTest.java
Tue Apr 14 09:54:29 2009
@@ -37,6 +37,8 @@
 import java.util.List;
 import java.util.Map;
 
+import tests.support.Support_Jetty;
+
 import junit.framework.TestCase;
 
 /**
@@ -249,7 +251,13 @@
         }
     }
 
-    public void setUp() {
+    private int jettyPort = 0;
+
+    private String jettyURL;
+
+    public void setUp() throws Exception {
+        jettyPort = Support_Jetty.startDefaultHttpServer();
+        jettyURL = "http://localhost:" + jettyPort + "/servlet";
         if (DEBUG) {
             System.out.println("\n==============================");
             System.out.println("===== Execution: " + getName());
@@ -300,7 +308,7 @@
      * @tests HttpURLConnection.getHeaderFields
      */
     public void test_getHeaderFields() throws Exception {
-        URL url = new URL("http://www.apache.org");
+        URL url = new URL(jettyURL);
         HttpURLConnection httpURLConnect = (HttpURLConnection) url
                 .openConnection();
         assertEquals(200, httpURLConnect.getResponseCode());
@@ -361,7 +369,7 @@
      * Test whether getOutputStream can work after connection
      */
     public void test_getOutputStream_AfterConnect() throws Exception {
-        URL url = new URL("http://www.apache.org");
+        URL url = new URL(jettyURL);
         HttpURLConnection connection = (HttpURLConnection) url.openConnection();
         connection.setDoOutput(true);
         connection.connect();
@@ -421,15 +429,16 @@
      */
     public void testUsingProxy2() throws Exception {
         try {
-            System.setProperty("http.proxyHost", "www.apache.org");
-            URL url = new URL("http://www.apache.org");
+            System.setProperty("http.proxyHost", "localhost");
+            System.setProperty("http.proxyPort", jettyPort + "");
+            URL url = new URL(jettyURL);
             HttpURLConnection urlConnect = (HttpURLConnection) url
                     .openConnection();
             urlConnect.getInputStream();
             assertTrue(urlConnect.usingProxy());
             
             System.setProperty("http.proxyPort", "81");
-            url = new URL("http://www.apache.org");
+            url = new URL(jettyURL);
             urlConnect = (HttpURLConnection) url.openConnection();
             urlConnect.getInputStream();
             assertFalse(urlConnect.usingProxy());



Mime
View raw message