author | jjg |
Wed, 04 Jan 2017 18:33:20 -0800 | |
changeset 43029 | 1cd1c816581e |
parent 39775 | 37b3d7bf72ee |
permissions | -rw-r--r-- |
17473 | 1 |
/* |
39132
e9499c06e138
8114860: Behavior of java.net.URLPermission.getActions() contradicts spec
vtewari
parents:
22105
diff
changeset
|
2 |
* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. |
17473 | 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 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. |
|
22 |
*/ |
|
23 |
||
20787
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
24 |
import java.net.URLPermission; |
17473 | 25 |
import java.io.*; |
26 |
||
27 |
/** |
|
28 |
* @test |
|
39775
37b3d7bf72ee
8161291: Serialization Tests for URLPermission is failing
vtewari
parents:
39137
diff
changeset
|
29 |
* @bug 8010464 8027570 8027687 8029354 8114860 8071660 8161291 |
17473 | 30 |
*/ |
31 |
||
20787
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
32 |
public class URLPermissionTest { |
17473 | 33 |
|
34 |
// super class for all test types |
|
35 |
abstract static class Test { |
|
36 |
boolean expected; |
|
37 |
abstract boolean execute(); |
|
38 |
}; |
|
39 |
||
22105
09df5383d1df
8029354: URLPermission.<init> throws llegalArgumentException: Invalid characters in hostname
michaelm
parents:
21621
diff
changeset
|
40 |
// Instantiation: should succeed |
09df5383d1df
8029354: URLPermission.<init> throws llegalArgumentException: Invalid characters in hostname
michaelm
parents:
21621
diff
changeset
|
41 |
static class CreateTest extends Test { |
09df5383d1df
8029354: URLPermission.<init> throws llegalArgumentException: Invalid characters in hostname
michaelm
parents:
21621
diff
changeset
|
42 |
String arg; |
09df5383d1df
8029354: URLPermission.<init> throws llegalArgumentException: Invalid characters in hostname
michaelm
parents:
21621
diff
changeset
|
43 |
CreateTest(String arg) { |
09df5383d1df
8029354: URLPermission.<init> throws llegalArgumentException: Invalid characters in hostname
michaelm
parents:
21621
diff
changeset
|
44 |
this.arg = arg; |
09df5383d1df
8029354: URLPermission.<init> throws llegalArgumentException: Invalid characters in hostname
michaelm
parents:
21621
diff
changeset
|
45 |
} |
09df5383d1df
8029354: URLPermission.<init> throws llegalArgumentException: Invalid characters in hostname
michaelm
parents:
21621
diff
changeset
|
46 |
|
09df5383d1df
8029354: URLPermission.<init> throws llegalArgumentException: Invalid characters in hostname
michaelm
parents:
21621
diff
changeset
|
47 |
@Override |
09df5383d1df
8029354: URLPermission.<init> throws llegalArgumentException: Invalid characters in hostname
michaelm
parents:
21621
diff
changeset
|
48 |
boolean execute() { |
09df5383d1df
8029354: URLPermission.<init> throws llegalArgumentException: Invalid characters in hostname
michaelm
parents:
21621
diff
changeset
|
49 |
try { |
09df5383d1df
8029354: URLPermission.<init> throws llegalArgumentException: Invalid characters in hostname
michaelm
parents:
21621
diff
changeset
|
50 |
URLPermission p = new URLPermission(arg); |
09df5383d1df
8029354: URLPermission.<init> throws llegalArgumentException: Invalid characters in hostname
michaelm
parents:
21621
diff
changeset
|
51 |
return true; |
09df5383d1df
8029354: URLPermission.<init> throws llegalArgumentException: Invalid characters in hostname
michaelm
parents:
21621
diff
changeset
|
52 |
} catch (Exception e) { |
09df5383d1df
8029354: URLPermission.<init> throws llegalArgumentException: Invalid characters in hostname
michaelm
parents:
21621
diff
changeset
|
53 |
return false; |
09df5383d1df
8029354: URLPermission.<init> throws llegalArgumentException: Invalid characters in hostname
michaelm
parents:
21621
diff
changeset
|
54 |
} |
09df5383d1df
8029354: URLPermission.<init> throws llegalArgumentException: Invalid characters in hostname
michaelm
parents:
21621
diff
changeset
|
55 |
} |
09df5383d1df
8029354: URLPermission.<init> throws llegalArgumentException: Invalid characters in hostname
michaelm
parents:
21621
diff
changeset
|
56 |
}; |
09df5383d1df
8029354: URLPermission.<init> throws llegalArgumentException: Invalid characters in hostname
michaelm
parents:
21621
diff
changeset
|
57 |
|
09df5383d1df
8029354: URLPermission.<init> throws llegalArgumentException: Invalid characters in hostname
michaelm
parents:
21621
diff
changeset
|
58 |
static CreateTest createtest(String arg) { |
09df5383d1df
8029354: URLPermission.<init> throws llegalArgumentException: Invalid characters in hostname
michaelm
parents:
21621
diff
changeset
|
59 |
return new CreateTest(arg); |
09df5383d1df
8029354: URLPermission.<init> throws llegalArgumentException: Invalid characters in hostname
michaelm
parents:
21621
diff
changeset
|
60 |
} |
09df5383d1df
8029354: URLPermission.<init> throws llegalArgumentException: Invalid characters in hostname
michaelm
parents:
21621
diff
changeset
|
61 |
|
20787
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
62 |
// Should throw an IAE on construction |
22105
09df5383d1df
8029354: URLPermission.<init> throws llegalArgumentException: Invalid characters in hostname
michaelm
parents:
21621
diff
changeset
|
63 |
|
20787
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
64 |
static class ExTest extends Test { |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
65 |
String arg; |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
66 |
ExTest(String arg) { |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
67 |
this.arg = arg; |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
68 |
} |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
69 |
|
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
70 |
@Override |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
71 |
boolean execute() { |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
72 |
try { |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
73 |
URLPermission p = new URLPermission(arg); |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
74 |
return false; |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
75 |
} catch (IllegalArgumentException e) { |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
76 |
return true; |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
77 |
} |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
78 |
} |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
79 |
}; |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
80 |
|
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
81 |
static ExTest extest(String arg) { |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
82 |
return new ExTest(arg); |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
83 |
} |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
84 |
|
17473 | 85 |
// Tests URL part of implies() method. This is the main test. |
86 |
static class URLImpliesTest extends Test { |
|
87 |
String arg1, arg2; |
|
88 |
||
89 |
URLImpliesTest(String arg1, String arg2, boolean expected) { |
|
90 |
this.arg1 = arg1; |
|
91 |
this.arg2 = arg2; |
|
92 |
this.expected = expected; |
|
93 |
} |
|
94 |
||
95 |
boolean execute() { |
|
20787
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
96 |
URLPermission p1 = new URLPermission (arg1, "GET:*"); |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
97 |
URLPermission p2 = new URLPermission (arg2, "GET:*"); |
17473 | 98 |
boolean result = p1.implies(p2); |
20787
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
99 |
if (result != expected) { |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
100 |
System.out.println("p1 = " + p1); |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
101 |
System.out.println("p2 = " + p2); |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
102 |
} |
17473 | 103 |
return result == expected; |
104 |
} |
|
105 |
}; |
|
106 |
||
107 |
static URLImpliesTest imtest(String arg1, String arg2, boolean expected) { |
|
108 |
return new URLImpliesTest(arg1, arg2, expected); |
|
109 |
} |
|
110 |
||
111 |
static class ActionImpliesTest extends Test { |
|
112 |
String arg1, arg2; |
|
39137
6cf0e983a1e1
8071660: URLPermission not handling empty method lists correctly
vtewari
parents:
39132
diff
changeset
|
113 |
String url1 = "http://www.foo.com/-"; |
6cf0e983a1e1
8071660: URLPermission not handling empty method lists correctly
vtewari
parents:
39132
diff
changeset
|
114 |
String url2 = "http://www.foo.com/a/b"; |
17473 | 115 |
|
116 |
ActionImpliesTest(String arg1, String arg2, boolean expected) { |
|
117 |
this.arg1 = arg1; |
|
118 |
this.arg2 = arg2; |
|
119 |
this.expected = expected; |
|
120 |
} |
|
121 |
||
39137
6cf0e983a1e1
8071660: URLPermission not handling empty method lists correctly
vtewari
parents:
39132
diff
changeset
|
122 |
ActionImpliesTest(String ur11, String url2, String arg1, String arg2, |
6cf0e983a1e1
8071660: URLPermission not handling empty method lists correctly
vtewari
parents:
39132
diff
changeset
|
123 |
boolean expected) { |
6cf0e983a1e1
8071660: URLPermission not handling empty method lists correctly
vtewari
parents:
39132
diff
changeset
|
124 |
this.url1 = ur11; |
6cf0e983a1e1
8071660: URLPermission not handling empty method lists correctly
vtewari
parents:
39132
diff
changeset
|
125 |
this.url2 = url2; |
6cf0e983a1e1
8071660: URLPermission not handling empty method lists correctly
vtewari
parents:
39132
diff
changeset
|
126 |
this.arg1 = arg1; |
6cf0e983a1e1
8071660: URLPermission not handling empty method lists correctly
vtewari
parents:
39132
diff
changeset
|
127 |
this.arg2 = arg2; |
6cf0e983a1e1
8071660: URLPermission not handling empty method lists correctly
vtewari
parents:
39132
diff
changeset
|
128 |
this.expected = expected; |
6cf0e983a1e1
8071660: URLPermission not handling empty method lists correctly
vtewari
parents:
39132
diff
changeset
|
129 |
} |
6cf0e983a1e1
8071660: URLPermission not handling empty method lists correctly
vtewari
parents:
39132
diff
changeset
|
130 |
|
20787
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
131 |
@Override |
17473 | 132 |
boolean execute() { |
20787
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
133 |
URLPermission p1 = new URLPermission(url1, arg1); |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
134 |
URLPermission p2 = new URLPermission(url2, arg2); |
17473 | 135 |
boolean result = p1.implies(p2); |
20787
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
136 |
|
17473 | 137 |
return result == expected; |
138 |
} |
|
139 |
} |
|
140 |
||
39132
e9499c06e138
8114860: Behavior of java.net.URLPermission.getActions() contradicts spec
vtewari
parents:
22105
diff
changeset
|
141 |
static ActionsStringTest actionstest(String arg, String expectedActions) { |
e9499c06e138
8114860: Behavior of java.net.URLPermission.getActions() contradicts spec
vtewari
parents:
22105
diff
changeset
|
142 |
return new ActionsStringTest(arg, expectedActions); |
e9499c06e138
8114860: Behavior of java.net.URLPermission.getActions() contradicts spec
vtewari
parents:
22105
diff
changeset
|
143 |
} |
e9499c06e138
8114860: Behavior of java.net.URLPermission.getActions() contradicts spec
vtewari
parents:
22105
diff
changeset
|
144 |
|
e9499c06e138
8114860: Behavior of java.net.URLPermission.getActions() contradicts spec
vtewari
parents:
22105
diff
changeset
|
145 |
static class ActionsStringTest extends Test { |
e9499c06e138
8114860: Behavior of java.net.URLPermission.getActions() contradicts spec
vtewari
parents:
22105
diff
changeset
|
146 |
|
e9499c06e138
8114860: Behavior of java.net.URLPermission.getActions() contradicts spec
vtewari
parents:
22105
diff
changeset
|
147 |
String expectedActions; |
e9499c06e138
8114860: Behavior of java.net.URLPermission.getActions() contradicts spec
vtewari
parents:
22105
diff
changeset
|
148 |
String arg; |
e9499c06e138
8114860: Behavior of java.net.URLPermission.getActions() contradicts spec
vtewari
parents:
22105
diff
changeset
|
149 |
|
e9499c06e138
8114860: Behavior of java.net.URLPermission.getActions() contradicts spec
vtewari
parents:
22105
diff
changeset
|
150 |
public ActionsStringTest(String arg, String expectedActions) { |
e9499c06e138
8114860: Behavior of java.net.URLPermission.getActions() contradicts spec
vtewari
parents:
22105
diff
changeset
|
151 |
this.arg = arg; |
e9499c06e138
8114860: Behavior of java.net.URLPermission.getActions() contradicts spec
vtewari
parents:
22105
diff
changeset
|
152 |
this.expectedActions = expectedActions; |
e9499c06e138
8114860: Behavior of java.net.URLPermission.getActions() contradicts spec
vtewari
parents:
22105
diff
changeset
|
153 |
} |
e9499c06e138
8114860: Behavior of java.net.URLPermission.getActions() contradicts spec
vtewari
parents:
22105
diff
changeset
|
154 |
|
e9499c06e138
8114860: Behavior of java.net.URLPermission.getActions() contradicts spec
vtewari
parents:
22105
diff
changeset
|
155 |
@Override |
e9499c06e138
8114860: Behavior of java.net.URLPermission.getActions() contradicts spec
vtewari
parents:
22105
diff
changeset
|
156 |
boolean execute() { |
e9499c06e138
8114860: Behavior of java.net.URLPermission.getActions() contradicts spec
vtewari
parents:
22105
diff
changeset
|
157 |
String url = "http://www.foo.com/"; |
e9499c06e138
8114860: Behavior of java.net.URLPermission.getActions() contradicts spec
vtewari
parents:
22105
diff
changeset
|
158 |
URLPermission urlp = new URLPermission(url, arg); |
e9499c06e138
8114860: Behavior of java.net.URLPermission.getActions() contradicts spec
vtewari
parents:
22105
diff
changeset
|
159 |
return (expectedActions.equals(urlp.getActions())); |
e9499c06e138
8114860: Behavior of java.net.URLPermission.getActions() contradicts spec
vtewari
parents:
22105
diff
changeset
|
160 |
} |
e9499c06e138
8114860: Behavior of java.net.URLPermission.getActions() contradicts spec
vtewari
parents:
22105
diff
changeset
|
161 |
} |
e9499c06e138
8114860: Behavior of java.net.URLPermission.getActions() contradicts spec
vtewari
parents:
22105
diff
changeset
|
162 |
|
17473 | 163 |
static ActionImpliesTest actest(String arg1, String arg2, boolean expected) { |
164 |
return new ActionImpliesTest(arg1, arg2, expected); |
|
165 |
} |
|
166 |
||
39137
6cf0e983a1e1
8071660: URLPermission not handling empty method lists correctly
vtewari
parents:
39132
diff
changeset
|
167 |
static ActionImpliesTest actest(String url1, String url2, String arg1, |
6cf0e983a1e1
8071660: URLPermission not handling empty method lists correctly
vtewari
parents:
39132
diff
changeset
|
168 |
String arg2, boolean expected) { |
6cf0e983a1e1
8071660: URLPermission not handling empty method lists correctly
vtewari
parents:
39132
diff
changeset
|
169 |
return new ActionImpliesTest(url1, url2, arg1, arg2, expected); |
6cf0e983a1e1
8071660: URLPermission not handling empty method lists correctly
vtewari
parents:
39132
diff
changeset
|
170 |
} |
6cf0e983a1e1
8071660: URLPermission not handling empty method lists correctly
vtewari
parents:
39132
diff
changeset
|
171 |
|
21414
a3ddb94a50c8
8027570: NullPointerException in URLPermission.hashCode()
michaelm
parents:
20787
diff
changeset
|
172 |
static class HashCodeTest extends Test { |
a3ddb94a50c8
8027570: NullPointerException in URLPermission.hashCode()
michaelm
parents:
20787
diff
changeset
|
173 |
String arg1, arg2; |
a3ddb94a50c8
8027570: NullPointerException in URLPermission.hashCode()
michaelm
parents:
20787
diff
changeset
|
174 |
int hash; |
a3ddb94a50c8
8027570: NullPointerException in URLPermission.hashCode()
michaelm
parents:
20787
diff
changeset
|
175 |
|
a3ddb94a50c8
8027570: NullPointerException in URLPermission.hashCode()
michaelm
parents:
20787
diff
changeset
|
176 |
HashCodeTest(String arg1, String arg2, int hash) { |
a3ddb94a50c8
8027570: NullPointerException in URLPermission.hashCode()
michaelm
parents:
20787
diff
changeset
|
177 |
this.arg1 = arg1; |
a3ddb94a50c8
8027570: NullPointerException in URLPermission.hashCode()
michaelm
parents:
20787
diff
changeset
|
178 |
this.arg2 = arg2; |
a3ddb94a50c8
8027570: NullPointerException in URLPermission.hashCode()
michaelm
parents:
20787
diff
changeset
|
179 |
this.hash = hash; |
a3ddb94a50c8
8027570: NullPointerException in URLPermission.hashCode()
michaelm
parents:
20787
diff
changeset
|
180 |
} |
a3ddb94a50c8
8027570: NullPointerException in URLPermission.hashCode()
michaelm
parents:
20787
diff
changeset
|
181 |
|
a3ddb94a50c8
8027570: NullPointerException in URLPermission.hashCode()
michaelm
parents:
20787
diff
changeset
|
182 |
@Override |
a3ddb94a50c8
8027570: NullPointerException in URLPermission.hashCode()
michaelm
parents:
20787
diff
changeset
|
183 |
boolean execute() { |
a3ddb94a50c8
8027570: NullPointerException in URLPermission.hashCode()
michaelm
parents:
20787
diff
changeset
|
184 |
URLPermission p = new URLPermission(arg1, arg2); |
a3ddb94a50c8
8027570: NullPointerException in URLPermission.hashCode()
michaelm
parents:
20787
diff
changeset
|
185 |
int h = p.hashCode(); |
a3ddb94a50c8
8027570: NullPointerException in URLPermission.hashCode()
michaelm
parents:
20787
diff
changeset
|
186 |
return h == hash; |
a3ddb94a50c8
8027570: NullPointerException in URLPermission.hashCode()
michaelm
parents:
20787
diff
changeset
|
187 |
} |
a3ddb94a50c8
8027570: NullPointerException in URLPermission.hashCode()
michaelm
parents:
20787
diff
changeset
|
188 |
} |
a3ddb94a50c8
8027570: NullPointerException in URLPermission.hashCode()
michaelm
parents:
20787
diff
changeset
|
189 |
|
a3ddb94a50c8
8027570: NullPointerException in URLPermission.hashCode()
michaelm
parents:
20787
diff
changeset
|
190 |
static HashCodeTest hashtest(String arg1, String arg2, int expected) { |
a3ddb94a50c8
8027570: NullPointerException in URLPermission.hashCode()
michaelm
parents:
20787
diff
changeset
|
191 |
return new HashCodeTest(arg1, arg2, expected); |
a3ddb94a50c8
8027570: NullPointerException in URLPermission.hashCode()
michaelm
parents:
20787
diff
changeset
|
192 |
} |
a3ddb94a50c8
8027570: NullPointerException in URLPermission.hashCode()
michaelm
parents:
20787
diff
changeset
|
193 |
|
20787
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
194 |
static class URLEqualityTest extends Test { |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
195 |
String arg1, arg2; |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
196 |
|
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
197 |
URLEqualityTest(String arg1, String arg2, boolean expected) { |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
198 |
this.arg1 = arg1; |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
199 |
this.arg2 = arg2; |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
200 |
this.expected = expected; |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
201 |
} |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
202 |
|
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
203 |
@Override |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
204 |
boolean execute() { |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
205 |
URLPermission p1 = new URLPermission(arg1); |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
206 |
URLPermission p2 = new URLPermission(arg2); |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
207 |
boolean result = p1.equals(p2); |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
208 |
|
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
209 |
return result == expected; |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
210 |
} |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
211 |
} |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
212 |
|
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
213 |
static URLEqualityTest eqtest(String arg1, String arg2, boolean expected) { |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
214 |
return new URLEqualityTest(arg1, arg2, expected); |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
215 |
} |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
216 |
|
17473 | 217 |
static Test[] pathImplies = { |
218 |
// single |
|
219 |
imtest("http://www.foo.com/", "http://www.foo.com/", true), |
|
220 |
imtest("http://www.bar.com/", "http://www.foo.com/", false), |
|
221 |
imtest("http://www.foo.com/a/b", "http://www.foo.com/", false), |
|
222 |
imtest("http://www.foo.com/a/b", "http://www.foo.com/a/b/c", false), |
|
223 |
// wildcard |
|
224 |
imtest("http://www.foo.com/a/b/*", "http://www.foo.com/a/b/c", true), |
|
225 |
imtest("http://www.foo.com/a/b/*", "http://www.foo.com/a/b/*", true), |
|
226 |
imtest("http://www.foo.com/a/b/*", "http://www.foo.com/a/b/c#frag", true), |
|
227 |
imtest("http://www.foo.com/a/b/*", "http://www.foo.com/a/b/c#frag?foo=foo", true), |
|
228 |
imtest("http://www.foo.com/a/b/*", "http://www.foo.com/b/b/c", false), |
|
229 |
imtest("http://www.foo.com/a/b/*", "http://www.foo.com/a/b/c.html", true), |
|
230 |
imtest("http://www.foo.com/a/b/*", "http://www.foo.com/a/b/c.html", true), |
|
231 |
imtest("http://www.foo.com/a/b/*", "https://www.foo.com/a/b/c", false), |
|
232 |
// recursive |
|
233 |
imtest("http://www.foo.com/a/b/-", "http://www.foo.com/a/b/-", true), |
|
234 |
imtest("http://www.foo.com/a/b/-", "http://www.foo.com/a/b/c", true), |
|
235 |
imtest("http://www.foo.com/a/b/-", "http://www.foo.com/a/b/c#frag", true), |
|
236 |
imtest("http://www.foo.com/a/b/-", "http://www.foo.com/a/b/c#frag?foo=foo", true), |
|
237 |
imtest("http://www.foo.com/a/b/-", "http://www.foo.com/b/b/c", false), |
|
238 |
imtest("http://www.foo.com/a/b/-", "http://www.foo.com/a/b/c.html", true), |
|
239 |
imtest("http://www.foo.com/a/b/-", "http://www.foo.com/a/b/c.html", true), |
|
240 |
imtest("http://www.foo.com/a/b/-", "http://www.foo.com/a/b/c/d/e.html", true), |
|
241 |
imtest("https://www.foo.com/a/b/-", "http://www.foo.com/a/b/c/d/e.html", false), |
|
242 |
imtest("http://www.foo.com/a/b/-", "http://www.foo.com/a/b/c/d/e#frag", true), |
|
243 |
imtest("http://www.foo.com/a/b/-", "https://www.foo.com/a/b/c", false), |
|
244 |
// special cases |
|
245 |
imtest("http:*", "https://www.foo.com/a/b/c", false), |
|
246 |
imtest("http:*", "http://www.foo.com/a/b/c", true), |
|
247 |
imtest("http:*", "http://foo/bar", true), |
|
21608
73c4bf75786c
8027687: The constructors of URLPermission class do not behave as described in javad
michaelm
parents:
21414
diff
changeset
|
248 |
imtest("http://WWW.foO.cOM/a/b/*", "http://wwW.foo.com/a/b/c", true), |
73c4bf75786c
8027687: The constructors of URLPermission class do not behave as described in javad
michaelm
parents:
21414
diff
changeset
|
249 |
imtest("http://wWw.fOo.cOm/a/b/*", "http://Www.foo.com/a/b/*", true), |
73c4bf75786c
8027687: The constructors of URLPermission class do not behave as described in javad
michaelm
parents:
21414
diff
changeset
|
250 |
imtest("http://www.FOO.com/", "http://www.foo.COM/", true), |
73c4bf75786c
8027687: The constructors of URLPermission class do not behave as described in javad
michaelm
parents:
21414
diff
changeset
|
251 |
imtest("http://66ww-w.F-O012O.com/", "http://66ww-w.f-o012o.COM/",true), |
73c4bf75786c
8027687: The constructors of URLPermission class do not behave as described in javad
michaelm
parents:
21414
diff
changeset
|
252 |
imtest("http://xn--ire-9la.com/", "http://xn--ire-9la.COM/", true), |
73c4bf75786c
8027687: The constructors of URLPermission class do not behave as described in javad
michaelm
parents:
21414
diff
changeset
|
253 |
imtest("http://x/", "http://X/", true), |
73c4bf75786c
8027687: The constructors of URLPermission class do not behave as described in javad
michaelm
parents:
21414
diff
changeset
|
254 |
imtest("http://x/", "http://x/", true), |
73c4bf75786c
8027687: The constructors of URLPermission class do not behave as described in javad
michaelm
parents:
21414
diff
changeset
|
255 |
imtest("http://X/", "http://X/", true), |
17473 | 256 |
imtest("http://foo/bar", "https://foo/bar", false) |
257 |
}; |
|
258 |
||
20787
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
259 |
// new functionality |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
260 |
|
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
261 |
static Test[] exceptionTests = { |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
262 |
extest("http://1.2.3.4.5/a/b/c"), |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
263 |
extest("http://www.*.com"), |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
264 |
extest("http://[foo.com]:99"), |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
265 |
extest("http://[fec0::X]:99"), |
21608
73c4bf75786c
8027687: The constructors of URLPermission class do not behave as described in javad
michaelm
parents:
21414
diff
changeset
|
266 |
extest("http:\\www.foo.com"), |
73c4bf75786c
8027687: The constructors of URLPermission class do not behave as described in javad
michaelm
parents:
21414
diff
changeset
|
267 |
extest("http://w_09ww.foo.com"), |
73c4bf75786c
8027687: The constructors of URLPermission class do not behave as described in javad
michaelm
parents:
21414
diff
changeset
|
268 |
extest("http://w&09ww.foo.com/p"), |
73c4bf75786c
8027687: The constructors of URLPermission class do not behave as described in javad
michaelm
parents:
21414
diff
changeset
|
269 |
extest("http://www+foo.com"), |
20787
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
270 |
extest("http:") |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
271 |
}; |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
272 |
|
21414
a3ddb94a50c8
8027570: NullPointerException in URLPermission.hashCode()
michaelm
parents:
20787
diff
changeset
|
273 |
static Test[] hashTests = { |
a3ddb94a50c8
8027570: NullPointerException in URLPermission.hashCode()
michaelm
parents:
20787
diff
changeset
|
274 |
hashtest("http://www.foo.com/path", "GET:X-Foo", 388644203), |
a3ddb94a50c8
8027570: NullPointerException in URLPermission.hashCode()
michaelm
parents:
20787
diff
changeset
|
275 |
hashtest("http:*", "*:*", 3255810) |
a3ddb94a50c8
8027570: NullPointerException in URLPermission.hashCode()
michaelm
parents:
20787
diff
changeset
|
276 |
}; |
a3ddb94a50c8
8027570: NullPointerException in URLPermission.hashCode()
michaelm
parents:
20787
diff
changeset
|
277 |
|
20787
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
278 |
static Test[] pathImplies2 = { |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
279 |
imtest("http://[FE80::]:99", "http://[fe80:0::]:99", true), |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
280 |
|
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
281 |
// hostnames |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
282 |
imtest("http://*.foo.com/a/b/-", "http://www.foo.com/a/b/c/d", true), |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
283 |
imtest("http://*.foo.com/a/b/-", "http://www.bar.com/a/b/c/d", false), |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
284 |
imtest("http://*.foo.com/a/b/-", "http://www.biz.bar.foo.com/a/b/c/d", true), |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
285 |
imtest("http://*.foo.com/a/b/-", "http://www.biz.bar.foo.como/a/b/c/d", false), |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
286 |
imtest("http://*/a/b/-", "http://www.biz.bar.foo.fuzz/a/b/c/d", true), |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
287 |
imtest("http://*/a/b/-", "http://*/a/b/c/d", true), |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
288 |
imtest("http://*.foo.com/a/b/-", "http://*/a/b/c/d", false), |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
289 |
imtest("http:*", "http://*/a/b/c/d", true), |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
290 |
|
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
291 |
// literal IPv4 addresses |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
292 |
imtest("http://1.2.3.4/a/b/-", "http://www.biz.bar.foo.com/a/b/c/d", false), |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
293 |
imtest("http://1.2.3.4/a/b/-", "http://1.2.3.4/a/b/c/d", true), |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
294 |
imtest("http://1.2.3.4/a/b/-", "http://1.2.88.4/a/b/c/d", false), |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
295 |
imtest("http:*", "http://1.2.88.4/a/b/c/d", true), |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
296 |
|
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
297 |
// literal IPv6 addresses |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
298 |
imtest("http://[fe80::]/a/b/-", "http://[fe80::0]/a/b/c", true), |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
299 |
imtest("http://[fe80::]/a/b/-", "http://[fe80::3]/a/b/c", false), |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
300 |
imtest("http://[1:2:3:4:5:6:7:8]/a/b/-","http://[1:002:03:4:0005:6:07:8]/a/b/c", true), |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
301 |
imtest("http://[1:2:3:4:5:6:7:8]/a/b/-","http://[1:002:03:4:0033:6:07:8]/a/b/c", false), |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
302 |
imtest("http://[1::2]/a/b/-", "http://[1:0:0:0::2]/a/b/c", true), |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
303 |
imtest("http://[1::2]/a/b/-", "http://[1:0:0:0::3]/a/b/c", false), |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
304 |
imtest("http://[FE80::]:99", "http://[fe80:0::]:99", true), |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
305 |
imtest("http:*", "http://[fe80:0::]:99", true), |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
306 |
|
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
307 |
// portranges |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
308 |
imtest("http://*.foo.com:1-2/a/b/-", "http://www.foo.com:1/a/b/c/d", true), |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
309 |
imtest("http://*.foo.com:1-2/a/b/-", "http://www.foo.com:3/a/b/c/d", false), |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
310 |
imtest("http://*.foo.com:3-/a/b/-", "http://www.foo.com:1/a/b/c/d", false), |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
311 |
imtest("http://*.foo.com:3-/a/b/-", "http://www.foo.com:4-5/a/b/c/d", true), |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
312 |
imtest("http://*.foo.com:3-/a/b/-", "http://www.foo.com:3-3/a/b/c/d", true), |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
313 |
imtest("http://*.foo.com:3-99/a/b/-", "http://www.foo.com:55-100/a/b/c/d", false), |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
314 |
imtest("http://*.foo.com:-44/a/b/-", "http://www.foo.com:1/a/b/c/d", true), |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
315 |
imtest("http://*.foo.com:-44/a/b/-", "http://www.foo.com:1-10/a/b/c/d", true), |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
316 |
imtest("http://*.foo.com:-44/a/b/-", "http://www.foo.com:44/a/b/c/d", true), |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
317 |
imtest("http://*.foo.com:-44/a/b/-", "http://www.foo.com:45/a/b/c/d", false), |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
318 |
imtest("http://www.foo.com:70-90/a/b", "http://www.foo.com/a/b", true), |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
319 |
imtest("https://www.foo.com/a/b", "https://www.foo.com:80/a/b", false), |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
320 |
imtest("https://www.foo.com:70-90/a/b", "https://www.foo.com/a/b", false), |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
321 |
imtest("https://www.foo.com/a/b", "https://www.foo.com:443/a/b", true), |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
322 |
imtest("https://www.foo.com:200-500/a/b", "https://www.foo.com/a/b", true), |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
323 |
imtest("http://www.foo.com:*/a/b", "http://www.foo.com:1-12345/a/b", true), |
22105
09df5383d1df
8029354: URLPermission.<init> throws llegalArgumentException: Invalid characters in hostname
michaelm
parents:
21621
diff
changeset
|
324 |
imtest("http://host/a/b", "http://HOST/a/b", true), |
20787
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
325 |
|
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
326 |
// misc |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
327 |
imtest("https:*", "http://www.foo.com", false), |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
328 |
imtest("https:*", "http:*", false) |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
329 |
}; |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
330 |
|
39137
6cf0e983a1e1
8071660: URLPermission not handling empty method lists correctly
vtewari
parents:
39132
diff
changeset
|
331 |
static final String FOO_URL = "http://www.foo.com/"; |
6cf0e983a1e1
8071660: URLPermission not handling empty method lists correctly
vtewari
parents:
39132
diff
changeset
|
332 |
static final String BAR_URL = "http://www.bar.com/"; |
6cf0e983a1e1
8071660: URLPermission not handling empty method lists correctly
vtewari
parents:
39132
diff
changeset
|
333 |
|
17473 | 334 |
static Test[] actionImplies = { |
335 |
actest("GET", "GET", true), |
|
336 |
actest("GET", "POST", false), |
|
337 |
actest("GET:", "PUT", false), |
|
338 |
actest("GET:", "GET", true), |
|
339 |
actest("GET,POST", "GET", true), |
|
340 |
actest("GET,POST:", "GET", true), |
|
341 |
actest("GET:X-Foo", "GET:x-foo", true), |
|
342 |
actest("GET:X-Foo,X-bar", "GET:x-foo", true), |
|
343 |
actest("GET:X-Foo", "GET:x-boo", false), |
|
344 |
actest("GET:X-Foo,X-Bar", "GET:x-bar,x-foo", true), |
|
345 |
actest("GET:X-Bar,X-Foo,X-Bar,Y-Foo", "GET:x-bar,x-foo", true), |
|
346 |
actest("GET:*", "GET:x-bar,x-foo", true), |
|
39137
6cf0e983a1e1
8071660: URLPermission not handling empty method lists correctly
vtewari
parents:
39132
diff
changeset
|
347 |
actest("*:*", "GET:x-bar,x-foo", true), |
6cf0e983a1e1
8071660: URLPermission not handling empty method lists correctly
vtewari
parents:
39132
diff
changeset
|
348 |
actest("", "GET:x-bar,x-foo", false), |
6cf0e983a1e1
8071660: URLPermission not handling empty method lists correctly
vtewari
parents:
39132
diff
changeset
|
349 |
actest("GET:x-bar,x-foo", "", true), |
6cf0e983a1e1
8071660: URLPermission not handling empty method lists correctly
vtewari
parents:
39132
diff
changeset
|
350 |
actest("", "", true), |
6cf0e983a1e1
8071660: URLPermission not handling empty method lists correctly
vtewari
parents:
39132
diff
changeset
|
351 |
actest("GET,DELETE", "GET,DELETE:x-foo", false), |
6cf0e983a1e1
8071660: URLPermission not handling empty method lists correctly
vtewari
parents:
39132
diff
changeset
|
352 |
actest(FOO_URL, BAR_URL, "", "GET:x-bar,x-foo", false), |
6cf0e983a1e1
8071660: URLPermission not handling empty method lists correctly
vtewari
parents:
39132
diff
changeset
|
353 |
actest(FOO_URL, BAR_URL, "GET:x-bar,x-foo", "", false), |
6cf0e983a1e1
8071660: URLPermission not handling empty method lists correctly
vtewari
parents:
39132
diff
changeset
|
354 |
actest(FOO_URL, BAR_URL, "", "", false) |
17473 | 355 |
}; |
356 |
||
39132
e9499c06e138
8114860: Behavior of java.net.URLPermission.getActions() contradicts spec
vtewari
parents:
22105
diff
changeset
|
357 |
static Test[] actionsStringTest = { |
39775
37b3d7bf72ee
8161291: Serialization Tests for URLPermission is failing
vtewari
parents:
39137
diff
changeset
|
358 |
actionstest("", ":"), |
37b3d7bf72ee
8161291: Serialization Tests for URLPermission is failing
vtewari
parents:
39137
diff
changeset
|
359 |
actionstest(":", ":"), |
39132
e9499c06e138
8114860: Behavior of java.net.URLPermission.getActions() contradicts spec
vtewari
parents:
22105
diff
changeset
|
360 |
actionstest(":X-Bar", ":X-Bar"), |
39775
37b3d7bf72ee
8161291: Serialization Tests for URLPermission is failing
vtewari
parents:
39137
diff
changeset
|
361 |
actionstest("GET", "GET:"), |
37b3d7bf72ee
8161291: Serialization Tests for URLPermission is failing
vtewari
parents:
39137
diff
changeset
|
362 |
actionstest("get", "GET:"), |
37b3d7bf72ee
8161291: Serialization Tests for URLPermission is failing
vtewari
parents:
39137
diff
changeset
|
363 |
actionstest("GET,POST", "GET,POST:"), |
37b3d7bf72ee
8161291: Serialization Tests for URLPermission is failing
vtewari
parents:
39137
diff
changeset
|
364 |
actionstest("GET,post", "GET,POST:"), |
37b3d7bf72ee
8161291: Serialization Tests for URLPermission is failing
vtewari
parents:
39137
diff
changeset
|
365 |
actionstest("get,post", "GET,POST:"), |
37b3d7bf72ee
8161291: Serialization Tests for URLPermission is failing
vtewari
parents:
39137
diff
changeset
|
366 |
actionstest("get,post,DELETE", "DELETE,GET,POST:"), |
37b3d7bf72ee
8161291: Serialization Tests for URLPermission is failing
vtewari
parents:
39137
diff
changeset
|
367 |
actionstest("GET,POST:", "GET,POST:"), |
39132
e9499c06e138
8114860: Behavior of java.net.URLPermission.getActions() contradicts spec
vtewari
parents:
22105
diff
changeset
|
368 |
actionstest("GET:X-Foo,X-bar", "GET:X-Bar,X-Foo"), |
e9499c06e138
8114860: Behavior of java.net.URLPermission.getActions() contradicts spec
vtewari
parents:
22105
diff
changeset
|
369 |
actionstest("GET,POST,DELETE:X-Bar,X-Foo,X-Bar,Y-Foo", "DELETE,GET,POST:X-Bar,X-Bar,X-Foo,Y-Foo") |
e9499c06e138
8114860: Behavior of java.net.URLPermission.getActions() contradicts spec
vtewari
parents:
22105
diff
changeset
|
370 |
}; |
e9499c06e138
8114860: Behavior of java.net.URLPermission.getActions() contradicts spec
vtewari
parents:
22105
diff
changeset
|
371 |
|
20787
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
372 |
static Test[] equalityTests = { |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
373 |
eqtest("http://www.foo.com", "http://www.FOO.CoM", true), |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
374 |
eqtest("http://[fe80:0:0::]:1-2", "HTTP://[FE80::]:1-2", true), |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
375 |
eqtest("HTTP://1.2.3.5/A/B/C", "http://1.2.3.5/A/b/C", false), |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
376 |
eqtest("HTTP://1.2.3.5/A/B/C", "HTTP://1.2.3.5/A/b/C", false), |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
377 |
eqtest("http:*", "http:*", true), |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
378 |
eqtest("http://www.foo.com/a/b", "https://www.foo.com/a/b", false), |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
379 |
eqtest("http://w.foo.com", "http://w.foo.com/", false), |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
380 |
eqtest("http://*.foo.com", "http://*.foo.com", true), |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
381 |
eqtest("http://www.foo.com/a/b", "http://www.foo.com:80/a/b", true), |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
382 |
eqtest("http://www.foo.com/a/b", "http://www.foo.com:82/a/b", false), |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
383 |
eqtest("https://www.foo.com/a/b", "https://www.foo.com:443/a/b", true), |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
384 |
eqtest("https://www.foo.com/a/b", "https://www.foo.com:444/a/b", false), |
22105
09df5383d1df
8029354: URLPermission.<init> throws llegalArgumentException: Invalid characters in hostname
michaelm
parents:
21621
diff
changeset
|
385 |
eqtest("http://michael@foo.com/bar","http://michael@foo.com/bar", true), |
09df5383d1df
8029354: URLPermission.<init> throws llegalArgumentException: Invalid characters in hostname
michaelm
parents:
21621
diff
changeset
|
386 |
eqtest("http://Michael@foo.com/bar","http://michael@goo.com/bar",false), |
09df5383d1df
8029354: URLPermission.<init> throws llegalArgumentException: Invalid characters in hostname
michaelm
parents:
21621
diff
changeset
|
387 |
eqtest("http://michael@foo.com/bar","http://george@foo.com/bar", true), |
09df5383d1df
8029354: URLPermission.<init> throws llegalArgumentException: Invalid characters in hostname
michaelm
parents:
21621
diff
changeset
|
388 |
eqtest("http://@foo.com/bar","http://foo.com/bar", true) |
09df5383d1df
8029354: URLPermission.<init> throws llegalArgumentException: Invalid characters in hostname
michaelm
parents:
21621
diff
changeset
|
389 |
}; |
09df5383d1df
8029354: URLPermission.<init> throws llegalArgumentException: Invalid characters in hostname
michaelm
parents:
21621
diff
changeset
|
390 |
|
09df5383d1df
8029354: URLPermission.<init> throws llegalArgumentException: Invalid characters in hostname
michaelm
parents:
21621
diff
changeset
|
391 |
static Test[] createTests = { |
09df5383d1df
8029354: URLPermission.<init> throws llegalArgumentException: Invalid characters in hostname
michaelm
parents:
21621
diff
changeset
|
392 |
createtest("http://user@foo.com/a/b/c"), |
09df5383d1df
8029354: URLPermission.<init> throws llegalArgumentException: Invalid characters in hostname
michaelm
parents:
21621
diff
changeset
|
393 |
createtest("http://user:pass@foo.com/a/b/c"), |
09df5383d1df
8029354: URLPermission.<init> throws llegalArgumentException: Invalid characters in hostname
michaelm
parents:
21621
diff
changeset
|
394 |
createtest("http://user:@foo.com/a/b/c") |
20787
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
395 |
}; |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
396 |
|
17473 | 397 |
static boolean failed = false; |
398 |
||
399 |
public static void main(String args[]) throws Exception { |
|
400 |
for (int i=0; i<pathImplies.length ; i++) { |
|
401 |
URLImpliesTest test = (URLImpliesTest)pathImplies[i]; |
|
402 |
Exception caught = null; |
|
403 |
boolean result = false; |
|
404 |
try { |
|
405 |
result = test.execute(); |
|
406 |
} catch (Exception e) { |
|
407 |
caught = e; |
|
408 |
e.printStackTrace(); |
|
409 |
} |
|
410 |
if (!result) { |
|
411 |
failed = true; |
|
20787
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
412 |
System.out.printf("path test %d failed: %s : %s\n", i, test.arg1, |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
413 |
test.arg2); |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
414 |
} else { |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
415 |
System.out.println ("path test " + i + " OK"); |
17473 | 416 |
} |
20787
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
417 |
|
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
418 |
} |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
419 |
|
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
420 |
// new tests for functionality added in revision of API |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
421 |
|
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
422 |
for (int i=0; i<pathImplies2.length ; i++) { |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
423 |
URLImpliesTest test = (URLImpliesTest)pathImplies2[i]; |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
424 |
Exception caught = null; |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
425 |
boolean result = false; |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
426 |
try { |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
427 |
result = test.execute(); |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
428 |
} catch (Exception e) { |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
429 |
caught = e; |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
430 |
e.printStackTrace(); |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
431 |
} |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
432 |
if (!result) { |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
433 |
failed = true; |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
434 |
System.out.printf("path2 test %d failed: %s : %s\n", i, test.arg1, |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
435 |
test.arg2); |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
436 |
} else { |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
437 |
System.out.println ("path2 test " + i + " OK"); |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
438 |
} |
17473 | 439 |
|
440 |
} |
|
20787
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
441 |
|
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
442 |
for (int i=0; i<equalityTests.length ; i++) { |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
443 |
URLEqualityTest test = (URLEqualityTest)equalityTests[i]; |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
444 |
Exception caught = null; |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
445 |
boolean result = false; |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
446 |
try { |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
447 |
result = test.execute(); |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
448 |
} catch (Exception e) { |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
449 |
caught = e; |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
450 |
e.printStackTrace(); |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
451 |
} |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
452 |
if (!result) { |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
453 |
failed = true; |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
454 |
System.out.printf("equality test %d failed: %s : %s\n", i, test.arg1, |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
455 |
test.arg2); |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
456 |
} else { |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
457 |
System.out.println ("equality test " + i + " OK"); |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
458 |
} |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
459 |
|
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
460 |
} |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
461 |
|
21414
a3ddb94a50c8
8027570: NullPointerException in URLPermission.hashCode()
michaelm
parents:
20787
diff
changeset
|
462 |
for (int i=0; i<hashTests.length; i++) { |
a3ddb94a50c8
8027570: NullPointerException in URLPermission.hashCode()
michaelm
parents:
20787
diff
changeset
|
463 |
HashCodeTest test = (HashCodeTest)hashTests[i]; |
a3ddb94a50c8
8027570: NullPointerException in URLPermission.hashCode()
michaelm
parents:
20787
diff
changeset
|
464 |
boolean result = test.execute(); |
a3ddb94a50c8
8027570: NullPointerException in URLPermission.hashCode()
michaelm
parents:
20787
diff
changeset
|
465 |
if (!result) { |
a3ddb94a50c8
8027570: NullPointerException in URLPermission.hashCode()
michaelm
parents:
20787
diff
changeset
|
466 |
System.out.printf ("test failed: %s %s %d\n", test.arg1, test.arg2, test.hash); |
a3ddb94a50c8
8027570: NullPointerException in URLPermission.hashCode()
michaelm
parents:
20787
diff
changeset
|
467 |
failed = true; |
a3ddb94a50c8
8027570: NullPointerException in URLPermission.hashCode()
michaelm
parents:
20787
diff
changeset
|
468 |
} else { |
a3ddb94a50c8
8027570: NullPointerException in URLPermission.hashCode()
michaelm
parents:
20787
diff
changeset
|
469 |
System.out.println ("hash test " + i + " OK"); |
a3ddb94a50c8
8027570: NullPointerException in URLPermission.hashCode()
michaelm
parents:
20787
diff
changeset
|
470 |
} |
a3ddb94a50c8
8027570: NullPointerException in URLPermission.hashCode()
michaelm
parents:
20787
diff
changeset
|
471 |
} |
a3ddb94a50c8
8027570: NullPointerException in URLPermission.hashCode()
michaelm
parents:
20787
diff
changeset
|
472 |
|
20787
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
473 |
for (int i=0; i<exceptionTests.length; i++) { |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
474 |
ExTest test = (ExTest)exceptionTests[i]; |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
475 |
boolean result = test.execute(); |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
476 |
if (!result) { |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
477 |
System.out.println ("test failed: " + test.arg); |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
478 |
failed = true; |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
479 |
} else { |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
480 |
System.out.println ("exception test " + i + " OK"); |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
481 |
} |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
482 |
} |
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
483 |
|
22105
09df5383d1df
8029354: URLPermission.<init> throws llegalArgumentException: Invalid characters in hostname
michaelm
parents:
21621
diff
changeset
|
484 |
for (int i=0; i<createTests.length; i++) { |
09df5383d1df
8029354: URLPermission.<init> throws llegalArgumentException: Invalid characters in hostname
michaelm
parents:
21621
diff
changeset
|
485 |
CreateTest test = (CreateTest)createTests[i]; |
09df5383d1df
8029354: URLPermission.<init> throws llegalArgumentException: Invalid characters in hostname
michaelm
parents:
21621
diff
changeset
|
486 |
boolean result = test.execute(); |
09df5383d1df
8029354: URLPermission.<init> throws llegalArgumentException: Invalid characters in hostname
michaelm
parents:
21621
diff
changeset
|
487 |
if (!result) { |
09df5383d1df
8029354: URLPermission.<init> throws llegalArgumentException: Invalid characters in hostname
michaelm
parents:
21621
diff
changeset
|
488 |
System.out.println ("test failed: " + test.arg); |
09df5383d1df
8029354: URLPermission.<init> throws llegalArgumentException: Invalid characters in hostname
michaelm
parents:
21621
diff
changeset
|
489 |
failed = true; |
09df5383d1df
8029354: URLPermission.<init> throws llegalArgumentException: Invalid characters in hostname
michaelm
parents:
21621
diff
changeset
|
490 |
} else { |
09df5383d1df
8029354: URLPermission.<init> throws llegalArgumentException: Invalid characters in hostname
michaelm
parents:
21621
diff
changeset
|
491 |
System.out.println ("create test " + i + " OK"); |
09df5383d1df
8029354: URLPermission.<init> throws llegalArgumentException: Invalid characters in hostname
michaelm
parents:
21621
diff
changeset
|
492 |
} |
09df5383d1df
8029354: URLPermission.<init> throws llegalArgumentException: Invalid characters in hostname
michaelm
parents:
21621
diff
changeset
|
493 |
} |
09df5383d1df
8029354: URLPermission.<init> throws llegalArgumentException: Invalid characters in hostname
michaelm
parents:
21621
diff
changeset
|
494 |
|
17473 | 495 |
for (int i=0; i<actionImplies.length ; i++) { |
496 |
ActionImpliesTest test = (ActionImpliesTest)actionImplies[i]; |
|
497 |
Exception caught = null; |
|
498 |
boolean result = false; |
|
499 |
try { |
|
500 |
result = test.execute(); |
|
501 |
} catch (Exception e) { |
|
502 |
caught = e; |
|
503 |
e.printStackTrace(); |
|
504 |
} |
|
505 |
if (!result) { |
|
506 |
failed = true; |
|
507 |
System.out.println ("test failed: " + test.arg1 + ": " + |
|
508 |
test.arg2 + " Exception: " + caught); |
|
509 |
} |
|
510 |
System.out.println ("action test " + i + " OK"); |
|
511 |
} |
|
512 |
||
39132
e9499c06e138
8114860: Behavior of java.net.URLPermission.getActions() contradicts spec
vtewari
parents:
22105
diff
changeset
|
513 |
for (int i = 0; i < actionsStringTest.length; i++) { |
e9499c06e138
8114860: Behavior of java.net.URLPermission.getActions() contradicts spec
vtewari
parents:
22105
diff
changeset
|
514 |
ActionsStringTest test = (ActionsStringTest) actionsStringTest[i]; |
e9499c06e138
8114860: Behavior of java.net.URLPermission.getActions() contradicts spec
vtewari
parents:
22105
diff
changeset
|
515 |
Exception caught = null; |
e9499c06e138
8114860: Behavior of java.net.URLPermission.getActions() contradicts spec
vtewari
parents:
22105
diff
changeset
|
516 |
boolean result = false; |
e9499c06e138
8114860: Behavior of java.net.URLPermission.getActions() contradicts spec
vtewari
parents:
22105
diff
changeset
|
517 |
try { |
e9499c06e138
8114860: Behavior of java.net.URLPermission.getActions() contradicts spec
vtewari
parents:
22105
diff
changeset
|
518 |
result = test.execute(); |
e9499c06e138
8114860: Behavior of java.net.URLPermission.getActions() contradicts spec
vtewari
parents:
22105
diff
changeset
|
519 |
} catch (Exception e) { |
e9499c06e138
8114860: Behavior of java.net.URLPermission.getActions() contradicts spec
vtewari
parents:
22105
diff
changeset
|
520 |
caught = e; |
e9499c06e138
8114860: Behavior of java.net.URLPermission.getActions() contradicts spec
vtewari
parents:
22105
diff
changeset
|
521 |
} |
e9499c06e138
8114860: Behavior of java.net.URLPermission.getActions() contradicts spec
vtewari
parents:
22105
diff
changeset
|
522 |
if (!result) { |
e9499c06e138
8114860: Behavior of java.net.URLPermission.getActions() contradicts spec
vtewari
parents:
22105
diff
changeset
|
523 |
failed = true; |
e9499c06e138
8114860: Behavior of java.net.URLPermission.getActions() contradicts spec
vtewari
parents:
22105
diff
changeset
|
524 |
System.out.println("test failed: " + test.arg + ": " |
e9499c06e138
8114860: Behavior of java.net.URLPermission.getActions() contradicts spec
vtewari
parents:
22105
diff
changeset
|
525 |
+ test.expectedActions + " Exception: " + caught); |
e9499c06e138
8114860: Behavior of java.net.URLPermission.getActions() contradicts spec
vtewari
parents:
22105
diff
changeset
|
526 |
} |
e9499c06e138
8114860: Behavior of java.net.URLPermission.getActions() contradicts spec
vtewari
parents:
22105
diff
changeset
|
527 |
System.out.println("Actions String test " + i + " OK"); |
e9499c06e138
8114860: Behavior of java.net.URLPermission.getActions() contradicts spec
vtewari
parents:
22105
diff
changeset
|
528 |
} |
e9499c06e138
8114860: Behavior of java.net.URLPermission.getActions() contradicts spec
vtewari
parents:
22105
diff
changeset
|
529 |
|
17473 | 530 |
serializationTest("http://www.foo.com/-", "GET,DELETE:*"); |
531 |
serializationTest("https://www.foo.com/-", "POST:X-Foo"); |
|
532 |
serializationTest("https:*", "*:*"); |
|
533 |
serializationTest("http://www.foo.com/a/b/s/", "POST:X-Foo"); |
|
534 |
serializationTest("http://www.foo.com/a/b/s/*", "POST:X-Foo"); |
|
535 |
||
536 |
if (failed) { |
|
537 |
throw new RuntimeException("some tests failed"); |
|
538 |
} |
|
539 |
||
540 |
} |
|
541 |
||
542 |
static void serializationTest(String name, String actions) |
|
543 |
throws Exception { |
|
544 |
||
20787
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
545 |
URLPermission out = new URLPermission(name, actions); |
17501
052f2c3a66e9
8014783: java/net/HttpURLPermission/HttpURLPermissionTest.java leaves files open
chegar
parents:
17473
diff
changeset
|
546 |
|
052f2c3a66e9
8014783: java/net/HttpURLPermission/HttpURLPermissionTest.java leaves files open
chegar
parents:
17473
diff
changeset
|
547 |
ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
052f2c3a66e9
8014783: java/net/HttpURLPermission/HttpURLPermissionTest.java leaves files open
chegar
parents:
17473
diff
changeset
|
548 |
ObjectOutputStream o = new ObjectOutputStream(baos); |
17473 | 549 |
o.writeObject(out); |
17501
052f2c3a66e9
8014783: java/net/HttpURLPermission/HttpURLPermissionTest.java leaves files open
chegar
parents:
17473
diff
changeset
|
550 |
ByteArrayInputStream bain = new ByteArrayInputStream(baos.toByteArray()); |
052f2c3a66e9
8014783: java/net/HttpURLPermission/HttpURLPermissionTest.java leaves files open
chegar
parents:
17473
diff
changeset
|
551 |
ObjectInputStream i = new ObjectInputStream(bain); |
20787
ab071ce90368
8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI
michaelm
parents:
17501
diff
changeset
|
552 |
URLPermission in = (URLPermission)i.readObject(); |
17473 | 553 |
if (!in.equals(out)) { |
554 |
System.out.println ("FAIL"); |
|
555 |
System.out.println ("in = " + in); |
|
556 |
System.out.println ("out = " + out); |
|
557 |
failed = true; |
|
558 |
} |
|
559 |
} |
|
560 |
} |