< prev index next >

test/java/net/HttpURLConnection/UnmodifiableMaps.java

Print this page

        

@@ -22,15 +22,15 @@
  */
 
 /**
  * @test
  * @bug 7128648
+ * @modules jdk.httpserver
  * @summary HttpURLConnection.getHeaderFields should return an unmodifiable Map
  */
 
 import java.io.IOException;
-import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.net.URI;
 import java.net.HttpURLConnection;
 import java.util.Collection;
 import java.util.ArrayList;

@@ -38,27 +38,27 @@
 import java.util.Map;
 import com.sun.net.httpserver.HttpExchange;
 import com.sun.net.httpserver.HttpHandler;
 import com.sun.net.httpserver.HttpServer;
 import com.sun.net.httpserver.Headers;
+import static java.net.Proxy.NO_PROXY;
 
 public class UnmodifiableMaps {
 
     void test(String[] args) throws Exception {
         HttpServer server = startHttpServer();
         try {
             InetSocketAddress address = server.getAddress();
-            URI uri = new URI("http://" + InetAddress.getLocalHost().getHostAddress()
-                              + ":" + address.getPort() + "/foo");
+            URI uri = new URI("http://localhost:" + address.getPort() + "/foo");
             doClient(uri);
         } finally {
             server.stop(0);
         }
     }
 
     void doClient(URI uri) throws Exception {
-        HttpURLConnection uc = (HttpURLConnection) uri.toURL().openConnection();
+        HttpURLConnection uc = (HttpURLConnection) uri.toURL().openConnection(NO_PROXY);
 
         // Test1: getRequestProperties is unmodifiable
         System.out.println("Check getRequestProperties");
         checkUnmodifiable(uc.getRequestProperties());
         uc.addRequestProperty("X", "V");
< prev index next >