コード例 #1
0
        /*
         * return the ViewFS File context to be used for tests
         */
        /// <exception cref="System.Exception"/>
        public static FileContext SetupForViewFsLocalFs(FileContextTestHelper helper)
        {
            FileContext fsTarget      = FileContext.GetLocalFSFileContext();
            Path        targetOfTests = helper.GetTestRootPath(fsTarget);

            // In case previous test was killed before cleanup
            fsTarget.Delete(targetOfTests, true);
            fsTarget.Mkdir(targetOfTests, FileContext.DefaultPerm, true);
            Configuration conf = new Configuration();
            // Set up viewfs link for test dir as described above
            string testDir = helper.GetTestRootPath(fsTarget).ToUri().GetPath();

            LinkUpFirstComponents(conf, testDir, fsTarget, "test dir");
            // Set up viewfs link for home dir as described above
            SetUpHomeDir(conf, fsTarget);
            // the test path may be relative to working dir - we need to make that work:
            // Set up viewfs link for wd as described above
            string wdDir = fsTarget.GetWorkingDirectory().ToUri().GetPath();

            LinkUpFirstComponents(conf, wdDir, fsTarget, "working dir");
            FileContext fc = FileContext.GetFileContext(FsConstants.ViewfsUri, conf);

            fc.SetWorkingDirectory(new Path(wdDir));
            // in case testdir relative to wd.
            Org.Mortbay.Log.Log.Info("Working dir is: " + fc.GetWorkingDirectory());
            //System.out.println("SRCOfTests = "+ getTestRootPath(fc, "test"));
            //System.out.println("TargetOfTests = "+ targetOfTests.toUri());
            return(fc);
        }
コード例 #2
0
        /// <summary>delete the test directory in the target local fs</summary>
        /// <exception cref="System.Exception"/>
        public static void TearDownForViewFsLocalFs(FileContextTestHelper helper)
        {
            FileContext fclocal       = FileContext.GetLocalFSFileContext();
            Path        targetOfTests = helper.GetTestRootPath(fclocal);

            fclocal.Delete(targetOfTests, true);
        }
コード例 #3
0
ファイル: TestChRootedFs.cs プロジェクト: orf53975/hadoop.net
 public virtual void TestMkdirDelete()
 {
     fc.Mkdir(fileContextTestHelper.GetTestRootPath(fc, "/dirX"), FileContext.DefaultPerm
              , false);
     Assert.True(FileContextTestHelper.IsDir(fc, new Path("/dirX")));
     Assert.True(FileContextTestHelper.IsDir(fcTarget, new Path(chrootedTo
                                                                , "dirX")));
     fc.Mkdir(fileContextTestHelper.GetTestRootPath(fc, "/dirX/dirY"), FileContext.DefaultPerm
              , false);
     Assert.True(FileContextTestHelper.IsDir(fc, new Path("/dirX/dirY"
                                                          )));
     Assert.True(FileContextTestHelper.IsDir(fcTarget, new Path(chrootedTo
                                                                , "dirX/dirY")));
     // Delete the created dir
     Assert.True(fc.Delete(new Path("/dirX/dirY"), false));
     NUnit.Framework.Assert.IsFalse(FileContextTestHelper.Exists(fc, new Path("/dirX/dirY"
                                                                              )));
     NUnit.Framework.Assert.IsFalse(FileContextTestHelper.Exists(fcTarget, new Path(chrootedTo
                                                                                    , "dirX/dirY")));
     Assert.True(fc.Delete(new Path("/dirX"), false));
     NUnit.Framework.Assert.IsFalse(FileContextTestHelper.Exists(fc, new Path("/dirX")
                                                                 ));
     NUnit.Framework.Assert.IsFalse(FileContextTestHelper.Exists(fcTarget, new Path(chrootedTo
                                                                                    , "dirX")));
 }
コード例 #4
0
 public virtual void TearDown()
 {
     fcTarget.Delete(fileContextTestHelper.GetTestRootPath(fcTarget), true);
     fcTarget2.Delete(fileContextTestHelper.GetTestRootPath(fcTarget2), true);
 }