@@ -43,25 +43,25 @@ public GenericUrlTest(String name) {
43
43
super (name );
44
44
}
45
45
46
- private static String MINIMAL = "foo ://bar" ;
46
+ private static final String MINIMAL = "http ://bar" ;
47
47
48
48
public void testBuild_minimal () {
49
49
GenericUrl url = new GenericUrl ();
50
- url .setScheme ("foo " );
50
+ url .setScheme ("http " );
51
51
url .setHost ("bar" );
52
52
assertEquals (MINIMAL , url .build ());
53
53
}
54
54
55
55
public void testParse_minimal () {
56
56
GenericUrl url = new GenericUrl (MINIMAL );
57
- assertEquals ("foo " , url .getScheme ());
57
+ assertEquals ("http " , url .getScheme ());
58
58
}
59
59
60
- private static String NO_PATH = "foo ://bar?a=b" ;
60
+ private static final String NO_PATH = "http ://bar?a=b" ;
61
61
62
62
public void testBuild_noPath () {
63
63
GenericUrl url = new GenericUrl ();
64
- url .setScheme ("foo " );
64
+ url .setScheme ("http " );
65
65
url .setHost ("bar" );
66
66
url .set ("a" , "b" );
67
67
assertEquals (NO_PATH , url .build ());
@@ -85,7 +85,7 @@ public void testBuild_noScheme() {
85
85
public void testBuild_noHost () {
86
86
GenericUrl url = new GenericUrl ();
87
87
try {
88
- url .setScheme ("foo " );
88
+ url .setScheme ("http " );
89
89
url .build ();
90
90
fail ("expected " + NullPointerException .class );
91
91
} catch (NullPointerException e ) {
@@ -95,19 +95,19 @@ public void testBuild_noHost() {
95
95
96
96
public void testParse_noPath () {
97
97
GenericUrl url = new GenericUrl (NO_PATH );
98
- assertEquals ("foo " , url .getScheme ());
98
+ assertEquals ("http " , url .getScheme ());
99
99
assertEquals ("bar" , url .getHost ());
100
100
assertEquals ("b" , url .getFirst ("a" ));
101
101
assertNull (url .getPathParts ());
102
102
}
103
103
104
- private static String SHORT_PATH = "foo ://bar/path?a=b" ;
104
+ private static final String SHORT_PATH = "http ://bar/path?a=b" ;
105
105
106
- private static List <String > SHORT_PATH_PARTS = Arrays .asList ("" , "path" );
106
+ private static final List <String > SHORT_PATH_PARTS = Arrays .asList ("" , "path" );
107
107
108
108
public void testBuild_shortPath () {
109
109
GenericUrl url = new GenericUrl ();
110
- url .setScheme ("foo " );
110
+ url .setScheme ("http " );
111
111
url .setHost ("bar" );
112
112
url .setPathParts (SHORT_PATH_PARTS );
113
113
url .set ("a" , "b" );
@@ -116,19 +116,19 @@ public void testBuild_shortPath() {
116
116
117
117
public void testParse_shortPath () {
118
118
GenericUrl url = new GenericUrl (SHORT_PATH );
119
- assertEquals ("foo " , url .getScheme ());
119
+ assertEquals ("http " , url .getScheme ());
120
120
assertEquals ("bar" , url .getHost ());
121
121
assertEquals (SHORT_PATH_PARTS , url .getPathParts ());
122
122
assertEquals ("b" , url .getFirst ("a" ));
123
123
}
124
124
125
- private static String LONG_PATH = "foo ://bar/path/to/resource?a=b" ;
125
+ private static final String LONG_PATH = "http ://bar/path/to/resource?a=b" ;
126
126
127
- private static List <String > LONG_PATH_PARTS = Arrays .asList ("" , "path" , "to" , "resource" );
127
+ private static final List <String > LONG_PATH_PARTS = Arrays .asList ("" , "path" , "to" , "resource" );
128
128
129
129
public void testBuild_longPath () {
130
130
GenericUrl url = new GenericUrl ();
131
- url .setScheme ("foo " );
131
+ url .setScheme ("http " );
132
132
url .setHost ("bar" );
133
133
url .setPathParts (LONG_PATH_PARTS );
134
134
url .set ("a" , "b" );
@@ -137,7 +137,7 @@ public void testBuild_longPath() {
137
137
138
138
public void testParse_longPath () {
139
139
GenericUrl url = new GenericUrl (LONG_PATH );
140
- assertEquals ("foo " , url .getScheme ());
140
+ assertEquals ("http " , url .getScheme ());
141
141
assertEquals ("bar" , url .getHost ());
142
142
assertEquals (LONG_PATH_PARTS , url .getPathParts ());
143
143
assertEquals ("b" , url .getFirst ("a" ));
@@ -157,17 +157,17 @@ public TestUrl(String encodedUrl) {
157
157
}
158
158
}
159
159
160
- private static String FULL =
160
+ private static final String FULL =
161
161
"https://user:%3Cpa&$w%40rd%3E@www.google.com:223/m8/feeds/contacts/"
162
162
+ "someone=%23%25&%20%3F%3Co%3E%7B%7D@gmail.com/"
163
163
+ "full?" + "foo=bar&" + "alt=json&" + "max-results=3&" + "prettyprint=true&"
164
164
+ "q=Go%3D%23/%25%26%20?%3Co%3Egle#%3CD@WNL:ADING%3E" ;
165
165
166
- private static List <String > FULL_PARTS =
166
+ private static final List <String > FULL_PARTS =
167
167
Arrays .asList ("" , "m8" , "feeds" , "contacts" , "someone=#%& ?<o>{}@gmail.com" , "full" );
168
168
169
- private static String USER_INFO = "user:<pa&$w@rd>" ;
170
- private static String FRAGMENT = "<D@WNL:ADING>" ;
169
+ private static final String USER_INFO = "user:<pa&$w@rd>" ;
170
+ private static final String FRAGMENT = "<D@WNL:ADING>" ;
171
171
172
172
public void testBuild_full () {
173
173
TestUrl url = new TestUrl ();
@@ -268,11 +268,12 @@ public FieldTypesUrl set(String fieldName, Object value) {
268
268
}
269
269
}
270
270
271
- private static String FIELD_TYPES = "foo://bar?B=true&D=-3.14&I=-3&b=true&d=-3.14&i=-3&s=a&a=b" ;
271
+ private static final String FIELD_TYPES =
272
+ "http://bar?B=true&D=-3.14&I=-3&b=true&d=-3.14&i=-3&s=a&a=b" ;
272
273
273
274
public void testBuild_fieldTypes () {
274
275
FieldTypesUrl url = new FieldTypesUrl ();
275
- url .setScheme ("foo " );
276
+ url .setScheme ("http " );
276
277
url .setHost ("bar" );
277
278
url .set ("a" , "b" );
278
279
url .B = true ;
@@ -288,7 +289,7 @@ public void testBuild_fieldTypes() {
288
289
289
290
public void testParse_fieldTypes () {
290
291
FieldTypesUrl url = new FieldTypesUrl (FIELD_TYPES );
291
- assertEquals ("foo " , url .getScheme ());
292
+ assertEquals ("http " , url .getScheme ());
292
293
assertEquals ("bar" , url .getHost ());
293
294
assertEquals ("b" , url .getFirst ("a" ));
294
295
assertNull (url .hidden );
@@ -301,11 +302,12 @@ public void testParse_fieldTypes() {
301
302
assertEquals ("a" , url .s );
302
303
}
303
304
304
- private static String FRAGMENT1 = "foo://bar/path/to/resource#fragme=%23/%25&%20?%3Co%3Ent" ;
305
+ private static final String FRAGMENT1 =
306
+ "http://bar/path/to/resource#fragme=%23/%25&%20?%3Co%3Ent" ;
305
307
306
308
public void testBuild_fragment1 () {
307
309
GenericUrl url = new GenericUrl ();
308
- url .setScheme ("foo " );
310
+ url .setScheme ("http " );
309
311
url .setHost ("bar" );
310
312
url .setPathParts (LONG_PATH_PARTS );
311
313
url .setFragment ("fragme=#/%& ?<o>nt" );
@@ -314,17 +316,17 @@ public void testBuild_fragment1() {
314
316
315
317
public void testParse_fragment1 () {
316
318
GenericUrl url = new GenericUrl (FRAGMENT1 );
317
- assertEquals ("foo " , url .getScheme ());
319
+ assertEquals ("http " , url .getScheme ());
318
320
assertEquals ("bar" , url .getHost ());
319
321
assertEquals (LONG_PATH_PARTS , url .getPathParts ());
320
322
assertEquals ("fragme=#/%& ?<o>nt" , url .getFragment ());
321
323
}
322
324
323
- private static String FRAGMENT2 = "foo ://bar/path/to/resource?a=b#fragment" ;
325
+ private static final String FRAGMENT2 = "http ://bar/path/to/resource?a=b#fragment" ;
324
326
325
327
public void testBuild_fragment2 () {
326
328
GenericUrl url = new GenericUrl ();
327
- url .setScheme ("foo " );
329
+ url .setScheme ("http " );
328
330
url .setHost ("bar" );
329
331
url .setPathParts (LONG_PATH_PARTS );
330
332
url .set ("a" , "b" );
@@ -334,7 +336,7 @@ public void testBuild_fragment2() {
334
336
335
337
public void testParse_fragment2 () {
336
338
GenericUrl url = new GenericUrl (FRAGMENT2 );
337
- assertEquals ("foo " , url .getScheme ());
339
+ assertEquals ("http " , url .getScheme ());
338
340
assertEquals ("bar" , url .getHost ());
339
341
assertEquals (LONG_PATH_PARTS , url .getPathParts ());
340
342
assertEquals ("b" , url .getFirst ("a" ));
@@ -451,6 +453,12 @@ public void testBuild_pathWithSlash() {
451
453
assertEquals (PATH_WITH_SLASH , url .build ());
452
454
}
453
455
456
+ public void testConstructorUnderscore () {
457
+ String url = "http://url_with_underscore.google.com" ;
458
+<
1241
/span> GenericUrl parsed = new GenericUrl (url );
459
+ assertEquals ("url_with_underscore.google.com" , parsed .getHost ());
460
+ }
461
+
454
462
public void testParse_pathWithSlash () {
455
463
GenericUrl url = new GenericUrl (PATH_WITH_SLASH );
456
464
assertEquals ("http" , url .getScheme ());
0 commit comments