Example #1
0
        public virtual void TestEmptyDownload()
        {
            JobConf conf = new JobConf();

            conf.SetClass("fs.mock.impl", typeof(TestLocalDistributedCacheManager.MockFileSystem
                                                 ), typeof(FileSystem));
            URI mockBase = new URI("mock://test-nn1/");

            Org.Mockito.Mockito.When(mockfs.GetUri()).ThenReturn(mockBase);
            Path working = new Path("mock://test-nn1/user/me/");

            Org.Mockito.Mockito.When(mockfs.GetWorkingDirectory()).ThenReturn(working);
            Org.Mockito.Mockito.When(mockfs.ResolvePath(Matchers.Any <Path>())).ThenAnswer(new
                                                                                           _Answer_190());
            Org.Mockito.Mockito.When(mockfs.GetFileStatus(Matchers.Any <Path>())).ThenAnswer(new
                                                                                             _Answer_197());
            Org.Mockito.Mockito.When(mockfs.GetConf()).ThenReturn(conf);
            Org.Mockito.Mockito.When(mockfs.Open(Matchers.Any <Path>(), Matchers.AnyInt())).ThenAnswer
                (new _Answer_206());
            conf.Set(MRJobConfig.CacheFiles, string.Empty);
            conf.Set(MRConfig.LocalDir, localDir.GetAbsolutePath());
            LocalDistributedCacheManager manager = new LocalDistributedCacheManager();

            try
            {
                manager.Setup(conf);
            }
            finally
            {
                manager.Close();
            }
        }
Example #2
0
        public virtual void TestDuplicateDownload()
        {
            JobConf conf = new JobConf();

            conf.SetClass("fs.mock.impl", typeof(TestLocalDistributedCacheManager.MockFileSystem
                                                 ), typeof(FileSystem));
            URI mockBase = new URI("mock://test-nn1/");

            Org.Mockito.Mockito.When(mockfs.GetUri()).ThenReturn(mockBase);
            Path working = new Path("mock://test-nn1/user/me/");

            Org.Mockito.Mockito.When(mockfs.GetWorkingDirectory()).ThenReturn(working);
            Org.Mockito.Mockito.When(mockfs.ResolvePath(Matchers.Any <Path>())).ThenAnswer(new
                                                                                           _Answer_234());
            URI      file     = new URI("mock://test-nn1/user/me/file.txt#link");
            Path     filePath = new Path(file);
            FilePath link     = new FilePath("link");

            Org.Mockito.Mockito.When(mockfs.GetFileStatus(Matchers.Any <Path>())).ThenAnswer(new
                                                                                             _Answer_245(filePath));
            Org.Mockito.Mockito.When(mockfs.GetConf()).ThenReturn(conf);
            FSDataInputStream @in = new FSDataInputStream(new TestLocalDistributedCacheManager.MockInputStream
                                                              (Sharpen.Runtime.GetBytesForString("This is a test file\n")));

            Org.Mockito.Mockito.When(mockfs.Open(Matchers.Any <Path>(), Matchers.AnyInt())).ThenAnswer
                (new _Answer_261(@in));
            DistributedCache.AddCacheFile(file, conf);
            DistributedCache.AddCacheFile(file, conf);
            conf.Set(MRJobConfig.CacheFileTimestamps, "101,101");
            conf.Set(MRJobConfig.CacheFilesSizes, "201,201");
            conf.Set(MRJobConfig.CacheFileVisibilities, "false,false");
            conf.Set(MRConfig.LocalDir, localDir.GetAbsolutePath());
            LocalDistributedCacheManager manager = new LocalDistributedCacheManager();

            try
            {
                manager.Setup(conf);
                NUnit.Framework.Assert.IsTrue(link.Exists());
            }
            finally
            {
                manager.Close();
            }
            NUnit.Framework.Assert.IsFalse(link.Exists());
        }