@Test public void testDeleteBranchIfExists() throws IOException { final URI newRepo = URI.create("git://deletebranchifexists1-test-repo"); provider.newFileSystem(newRepo, EMPTY_ENV); final Path path = provider.getPath(URI.create("git://user_branch@deletebranchifexists1-test-repo/path/to/myfile.txt")); final OutputStream outStream = provider.newOutputStream(path); assertThat(outStream).isNotNull(); outStream.write("my cool content".getBytes()); outStream.close(); provider.newInputStream(path).close(); assertThat(provider.deleteIfExists(provider.getPath(URI.create("git://user_branch@deletebranchifexists1-test-repo")))).isTrue(); assertThat(provider.deleteIfExists(provider.getPath(URI.create("git://not_user_branch@deletebranchifexists1-test-repo")))).isFalse(); assertThat(provider.deleteIfExists(provider.getPath(URI.create("git://user_branch@deletebranchifexists1-test-repo")))).isFalse(); }
@Test public void testDeleteBranchIfExists() throws IOException { final URI newRepo = URI.create("git://deletebranchifexists1-test-repo"); provider.newFileSystem(newRepo, EMPTY_ENV); final Path path = provider.getPath(URI.create("git://user_branch@deletebranchifexists1-test-repo/path/to/myfile.txt")); final OutputStream outStream = provider.newOutputStream(path); assertThat(outStream).isNotNull(); outStream.write("my cool content".getBytes()); outStream.close(); provider.newInputStream(path).close(); assertThat(provider.deleteIfExists(provider.getPath(URI.create("git://user_branch@deletebranchifexists1-test-repo")))).isTrue(); assertThat(provider.deleteIfExists(provider.getPath(URI.create("git://not_user_branch@deletebranchifexists1-test-repo")))).isFalse(); assertThat(provider.deleteIfExists(provider.getPath(URI.create("git://user_branch@deletebranchifexists1-test-repo")))).isFalse(); }
@Test public void testDeleteIfExists() throws IOException { final URI newRepo = URI.create("git://deleteifexists1-test-repo"); provider.newFileSystem(newRepo, EMPTY_ENV); final Path path = provider.getPath(URI.create("git://user_branch@deleteifexists1-test-repo/path/to/myfile.txt")); final OutputStream outStream = provider.newOutputStream(path); assertThat(outStream).isNotNull(); outStream.write("my cool content".getBytes()); outStream.close(); provider.newInputStream(path).close(); assertThat(provider.deleteIfExists(provider.getPath(URI.create("git://user_branch@deleteifexists1-test-repo/non_existent_path")))).isFalse(); try { provider.deleteIfExists(provider.getPath(URI.create("git://user_branch@deleteifexists1-test-repo/path/to/"))); failBecauseExceptionWasNotThrown(DirectoryNotEmptyException.class); } catch (DirectoryNotEmptyException ignored) { } assertThat(provider.deleteIfExists(path)).isTrue(); }
@Test public void testDeleteIfExists() throws IOException { final URI newRepo = URI.create("git://deleteifexists1-test-repo"); provider.newFileSystem(newRepo, EMPTY_ENV); final Path path = provider.getPath(URI.create("git://user_branch@deleteifexists1-test-repo/path/to/myfile.txt")); final OutputStream outStream = provider.newOutputStream(path); assertThat(outStream).isNotNull(); outStream.write("my cool content".getBytes()); outStream.close(); provider.newInputStream(path).close(); assertThat(provider.deleteIfExists(provider.getPath(URI.create("git://user_branch@deleteifexists1-test-repo/non_existent_path")))).isFalse(); try { provider.deleteIfExists(provider.getPath(URI.create("git://user_branch@deleteifexists1-test-repo/path/to/"))); failBecauseExceptionWasNotThrown(DirectoryNotEmptyException.class); } catch (DirectoryNotEmptyException ignored) { } assertThat(provider.deleteIfExists(path)).isTrue(); }