public virtual void TestListStatus() { // Empty root directory CheckStatus("/"); // Root directory with files and directories CreateFile("/a", 1); CreateFile("/b", 1); Mkdirs("/dir"); CheckFile(new Path("/a")); CheckFile(new Path("/b")); CheckStatus("/"); // A directory with files and directories CreateFile("/dir/.a.crc", 1); CreateFile("/dir/b", 1); Mkdirs("/dir/dir1"); CheckFile(new Path("/dir/.a.crc")); CheckFile(new Path("/dir/b")); CheckStatus("/dir"); // Non existent path CheckStatus("/nonexistent"); CheckStatus("/nonexistent/a"); string username = UserGroupInformation.GetCurrentUser().GetShortUserName() + "1"; HftpFileSystem hftp2 = cluster.GetHftpFileSystemAs(username, Conf, 0, "somegroup" ); { //test file not found on hftp Path nonexistent = new Path("/nonexistent"); try { hftp2.GetFileStatus(nonexistent); NUnit.Framework.Assert.Fail(); } catch (IOException ioe) { FileSystem.Log.Info("GOOD: getting an exception", ioe); } } { //test permission error on hftp Path dir = new Path("/dir"); fs.SetPermission(dir, new FsPermission((short)0)); try { hftp2.GetFileStatus(new Path(dir, "a")); NUnit.Framework.Assert.Fail(); } catch (IOException ioe) { FileSystem.Log.Info("GOOD: getting an exception", ioe); } } }
/// <exception cref="System.IO.IOException"/> private void CheckFile(Path f) { Path hdfspath = fs.MakeQualified(f); FileStatus hdfsstatus = fs.GetFileStatus(hdfspath); FileSystem.Log.Info("hdfspath=" + hdfspath); Path hftppath = hftpFs.MakeQualified(f); FileStatus hftpstatus = hftpFs.GetFileStatus(hftppath); FileSystem.Log.Info("hftppath=" + hftppath); NUnit.Framework.Assert.AreEqual(hdfspath.ToUri().GetPath(), hdfsstatus.GetPath(). ToUri().GetPath()); CheckFileStatus(hdfsstatus, hftpstatus); }