public virtual void TestDeleteNonexistentPathNonRecursive()
        {
            Path path = Path("testDeleteNonexistentPathNonRecursive");

            ContractTestUtils.AssertPathDoesNotExist(GetFileSystem(), "leftover", path);
            ContractTestUtils.RejectRootOperation(path);
            NUnit.Framework.Assert.IsFalse("Returned true attempting to recursively delete" +
                                           " a nonexistent path " + path, GetFileSystem().Delete(path, false));
        }
        public virtual void TestDeleteNonEmptyDirRecursive()
        {
            Path path = Path("testDeleteNonEmptyDirNonRecursive");

            Mkdirs(path);
            Path file = new Path(path, "childfile");

            ContractTestUtils.WriteTextFile(GetFileSystem(), file, "goodbye, world", true);
            AssertDeleted(path, true);
            ContractTestUtils.AssertPathDoesNotExist(GetFileSystem(), "not deleted", file);
        }
        public virtual void TestDeleteDeepEmptyDir()
        {
            Mkdirs(Path("testDeleteDeepEmptyDir/d1/d2/d3/d4"));
            AssertDeleted(Path("testDeleteDeepEmptyDir/d1/d2/d3"), true);
            FileSystem fs = GetFileSystem();

            ContractTestUtils.AssertPathDoesNotExist(fs, "not deleted", Path("testDeleteDeepEmptyDir/d1/d2/d3/d4"
                                                                             ));
            ContractTestUtils.AssertPathDoesNotExist(fs, "not deleted", Path("testDeleteDeepEmptyDir/d1/d2/d3"
                                                                             ));
            ContractTestUtils.AssertPathExists(fs, "parent dir is deleted", Path("testDeleteDeepEmptyDir/d1/d2"
                                                                                 ));
        }
Пример #4
0
        public virtual void TestRenameWithNonEmptySubDir()
        {
            Path       renameTestDir         = Path("testRenameWithNonEmptySubDir");
            Path       srcDir                = new Path(renameTestDir, "src1");
            Path       srcSubDir             = new Path(srcDir, "sub");
            Path       finalDir              = new Path(renameTestDir, "dest");
            FileSystem fs                    = GetFileSystem();
            bool       renameRemoveEmptyDest = IsSupported(RenameRemoveDestIfEmptyDir);

            ContractTestUtils.Rm(fs, renameTestDir, true, false);
            fs.Mkdirs(srcDir);
            fs.Mkdirs(finalDir);
            ContractTestUtils.WriteTextFile(fs, new Path(srcDir, "source.txt"), "this is the file in src dir"
                                            , false);
            ContractTestUtils.WriteTextFile(fs, new Path(srcSubDir, "subfile.txt"), "this is the file in src/sub dir"
                                            , false);
            ContractTestUtils.AssertPathExists(fs, "not created in src dir", new Path(srcDir,
                                                                                      "source.txt"));
            ContractTestUtils.AssertPathExists(fs, "not created in src/sub dir", new Path(srcSubDir
                                                                                          , "subfile.txt"));
            fs.Rename(srcDir, finalDir);
            // Accept both POSIX rename behavior and CLI rename behavior
            if (renameRemoveEmptyDest)
            {
                // POSIX rename behavior
                ContractTestUtils.AssertPathExists(fs, "not renamed into dest dir", new Path(finalDir
                                                                                             , "source.txt"));
                ContractTestUtils.AssertPathExists(fs, "not renamed into dest/sub dir", new Path(
                                                       finalDir, "sub/subfile.txt"));
            }
            else
            {
                // CLI rename behavior
                ContractTestUtils.AssertPathExists(fs, "not renamed into dest dir", new Path(finalDir
                                                                                             , "src1/source.txt"));
                ContractTestUtils.AssertPathExists(fs, "not renamed into dest/sub dir", new Path(
                                                       finalDir, "src1/sub/subfile.txt"));
            }
            ContractTestUtils.AssertPathDoesNotExist(fs, "not deleted", new Path(srcDir, "source.txt"
                                                                                 ));
        }
Пример #5
0
 /// <summary>assert that a path does not</summary>
 /// <param name="message">message to use in an assertion</param>
 /// <param name="path">path to probe</param>
 /// <exception cref="System.IO.IOException">IO problems</exception>
 public virtual void AssertPathDoesNotExist(string message, Org.Apache.Hadoop.FS.Path
                                            path)
 {
     ContractTestUtils.AssertPathDoesNotExist(fileSystem, message, path);
 }