@Test public void copyBranchesNotAtTheSameFSShouldNotBeAllowedTest() throws IOException { final URI newRepo = URI.create("git://movebranch-repo"); provider.newFileSystem(newRepo, EMPTY_ENV); final URI anotherRepo = URI.create("git://another-repo"); provider.newFileSystem(anotherRepo, EMPTY_ENV); { final Path path = provider.getPath(URI.create("git://another-branch@movebranch-repo/dorinha.txt")); final OutputStream outStream = provider.newOutputStream(path); outStream.write("little baby another-branch".getBytes()); outStream.close(); } final Path source = provider.getPath(URI.create("git://another-branch@movebranch-repo/")); final Path target = provider.getPath(URI.create("git://another-branch-moved@another-repo/")); assertThatThrownBy(() -> provider.copy(source, target)) .isInstanceOf(IllegalStateException.class); }
@Test(expected = GitException.class) public void testTryToMergeNonexistentBranch() throws IOException { final URI newRepo = URI.create("git://merge-test-repo"); provider.newFileSystem(newRepo, EMPTY_ENV); { final Path path = provider.getPath(URI.create("git://master@merge-test-repo/myfile1.txt")); final OutputStream outStream = provider.newOutputStream(path); outStream.write("my cool content".getBytes()); outStream.close(); } final Path master = provider.getPath(URI.create("git://master@merge-test-repo")); final Path develop = provider.getPath(URI.create("git://develop@merge-test-repo")); provider.copy(develop, master, new MergeCopyOption()); }
@Test public void copyBranchesNotAtTheSameFSShouldNotBeAllowedTest() throws IOException { final URI newRepo = URI.create("git://movebranch-repo"); provider.newFileSystem(newRepo, EMPTY_ENV); final URI anotherRepo = URI.create("git://another-repo"); provider.newFileSystem(anotherRepo, EMPTY_ENV); { final Path path = provider.getPath(URI.create("git://another-branch@movebranch-repo/dorinha.txt")); final OutputStream outStream = provider.newOutputStream(path); outStream.write("little baby another-branch".getBytes()); outStream.close(); } final Path source = provider.getPath(URI.create("git://another-branch@movebranch-repo/")); final Path target = provider.getPath(URI.create("git://another-branch-moved@another-repo/")); assertThatThrownBy(() -> provider.copy(source, target)) .isInstanceOf(IllegalStateException.class); }
@Test(expected = GitException.class) public void testTryToMergeNonexistentBranch() throws IOException { final URI newRepo = URI.create("git://merge-test-repo"); provider.newFileSystem(newRepo, EMPTY_ENV); { final Path path = provider.getPath(URI.create("git://master@merge-test-repo/myfile1.txt")); final OutputStream outStream = provider.newOutputStream(path); outStream.write("my cool content".getBytes()); outStream.close(); } final Path master = provider.getPath(URI.create("git://master@merge-test-repo")); final Path develop = provider.getPath(URI.create("git://develop@merge-test-repo")); provider.copy(develop, master, new MergeCopyOption()); }
@Test(expected = IllegalArgumentException.class) public void testMissingParemeter() throws IOException { final URI newRepo = URI.create("git://merge-test-repo"); provider.newFileSystem(newRepo, EMPTY_ENV); { final Path path = provider.getPath(URI.create("git://master@merge-test-repo/myfile1.txt")); final OutputStream outStream = provider.newOutputStream(path); outStream.write("my cool content".getBytes()); outStream.close(); } final Path master = provider.getPath(URI.create("git://master@merge-test-repo")); final Path develop = provider.getPath(URI.create("git://develop@merge-test-repo")); provider.copy(develop, null, new MergeCopyOption()); } }
@Test(expected = IllegalArgumentException.class) public void testMissingParemeter() throws IOException { final URI newRepo = URI.create("git://merge-test-repo"); provider.newFileSystem(newRepo, EMPTY_ENV); { final Path path = provider.getPath(URI.create("git://master@merge-test-repo/myfile1.txt")); final OutputStream outStream = provider.newOutputStream(path); outStream.write("my cool content".getBytes()); outStream.close(); } final Path master = provider.getPath(URI.create("git://master@merge-test-repo")); final Path develop = provider.getPath(URI.create("git://develop@merge-test-repo")); provider.copy(develop, null, new MergeCopyOption()); } }
final Path target = provider.getPath(URI.create("git://other_branch@copybranch-test-repo")); provider.copy(source, target); assertThatThrownBy(() -> provider.copy(source, target)) .isInstanceOf(FileAlreadyExistsException.class); final Path notExists2 = provider.getPath(URI.create("git://xxx_other_branch@copybranch-test-repo")); assertThatThrownBy(() -> provider.copy(notExists, notExists2)) .isInstanceOf(NoSuchFileException.class);
@Test public void copyBranchesTest() throws IOException { final URI newRepo = URI.create("git://movebranch-repo"); provider.newFileSystem(newRepo, EMPTY_ENV); { final Path path = provider.getPath(URI.create("git://another-branch@movebranch-repo/dorinha.txt")); final OutputStream outStream = provider.newOutputStream(path); outStream.write("little baby another-branch".getBytes()); outStream.close(); } final Path source = provider.getPath(URI.create("git://another-branch@movebranch-repo/")); final Path target = provider.getPath(URI.create("git://another-branch-moved@movebranch-repo/")); provider.copy(source, target); final String originalContent = extractContent(provider.getPath(URI.create("git://another-branch@movebranch-repo/dorinha.txt"))); assertThat(originalContent).isNotNull().isEqualTo("little baby another-branch"); final String contentMoved = extractContent(provider.getPath(URI.create("git://another-branch-moved@movebranch-repo/dorinha.txt"))); assertThat(contentMoved).isNotNull().isEqualTo("little baby another-branch"); }
@Test public void copyBranchesTest() throws IOException { final URI newRepo = URI.create("git://movebranch-repo"); provider.newFileSystem(newRepo, EMPTY_ENV); { final Path path = provider.getPath(URI.create("git://another-branch@movebranch-repo/dorinha.txt")); final OutputStream outStream = provider.newOutputStream(path); outStream.write("little baby another-branch".getBytes()); outStream.close(); } final Path source = provider.getPath(URI.create("git://another-branch@movebranch-repo/")); final Path target = provider.getPath(URI.create("git://another-branch-moved@movebranch-repo/")); provider.copy(source, target); final String originalContent = extractContent(provider.getPath(URI.create("git://another-branch@movebranch-repo/dorinha.txt"))); assertThat(originalContent).isNotNull().isEqualTo("little baby another-branch"); final String contentMoved = extractContent(provider.getPath(URI.create("git://another-branch-moved@movebranch-repo/dorinha.txt"))); assertThat(contentMoved).isNotNull().isEqualTo("little baby another-branch"); }
@Test public void testCopyFilesAcrossRepositories() throws IOException { final URI newRepo1 = URI.create("git://copyasset-test-repo1"); provider.newFileSystem(newRepo1, EMPTY_ENV); final URI newRepo2 = URI.create("git://copyasset-test-repo2"); provider.newFileSystem(newRepo2, EMPTY_ENV); final Path path = provider.getPath(URI.create("git://master@copyasset-test-repo1/myfile1.txt")); { final OutputStream outStream = provider.newOutputStream(path); outStream.write("my cool content".getBytes()); outStream.close(); } final Path target = provider.getPath(URI.create("git://master@copyasset-test-repo2/myfile1.txt")); provider.copy(path, target); final DirectoryStream<Path> stream = provider.newDirectoryStream(provider.getPath(URI.create("git://master@copyasset-test-repo2/")), null); for (Path path1 : stream) { System.out.println("content: " + path1.toUri()); } assertThat(stream).isNotNull().hasSize(1); }
@Test public void testCopyFilesAcrossRepositories() throws IOException { final URI newRepo1 = URI.create("git://copyasset-test-repo1"); provider.newFileSystem(newRepo1, EMPTY_ENV); final URI newRepo2 = URI.create("git://copyasset-test-repo2"); provider.newFileSystem(newRepo2, EMPTY_ENV); final Path path = provider.getPath(URI.create("git://master@copyasset-test-repo1/myfile1.txt")); { final OutputStream outStream = provider.newOutputStream(path); outStream.write("my cool content".getBytes()); outStream.close(); } final Path target = provider.getPath(URI.create("git://master@copyasset-test-repo2/myfile1.txt")); provider.copy(path, target); final DirectoryStream<Path> stream = provider.newDirectoryStream(provider.getPath(URI.create("git://master@copyasset-test-repo2/")), null); for (Path path1 : stream) { System.out.println("content: " + path1.toUri()); } assertThat(stream).isNotNull().hasSize(1); }
provider.copy(path, target);
provider.copy(path, target);
copy(source, target, options);