summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Pearce <spearce@spearce.org>2013-04-19 12:01:58 -0700
committerShawn Pearce <spearce@spearce.org>2013-04-19 12:04:47 -0700
commit1b4320f1fa46169ad08a1d3d40ca00a4224881cd (patch)
treedfb524bf4183ed53ad730826a99bfa2de05350a7
parentee222a3be1e8b902667a739625047eef29154924 (diff)
downloadjgit-1b4320f1fa46169ad08a1d3d40ca00a4224881cd.tar.gz
jgit-1b4320f1fa46169ad08a1d3d40ca00a4224881cd.zip
Revert "Add tests for FileUtils.delete and EMPTY_DIREECTORIES_ONLY"
This reverts commit 7aa54967a26cb027fe390ad1c624ebb30f9ac6d5. The unit test dependend upon the specific order of names that listFiles() returned members in. The order is completely undefined and may differ even on different versions of Linux based systems. A proper unit test for this code would have considered both cases, where the deletion function was able to remove an empty subdirectory, or fail to remove a subdirectory because a file was still present within. This is not such a test. Change-Id: Ib0a706fea01e4b1ed8c8e859247d247a1279b4bc
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/util/FileUtilTest.java85
1 files changed, 0 insertions, 85 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/FileUtilTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/FileUtilTest.java
index f6f6753c75..3cd01453a1 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/FileUtilTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/FileUtilTest.java
@@ -119,91 +119,6 @@ public class FileUtilTest {
}
@Test
- public void testDeleteRecursiveEmpty() throws IOException {
- File f1 = new File(trash, "test/test/a");
- File f2 = new File(trash, "test/a");
- File d1 = new File(trash, "test");
- File d2 = new File(trash, "test/test");
- File d3 = new File(trash, "test/b");
- FileUtils.mkdirs(f1.getParentFile());
- FileUtils.createNewFile(f2);
- FileUtils.createNewFile(f1);
- FileUtils.mkdirs(d3);
-
- // Cannot delete hierarchy since files exist
- try {
- FileUtils.delete(d1, FileUtils.EMPTY_DIRECTORIES_ONLY);
- fail("delete should fail");
- } catch (IOException e1) {
- try {
- FileUtils.delete(d1, FileUtils.EMPTY_DIRECTORIES_ONLY|FileUtils.RECURSIVE);
- fail("delete should fail");
- } catch (IOException e2) {
- // Everything still there
- assertTrue(f1.exists());
- assertTrue(f2.exists());
- assertTrue(d1.exists());
- assertTrue(d2.exists());
- assertTrue(d3.exists());
- }
- }
-
- // setup: delete files, only directories left
- assertTrue(f1.delete());
- assertTrue(f2.delete());
-
- // Shall not delete hierarchy without recursive
- try {
- FileUtils.delete(d1, FileUtils.EMPTY_DIRECTORIES_ONLY);
- fail("delete should fail");
- } catch (IOException e2) {
- // Everything still there
- assertTrue(d1.exists());
- assertTrue(d2.exists());
- assertTrue(d3.exists());
- }
-
- // Now delete the empty hierarchy
- FileUtils.delete(d2, FileUtils.EMPTY_DIRECTORIES_ONLY
- | FileUtils.RECURSIVE);
- assertFalse(d2.exists());
-
- // Will fail to delete non-existing without SKIP_MISSING
- try {
- FileUtils.delete(d2, FileUtils.EMPTY_DIRECTORIES_ONLY);
- fail("Cannot delete non-existent entity");
- } catch (IOException e) {
- // ok
- }
-
- // ..with SKIP_MISSING there is no exception
- FileUtils.delete(d2, FileUtils.EMPTY_DIRECTORIES_ONLY
- | FileUtils.SKIP_MISSING);
- FileUtils.delete(d2, FileUtils.EMPTY_DIRECTORIES_ONLY
- | FileUtils.RECURSIVE | FileUtils.SKIP_MISSING);
-
- // essentially the same, using IGNORE_ERRORS
- FileUtils.delete(d2, FileUtils.EMPTY_DIRECTORIES_ONLY
- | FileUtils.IGNORE_ERRORS);
- FileUtils.delete(d2, FileUtils.EMPTY_DIRECTORIES_ONLY
- | FileUtils.RECURSIVE | FileUtils.IGNORE_ERRORS);
- }
-
- @Test
- public void testDeleteRecursiveEmptyDirectoriesOnlyButIsFile()
- throws IOException {
- File f1 = new File(trash, "test/test/a");
- FileUtils.mkdirs(f1.getParentFile());
- FileUtils.createNewFile(f1);
- try {
- FileUtils.delete(f1, FileUtils.EMPTY_DIRECTORIES_ONLY);
- fail("delete should fail");
- } catch (IOException e) {
- assertTrue(f1.exists());
- }
- }
-
- @Test
public void testMkdir() throws IOException {
File d = new File(trash, "test");
FileUtils.mkdir(d);