@Test public void testGetFileSystem() { final URI newRepo = URI.create("git://new-repo-name"); final FileSystem fs = provider.newFileSystem(newRepo, EMPTY_ENV); assertThat(fs).isNotNull(); assertThat(provider.getFileSystem(newRepo)).isEqualTo(fs); assertThat(provider.getFileSystem(URI.create("git://master@new-repo-name"))).isEqualTo(fs); assertThat(provider.getFileSystem(URI.create("git://branch@new-repo-name"))).isEqualTo(fs); assertThat(provider.getFileSystem(URI.create("git://branch@new-repo-name?_fetch"))).isEqualTo(fs); }
@Test public void testGetFileSystem() { final URI newRepo = URI.create("git://new-repo-name"); final FileSystem fs = provider.newFileSystem(newRepo, EMPTY_ENV); assertThat(fs).isNotNull(); assertThat(provider.getFileSystem(newRepo)).isEqualTo(fs); assertThat(provider.getFileSystem(URI.create("git://master@new-repo-name"))).isEqualTo(fs); assertThat(provider.getFileSystem(URI.create("git://branch@new-repo-name"))).isEqualTo(fs); assertThat(provider.getFileSystem(URI.create("git://branch@new-repo-name?_fetch"))).isEqualTo(fs); }
@Test(expected = FileSystemNotFoundException.class) public void testGetFileSystemNotExisting() { final URI newRepo = URI.create("git://not-new-repo-name"); provider.getFileSystem(newRepo); }
@Test(expected = FileSystemNotFoundException.class) public void testGetFileSystemNotExisting() { final URI newRepo = URI.create("git://not-new-repo-name"); provider.getFileSystem(newRepo); }
@Test public void testInvalidURIGetFileSystem() { final URI newRepo = URI.create("git:///new-repo-name"); try { provider.getFileSystem(newRepo); failBecauseExceptionWasNotThrown(IllegalArgumentException.class); } catch (final IllegalArgumentException ex) { assertThat(ex.getMessage()).isEqualTo("Parameter named 'uri' is invalid, missing host repository!"); } }
@Test public void testInvalidURIGetFileSystem() { final URI newRepo = URI.create("git:///new-repo-name"); try { provider.getFileSystem(newRepo); failBecauseExceptionWasNotThrown(IllegalArgumentException.class); } catch (final IllegalArgumentException ex) { assertThat(ex.getMessage()).isEqualTo("Parameter named 'uri' is invalid, missing host repository!"); } }
@Test public void resolveComposedFSNames() { final URI simpleName = URI.create("git://dora-repo"); final FileSystem fsSimpleName = provider.newFileSystem(simpleName, EMPTY_ENV); assertThat(fsSimpleName).isNotNull(); final URI composedName = URI.create("git://ou-dora/dora-repo"); final FileSystem fsComposedName = provider.newFileSystem(composedName, EMPTY_ENV); assertThat(fsComposedName).isNotNull(); assertNotSame(fsSimpleName, fsComposedName); assertEquals(fsSimpleName, provider.getFileSystem(simpleName)); assertEquals(fsComposedName, provider.getFileSystem(composedName)); final URI simpleFileName = URI.create("git://dora-repo/file.txt"); assertEquals(fsSimpleName, provider.getFileSystem(simpleFileName)); final URI composedFileName = URI.create("git://ou-dora/dora-repo/file.txt"); assertEquals(fsComposedName, provider.getFileSystem(composedFileName)); }
@Test public void resolveComposedFSNames() { final URI simpleName = URI.create("git://dora-repo"); final FileSystem fsSimpleName = provider.newFileSystem(simpleName, EMPTY_ENV); assertThat(fsSimpleName).isNotNull(); final URI composedName = URI.create("git://ou-dora/dora-repo"); final FileSystem fsComposedName = provider.newFileSystem(composedName, EMPTY_ENV); assertThat(fsComposedName).isNotNull(); assertNotSame(fsSimpleName, fsComposedName); assertEquals(fsSimpleName, provider.getFileSystem(simpleName)); assertEquals(fsComposedName, provider.getFileSystem(composedName)); final URI simpleFileName = URI.create("git://dora-repo/file.txt"); assertEquals(fsSimpleName, provider.getFileSystem(simpleFileName)); final URI composedFileName = URI.create("git://ou-dora/dora-repo/file.txt"); assertEquals(fsComposedName, provider.getFileSystem(composedFileName)); }
@Test public void testCreateANewDirectoryWithMigrationEnv() { final Map<String, ?> envMigrate = new HashMap<String, Object>() {{ put("init", Boolean.TRUE); put("migrate-from", URI.create("git://old")); }}; String newPath = "git://test/old"; final URI newUri = URI.create(newPath); provider.newFileSystem(newUri, envMigrate); provider.getFileSystem(newUri); assertThat(new File(provider.getGitRepoContainerDir(), "test/old" + ".git")).exists(); assertThat(provider.getFileSystem(newUri)).isNotNull(); } }
@Test public void testCreateANewDirectoryWithMigrationEnv() { final Map<String, ?> envMigrate = new HashMap<String, Object>() {{ put("init", Boolean.TRUE); put("migrate-from", URI.create("git://old")); }}; String newPath = "git://test/old"; final URI newUri = URI.create(newPath); provider.newFileSystem(newUri, envMigrate); provider.getFileSystem(newUri); assertThat(new File(provider.getGitRepoContainerDir(), "test/old" + ".git")).exists(); assertThat(provider.getFileSystem(newUri)).isNotNull(); } }
@Test public void testNewFileSystemCloneAndRescan() throws IOException { final URI originRepo = URI.create("git://my-simple-test-origin-name"); final JGitFileSystem origin = (JGitFileSystem) provider.newFileSystem(originRepo, Collections.emptyMap()); new Commit(origin.getGit(), "master", "user1", "user1@example.com", "commitx", null, null, false, new HashMap<String, File>() {{ put("file.txt", tempFile("temp")); }}).execute(); final URI newRepo = URI.create("git://my-repo-name"); final Map<String, Object> env = new HashMap<String, Object>() {{ put(JGitFileSystemProviderConfiguration.GIT_ENV_KEY_DEFAULT_REMOTE_NAME, "git://localhost:" + gitDaemonPort + "/my-simple-test-origin-name"); }}; final FileSystem fs = provider.newFileSystem(newRepo, env); assertThat(fs).isNotNull(); assertThat(fs.getRootDirectories()).hasSize(1); final FileSystem fs2 = provider.getFileSystem(newRepo); assertThat(fs2).isNotNull(); assertThat(fs2.getRootDirectories()).hasSize(1); }
@Test public void testNewFileSystemCloneAndRescan() throws IOException { final URI originRepo = URI.create("git://my-simple-test-origin-name"); final JGitFileSystem origin = (JGitFileSystem) provider.newFileSystem(originRepo, Collections.emptyMap()); new Commit(origin.getGit(), "master", "user1", "user1@example.com", "commitx", null, null, false, new HashMap<String, File>() {{ put("file.txt", tempFile("temp")); }}).execute(); final URI newRepo = URI.create("git://my-repo-name"); final Map<String, Object> env = new HashMap<String, Object>() {{ put(JGitFileSystemProviderConfiguration.GIT_ENV_KEY_DEFAULT_REMOTE_NAME, "git://localhost:" + gitDaemonPort + "/my-simple-test-origin-name"); }}; final FileSystem fs = provider.newFileSystem(newRepo, env); assertThat(fs).isNotNull(); assertThat(fs.getRootDirectories()).hasSize(1); final FileSystem fs2 = provider.getFileSystem(newRepo); assertThat(fs2).isNotNull(); assertThat(fs2.getRootDirectories()).hasSize(1); }
provider.getFileSystem(URI.create("git://repo-clone?push=ssh://admin@localhost:" + gitSSHPort + "/repo"));
}}).execute(); provider.getFileSystem(URI.create("git://my-repo-name?sync=git://localhost:" + gitDaemonPort + "/my-simple-test-origin-name&force")); }}).execute(); provider.getFileSystem(URI.create("git://my-repo-name?sync=git://localhost:" + gitDaemonPort + "/my-simple-test-origin-name&force"));
provider.getFileSystem(URI.create("git://repo-clone?push=ssh://admin@localhost:" + gitSSHPort + "/repo"));
}}).execute(); provider.getFileSystem(URI.create("git://my-repo2?sync=git://localhost:" + gitDaemonPort + "/my-simple-test-origin-repo&force")); }}).execute(); provider.getFileSystem(URI.create("git://my-repo2?sync=git://localhost:" + gitDaemonPort + "/my-simple-test-origin-repo&force"));
}}).execute(); provider.getFileSystem(URI.create("git://my-repo-name?sync=git://localhost:" + gitDaemonPort + "/my-simple-test-origin-name&force")); }}).execute(); provider.getFileSystem(URI.create("git://my-repo-name?sync=git://localhost:" + gitDaemonPort + "/my-simple-test-origin-name&force"));
final JGitFileSystemProvider provider = (JGitFileSystemProvider) FileSystemProviders.resolveProvider(originRepo); final JGitFileSystem origin = (JGitFileSystem) provider.getFileSystem(originRepo);
}}).execute(); provider.getFileSystem(URI.create("git://my-repo2?sync=git://localhost:" + gitDaemonPort + "/my-simple-test-origin-repo&force")); }}).execute(); provider.getFileSystem(URI.create("git://my-repo2?sync=git://localhost:" + gitDaemonPort + "/my-simple-test-origin-repo&force"));