test/jdk/sun/net/www/protocol/http/B8012625.java
changeset 54314 46cf212cdcca
parent 47216 71c04702a3d5
child 54681 edd709e64ea1
--- a/test/jdk/sun/net/www/protocol/http/B8012625.java	Wed Mar 27 13:00:57 2019 -0700
+++ b/test/jdk/sun/net/www/protocol/http/B8012625.java	Wed Mar 27 09:06:43 2019 -0700
@@ -24,6 +24,7 @@
 /**
  * @test
  * @bug 8012625
+ * @library /test/lib
  * @modules jdk.httpserver
  * @run main B8012625
  */
@@ -34,6 +35,9 @@
 import java.net.*;
 import java.io.*;
 import java.util.concurrent.*;
+
+import jdk.test.lib.net.URIBuilder;
+
 import com.sun.net.httpserver.*;
 
 public class B8012625 implements HttpHandler {
@@ -44,8 +48,13 @@
     }
 
     public void run() throws Exception {
-        String u = "http://127.0.0.1:" + port + "/foo";
-        URL url = new URL(u);
+        URL url = URIBuilder.newBuilder()
+            .scheme("http")
+            .loopback()
+            .port(port)
+            .path("/foo")
+            .toURL();
+        System.out.println("URL: " + url);
         HttpURLConnection uc = (HttpURLConnection)url.openConnection();
         uc.setDoOutput(true);
         uc.setRequestMethod("POST");