2
|
1 |
/*
|
|
2 |
* Copyright 2003 Sun Microsystems, Inc. All Rights Reserved.
|
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation.
|
|
8 |
*
|
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
13 |
* accompanied this code).
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License version
|
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18 |
*
|
|
19 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
20 |
* CA 95054 USA or visit www.sun.com if you need additional information or
|
|
21 |
* have any questions.
|
|
22 |
*/
|
|
23 |
|
|
24 |
/* @test
|
|
25 |
* @bug 4937962
|
|
26 |
* @summary ProxySelector.connectFailed and .select never throw IllegalArgumentException
|
|
27 |
*/
|
|
28 |
import java.net.*;
|
|
29 |
import java.util.List;
|
|
30 |
import java.io.IOException;
|
|
31 |
|
|
32 |
public class NullArguments {
|
|
33 |
public static void main(String[] args) {
|
|
34 |
ProxySelector ps = ProxySelector.getDefault();
|
|
35 |
List p = null;
|
|
36 |
boolean ok = false;
|
|
37 |
if (ps != null) {
|
|
38 |
try {
|
|
39 |
p = ps.select(null);
|
|
40 |
} catch (IllegalArgumentException iae) {
|
|
41 |
System.out.println("OK");
|
|
42 |
ok = true;
|
|
43 |
}
|
|
44 |
if (!ok)
|
|
45 |
throw new RuntimeException("Expected IllegalArgumentException!");
|
|
46 |
URI uri = null;
|
|
47 |
try {
|
|
48 |
uri = new URI("http://java.sun.com");
|
|
49 |
} catch (java.net.URISyntaxException use) {
|
|
50 |
// can't happen
|
|
51 |
}
|
|
52 |
SocketAddress sa = new InetSocketAddress("localhost", 80);
|
|
53 |
IOException ioe = new IOException("dummy IOE");
|
|
54 |
ok = false;
|
|
55 |
try {
|
|
56 |
ps.connectFailed(uri, sa, null);
|
|
57 |
} catch (IllegalArgumentException iae) {
|
|
58 |
System.out.println("OK");
|
|
59 |
ok = true;
|
|
60 |
}
|
|
61 |
if (!ok)
|
|
62 |
throw new RuntimeException("Expected IllegalArgumentException!");
|
|
63 |
ok = false;
|
|
64 |
try {
|
|
65 |
ps.connectFailed(uri, null, ioe);
|
|
66 |
} catch (IllegalArgumentException iae) {
|
|
67 |
System.out.println("OK");
|
|
68 |
ok = true;
|
|
69 |
}
|
|
70 |
if (!ok)
|
|
71 |
throw new RuntimeException("Expected IllegalArgumentException!");
|
|
72 |
ok = false;
|
|
73 |
try {
|
|
74 |
ps.connectFailed(null, sa, ioe);
|
|
75 |
} catch (IllegalArgumentException iae) {
|
|
76 |
System.out.println("OK");
|
|
77 |
ok = true;
|
|
78 |
}
|
|
79 |
if (!ok)
|
|
80 |
throw new RuntimeException("Expected IllegalArgumentException!");
|
|
81 |
}
|
|
82 |
}
|
|
83 |
}
|