Пример #1
0
 @Test
 public void testRenameOverExistingNonEmptyDirectory() throws IOException {
   File d = new File(trash, "d");
   FileUtils.mkdirs(d);
   File f1 = new File(trash, "d/f");
   File f2 = new File(trash, "d/g");
   File d1 = new File(trash, "d/g/h/i");
   File f3 = new File(trash, "d/g/h/f");
   FileUtils.mkdirs(d1);
   JGitTestUtil.write(f1, "f1");
   JGitTestUtil.write(f3, "f3");
   // test
   try {
     FileUtils.rename(f1, f2);
     fail("rename to non-empty directory should fail");
   } catch (IOException e) {
     assertEquals("f1", JGitTestUtil.read(f1)); // untouched source
     assertEquals("f3", JGitTestUtil.read(f3)); // untouched
     // empty directories within f2 may or may not have been deleted
   }
 }
Пример #2
0
 @Test
 public void testRenameOverNonExistingFile() throws IOException {
   File d = new File(trash, "d");
   FileUtils.mkdirs(d);
   File f1 = new File(trash, "d/f");
   File f2 = new File(trash, "d/g");
   JGitTestUtil.write(f1, "f1");
   // test
   FileUtils.rename(f1, f2);
   assertFalse(f1.exists());
   assertTrue(f2.exists());
   assertEquals("f1", JGitTestUtil.read(f2));
 }
Пример #3
0
 protected String read(final File file) throws IOException {
   return JGitTestUtil.read(file);
 }