예제 #1
0
        public virtual void TestDirectory()
        {
            fc.Mkdir(Dir1, FsPermission.GetDefault(), true);
            // test empty directory
            RemoteIterator <LocatedFileStatus> itor = fc.Util().ListFiles(Dir1, true);

            NUnit.Framework.Assert.IsFalse(itor.HasNext());
            itor = fc.Util().ListFiles(Dir1, false);
            NUnit.Framework.Assert.IsFalse(itor.HasNext());
            // testing directory with 1 file
            WriteFile(fc, File2, FileLen);
            itor = fc.Util().ListFiles(Dir1, true);
            LocatedFileStatus stat = itor.Next();

            NUnit.Framework.Assert.IsFalse(itor.HasNext());
            NUnit.Framework.Assert.IsTrue(stat.IsFile());
            NUnit.Framework.Assert.AreEqual(FileLen, stat.GetLen());
            NUnit.Framework.Assert.AreEqual(fc.MakeQualified(File2), stat.GetPath());
            NUnit.Framework.Assert.AreEqual(1, stat.GetBlockLocations().Length);
            itor = fc.Util().ListFiles(Dir1, false);
            stat = itor.Next();
            NUnit.Framework.Assert.IsFalse(itor.HasNext());
            NUnit.Framework.Assert.IsTrue(stat.IsFile());
            NUnit.Framework.Assert.AreEqual(FileLen, stat.GetLen());
            NUnit.Framework.Assert.AreEqual(fc.MakeQualified(File2), stat.GetPath());
            NUnit.Framework.Assert.AreEqual(1, stat.GetBlockLocations().Length);
            // test more complicated directory
            WriteFile(fc, File1, FileLen);
            WriteFile(fc, File3, FileLen);
            itor = fc.Util().ListFiles(TestDir, true);
            stat = itor.Next();
            NUnit.Framework.Assert.IsTrue(stat.IsFile());
            NUnit.Framework.Assert.AreEqual(fc.MakeQualified(File2), stat.GetPath());
            stat = itor.Next();
            NUnit.Framework.Assert.IsTrue(stat.IsFile());
            NUnit.Framework.Assert.AreEqual(fc.MakeQualified(File3), stat.GetPath());
            stat = itor.Next();
            NUnit.Framework.Assert.IsTrue(stat.IsFile());
            NUnit.Framework.Assert.AreEqual(fc.MakeQualified(File1), stat.GetPath());
            NUnit.Framework.Assert.IsFalse(itor.HasNext());
            itor = fc.Util().ListFiles(TestDir, false);
            stat = itor.Next();
            NUnit.Framework.Assert.IsTrue(stat.IsFile());
            NUnit.Framework.Assert.AreEqual(fc.MakeQualified(File1), stat.GetPath());
            NUnit.Framework.Assert.IsFalse(itor.HasNext());
        }
예제 #2
0
        public virtual void TestFile()
        {
            fc.Mkdir(TestDir, FsPermission.GetDefault(), true);
            WriteFile(fc, File1, FileLen);
            RemoteIterator <LocatedFileStatus> itor = fc.Util().ListFiles(File1, true);
            LocatedFileStatus stat = itor.Next();

            NUnit.Framework.Assert.IsFalse(itor.HasNext());
            NUnit.Framework.Assert.IsTrue(stat.IsFile());
            NUnit.Framework.Assert.AreEqual(FileLen, stat.GetLen());
            NUnit.Framework.Assert.AreEqual(fc.MakeQualified(File1), stat.GetPath());
            NUnit.Framework.Assert.AreEqual(1, stat.GetBlockLocations().Length);
            itor = fc.Util().ListFiles(File1, false);
            stat = itor.Next();
            NUnit.Framework.Assert.IsFalse(itor.HasNext());
            NUnit.Framework.Assert.IsTrue(stat.IsFile());
            NUnit.Framework.Assert.AreEqual(FileLen, stat.GetLen());
            NUnit.Framework.Assert.AreEqual(fc.MakeQualified(File1), stat.GetPath());
            NUnit.Framework.Assert.AreEqual(1, stat.GetBlockLocations().Length);
        }
 public override long GetLen()
 {
     return(myFs.GetLen());
 }