@Test public void testGetPath() { final URI newRepo = URI.create("git://new-get-repo-name"); provider.newFileSystem(newRepo, EMPTY_ENV); final Path path = provider.getPath(URI.create("git://master@new-get-repo-name/home")); AssertionsForClassTypes.assertThat(path).isNotNull(); assertThat(path.getRoot().toString()).isEqualTo("/"); Path root = path.getRoot(); Path path1 = root.toRealPath(); assertThat(root.toRealPath().toUri().toString()).isEqualTo("git://master@new-get-repo-name/"); assertThat(path.toString()).isEqualTo("/home"); final Path pathRelative = provider.getPath(URI.create("git://master@new-get-repo-name/:home")); AssertionsForClassTypes.assertThat(pathRelative).isNotNull(); assertThat(pathRelative.toRealPath().toUri().toString()).isEqualTo("git://master@new-get-repo-name/:home"); assertThat(pathRelative.getRoot().toString()).isEqualTo(""); assertThat(pathRelative.toString()).isEqualTo("home"); }
@Test public void testGetPath() { final URI newRepo = URI.create("git://new-get-repo-name"); provider.newFileSystem(newRepo, EMPTY_ENV); final Path path = provider.getPath(URI.create("git://master@new-get-repo-name/home")); AssertionsForClassTypes.assertThat(path).isNotNull(); assertThat(path.getRoot().toString()).isEqualTo("/"); Path root = path.getRoot(); Path path1 = root.toRealPath(); assertThat(root.toRealPath().toUri().toString()).isEqualTo("git://master@new-get-repo-name/"); assertThat(path.toString()).isEqualTo("/home"); final Path pathRelative = provider.getPath(URI.create("git://master@new-get-repo-name/:home")); AssertionsForClassTypes.assertThat(pathRelative).isNotNull(); assertThat(pathRelative.toRealPath().toUri().toString()).isEqualTo("git://master@new-get-repo-name/:home"); assertThat(pathRelative.getRoot().toString()).isEqualTo(""); assertThat(pathRelative.toString()).isEqualTo("home"); }
@Test public void testRelativeToURIUnix() { final FileSystemProvider fsprovider = mock(FileSystemProvider.class); when(fsprovider.isDefault()).thenReturn(true); when(fsprovider.getScheme()).thenReturn("file"); when(fs.provider()).thenReturn(fsprovider); when(fs.getSeparator()).thenReturn("/"); final Path path = create(fs, "path/to/file.txt", false); final URI uri = path.toUri(); assertThat(path).isNotNull(); assertThat(uri).isNotNull(); assertThat(uri.toString()).isEqualTo("default://" + DEFAULT_PATH + "path/to/file.txt"); assertThat(path.toRealPath().toUri().toString()).isEqualTo("file://" + DEFAULT_PATH + "path/to/file.txt"); }
@Test public void testAbsoluteToURIUnix() { final FileSystemProvider fsprovider = mock(FileSystemProvider.class); when(fsprovider.isDefault()).thenReturn(true); when(fsprovider.getScheme()).thenReturn("file"); when(fs.provider()).thenReturn(fsprovider); when(fs.getSeparator()).thenReturn("/"); final Path path = create(fs, "/path/to/file.txt", false); final URI uri = path.toUri(); assertThat(path).isNotNull(); assertThat(uri).isNotNull(); assertThat(uri.toString()).isEqualTo("default:///path/to/file.txt"); final Path realPath = path.toRealPath(); assertThat(realPath).isNotNull(); assertThat(realPath.toRealPath()).isEqualTo(realPath); assertThat(realPath.toUri()).isNotNull(); assertThat(realPath.toUri().toString()).isEqualTo("file:///path/to/file.txt"); }
@Test public void testAbsoluteToURIWindows() { final FileSystemProvider fsprovider = mock(FileSystemProvider.class); when(fsprovider.isDefault()).thenReturn(true); when(fsprovider.getScheme()).thenReturn("file"); when(fs.provider()).thenReturn(fsprovider); when(fs.getSeparator()).thenReturn("\\"); final Path path = create(fs, "c:\\path\\to\\file.txt", false); final URI uri = path.toUri(); assertThat(path).isNotNull(); assertThat(uri).isNotNull(); assertThat(uri.toString()).isEqualTo("default:///c:/path/to/file.txt"); final Path realPath = path.toRealPath(); assertThat(realPath).isNotNull(); assertThat(realPath.toRealPath()).isEqualTo(realPath); assertThat(realPath.toUri()).isNotNull(); assertThat(realPath.toUri().toString()).isEqualTo("file:///c:/path/to/file.txt"); }
@Test public void testRelativeToURIWindows() { final FileSystemProvider fsprovider = mock(FileSystemProvider.class); when(fsprovider.isDefault()).thenReturn(true); when(fsprovider.getScheme()).thenReturn("file"); when(fs.provider()).thenReturn(fsprovider); when(fs.getSeparator()).thenReturn("\\"); final Path path = create(fs, "path\\to\\file.txt", false); final URI uri = path.toUri(); assertThat(uri).isNotNull(); assertWindowsUri(uri.toString(), "default:///", DEFAULT_PATH + "path/to/file.txt"); assertThat(path).isNotNull(); assertWindowsUri(path.toRealPath().toUri().toString(), "file:///", DEFAULT_PATH + "path/to/file.txt"); }
public Metadata create() { return MetadataBuilder.newMetadata() .withPath(Paths.convert(path)) .withRealPath(Paths.convert(path.toRealPath())) .withCheckinComment(getCheckinComment()) .withLastContributor(getLastContributor()) .withCreator(getCreator()) .withLastModified(getLastModified()) .withDateCreated(getDateCreated()) .withSubject(getSubject()) .withType(getType()) .withExternalRelation(getExternalRelation()) .withExternalSource(getExternalSource()) .withDescription(getDescription()) .withTags(getTags()) .withDiscussion(getDiscussion()) .withLockInfo(retrieveLockInfo(Paths.convert(path))) .withVersion(getVersion()) .withGenerated(getGenerated()) .build(); }
public Metadata create() { return MetadataBuilder.newMetadata() .withPath(Paths.convert(path)) .withRealPath(Paths.convert(path.toRealPath())) .withCheckinComment(getCheckinComment()) .withLastContributor(getLastContributor()) .withCreator(getCreator()) .withLastModified(getLastModified()) .withDateCreated(getDateCreated()) .withSubject(getSubject()) .withType(getType()) .withExternalRelation(getExternalRelation()) .withExternalSource(getExternalSource()) .withDescription(getDescription()) .withTags(getTags()) .withDiscussion(getDiscussion()) .withLockInfo(retrieveLockInfo(Paths.convert(path))) .withVersion(getVersion()) .withGenerated(getGenerated()) .build(); }