Skip to content

Commit c42aa6e

Browse files
author
Vladimir Kotal
committed
use URI.create() to construct absolute paths
1 parent 225d085 commit c42aa6e

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

opengrok-indexer/src/test/java/org/opengrok/indexer/util/PathUtilsTest.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
import java.io.File;
2727
import java.io.IOException;
28+
import java.net.URI;
2829
import java.nio.file.Files;
2930
import java.nio.file.Path;
3031
import java.nio.file.Paths;
@@ -63,16 +64,16 @@ public void tearDown() {
6364

6465
@Test
6566
public void shouldHandleSameInputs() throws IOException {
66-
final String USR_BIN = "/usr/bin";
67+
final String USR_BIN = Paths.get(URI.create("file:///usr/bin")).toString();
6768
String rel = PathUtils.getRelativeToCanonical(USR_BIN, USR_BIN);
68-
Assert.assertEquals("/usr/bin rel to itself", "", rel);
69+
Assert.assertEquals(USR_BIN + " rel to itself", "", rel);
6970
}
7071

7172
@Test
7273
public void shouldHandleEffectivelySameInputs() throws IOException {
73-
final String USR_BIN = "/usr/bin";
74-
String rel = PathUtils.getRelativeToCanonical(USR_BIN + "/", USR_BIN);
75-
Assert.assertEquals("/usr/bin rel to ~itself", "", rel);
74+
final String USR_BIN = Paths.get(URI.create("file:///usr/bin")).toString();
75+
String rel = PathUtils.getRelativeToCanonical(USR_BIN + File.separator, USR_BIN);
76+
Assert.assertEquals(USR_BIN + " rel to ~itself", "", rel);
7677
}
7778

7879
@Test

0 commit comments

Comments
 (0)