diff options
author | buchgr <buchgr@google.com> | 2017-09-14 14:36:44 +0200 |
---|---|---|
committer | Philipp Wollermann <philwo@google.com> | 2017-09-14 18:48:10 +0200 |
commit | 5ef576fc95699af3ce1199ad51c23be8b96258f6 (patch) | |
tree | cf1bbe7dc2b0196fd91cece8655a2a21cc06802f /src/test/java/com/google/devtools/build/lib/vfs | |
parent | f26e8694ae78599b3e2004e3360eaf3443fa53a6 (diff) |
bep: Properly URI encode file paths
RELNOTES: The Build Event Protocol's File.uri field is now properly
encoded according to RFC2396.
PiperOrigin-RevId: 168674865
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/vfs')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/vfs/PathTest.java | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/vfs/PathTest.java b/src/test/java/com/google/devtools/build/lib/vfs/PathTest.java index dbdc0186de..8a1e14fbcf 100644 --- a/src/test/java/com/google/devtools/build/lib/vfs/PathTest.java +++ b/src/test/java/com/google/devtools/build/lib/vfs/PathTest.java @@ -26,6 +26,7 @@ import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.lang.ref.WeakReference; +import java.net.URI; import java.util.Collections; import java.util.List; import org.junit.Before; @@ -301,6 +302,13 @@ public class PathTest { assertThat(segment.toString()).isEqualTo("/foo/bar.txt"); } + @Test + public void testToURI() throws Exception { + Path p = root.getRelative("/tmp/foo bar.txt"); + URI uri = p.toURI(); + assertThat(uri.toString()).isEqualTo("file:///tmp/foo%20bar.txt"); + } + private void assertAsFragmentWorks(String expected) { assertThat(filesystem.getPath(expected).asFragment()).isEqualTo(PathFragment.create(expected)); } |