示例#1
0
 public virtual void TestCreateDelete()
 {
     // Create file
     fileContextTestHelper.CreateFileNonRecursive(fc, "/foo");
     Assert.True(FileContextTestHelper.IsFile(fc, new Path("/foo")));
     Assert.True(FileContextTestHelper.IsFile(fcTarget, new Path(chrootedTo
                                                                 , "foo")));
     // Create file with recursive dir
     fileContextTestHelper.CreateFile(fc, "/newDir/foo");
     Assert.True(FileContextTestHelper.IsFile(fc, new Path("/newDir/foo"
                                                           )));
     Assert.True(FileContextTestHelper.IsFile(fcTarget, new Path(chrootedTo
                                                                 , "newDir/foo")));
     // Delete the created file
     Assert.True(fc.Delete(new Path("/newDir/foo"), false));
     NUnit.Framework.Assert.IsFalse(FileContextTestHelper.Exists(fc, new Path("/newDir/foo"
                                                                              )));
     NUnit.Framework.Assert.IsFalse(FileContextTestHelper.Exists(fcTarget, new Path(chrootedTo
                                                                                    , "newDir/foo")));
     // Create file with a 2 component dirs recursively
     fileContextTestHelper.CreateFile(fc, "/newDir/newDir2/foo");
     Assert.True(FileContextTestHelper.IsFile(fc, new Path("/newDir/newDir2/foo"
                                                           )));
     Assert.True(FileContextTestHelper.IsFile(fcTarget, new Path(chrootedTo
                                                                 , "newDir/newDir2/foo")));
     // Delete the created file
     Assert.True(fc.Delete(new Path("/newDir/newDir2/foo"), false));
     NUnit.Framework.Assert.IsFalse(FileContextTestHelper.Exists(fc, new Path("/newDir/newDir2/foo"
                                                                              )));
     NUnit.Framework.Assert.IsFalse(FileContextTestHelper.Exists(fcTarget, new Path(chrootedTo
                                                                                    , "newDir/newDir2/foo")));
 }
示例#2
0
        public virtual void TestOperationsThroughMountLinks()
        {
            // Create file
            fileContextTestHelper.CreateFileNonRecursive(fcView, "/user/foo");
            Assert.True("Create file should be file", FileContextTestHelper.IsFile
                            (fcView, new Path("/user/foo")));
            Assert.True("Target of created file should be type file", FileContextTestHelper.IsFile
                            (fcTarget, new Path(targetTestRoot, "user/foo")));
            // Delete the created file
            Assert.True("Delete should succeed", fcView.Delete(new Path("/user/foo"
                                                                        ), false));
            NUnit.Framework.Assert.IsFalse("File should not exist after delete", FileContextTestHelper.Exists
                                               (fcView, new Path("/user/foo")));
            NUnit.Framework.Assert.IsFalse("Target File should not exist after delete", FileContextTestHelper.Exists
                                               (fcTarget, new Path(targetTestRoot, "user/foo")));
            // Create file with a 2 component dirs
            fileContextTestHelper.CreateFileNonRecursive(fcView, "/internalDir/linkToDir2/foo"
                                                         );
            Assert.True("Created file should be type file", FileContextTestHelper.IsFile
                            (fcView, new Path("/internalDir/linkToDir2/foo")));
            Assert.True("Target of created file should be type file", FileContextTestHelper.IsFile
                            (fcTarget, new Path(targetTestRoot, "dir2/foo")));
            // Delete the created file
            Assert.True("Delete should suceed", fcView.Delete(new Path("/internalDir/linkToDir2/foo"
                                                                       ), false));
            NUnit.Framework.Assert.IsFalse("File should not exist after deletion", FileContextTestHelper.Exists
                                               (fcView, new Path("/internalDir/linkToDir2/foo")));
            NUnit.Framework.Assert.IsFalse("Target should not exist after deletion", FileContextTestHelper.Exists
                                               (fcTarget, new Path(targetTestRoot, "dir2/foo")));
            // Create file with a 3 component dirs
            fileContextTestHelper.CreateFileNonRecursive(fcView, "/internalDir/internalDir2/linkToDir3/foo"
                                                         );
            Assert.True("Created file should be of type file", FileContextTestHelper.IsFile
                            (fcView, new Path("/internalDir/internalDir2/linkToDir3/foo")));
            Assert.True("Target of created file should also be type file",
                        FileContextTestHelper.IsFile(fcTarget, new Path(targetTestRoot, "dir3/foo")));
            // Recursive Create file with missing dirs
            fileContextTestHelper.CreateFile(fcView, "/internalDir/linkToDir2/missingDir/miss2/foo"
                                             );
            Assert.True("Created file should be of type file", FileContextTestHelper.IsFile
                            (fcView, new Path("/internalDir/linkToDir2/missingDir/miss2/foo")));
            Assert.True("Target of created file should also be type file",
                        FileContextTestHelper.IsFile(fcTarget, new Path(targetTestRoot, "dir2/missingDir/miss2/foo"
                                                                        )));
            // Delete the created file
            Assert.True("Delete should succeed", fcView.Delete(new Path("/internalDir/internalDir2/linkToDir3/foo"
                                                                        ), false));
            NUnit.Framework.Assert.IsFalse("Deleted File should not exist", FileContextTestHelper.Exists
                                               (fcView, new Path("/internalDir/internalDir2/linkToDir3/foo")));
            NUnit.Framework.Assert.IsFalse("Target of deleted file should not exist", FileContextTestHelper.Exists
                                               (fcTarget, new Path(targetTestRoot, "dir3/foo")));
            // mkdir
            fcView.Mkdir(fileContextTestHelper.GetTestRootPath(fcView, "/user/dirX"), FileContext
                         .DefaultPerm, false);
            Assert.True("New dir should be type dir", FileContextTestHelper.IsDir
                            (fcView, new Path("/user/dirX")));
            Assert.True("Target of new dir should be of type dir", FileContextTestHelper.IsDir
                            (fcTarget, new Path(targetTestRoot, "user/dirX")));
            fcView.Mkdir(fileContextTestHelper.GetTestRootPath(fcView, "/user/dirX/dirY"), FileContext
                         .DefaultPerm, false);
            Assert.True("New dir should be type dir", FileContextTestHelper.IsDir
                            (fcView, new Path("/user/dirX/dirY")));
            Assert.True("Target of new dir should be of type dir", FileContextTestHelper.IsDir
                            (fcTarget, new Path(targetTestRoot, "user/dirX/dirY")));
            // Delete the created dir
            Assert.True("Delete should succeed", fcView.Delete(new Path("/user/dirX/dirY"
                                                                        ), false));
            NUnit.Framework.Assert.IsFalse("Deleted File should not exist", FileContextTestHelper.Exists
                                               (fcView, new Path("/user/dirX/dirY")));
            NUnit.Framework.Assert.IsFalse("Deleted Target should not exist", FileContextTestHelper.Exists
                                               (fcTarget, new Path(targetTestRoot, "user/dirX/dirY")));
            Assert.True("Delete should succeed", fcView.Delete(new Path("/user/dirX"
                                                                        ), false));
            NUnit.Framework.Assert.IsFalse("Deleted File should not exist", FileContextTestHelper.Exists
                                               (fcView, new Path("/user/dirX")));
            NUnit.Framework.Assert.IsFalse("Deleted Target should not exist", FileContextTestHelper.Exists
                                               (fcTarget, new Path(targetTestRoot, "user/dirX")));
            // Rename a file
            fileContextTestHelper.CreateFile(fcView, "/user/foo");
            fcView.Rename(new Path("/user/foo"), new Path("/user/fooBar"));
            NUnit.Framework.Assert.IsFalse("Renamed src should not exist", FileContextTestHelper.Exists
                                               (fcView, new Path("/user/foo")));
            NUnit.Framework.Assert.IsFalse(FileContextTestHelper.Exists(fcTarget, new Path(targetTestRoot
                                                                                           , "user/foo")));
            Assert.True(FileContextTestHelper.IsFile(fcView, fileContextTestHelper
                                                     .GetTestRootPath(fcView, "/user/fooBar")));
            Assert.True(FileContextTestHelper.IsFile(fcTarget, new Path(targetTestRoot
                                                                        , "user/fooBar")));
            fcView.Mkdir(new Path("/user/dirFoo"), FileContext.DefaultPerm, false);
            fcView.Rename(new Path("/user/dirFoo"), new Path("/user/dirFooBar"));
            NUnit.Framework.Assert.IsFalse("Renamed src should not exist", FileContextTestHelper.Exists
                                               (fcView, new Path("/user/dirFoo")));
            NUnit.Framework.Assert.IsFalse("Renamed src should not exist in target", FileContextTestHelper.Exists
                                               (fcTarget, new Path(targetTestRoot, "user/dirFoo")));
            Assert.True("Renamed dest should  exist as dir", FileContextTestHelper.IsDir
                            (fcView, fileContextTestHelper.GetTestRootPath(fcView, "/user/dirFooBar")));
            Assert.True("Renamed dest should  exist as dir in target", FileContextTestHelper.IsDir
                            (fcTarget, new Path(targetTestRoot, "user/dirFooBar")));
            // Make a directory under a directory that's mounted from the root of another FS
            fcView.Mkdir(new Path("/targetRoot/dirFoo"), FileContext.DefaultPerm, false);
            Assert.True(FileContextTestHelper.Exists(fcView, new Path("/targetRoot/dirFoo"
                                                                      )));
            bool dirFooPresent = false;
            RemoteIterator <FileStatus> dirContents = fcView.ListStatus(new Path("/targetRoot/"
                                                                                 ));

            while (dirContents.HasNext())
            {
                FileStatus fileStatus = dirContents.Next();
                if (fileStatus.GetPath().GetName().Equals("dirFoo"))
                {
                    dirFooPresent = true;
                }
            }
            Assert.True(dirFooPresent);
        }