@Override public Path resolveSibling(final Path other) { checkNotNull("other", other); final Path parent = this.getParent(); if (parent == null || other.isAbsolute()) { return other; } return parent.resolve(other); }
@Override public Path resolveSibling(final Path other) { checkNotNull("other", other); final Path parent = this.getParent(); if (parent == null || other.isAbsolute()) { return other; } return parent.resolve(other); }
@Override public Path resolveSibling(final Path other) { checkNotNull("other", other); final Path parent = this.getParent(); if (parent == null || other.isAbsolute()) { return other; } return parent.resolve(other); }
@Test public void validateGetPath() { final SimpleFileSystemProvider fsProvider = new SimpleFileSystemProvider(); final URI uri = URI.create("file:///path/to/file.txt"); final Path path = fsProvider.getPath(uri); AssertionsForClassTypes.assertThat(path).isNotNull(); assertThat(path.isAbsolute()).isTrue(); assertThat(path.getFileSystem()).isEqualTo(fsProvider.getFileSystem(uri)); assertThat(path.getFileSystem().provider()).isEqualTo(fsProvider); assertThat(path.toString()).isEqualTo("/path/to/file.txt"); }
@Test public void validateGetPath() { final SimpleFileSystemProvider fsProvider = new SimpleFileSystemProvider(); final URI uri = URI.create("file:///path/to/file.txt"); final Path path = fsProvider.getPath(uri); AssertionsForClassTypes.assertThat(path).isNotNull(); assertThat(path.isAbsolute()).isTrue(); assertThat(path.getFileSystem()).isEqualTo(fsProvider.getFileSystem(uri)); assertThat(path.getFileSystem().provider()).isEqualTo(fsProvider); assertThat(path.toString()).isEqualTo("/path/to/file.txt"); }
@Test public void simpleGetEmpty() { final Path path = Paths.get(""); assertThat(path).isNotNull(); assertThat(path.isAbsolute()).isFalse(); assertThat(path.toString()).isEqualTo(""); }
@Test public void simplePartitionedWindowsGet() { final Path path = Paths.get("c:\\path", "to", "file.txt"); assertThat(path).isNotNull(); assertThat(path.isAbsolute()).isTrue(); assertThat(path.toString()).isEqualTo("c:\\path" + "\\" + "to" + "\\" + "file.txt"); }
@Test public void simpleGet() { final Path path = Paths.get("/path/to/file.txt"); assertThat(path).isNotNull(); assertThat(path.isAbsolute()).isTrue(); assertThat(path.toString()).isEqualTo("/path/to/file.txt"); }
@Test public void simpleWindowsGet() { final Path path = Paths.get("c:\\path\\to\\file.txt"); assertThat(path).isNotNull(); assertThat(path.isAbsolute()).isTrue(); assertThat(path.toString()).isEqualTo("c:\\path\\to\\file.txt"); }
@Test public void simpleGetURI() { final Path path = Paths.get(URI.create("file:///path/to/file.txt")); assertThat(path).isNotNull(); assertThat(path.isAbsolute()).isTrue(); assertThat(path.toString()).isEqualTo("/path/to/file.txt"); assertThat(path).isEqualTo(Paths.get("/path/to/file.txt")); }
@Test public void simplePartitionedGet() { final Path path = Paths.get("/path", "to", "file.txt"); assertThat(path).isNotNull(); assertThat(path.isAbsolute()).isTrue(); assertThat(path.toString()).isEqualTo("/path/to/file.txt"); assertThat(path).isEqualTo(Paths.get("/path/to/file.txt")); }
@Test public void simpleGetButUsingURIAsString() { final Path path = Paths.get("file:///path/to/file.txt"); assertThat(path).isNotNull(); assertThat(path.isAbsolute()).isTrue(); assertThat(path.toString()).isEqualTo("/path/to/file.txt"); assertThat(path).isEqualTo(Paths.get("/path/to/file.txt")); }
@Test public void simpleGetButUsingURIAsStringAndDefaultScheme() { final Path path = Paths.get("default:///path/to/file.txt"); assertThat(path).isNotNull(); assertThat(path.isAbsolute()).isTrue(); assertThat(path.toString()).isEqualTo("/path/to/file.txt"); assertThat(path).isEqualTo(Paths.get("/path/to/file.txt")); }
@Test public void testSimpleBranchedGitRoot() { when(fs.getSeparator()).thenReturn("/"); final Path path = JGitPathImpl.create(fs, "/", "master@my-host", false); assertThat(path).isNotNull(); assertThat(path.isAbsolute()).isTrue(); assertThat(path.toString()).isEqualTo("/"); assertThat(path.toUri().toString()).isEqualTo("git://master@my-host/"); assertThat(path.getRoot().toString()).isEqualTo("/"); assertThat(path.getNameCount()).isEqualTo(0); }
@Test public void testSimpleBranchedGitRelative() { when(fs.getSeparator()).thenReturn("/"); final Path path = JGitPathImpl.create(fs, "home", "master@my-host", false); assertThat(path).isNotNull(); assertThat(path.isAbsolute()).isFalse(); assertThat(path.toString()).isEqualTo("home"); assertThat(path.toUri().toString()).isEqualTo("git://master@my-host/:home"); assertThat(path.getRoot().toString()).isEqualTo(""); assertThat(path.getNameCount()).isEqualTo(1); }
@Test public void testSimpleBranchedGitRoot2() { when(fs.getSeparator()).thenReturn("/"); final Path path = JGitPathImpl.create(fs, "/path/to/some/place.txt", "master@my-host", false); assertThat(path).isNotNull(); assertThat(path.isAbsolute()).isTrue(); assertThat(path.toString()).isEqualTo("/path/to/some/place.txt"); assertThat(path.toUri().toString()).isEqualTo("git://master@my-host/path/to/some/place.txt"); assertThat(path.getNameCount()).isEqualTo(4); assertThat(path.getName(0).toString()).isEqualTo("path"); assertThat(path.getRoot().toString()).isEqualTo("/"); }
@Test public void testSimpleBranchedGitRoot() { when(fs.getSeparator()).thenReturn("/"); final Path path = JGitPathImpl.create(fs, "/", "master@my-host", false); assertThat(path).isNotNull(); assertThat(path.isAbsolute()).isTrue(); assertThat(path.toString()).isEqualTo("/"); assertThat(path.toUri().toString()).isEqualTo("git://master@my-host/"); assertThat(path.getRoot().toString()).isEqualTo("/"); assertThat(path.getNameCount()).isEqualTo(0); }
@Test public void testSimpleBranchedGitRelative() { when(fs.getSeparator()).thenReturn("/"); final Path path = JGitPathImpl.create(fs, "home", "master@my-host", false); assertThat(path).isNotNull(); assertThat(path.isAbsolute()).isFalse(); assertThat(path.toString()).isEqualTo("home"); assertThat(path.toUri().toString()).isEqualTo("git://master@my-host/:home"); assertThat(path.getRoot().toString()).isEqualTo(""); assertThat(path.getNameCount()).isEqualTo(1); }
@Test public void testSimpleBranchedGit() { final Path path = JGitPathImpl.create(fs, "", "master@my-host", false); assertThat(path).isNotNull(); assertThat(path.isAbsolute()).isTrue(); assertThat(path.toString()).isEqualTo("/"); assertThat(path.toUri().toString()).isEqualTo("git://master@my-host/"); assertThat(path.getRoot()).isEqualTo(path); assertThat(path.getNameCount()).isEqualTo(0); assertThat(path.getRoot()).isEqualTo(path); }
@Test public void testSimpleBranchedGit() { final Path path = JGitPathImpl.create(fs, "", "master@my-host", false); assertThat(path).isNotNull(); assertThat(path.isAbsolute()).isTrue(); assertThat(path.toString()).isEqualTo("/"); assertThat(path.toUri().toString()).isEqualTo("git://master@my-host/"); assertThat(path.getRoot()).isEqualTo(path); assertThat(path.getNameCount()).isEqualTo(0); assertThat(path.getRoot()).isEqualTo(path); }