1
1
/*
2
- * Copyright (c) 2000, 2019 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2000, 2022 , Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
24
24
/* @test
25
25
* @summary Unit test for java.net.URI
26
26
* @bug 4464135 4505046 4503239 4438319 4991359 4866303 7023363 7041800
27
- * 7171415 6933879
27
+ * 7171415 6339649 6933879 8037396 8272072
28
28
* @author Mark Reinhold
29
29
*/
30
30
@@ -1364,6 +1364,7 @@ static void eq(URI u, URI v) throws URISyntaxException {
1364
1364
}
1365
1365
1366
1366
static void eq (String expected , String actual ) {
1367
+ testCount ++;
1367
1368
if (expected == null && actual == null ) {
1368
1369
return ;
1369
1370
}
@@ -1612,9 +1613,11 @@ static void clargs(String base, String uri) {
1612
1613
// miscellaneous bugs/rfes that don't fit in with the test framework
1613
1614
1614
1615
static void bugs () {
1616
+ header ("Bugs" );
1615
1617
b6339649 ();
1616
1618
b6933879 ();
1617
1619
b8037396 ();
1620
+ b8272072 ();
1618
1621
}
1619
1622
1620
1623
// 6339649 - include detail message from nested exception
@@ -1626,6 +1629,7 @@ private static void b6339649() {
1626
1629
throw new RuntimeException ("No detail message" );
1627
1630
}
1628
1631
}
1632
+ testCount ++;
1629
1633
}
1630
1634
1631
1635
// 6933879 - check that "." and "_" characters are allowed in IPv6 scope_id.
@@ -1673,6 +1677,24 @@ private static void b8037396() {
1673
1677
eq ("a%20b[c%20d]" , u .getRawFragment ());
1674
1678
}
1675
1679
1680
+ // 8272072 - Resolving URI relative path with no "/" may lead to incorrect toString
1681
+ private static void b8272072 () {
1682
+ try {
1683
+ URI baseURI = new URI ("http://example.com" );
1684
+ URI relativeURI = new URI ("test" );
1685
+ URI resolvedURI = baseURI .resolve (relativeURI );
1686
+
1687
+ eq (new URI ("http://example.com/test" ), resolvedURI );
1688
+
1689
+ baseURI = new URI ("relativeBase" );
1690
+ resolvedURI = baseURI .resolve (relativeURI );
1691
+
1692
+ eq (new URI ("test" ), resolvedURI );
1693
+ } catch (URISyntaxException e ) {
1694
+ throw new AssertionError ("shouldn't ever happen" , e );
1695
+ }
1696
+ }
1697
+
1676
1698
public static void main (String [] args ) throws Exception {
1677
1699
switch (args .length ) {
1678
1700
0 commit comments