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" )); }
public virtual void TestDeleteSingleFile() { // Test delete of just a file Path path = Path("testDeleteSingleFile/d1/d2"); Mkdirs(path); Path file = new Path(path, "childfile"); ContractTestUtils.WriteTextFile(GetFileSystem(), file, "single file to be deleted." , true); ContractTestUtils.AssertPathExists(GetFileSystem(), "single file not created", file ); AssertDeleted(file, false); }
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" )); }
/// <summary>assert that a path exists</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 AssertPathExists(string message, Org.Apache.Hadoop.FS.Path path ) { ContractTestUtils.AssertPathExists(fileSystem, message, path); }