示例#1
0
        /// <exception cref="System.Exception"/>
        private void _testInputFiles(bool withFilter, bool withGlob)
        {
            ICollection <Path> createdFiles = CreateFiles();
            JobConf            conf         = new JobConf();
            Path inputDir = (withGlob) ? new Path(workDir, "a*") : workDir;

            FileInputFormat.SetInputPaths(conf, inputDir);
            conf.SetInputFormat(typeof(TestFileInputFormatPathFilter.DummyFileInputFormat));
            if (withFilter)
            {
                FileInputFormat.SetInputPathFilter(conf, typeof(TestFileInputFormatPathFilter.TestPathFilter
                                                                ));
            }
            TestFileInputFormatPathFilter.DummyFileInputFormat inputFormat = (TestFileInputFormatPathFilter.DummyFileInputFormat
                                                                              )conf.GetInputFormat();
            ICollection <Path> computedFiles = new HashSet <Path>();

            foreach (FileStatus file in inputFormat.ListStatus(conf))
            {
                computedFiles.AddItem(file.GetPath());
            }
            createdFiles.Remove(localFs.MakeQualified(new Path(workDir, "_hello")));
            createdFiles.Remove(localFs.MakeQualified(new Path(workDir, ".hello")));
            if (withFilter)
            {
                createdFiles.Remove(localFs.MakeQualified(new Path(workDir, "aa")));
                createdFiles.Remove(localFs.MakeQualified(new Path(workDir, "bb")));
            }
            if (withGlob)
            {
                createdFiles.Remove(localFs.MakeQualified(new Path(workDir, "b")));
                createdFiles.Remove(localFs.MakeQualified(new Path(workDir, "bb")));
            }
            NUnit.Framework.Assert.AreEqual(createdFiles, computedFiles);
        }