Skip to content

Commit e62e341

Browse files
committed
Taken into account PR review comments
1 parent 8928a03 commit e62e341

1 file changed

Lines changed: 34 additions & 33 deletions

File tree

org.restlet.java/org.restlet/src/test/java/org/restlet/data/ReferenceTestCase.java

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ protected Reference getReference() {
6161
* Test addition methods.
6262
*/
6363
@Test
64-
public void testAdditions() throws Exception {
64+
void testAdditions() throws Exception {
6565
final Reference ref = new Reference("http://restlet.org");
6666
ref.addQueryParameter("abc", "123");
6767
assertEquals("http://restlet.org?abc=123", ref.toString());
@@ -74,7 +74,7 @@ public void testAdditions() throws Exception {
7474
}
7575

7676
@Test
77-
public void testEmptyRef() {
77+
void testEmptyRef() {
7878
Reference reference = new Reference();
7979
reference.setAuthority("testAuthority"); // must not produce NPE
8080

@@ -132,7 +132,7 @@ public void testEmptyRef() {
132132
"http://localhost#fragment/abc?query,/def",
133133
"http://localhost?query/abc,/def"
134134
})
135-
public void testSetPath(String reference, String path) {
135+
void testSetPath(String reference, String path) {
136136
final Reference ref = new Reference(reference);
137137
ref.setPath(path);
138138
assertEquals(path, ref.getPath());
@@ -149,7 +149,7 @@ public void testEquals() {
149149
}
150150

151151
@Test
152-
public void testGetLastSegment() {
152+
void testGetLastSegment() {
153153
Reference reference = new Reference("http://hostname");
154154
assertNull(reference.getLastSegment());
155155

@@ -173,7 +173,7 @@ public void testGetLastSegment() {
173173
* Test hostname getting/setting.
174174
*/
175175
@Test
176-
public void testHostName() {
176+
void testHostName() {
177177
final Reference ref = getReference();
178178
String host = "restlet.org";
179179
ref.setHostDomain(host);
@@ -186,7 +186,7 @@ public void testHostName() {
186186
}
187187

188188
@Test
189-
public void testMatrix() {
189+
void testMatrix() {
190190
final Reference ref1 = new Reference(
191191
"http://domain.tld/whatever/a=1;b=2;c=4?x=a&y=b");
192192
final Reference ref2 = new Reference(
@@ -218,7 +218,7 @@ public void testMatrix() {
218218
}
219219

220220
@Test
221-
public void testOriginalRef() {
221+
void testOriginalRef() {
222222
Reference ref = new Reference("http://localhost/test");
223223
Series<Header> headers = new Series<>(Header.class);
224224
headers.add(HeaderConstants.HEADER_X_FORWARDED_PROTO, "HTTPS");
@@ -234,7 +234,7 @@ public void testOriginalRef() {
234234
* URIs.
235235
*/
236236
@Test
237-
public void testParentRef() {
237+
void testParentRef() {
238238
Reference baseRef = new Reference("http://test.com/foo/bar");
239239
Reference parentRef = baseRef.getParentRef();
240240
assertEquals("http://test.com/foo/", parentRef.toString());
@@ -260,7 +260,7 @@ class TestParsing {
260260
"http://localhost/path#frag/ment,http,localhost,/path,,frag/ment",
261261
"http://localhost/path?qu/ery,http,localhost,/path,qu/ery,"
262262
} )
263-
public void testComponentsParsing(String reference,
263+
void testComponentsParsing(String reference,
264264
String scheme, String authority, String path, String query, String fragment) {
265265
final Reference ref = new Reference(reference);
266266
assertEquals(scheme, ref.getScheme());
@@ -289,13 +289,13 @@ public void testComponentsParsing(String reference,
289289
"http://localhost/path#fragment?query,false,true,http://localhost/path#fragment?query",
290290
"http://localhost/path#fragment?query,false,false,http://localhost/path"
291291
} )
292-
public void testParsingOfQueryAndFragment(String reference, boolean query, boolean fragment, String toString) {
292+
void testParsingOfQueryAndFragment(String reference, boolean query, boolean fragment, String toString) {
293293
final Reference ref = new Reference(reference);
294294
assertEquals(ref.toString(query, fragment), toString);
295295
}
296296

297297
@Test
298-
public void testGetters() {
298+
void testGetters() {
299299
final Reference host = new Reference("http://host.com");
300300
final Reference slashdir = new Reference(host, "/dir");
301301
final Reference dir = new Reference(host, "dir");
@@ -346,6 +346,7 @@ public void testGetters() {
346346
"http://host.com/dir/sub?query", "http://host.com/dir/sub?query",
347347
"http://host.com/dir/sub?query", "query", null);
348348
}
349+
349350
private void testGetters(Reference reference, String scheme, String authority,
350351
String path, String remainingPart, String toString,
351352
String targetRef, String query, String relativePart) {
@@ -399,7 +400,7 @@ private void testGetters(Reference reference, String scheme, String authority,
399400
"http://a/b/c/d;p?q,g;x=1/./y,http://a/b/c/g;x=1/y",
400401
"http://a/b/c/d;p?q,g;x=1/../y,http://a/b/c/y"
401402
})
402-
public void testResolutionRelativeReference(String baseUri, String relativeUri,
403+
void testResolutionRelativeReference(String baseUri, String relativeUri,
403404
String expectedAbsoluteUri) {
404405
final Reference baseRef = new Reference(baseUri);
405406
final Reference relativeRef = new Reference(baseRef, relativeUri);
@@ -427,7 +428,7 @@ public void testResolutionRelativeReference(String baseUri, String relativeUri,
427428
"http://a/b/c/g/,http://a/b/c/,..",
428429
"http://a/b/c/g/,http://a/b/,../.."
429430
})
430-
public void testRelativizeAbsoluteReference(String baseUri, String absoluteUri,
431+
void testRelativizeAbsoluteReference(String baseUri, String absoluteUri,
431432
String expectedRelativeUri) {
432433
final Reference baseRef = new Reference(baseUri);
433434
final Reference absoluteRef = new Reference(absoluteUri);
@@ -441,20 +442,20 @@ public void testRelativizeAbsoluteReference(String baseUri, String absoluteUri,
441442
*/
442443
@ParameterizedTest
443444
@ValueSource(ints = {8080, 9090})
444-
public void testPort(int port) {
445+
void testPort(int port) {
445446
Reference ref = getDefaultReference();
446447
ref.setHostPort(port);
447448
assertEquals(port, ref.getHostPort());
448449
}
449450

450451
@Test
451-
public void testPortIPv6() {
452+
void testPortIPv6() {
452453
Reference ref = new Reference("http://[::1]:8182");
453454
assertEquals(8182, ref.getHostPort());
454455
}
455456

456457
@Test
457-
public void testProtocolConstructors() {
458+
void testProtocolConstructors() {
458459
assertEquals("http://restlet.org", new Reference(Protocol.HTTP,
459460
"restlet.org").toString());
460461
assertEquals("https://restlet.org:8443", new Reference(Protocol.HTTPS,
@@ -466,7 +467,7 @@ public void testProtocolConstructors() {
466467
}
467468

468469
@Test
469-
public void testQuery() {
470+
void testQuery() {
470471

471472
Reference ref1 = new Reference(
472473
"http://localhost/search?q=anythingelse%");
@@ -486,14 +487,14 @@ public void testQuery() {
486487
}
487488

488489
@Test
489-
public void testQueryWithUri() {
490+
void testQueryWithUri() {
490491
Reference ref = new Reference(new Reference("http://localhost:8111/"),
491492
"http://localhost:8111/contrats/123?srvgwt=localhost:9997");
492493
assertEquals("contrats/123?srvgwt=localhost:9997", ref.getRelativeRef().toString());
493494
}
494495

495496
@Test
496-
public void testRiap() {
497+
void testRiap() {
497498
Reference baseRef = new Reference("riap://component/exist/db/");
498499
Reference ref = new Reference(baseRef, "something.xq");
499500
assertEquals("riap://component/exist/db/something.xq", ref
@@ -504,7 +505,7 @@ public void testRiap() {
504505
* Test scheme getting/setting.
505506
*/
506507
@Test
507-
public void testScheme() {
508+
void testScheme() {
508509
final Reference ref = getDefaultReference();
509510
assertEquals(DEFAULT_SCHEME, ref.getScheme());
510511
final String scheme = "https";
@@ -518,7 +519,7 @@ public void testScheme() {
518519
* Test scheme specific part getting/setting.
519520
*/
520521
@Test
521-
public void testSchemeSpecificPart() {
522+
void testSchemeSpecificPart() {
522523
final Reference ref = getDefaultReference();
523524
String part = "//restlet.org";
524525
assertEquals(part, ref.getSchemeSpecificPart());
@@ -531,7 +532,7 @@ public void testSchemeSpecificPart() {
531532
* Test setting of the last segment.
532533
*/
533534
@Test
534-
public void testSetLastSegment() {
535+
void testSetLastSegment() {
535536
Reference ref = new Reference("http://localhost:1234");
536537
ref.addSegment("test");
537538
assertEquals("http://localhost:1234/test", ref.toString());
@@ -561,7 +562,7 @@ public void testSetLastSegment() {
561562
"http://localhost:81/?query,//localhost:81/?query",
562563
"http://localhost:81/?query=https://perdu.com,//localhost:81/?query=https://perdu.com",
563564
})
564-
public void testSchemeSpecificPart(final String uri, final String expected) {
565+
void testSchemeSpecificPart(final String uri, final String expected) {
565566
Reference ref = new Reference(uri);
566567
assertEquals(expected, ref.getSchemeSpecificPart());
567568
}
@@ -577,7 +578,7 @@ public void testSchemeSpecificPart(final String uri, final String expected) {
577578
"http://localhost:81/?query=https://perdu.com,localhost:81",
578579
"http://localhost:81?query=https://perdu.com,localhost:81",
579580
})
580-
public void testAuthority(final String uri, final String expected) {
581+
void testAuthority(final String uri, final String expected) {
581582
Reference ref = new Reference(uri);
582583
assertEquals(expected, ref.getAuthority());
583584
}
@@ -595,13 +596,13 @@ public void testAuthority(final String uri, final String expected) {
595596
"http://localhost:81/?query=https://perdu.com/1234,/",
596597
"http://localhost:81?query=https://perdu.com/1234,"
597598
})
598-
public void testPath(final String uri, final String expected) {
599+
void testPath(final String uri, final String expected) {
599600
Reference ref = new Reference(uri);
600601
assertEquals(expected, ref.getPath());
601602
}
602603

603604
@Test
604-
public void testTargetRef() {
605+
void testTargetRef() {
605606
Reference ref = new Reference(
606607
"http://twitter.com?status=RT @gamasutra: Devil May Cry : Born Again http://www.gamasutra.com/view/feature/177267/");
607608
Reference targetRef = new Reference(
@@ -617,7 +618,7 @@ public void testTargetRef() {
617618
* Test references that are unequal.
618619
*/
619620
@Test
620-
public void testUnEquals() throws Exception {
621+
void testUnEquals() throws Exception {
621622
final String uri1 = "http://restlet.org/";
622623
final String uri2 = "http://restlet.net/";
623624
final Reference ref1 = new Reference(uri1);
@@ -626,7 +627,7 @@ public void testUnEquals() throws Exception {
626627
}
627628

628629
@Test
629-
public void testUserinfo() {
630+
void testUserinfo() {
630631
final Reference reference = new Reference("http://localhost:81");
631632
// This format is deprecated; however, we may prevent failures.
632633
reference.setUserInfo("login:password");
@@ -661,7 +662,7 @@ public void testUserinfo() {
661662
}
662663

663664
@Test
664-
public void testValidity() {
665+
void testValidity() {
665666
String uri = "http ://domain.tld/whatever/";
666667
Reference ref = new Reference(uri);
667668
assertEquals("http%20://domain.tld/whatever/", ref.toString());
@@ -681,7 +682,7 @@ class TestFailures {
681682
"https://normal.com[user@vulndetector].com/",
682683
"https://normal.com[@]vulndetector.com/"
683684
})
684-
public void shouldFailWhenParsingIncorrectHosts(String reference) {
685+
void shouldFailWhenParsingIncorrectHosts(String reference) {
685686
assertThrows(IllegalArgumentException.class, () -> new Reference(reference).getAuthority());
686687
}
687688

@@ -693,23 +694,23 @@ public void shouldFailWhenParsingIncorrectHosts(String reference) {
693694
"https://[ffff::127.0.0.4000]",
694695
"https://[0:0::vulndetector.com]:80",
695696
"https://[2001:db8::vulndetector.com]"})
696-
public void shouldFailWhenParsingIncorrectIPv6Hosts(String reference) {
697+
void shouldFailWhenParsingIncorrectIPv6Hosts(String reference) {
697698
assertThrows(IllegalArgumentException.class, () -> new Reference(reference).getAuthority());
698699
}
699700

700701
@ParameterizedTest
701702
@ValueSource(strings = {
702703
"http://localhost:18:19",
703704
"http://localhost:18ab"})
704-
public void shouldFailWhenParsingIncorrectPort(String reference) {
705+
void shouldFailWhenParsingIncorrectPort(String reference) {
705706
assertThrows(IllegalArgumentException.class, () -> new Reference(reference).getAuthority());
706707
}
707708

708709
@ParameterizedTest
709710
@ValueSource(strings = {
710711
"https>://vulndetector.com/path",
711712
"https%25://vulndetector.com/path"})
712-
public void shouldFailWhenParsingIncorrectScheme(String reference) {
713+
void shouldFailWhenParsingIncorrectScheme(String reference) {
713714
assertThrows(IllegalArgumentException.class, () -> new Reference(reference).getScheme());
714715
}
715716
}

0 commit comments

Comments
 (0)