@Test public void testComplexExtractPath() { final URI newRepo = URI.create("git://test/repo"); final FileSystem fs = provider.newFileSystem(newRepo, EMPTY_ENV); String path = "git://origin/master@test/repo/readme.md"; final URI uri = URI.create(path); final String extracted = provider.extractPath(uri); assertThat(extracted).isEqualTo("/readme.md"); }
@Test public void testComplexExtractPath() { final URI newRepo = URI.create("git://test/repo"); final FileSystem fs = provider.newFileSystem(newRepo, EMPTY_ENV); String path = "git://origin/master@test/repo/readme.md"; final URI uri = URI.create(path); final String extracted = provider.extractPath(uri); assertThat(extracted).isEqualTo("/readme.md"); }
@Override public Path getPath(final URI uri) throws IllegalArgumentException, FileSystemNotFoundException, SecurityException { checkNotNull("uri", uri); checkCondition("uri scheme not supported", uri.getScheme().equals(getScheme()) || uri.getScheme().equals("default")); checkURI("uri", uri); final JGitFileSystem fileSystem = fileSystems.get(extractRepoName(uri)); if (fileSystem == null) { throw new FileSystemNotFoundException(); } try { return JGitPathImpl.create(fileSystem, URIUtil.decode(extractPath(uri)), extractHost(uri), false); } catch (final URIException e) { return null; } }
@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 testExtractPathWithAuthority() { provider.newFileSystem(URI.create("git://test/repo"), new HashMap<String, Object>() {{ put("init", Boolean.TRUE); }}); String path = "git://master@test/repo/readme.md"; final URI uri = URI.create(path); final String extracted = provider.extractPath(uri); assertThat(extracted).isEqualTo("/readme.md"); }
@Test public void testExtractPathWithAuthority() { provider.newFileSystem(URI.create("git://test/repo"), new HashMap<String, Object>() {{ put("init", Boolean.TRUE); }}); String path = "git://master@test/repo/readme.md"; final URI uri = URI.create(path); final String extracted = provider.extractPath(uri); assertThat(extracted).isEqualTo("/readme.md"); }
@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 getPathForComposedFSNames2() { URI composedName = URI.create("git://user1/dora"); FileSystem fsComposedName1 = provider.newFileSystem(composedName, EMPTY_ENV); URI composedName2 = URI.create("git://user2/dora"); FileSystem fsComposedName2 = provider.newFileSystem(composedName2, EMPTY_ENV); URI composedFileName1 = URI.create("git://user1/dora/file.txt"); Path path1 = provider.getPath(composedFileName1); URI composedFileName2 = URI.create("git://user2/dora/file.txt"); Path path2 = provider.getPath(composedFileName2); assertNotEquals(fsComposedName1, fsComposedName2); assertNotEquals(path1.getFileSystem(), path2.getFileSystem()); assertEquals(path2.toString(), provider.extractPath(composedFileName2)); }
@Test public void getPathForComposedFSNames2() { URI composedName = URI.create("git://user1/dora"); FileSystem fsComposedName1 = provider.newFileSystem(composedName, EMPTY_ENV); URI composedName2 = URI.create("git://user2/dora"); FileSystem fsComposedName2 = provider.newFileSystem(composedName2, EMPTY_ENV); URI composedFileName1 = URI.create("git://user1/dora/file.txt"); Path path1 = provider.getPath(composedFileName1); URI composedFileName2 = URI.create("git://user2/dora/file.txt"); Path path2 = provider.getPath(composedFileName2); assertNotEquals(fsComposedName1, fsComposedName2); assertNotEquals(path1.getFileSystem(), path2.getFileSystem()); assertEquals(path2.toString(), provider.extractPath(composedFileName2)); }