public virtual void TestRmNonEmptyRootDirNonRecursive()
        {
            //extra sanity checks here to avoid support calls about complete loss of data
            SkipIfUnsupported(TestRootTestsEnabled);
            Path   root      = new Path("/");
            string touchfile = "/testRmNonEmptyRootDirNonRecursive";
            Path   file      = new Path(touchfile);

            ContractTestUtils.Touch(GetFileSystem(), file);
            ContractTestUtils.AssertIsDirectory(GetFileSystem(), root);
            try
            {
                bool deleted = GetFileSystem().Delete(root, false);
                NUnit.Framework.Assert.Fail("non recursive delete should have raised an exception,"
                                            + " but completed with exit code " + deleted);
            }
            catch (IOException e)
            {
                //expected
                HandleExpectedException(e);
            }
            finally
            {
                GetFileSystem().Delete(file, false);
            }
            ContractTestUtils.AssertIsDirectory(GetFileSystem(), root);
        }
        public virtual void TestMkDirDepth1()
        {
            FileSystem fs  = GetFileSystem();
            Path       dir = new Path("/testmkdirdepth1");

            AssertPathDoesNotExist("directory already exists", dir);
            fs.Mkdirs(dir);
            ContractTestUtils.AssertIsDirectory(GetFileSystem(), dir);
            AssertPathExists("directory already exists", dir);
            AssertDeleted(dir, true);
        }
        public virtual void TestRmEmptyRootDirNonRecursive()
        {
            //extra sanity checks here to avoid support calls about complete loss of data
            SkipIfUnsupported(TestRootTestsEnabled);
            Path root = new Path("/");

            ContractTestUtils.AssertIsDirectory(GetFileSystem(), root);
            bool deleted = GetFileSystem().Delete(root, true);

            Log.Info("rm / of empty dir result is {}", deleted);
            ContractTestUtils.AssertIsDirectory(GetFileSystem(), root);
        }
        public virtual void TestDeleteNonEmptyDirNonRecursive()
        {
            Path path = Path("testDeleteNonEmptyDirNonRecursive");

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

            ContractTestUtils.WriteTextFile(GetFileSystem(), file, "goodbye, world", true);
            try
            {
                ContractTestUtils.RejectRootOperation(path);
                bool deleted = GetFileSystem().Delete(path, false);
                NUnit.Framework.Assert.Fail("non recursive delete should have raised an exception,"
                                            + " but completed with exit code " + deleted);
            }
            catch (IOException expected)
            {
                //expected
                HandleExpectedException(expected);
            }
            ContractTestUtils.AssertIsDirectory(GetFileSystem(), path);
        }
        public virtual void TestRmRootRecursive()
        {
            //extra sanity checks here to avoid support calls about complete loss of data
            SkipIfUnsupported(TestRootTestsEnabled);
            Path root = new Path("/");

            ContractTestUtils.AssertIsDirectory(GetFileSystem(), root);
            Path file = new Path("/testRmRootRecursive");

            ContractTestUtils.Touch(GetFileSystem(), file);
            bool deleted = GetFileSystem().Delete(root, true);

            ContractTestUtils.AssertIsDirectory(GetFileSystem(), root);
            Log.Info("rm -rf / result is {}", deleted);
            if (deleted)
            {
                AssertPathDoesNotExist("expected file to be deleted", file);
            }
            else
            {
                AssertPathExists("expected file to be preserved", file);
            }
        }
示例#6
0
 /// <summary>
 /// Assert that a file exists and whose
 /// <see cref="Org.Apache.Hadoop.FS.FileStatus"/>
 /// entry
 /// declares that this is a file and not a symlink or directory.
 /// </summary>
 /// <param name="path">name of the file</param>
 /// <exception cref="System.IO.IOException">IO problems during file operations</exception>
 protected internal virtual void AssertIsDirectory(Org.Apache.Hadoop.FS.Path path)
 {
     ContractTestUtils.AssertIsDirectory(fileSystem, path);
 }