author | amurillo |
Wed, 15 Aug 2012 16:49:38 -0700 | |
changeset 13465 | d3fc5d192448 |
parent 7668 | d4a77089c587 |
permissions | -rw-r--r-- |
3855
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
1 |
/* |
7668 | 2 |
* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. |
3855
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
4 |
* |
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
8 |
* |
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
13 |
* accompanied this code). |
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
14 |
* |
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
18 |
* |
5506 | 19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
3855
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
22 |
*/ |
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
23 |
/* |
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
24 |
* @test |
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
25 |
* @bug 6737819 |
5165
5693cc1e95c6
6937703: java/net regression test issues with samevm
chegar
parents:
3855
diff
changeset
|
26 |
* @run main/othervm B6737819 |
3855
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
27 |
* @summary sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost |
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
28 |
*/ |
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
29 |
|
5165
5693cc1e95c6
6937703: java/net regression test issues with samevm
chegar
parents:
3855
diff
changeset
|
30 |
/* Run in othervm mode since the test sets HTTP proxy system properties that |
5693cc1e95c6
6937703: java/net regression test issues with samevm
chegar
parents:
3855
diff
changeset
|
31 |
* are read once and cached by the protocol handler. A previous test using the |
5693cc1e95c6
6937703: java/net regression test issues with samevm
chegar
parents:
3855
diff
changeset
|
32 |
* HTTP handler may run and these system properties may be ignored for this test. |
5693cc1e95c6
6937703: java/net regression test issues with samevm
chegar
parents:
3855
diff
changeset
|
33 |
*/ |
5693cc1e95c6
6937703: java/net regression test issues with samevm
chegar
parents:
3855
diff
changeset
|
34 |
|
3855
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
35 |
import java.net.ProxySelector; |
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
36 |
import java.net.Proxy; |
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
37 |
import java.net.URI; |
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
38 |
|
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
39 |
public class B6737819 { |
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
40 |
private static String[] uris = { |
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
41 |
"http://localhost/index.html", |
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
42 |
"http://127.0.0.1/index.html", |
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
43 |
"http://127.2/index.html", |
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
44 |
"http://[::1]/index.html" |
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
45 |
}; |
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
46 |
public static void main(String[] args) throws Exception { |
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
47 |
System.setProperty("http.proxyHost", "myproxy"); |
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
48 |
System.setProperty("http.proxyPort", "8080"); |
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
49 |
ProxySelector sel = ProxySelector.getDefault(); |
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
50 |
java.util.List<Proxy> l; |
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
51 |
// Default value for http.nonProxyHots should exclude all this uris |
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
52 |
// from going through the HTTP proxy |
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
53 |
for (String s : uris) { |
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
54 |
l = sel.select(new URI(s)); |
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
55 |
if (l.size() == 1 && l.get(0).type() != Proxy.Type.DIRECT) { |
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
56 |
throw new RuntimeException("ProxySelector returned the wrong proxy for " + s); |
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
57 |
} |
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
58 |
} |
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
59 |
// Let's override the default nonProxyHosts and make sure we now get a |
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
60 |
// HTTP proxy |
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
61 |
System.setProperty("http.nonProxyHosts", ""); |
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
62 |
for (String s : uris) { |
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
63 |
l = sel.select(new URI(s)); |
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
64 |
if (l.size() == 1 && l.get(0).type() != Proxy.Type.HTTP) { |
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
65 |
throw new RuntimeException("ProxySelector returned the wrong proxy for " + s); |
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
66 |
} |
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
67 |
} |
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
68 |
} |
653df3a7256d
6737819: sun.misc.net.DefaultProxySelector doesn't use proxy setting to localhost
jccollet
parents:
diff
changeset
|
69 |
} |