private JGitPathImpl composePath(final JGitPathImpl directory, final JGitPathImpl fileName) { if (directory.getPath().endsWith("/")) { return toPathImpl(getPath(URI.create(directory.toUri().toString() + fileName.toString(false)))); } return toPathImpl(getPath(URI.create(directory.toUri().toString() + "/" + fileName.toString(false)))); }
private JGitPathImpl composePath(final JGitPathImpl directory, final JGitPathImpl fileName, final CopyOption... options) { if (directory.getPath().endsWith("/")) { return toPathImpl(getPath(URI.create(directory.toUri().toString() + uriEncode(fileName.toString(false))))); } return toPathImpl(getPath(URI.create(directory.toUri().toString() + "/" + uriEncode(fileName.toString(false))))); }
private void commitFile() throws IOException { final Path path = provider.getPath(URI.create(GIT + REPO_NAME + NEW_FILE_PATH)); final OutputStream outStream = provider.newOutputStream(path); assertThat(outStream).isNotNull(); outStream.write(("my content").getBytes()); outStream.close(); } }
private void commitFile() throws IOException { final Path path = provider.getPath(URI.create(GIT + REPO_NAME + NEW_FILE_PATH)); final OutputStream outStream = provider.newOutputStream(path); assertThat(outStream).isNotNull(); outStream.write(("my content").getBytes()); outStream.close(); } }
@Test public void testCreateSymbolicLinkUnsupportedOp() { final URI newRepo = URI.create("git://symbolic-repo-name"); provider.newFileSystem(newRepo, EMPTY_ENV); final Path link = provider.getPath(URI.create("git://symbolic-repo-name/link.lnk")); final Path path = provider.getPath(URI.create("git://symbolic-repo-name/file.txt")); assertThatThrownBy(() -> provider.createSymbolicLink(link, path)) .isInstanceOf(UnsupportedOperationException.class); }
@Test public void testCreateLinkUnsupportedOp() { final URI newRepo = URI.create("git://link-repo-name"); provider.newFileSystem(newRepo, EMPTY_ENV); final Path link = provider.getPath(URI.create("git://link-repo-name/link.lnk")); final Path path = provider.getPath(URI.create("git://link-repo-name/file.txt")); assertThatThrownBy(() -> provider.createLink(link, path)) .isInstanceOf(UnsupportedOperationException.class); }
@Test public void testCreateLinkUnsupportedOp() { final URI newRepo = URI.create("git://link-repo-name"); provider.newFileSystem(newRepo, EMPTY_ENV); final Path link = provider.getPath(URI.create("git://link-repo-name/link.lnk")); final Path path = provider.getPath(URI.create("git://link-repo-name/file.txt")); assertThatThrownBy(() -> provider.createLink(link, path)) .isInstanceOf(UnsupportedOperationException.class); }
@Test public void testInvalidURIGetPath() { final URI uri = URI.create("git:///master@new-get-repo-name/home"); try { provider.getPath(uri); failBecauseExceptionWasNotThrown(IllegalArgumentException.class); } catch (final IllegalArgumentException ex) { assertThat(ex.getMessage()).isEqualTo("Parameter named 'uri' is invalid, missing host repository!"); } }
@Test public void testInvalidURIGetPath() { final URI uri = URI.create("git:///master@new-get-repo-name/home"); try { provider.getPath(uri); failBecauseExceptionWasNotThrown(IllegalArgumentException.class); } catch (final IllegalArgumentException ex) { assertThat(ex.getMessage()).isEqualTo("Parameter named 'uri' is invalid, missing host repository!"); } }
@Test public void testNewFileChannelUnsupportedOp() { final URI newRepo = URI.create("git://newfcrepo-name"); provider.newFileSystem(newRepo, EMPTY_ENV); final Path path = provider.getPath(URI.create("git://newfcrepo-name/file.txt")); final Set<? extends OpenOption> options = emptySet(); assertThatThrownBy(() -> provider.newFileChannel(path, options)) .isInstanceOf(UnsupportedOperationException.class); }
@Test public void testNewAsynchronousFileChannelUnsupportedOp() { final URI newRepo = URI.create("git://newasyncrepo-name"); provider.newFileSystem(newRepo, EMPTY_ENV); final Path path = provider.getPath(URI.create("git://newasyncrepo-name/file.txt")); final Set<? extends OpenOption> options = emptySet(); assertThatThrownBy(() -> provider.newAsynchronousFileChannel(path, options, null)) .isInstanceOf(UnsupportedOperationException.class); }
@Test public void testNewAsynchronousFileChannelUnsupportedOp() { final URI newRepo = URI.create("git://newasyncrepo-name"); provider.newFileSystem(newRepo, EMPTY_ENV); final Path path = provider.getPath(URI.create("git://newasyncrepo-name/file.txt")); final Set<? extends OpenOption> options = emptySet(); assertThatThrownBy(() -> provider.newAsynchronousFileChannel(path, options, null)) .isInstanceOf(UnsupportedOperationException.class); }
@Test public void testReadSymbolicLinkUnsupportedOp() { final URI newRepo = URI.create("git://read-link-repo-name"); provider.newFileSystem(newRepo, EMPTY_ENV); final Path link = provider.getPath(URI.create("git://read-link-repo-name/link.lnk")); assertThatThrownBy(() -> provider.readSymbolicLink(link)) .isInstanceOf(UnsupportedOperationException.class); } }
@Test public void extractPathTest() { URI composedName = URI.create("git://user1/dora"); FileSystem fsComposedName1 = provider.newFileSystem(composedName, EMPTY_ENV); URI composedFileName1 = URI.create("git://user1/dora/file.txt"); Path path1 = provider.getPath(composedFileName1); assertEquals(path1.toString(), provider.extractPath(composedFileName1)); }
@Test public void testReadSymbolicLinkUnsupportedOp() { final URI newRepo = URI.create("git://read-link-repo-name"); provider.newFileSystem(newRepo, EMPTY_ENV); final Path link = provider.getPath(URI.create("git://read-link-repo-name/link.lnk")); assertThatThrownBy(() -> provider.readSymbolicLink(link)) .isInstanceOf(UnsupportedOperationException.class); } }
@Test public void extractPathTest() { URI composedName = URI.create("git://user1/dora"); FileSystem fsComposedName1 = provider.newFileSystem(composedName, EMPTY_ENV); URI composedFileName1 = URI.create("git://user1/dora/file.txt"); Path path1 = provider.getPath(composedFileName1); assertEquals(path1.toString(), provider.extractPath(composedFileName1)); }
@Test public void checkRootPath() { URI composedName = URI.create("git://dora-repo/subdir1"); FileSystem fsComposedName = provider.newFileSystem(composedName, EMPTY_ENV); Path path = provider.getPath(URI.create("git://dora-repo/subdir1/file.txt")); Path path1 = provider.getPath(URI.create("git://origin/bla@dora-repo/subdir1/file2.txt")); assertEquals(fsComposedName, path.getRoot().getFileSystem()); assertEquals(fsComposedName, path1.getRoot().getFileSystem()); }
@Test public void checkRootPath() { URI composedName = URI.create("git://dora-repo/subdir1"); FileSystem fsComposedName = provider.newFileSystem(composedName, EMPTY_ENV); Path path = provider.getPath(URI.create("git://dora-repo/subdir1/file.txt")); Path path1 = provider.getPath(URI.create("git://origin/bla@dora-repo/subdir1/file2.txt")); assertEquals(fsComposedName, path.getRoot().getFileSystem()); assertEquals(fsComposedName, path1.getRoot().getFileSystem()); }
@Test public void testNewFileSystemWithSubfolder() { final URI newRepo = URI.create("git://test/sub-repo-name"); final FileSystem fs = provider.newFileSystem(newRepo, EMPTY_ENV); assertThat(fs).isNotNull(); final DirectoryStream<Path> stream = provider.newDirectoryStream(provider.getPath(newRepo), null); assertThat(stream).isEmpty(); }
@Test public void testNewFileSystemWithSubfolder() { final URI newRepo = URI.create("git://test/sub-repo-name"); final FileSystem fs = provider.newFileSystem(newRepo, EMPTY_ENV); assertThat(fs).isNotNull(); final DirectoryStream<Path> stream = provider.newDirectoryStream(provider.getPath(newRepo), null); assertThat(stream).isEmpty(); }