@Test public void testPathNonBranchRooted() throws IOException, GitAPIException { final JGitFileSystemProvider fsProvider = mock(JGitFileSystemProvider.class); when(fsProvider.isDefault()).thenReturn(false); when(fsProvider.getScheme()).thenReturn("git"); final Git git = setupGit(); final JGitFileSystemImpl fileSystem = new JGitFileSystemImpl(fsProvider, null, git, createFSLock(git), "my-repo", CredentialsProvider.getDefault(), null, null); final Path path = fileSystem.getPath("/path/to/some/place.txt"); AssertionsForClassTypes.assertThat(path).isNotNull(); assertThat(path.isAbsolute()).isTrue(); assertThat(path.toString()).isEqualTo("/path/to/some/place.txt"); assertThat(path.toUri().toString()).isEqualTo("git://master@my-repo/path/to/some/place.txt"); assertThat(path.getNameCount()).isEqualTo(4); assertThat(path.getName(0).toString()).isNotNull().isEqualTo("path"); assertThat(path.getRoot().toString()).isNotNull().isEqualTo("/"); }
@Test public void testPathNonBranchNonRooted() throws IOException, GitAPIException { final JGitFileSystemProvider fsProvider = mock(JGitFileSystemProvider.class); when(fsProvider.isDefault()).thenReturn(false); when(fsProvider.getScheme()).thenReturn("git"); final Git git = setupGit(); final JGitFileSystemImpl fileSystem = new JGitFileSystemImpl(fsProvider, null, git, createFSLock(git), "my-repo", CredentialsProvider.getDefault(), null, null); final Path path = fileSystem.getPath("path/to/some/place.txt"); AssertionsForClassTypes.assertThat(path).isNotNull(); assertThat(path.isAbsolute()).isFalse(); assertThat(path.toString()).isEqualTo("path/to/some/place.txt"); assertThat(path.toUri().toString()).isEqualTo("git://master@my-repo/:path/to/some/place.txt"); assertThat(path.getNameCount()).isEqualTo(4); assertThat(path.getName(0).toString()).isNotNull().isEqualTo("path"); assertThat(path.getRoot().toString()).isNotNull().isEqualTo(""); }
@Test public void testPathBranchRooted2() throws IOException, GitAPIException { final JGitFileSystemProvider fsProvider = mock(JGitFileSystemProvider.class); when(fsProvider.isDefault()).thenReturn(false); when(fsProvider.getScheme()).thenReturn("git"); final Git git = setupGit(); final JGitFileSystemImpl fileSystem = new JGitFileSystemImpl(fsProvider, null, git, createFSLock(git), "my-repo", CredentialsProvider.getDefault(), null, null); final Path path = fileSystem.getPath("test-branch", "/path/to", "some/place.txt"); AssertionsForClassTypes.assertThat(path).isNotNull(); assertThat(path.isAbsolute()).isTrue(); assertThat(path.toString()).isEqualTo("/path/to/some/place.txt"); assertThat(path.toUri().toString()).isEqualTo("git://test-branch@my-repo/path/to/some/place.txt"); assertThat(path.getNameCount()).isEqualTo(4); assertThat(path.getName(0).toString()).isNotNull().isEqualTo("path"); assertThat(path.getRoot().toString()).isNotNull().isEqualTo("/"); }
@Test public void testPathNonBranchNonRooted() throws IOException, GitAPIException { final JGitFileSystemProvider fsProvider = mock(JGitFileSystemProvider.class); when(fsProvider.isDefault()).thenReturn(false); when(fsProvider.getScheme()).thenReturn("git"); final Git git = setupGit(); final JGitFileSystemImpl fileSystem = new JGitFileSystemImpl(fsProvider, null, git, createFSLock(git), "my-repo", CredentialsProvider.getDefault(), null, null); final Path path = fileSystem.getPath("path/to/some/place.txt"); AssertionsForClassTypes.assertThat(path).isNotNull(); assertThat(path.isAbsolute()).isFalse(); assertThat(path.toString()).isEqualTo("path/to/some/place.txt"); assertThat(path.toUri().toString()).isEqualTo("git://master@my-repo/:path/to/some/place.txt"); assertThat(path.getNameCount()).isEqualTo(4); assertThat(path.getName(0).toString()).isNotNull().isEqualTo("path"); assertThat(path.getRoot().toString()).isNotNull().isEqualTo(""); }
@Test public void testPathBranchRooted() throws IOException, GitAPIException { final JGitFileSystemProvider fsProvider = mock(JGitFileSystemProvider.class); when(fsProvider.isDefault()).thenReturn(false); when(fsProvider.getScheme()).thenReturn("git"); final Git git = setupGit(); final JGitFileSystemImpl fileSystem = new JGitFileSystemImpl(fsProvider, null, git, createFSLock(git), "my-repo", CredentialsProvider.getDefault(), null, null); final Path path = fileSystem.getPath("test-branch", "/path/to/some/place.txt"); AssertionsForClassTypes.assertThat(path).isNotNull(); assertThat(path.isAbsolute()).isTrue(); assertThat(path.toString()).isEqualTo("/path/to/some/place.txt"); assertThat(path.toUri().toString()).isEqualTo("git://test-branch@my-repo/path/to/some/place.txt"); assertThat(path.getNameCount()).isEqualTo(4); assertThat(path.getName(0).toString()).isNotNull().isEqualTo("path"); assertThat(path.getRoot().toString()).isNotNull().isEqualTo("/"); }
@Test public void testPathBranchRooted2() throws IOException, GitAPIException { final JGitFileSystemProvider fsProvider = mock(JGitFileSystemProvider.class); when(fsProvider.isDefault()).thenReturn(false); when(fsProvider.getScheme()).thenReturn("git"); final Git git = setupGit(); final JGitFileSystemImpl fileSystem = new JGitFileSystemImpl(fsProvider, null, git, createFSLock(git), "my-repo", CredentialsProvider.getDefault(), null, null); final Path path = fileSystem.getPath("test-branch", "/path/to", "some/place.txt"); AssertionsForClassTypes.assertThat(path).isNotNull(); assertThat(path.isAbsolute()).isTrue(); assertThat(path.toString()).isEqualTo("/path/to/some/place.txt"); assertThat(path.toUri().toString()).isEqualTo("git://test-branch@my-repo/path/to/some/place.txt"); assertThat(path.getNameCount()).isEqualTo(4); assertThat(path.getName(0).toString()).isNotNull().isEqualTo("path"); assertThat(path.getRoot().toString()).isNotNull().isEqualTo("/"); }
@Test public void testPathBranchNonRooted2() throws IOException, GitAPIException { final JGitFileSystemProvider fsProvider = mock(JGitFileSystemProvider.class); when(fsProvider.isDefault()).thenReturn(false); when(fsProvider.getScheme()).thenReturn("git"); final Git git = setupGit(); final JGitFileSystemImpl fileSystem = new JGitFileSystemImpl(fsProvider, null, git, createFSLock(git), "my-repo", CredentialsProvider.getDefault(), null, null); final Path path = fileSystem.getPath("test-branch", "path/to", "some/place.txt"); AssertionsForClassTypes.assertThat(path).isNotNull(); assertThat(path.isAbsolute()).isFalse(); assertThat(path.toString()).isEqualTo("path/to/some/place.txt"); assertThat(path.toUri().toString()).isEqualTo("git://test-branch@my-repo/:path/to/some/place.txt"); assertThat(path.getNameCount()).isEqualTo(4); assertThat(path.getName(0).toString()).isNotNull().isEqualTo("path"); assertThat(path.getRoot().toString()).isNotNull().isEqualTo(""); }
@Test public void testPathBranchNonRooted() throws IOException, GitAPIException { final JGitFileSystemProvider fsProvider = mock(JGitFileSystemProvider.class); when(fsProvider.isDefault()).thenReturn(false); when(fsProvider.getScheme()).thenReturn("git"); final Git git = setupGit(); final JGitFileSystemImpl fileSystem = new JGitFileSystemImpl(fsProvider, null, git, createFSLock(git), "my-repo", CredentialsProvider.getDefault(), null, null); final Path path = fileSystem.getPath("test-branch", "path/to/some/place.txt"); AssertionsForClassTypes.assertThat(path).isNotNull(); assertThat(path.isAbsolute()).isFalse(); assertThat(path.toString()).isEqualTo("path/to/some/place.txt"); assertThat(path.toUri().toString()).isEqualTo("git://test-branch@my-repo/:path/to/some/place.txt"); assertThat(path.getNameCount()).isEqualTo(4); assertThat(path.getName(0).toString()).isNotNull().isEqualTo("path"); assertThat(path.getRoot().toString()).isNotNull().isEqualTo(""); }
@Test public void testPathNonBranchRooted() throws IOException, GitAPIException { final JGitFileSystemProvider fsProvider = mock(JGitFileSystemProvider.class); when(fsProvider.isDefault()).thenReturn(false); when(fsProvider.getScheme()).thenReturn("git"); final Git git = setupGit(); final JGitFileSystemImpl fileSystem = new JGitFileSystemImpl(fsProvider, null, git, createFSLock(git), "my-repo", CredentialsProvider.getDefault(), null, null); final Path path = fileSystem.getPath("/path/to/some/place.txt"); AssertionsForClassTypes.assertThat(path).isNotNull(); assertThat(path.isAbsolute()).isTrue(); assertThat(path.toString()).isEqualTo("/path/to/some/place.txt"); assertThat(path.toUri().toString()).isEqualTo("git://master@my-repo/path/to/some/place.txt"); assertThat(path.getNameCount()).isEqualTo(4); assertThat(path.getName(0).toString()).isNotNull().isEqualTo("path"); assertThat(path.getRoot().toString()).isNotNull().isEqualTo("/"); }
@Test public void testPathBranchNonRooted2() throws IOException, GitAPIException { final JGitFileSystemProvider fsProvider = mock(JGitFileSystemProvider.class); when(fsProvider.isDefault()).thenReturn(false); when(fsProvider.getScheme()).thenReturn("git"); final Git git = setupGit(); final JGitFileSystemImpl fileSystem = new JGitFileSystemImpl(fsProvider, null, git, createFSLock(git), "my-repo", CredentialsProvider.getDefault(), null, null); final Path path = fileSystem.getPath("test-branch", "path/to", "some/place.txt"); AssertionsForClassTypes.assertThat(path).isNotNull(); assertThat(path.isAbsolute()).isFalse(); assertThat(path.toString()).isEqualTo("path/to/some/place.txt"); assertThat(path.toUri().toString()).isEqualTo("git://test-branch@my-repo/:path/to/some/place.txt"); assertThat(path.getNameCount()).isEqualTo(4); assertThat(path.getName(0).toString()).isNotNull().isEqualTo("path"); assertThat(path.getRoot().toString()).isNotNull().isEqualTo(""); }
@Test public void testPathBranchRooted() throws IOException, GitAPIException { final JGitFileSystemProvider fsProvider = mock(JGitFileSystemProvider.class); when(fsProvider.isDefault()).thenReturn(false); when(fsProvider.getScheme()).thenReturn("git"); final Git git = setupGit(); final JGitFileSystemImpl fileSystem = new JGitFileSystemImpl(fsProvider, null, git, createFSLock(git), "my-repo", CredentialsProvider.getDefault(), null, null); final Path path = fileSystem.getPath("test-branch", "/path/to/some/place.txt"); AssertionsForClassTypes.assertThat(path).isNotNull(); assertThat(path.isAbsolute()).isTrue(); assertThat(path.toString()).isEqualTo("/path/to/some/place.txt"); assertThat(path.toUri().toString()).isEqualTo("git://test-branch@my-repo/path/to/some/place.txt"); assertThat(path.getNameCount()).isEqualTo(4); assertThat(path.getName(0).toString()).isNotNull().isEqualTo("path"); assertThat(path.getRoot().toString()).isNotNull().isEqualTo("/"); }
@Test public void testPathBranchNonRooted() throws IOException, GitAPIException { final JGitFileSystemProvider fsProvider = mock(JGitFileSystemProvider.class); when(fsProvider.isDefault()).thenReturn(false); when(fsProvider.getScheme()).thenReturn("git"); final Git git = setupGit(); final JGitFileSystemImpl fileSystem = new JGitFileSystemImpl(fsProvider, null, git, createFSLock(git), "my-repo", CredentialsProvider.getDefault(), null, null); final Path path = fileSystem.getPath("test-branch", "path/to/some/place.txt"); AssertionsForClassTypes.assertThat(path).isNotNull(); assertThat(path.isAbsolute()).isFalse(); assertThat(path.toString()).isEqualTo("path/to/some/place.txt"); assertThat(path.toUri().toString()).isEqualTo("git://test-branch@my-repo/:path/to/some/place.txt"); assertThat(path.getNameCount()).isEqualTo(4); assertThat(path.getName(0).toString()).isNotNull().isEqualTo("path"); assertThat(path.getRoot().toString()).isNotNull().isEqualTo(""); }
@Test public void testPathEqualsWithDifferentRepos() throws IOException, GitAPIException { final JGitFileSystemProvider fsProvider = mock(JGitFileSystemProvider.class); final Git git1 = setupGit(); final JGitFileSystemImpl fileSystem1 = new JGitFileSystemImpl(fsProvider, null, git1, createFSLock(git1), "my-repo1", CredentialsProvider.getDefault(), null, null); final Git git2 = setupGit(); final JGitFileSystemImpl fileSystem2 = new JGitFileSystemImpl(fsProvider, null, git2, createFSLock(git2), "my-repo2", CredentialsProvider.getDefault(), null, null); final Path path1 = fileSystem1.getPath("master", "/path/to/some.txt"); final Path path2 = fileSystem2.getPath("master", "/path/to/some.txt"); AssertionsForClassTypes.assertThat(path1).isNotEqualTo(path2); AssertionsForClassTypes.assertThat(path1).isEqualTo(fileSystem1.getPath("/path/to/some.txt")); }
@Test public void testPathEqualsWithDifferentRepos() throws IOException, GitAPIException { final JGitFileSystemProvider fsProvider = mock(JGitFileSystemProvider.class); final Git git1 = setupGit(); final JGitFileSystemImpl fileSystem1 = new JGitFileSystemImpl(fsProvider, null, git1, createFSLock(git1), "my-repo1", CredentialsProvider.getDefault(), null, null); final Git git2 = setupGit(); final JGitFileSystemImpl fileSystem2 = new JGitFileSystemImpl(fsProvider, null, git2, createFSLock(git2), "my-repo2", CredentialsProvider.getDefault(), null, null); final Path path1 = fileSystem1.getPath("master", "/path/to/some.txt"); final Path path2 = fileSystem2.getPath("master", "/path/to/some.txt"); AssertionsForClassTypes.assertThat(path1).isNotEqualTo(path2); AssertionsForClassTypes.assertThat(path1).isEqualTo(fileSystem1.getPath("/path/to/some.txt")); }
}}).execute(); InputStream stream = provider.newInputStream(anotherInstanceOfFs1.getPath("realInstanceFs1File.txt")); assertNotNull(stream); String content = new Scanner(stream).useDelimiter("\\A").next(); }}).execute(); stream = provider.newInputStream(realInstanceFs1.getPath("anotherInstanceOfFs1File.txt")); assertNotNull(stream); content = new Scanner(stream).useDelimiter("\\A").next();
}}).execute(); InputStream stream = provider.newInputStream(anotherInstanceOfFs1.getPath("realInstanceFs1File.txt")); assertNotNull(stream); String content = new Scanner(stream).useDelimiter("\\A").next(); }}).execute(); stream = provider.newInputStream(realInstanceFs1.getPath("anotherInstanceOfFs1File.txt")); assertNotNull(stream); content = new Scanner(stream).useDelimiter("\\A").next();