Пример #1
0
        public virtual void TestAclMethodsPathTranslation()
        {
            Configuration conf = new Configuration();

            conf.SetClass("fs.mockfs.impl", typeof(TestChRootedFileSystem.MockFileSystem), typeof(
                              FileSystem));
            URI chrootUri = URI.Create("mockfs://foo/a/b");
            ChRootedFileSystem chrootFs = new ChRootedFileSystem(chrootUri, conf);
            FileSystem         mockFs   = ((FilterFileSystem)chrootFs.GetRawFileSystem()).GetRawFileSystem
                                              ();
            Path             chrootPath = new Path("/c");
            Path             rawPath    = new Path("/a/b/c");
            IList <AclEntry> entries    = Collections.EmptyList();

            chrootFs.ModifyAclEntries(chrootPath, entries);
            Org.Mockito.Mockito.Verify(mockFs).ModifyAclEntries(rawPath, entries);
            chrootFs.RemoveAclEntries(chrootPath, entries);
            Org.Mockito.Mockito.Verify(mockFs).RemoveAclEntries(rawPath, entries);
            chrootFs.RemoveDefaultAcl(chrootPath);
            Org.Mockito.Mockito.Verify(mockFs).RemoveDefaultAcl(rawPath);
            chrootFs.RemoveAcl(chrootPath);
            Org.Mockito.Mockito.Verify(mockFs).RemoveAcl(rawPath);
            chrootFs.SetAcl(chrootPath, entries);
            Org.Mockito.Mockito.Verify(mockFs).SetAcl(rawPath, entries);
            chrootFs.GetAclStatus(chrootPath);
            Org.Mockito.Mockito.Verify(mockFs).GetAclStatus(rawPath);
        }
Пример #2
0
        public virtual void TestDeleteOnExitPathHandling()
        {
            Configuration conf = new Configuration();

            conf.SetClass("fs.mockfs.impl", typeof(TestChRootedFileSystem.MockFileSystem), typeof(
                              FileSystem));
            URI chrootUri = URI.Create("mockfs://foo/a/b");
            ChRootedFileSystem chrootFs = new ChRootedFileSystem(chrootUri, conf);
            FileSystem         mockFs   = ((FilterFileSystem)chrootFs.GetRawFileSystem()).GetRawFileSystem
                                              ();
            // ensure delete propagates the correct path
            Path chrootPath = new Path("/c");
            Path rawPath    = new Path("/a/b/c");

            chrootFs.Delete(chrootPath, false);
            Org.Mockito.Mockito.Verify(mockFs).Delete(Eq(rawPath), Eq(false));
            Org.Mockito.Mockito.Reset(mockFs);
            // fake that the path exists for deleteOnExit
            FileStatus stat = Org.Mockito.Mockito.Mock <FileStatus>();

            Org.Mockito.Mockito.When(mockFs.GetFileStatus(Eq(rawPath))).ThenReturn(stat);
            // ensure deleteOnExit propagates the correct path
            chrootFs.DeleteOnExit(chrootPath);
            chrootFs.Close();
            Org.Mockito.Mockito.Verify(mockFs).Delete(Eq(rawPath), Eq(true));
        }