8166359: java/net/URLPermission/nstest/lookup.sh fails if proxy is set since fix for JDK-8161016
authorxiaofeya
Wed, 21 Sep 2016 02:19:59 -0700
changeset 41105 52157c912fd9
parent 41104 165401a41a97
child 41106 f37e9bfeae01
child 41107 567f832618d7
8166359: java/net/URLPermission/nstest/lookup.sh fails if proxy is set since fix for JDK-8161016 Reviewed-by: chegar Contributed-by: Felix Yang <felix.yang@oracle.com>
jdk/test/java/net/URLPermission/nstest/LookupTest.java
jdk/test/java/net/URLPermission/nstest/LookupTestHosts
jdk/test/java/net/URLPermission/nstest/lookup.sh
--- a/jdk/test/java/net/URLPermission/nstest/LookupTest.java	Wed Sep 21 08:55:47 2016 +0800
+++ b/jdk/test/java/net/URLPermission/nstest/LookupTest.java	Wed Sep 21 02:19:59 2016 -0700
@@ -37,6 +37,7 @@
         String url, boolean throwsSecException, boolean throwsIOException)
     {
         try {
+            ProxySelector.setDefault(null);
             URL u = new URL(url);
             System.err.println ("Connecting to " + u);
             URLConnection urlc = u.openConnection();
@@ -71,7 +72,7 @@
             System.out.print(port);
         } else if (cmd.equals("-runtest")) {
             port = Integer.parseInt(args[1]);
-            String hostsFileName = System.getProperty("test.src", ".") + "/LookupTestHosts";
+            String hostsFileName = System.getProperty("user.dir", ".") + "/LookupTestHosts";
             System.setProperty("jdk.net.hosts.file", hostsFileName);
             addMappingToHostsFile("allowedAndFound.com", "127.0.0.1", hostsFileName, false);
             addMappingToHostsFile("notAllowedButFound.com", "99.99.99.99", hostsFileName, true);
--- a/jdk/test/java/net/URLPermission/nstest/LookupTestHosts	Wed Sep 21 08:55:47 2016 +0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-127.0.0.1 allowedAndFound.com
-99.99.99.99 notAllowedButFound.com
--- a/jdk/test/java/net/URLPermission/nstest/lookup.sh	Wed Sep 21 08:55:47 2016 +0800
+++ b/jdk/test/java/net/URLPermission/nstest/lookup.sh	Wed Sep 21 02:19:59 2016 -0700
@@ -48,6 +48,7 @@
 grant {
     permission java.net.URLPermission "http://allowedAndFound.com:${port}/-", "*:*";
     permission java.net.URLPermission "http://allowedButNotfound.com:${port}/-", "*:*";
+    permission java.net.NetPermission "setProxySelector";
     permission java.io.FilePermission "<<ALL FILES>>", "read,write,delete";
     permission java.util.PropertyPermission "java.io.tmpdir", "read";