public void HadoopFileSystemDeleteTest()
        {
            HadoopFileSystem fileSystem = new HadoopFileSystem(_hostname, _portNumber, _authentication);

            if (!fileSystem.IsConnected)
            {
                Assert.Inconclusive();
            }


            // existing path

            fileSystem.CreateDirectory(_directoryPath);

            Assert.IsTrue(fileSystem.Exists(_directoryPath));
            Assert.IsTrue(fileSystem.IsDirectory(_directoryPath));

            fileSystem.Delete(_directoryPath);

            Assert.IsFalse(fileSystem.Exists(_directoryPath));
            Assert.IsFalse(fileSystem.IsDirectory(_directoryPath));


            // exceptions

            Assert.Throws <ArgumentNullException>(() => fileSystem.Delete(null));
            Assert.Throws <ArgumentException>(() => fileSystem.Delete(String.Empty));
            Assert.Throws <ArgumentException>(() => fileSystem.Delete("InvalidPath"));
            Assert.Throws <ArgumentException>(() => fileSystem.Delete("/NotExistingPath"));
        }
예제 #2
0
        public void HadoopFileSystemDeleteTest()
        {
            HadoopFileSystem fileSystem = new HadoopFileSystem(this.hostname, this.portNumber, this.authentication);

            if (!fileSystem.IsConnected)
            {
                Assert.Inconclusive();
            }

            // existing path

            fileSystem.CreateDirectory(this.directoryPath);

            fileSystem.Exists(this.directoryPath).ShouldBeTrue();
            fileSystem.IsDirectory(this.directoryPath).ShouldBeTrue();

            fileSystem.Delete(this.directoryPath);

            fileSystem.Exists(this.directoryPath).ShouldBeFalse();
            fileSystem.IsDirectory(this.directoryPath).ShouldBeFalse();

            // exceptions

            Should.Throw <ArgumentNullException>(() => fileSystem.Delete(null));
            Should.Throw <ArgumentException>(() => fileSystem.Delete(String.Empty));
            Should.Throw <ArgumentException>(() => fileSystem.Delete("InvalidPath"));
            Should.Throw <ArgumentException>(() => fileSystem.Delete("/NotExistingPath"));
        }
        public void HadoopFileSystemCreateDirectoryTest()
        {
            HadoopFileSystem fileSystem = new HadoopFileSystem(_hostname, _portNumber, _authentication);

            if (!fileSystem.IsConnected)
            {
                Assert.Inconclusive();
            }


            // new directory

            Assert.IsFalse(fileSystem.Exists(_directoryPath));

            fileSystem.CreateDirectory(_directoryPath);

            Assert.IsTrue(fileSystem.Exists(_directoryPath));
            Assert.IsTrue(fileSystem.IsDirectory(_directoryPath));

            fileSystem.CreateDirectory(_directoryPath + "/InternalDirectory");

            Assert.IsTrue(fileSystem.Exists(_directoryPath + "/InternalDirectory"));
            Assert.IsTrue(fileSystem.IsDirectory(_directoryPath + "/InternalDirectory"));


            // existing directory

            fileSystem.CreateDirectory("/");
            fileSystem.CreateDirectory(_directoryPath);

            Assert.IsTrue(fileSystem.Exists(_directoryPath));

            fileSystem.Delete(_directoryPath);


            // multiple new directories

            fileSystem.CreateDirectory(_directoryPath + "/InternalDirectory");

            Assert.IsTrue(fileSystem.Exists(_directoryPath));
            Assert.IsTrue(fileSystem.Exists(_directoryPath + "/InternalDirectory"));

            fileSystem.Delete(_directoryPath);


            // exceptions

            Assert.Throws <ArgumentNullException>(() => fileSystem.CreateDirectory(null));
            Assert.Throws <ArgumentException>(() => fileSystem.CreateDirectory(String.Empty));
            Assert.Throws <ArgumentException>(() => fileSystem.CreateDirectory("InvalidPath"));
        }
        public void HadoopFileSystemGetDirectoryTest()
        {
            HadoopFileSystem fileSystem = new HadoopFileSystem(_hostname, _portNumber, _authentication);

            if (!fileSystem.IsConnected)
            {
                Assert.Inconclusive();
            }


            // valid parameters

            fileSystem.CreateDirectory(_directoryPath);
            fileSystem.CreateDirectory(_directoryPath + "/InternalDirectory");

            Assert.AreEqual("/", fileSystem.GetDirectory("/"));
            Assert.AreEqual(_directoryPath, fileSystem.GetDirectory(_directoryPath));
            Assert.AreEqual(_directoryPath, fileSystem.GetDirectory(_directoryPath + "/"));
            Assert.AreEqual(_directoryPath + "/InternalDirectory", fileSystem.GetDirectory(_directoryPath + "/InternalDirectory"));

            fileSystem.Delete(_directoryPath);


            // exceptions

            Assert.Throws <ArgumentNullException>(() => fileSystem.GetDirectory(null));
            Assert.Throws <ArgumentException>(() => fileSystem.GetDirectory(String.Empty));
            Assert.Throws <ArgumentException>(() => fileSystem.GetDirectory(":"));
            Assert.Throws <ArgumentException>(() => fileSystem.GetDirectory("/NotExistingPath/"));
        }
예제 #5
0
        public void TestCopyFromLocalAndBack()
        {
            var localFile           = FileSystemTestUtilities.MakeLocalTempFile();
            var localFileDownloaded = localFile + ".2";
            var remoteUri           = GetTempUri();

            _fileSystem.CopyFromLocal(localFile, remoteUri);
            _fileSystem.CopyToLocal(remoteUri, localFileDownloaded);

            Assert.True(File.Exists(localFileDownloaded), "A file up and downloaded should exist on the local file system.");
            Assert.True(FileSystemTestUtilities.HaveSameContent(localFile, localFileDownloaded), "A file up and downloaded should not have changed content.");

            _fileSystem.Delete(remoteUri);
            File.Delete(localFile);
            File.Delete(localFileDownloaded);
        }
예제 #6
0
        public void HadoopFileSystemGetDirectoryTest()
        {
            HadoopFileSystem fileSystem = new HadoopFileSystem(this.hostname, this.portNumber, this.authentication);

            if (!fileSystem.IsConnected)
            {
                Assert.Inconclusive();
            }

            // valid parameters

            fileSystem.CreateDirectory(this.directoryPath);
            fileSystem.CreateDirectory(this.directoryPath + "/InternalDirectory");

            fileSystem.GetDirectory("/").ShouldBe("/");
            fileSystem.GetDirectory(this.directoryPath).ShouldBe(this.directoryPath);
            fileSystem.GetDirectory(this.directoryPath + "/").ShouldBe(this.directoryPath);
            fileSystem.GetDirectory(this.directoryPath + "/InternalDirectory").ShouldBe(this.directoryPath + "/InternalDirectory");

            fileSystem.Delete(this.directoryPath);

            // exceptions

            Should.Throw <ArgumentNullException>(() => fileSystem.GetDirectory(null));
            Should.Throw <ArgumentException>(() => fileSystem.GetDirectory(String.Empty));
            Should.Throw <ArgumentException>(() => fileSystem.GetDirectory(":"));
            Should.Throw <ArgumentException>(() => fileSystem.GetDirectory("/NotExistingPath/"));
        }
        public void TearDown()
        {
            HadoopFileSystem fileSystem = new HadoopFileSystem(_hostname, _portNumber, _authentication);

            // remove the test directory
            if (fileSystem.IsConnected && fileSystem.Exists(_directoryPath))
            {
                fileSystem.Delete(_directoryPath);
            }
        }
예제 #8
0
        public void HadoopFileSystemGetFileSystemEntriesTest()
        {
            HadoopFileSystem fileSystem = new HadoopFileSystem(this.hostname, this.portNumber, this.authentication);

            if (!fileSystem.IsConnected)
            {
                Assert.Inconclusive();
            }

            // empty directory

            fileSystem.CreateDirectory(this.directoryPath);
            fileSystem.GetFileSystemEntries(this.directoryPath).ShouldBeEmpty();

            // only directories

            fileSystem.CreateDirectory(this.directoryPath + "/InnerDirectory1");
            fileSystem.CreateDirectory(this.directoryPath + "/InnerDirectory2");

            FileSystemEntry[] directories = fileSystem.GetFileSystemEntries(this.directoryPath);

            directories.Length.ShouldBe(2);
            directories[0].Path.ShouldBe(this.directoryPath + "/InnerDirectory1");
            directories[1].Path.ShouldBe(this.directoryPath + "/InnerDirectory2");

            // with search pattern

            directories = fileSystem.GetFileSystemEntries(this.directoryPath, "*1", false);

            directories.Length.ShouldBe(1);
            directories[0].Path.ShouldBe(this.directoryPath + "/InnerDirectory1");

            // recursive

            fileSystem.CreateDirectory(this.directoryPath + "/InnerDirectory1/DeepInnerDirectory1");
            fileSystem.CreateDirectory(this.directoryPath + "/InnerDirectory1/DeepInnerDirectory2");

            directories = fileSystem.GetFileSystemEntries(this.directoryPath, "*", true);

            directories.Length.ShouldBe(4);
            directories[0].Path.ShouldBe(this.directoryPath + "/InnerDirectory1");
            directories[1].Path.ShouldBe(this.directoryPath + "/InnerDirectory1/DeepInnerDirectory1");
            directories[2].Path.ShouldBe(this.directoryPath + "/InnerDirectory1/DeepInnerDirectory2");
            directories[3].Path.ShouldBe(this.directoryPath + "/InnerDirectory2");

            fileSystem.Delete(this.directoryPath);

            // exceptions

            Should.Throw <ArgumentNullException>(() => fileSystem.GetFileSystemEntries(null));
            Should.Throw <ArgumentException>(() => fileSystem.GetFileSystemEntries(String.Empty));
            Should.Throw <ArgumentException>(() => fileSystem.GetFileSystemEntries(":"));
            Should.Throw <ArgumentException>(() => fileSystem.GetFileSystemEntries("/NotExistingPath/"));
        }
        public void HadoopFileSystemGetFileSystemEntriesTest()
        {
            HadoopFileSystem fileSystem = new HadoopFileSystem(_hostname, _portNumber, _authentication);

            if (!fileSystem.IsConnected)
            {
                Assert.Inconclusive();
            }


            // empty directory

            fileSystem.CreateDirectory(_directoryPath);

            Assert.AreEqual(0, fileSystem.GetFileSystemEntries(_directoryPath).Length);


            // only directories

            fileSystem.CreateDirectory(_directoryPath + "/InnerDirectory1");
            fileSystem.CreateDirectory(_directoryPath + "/InnerDirectory2");

            FileSystemEntry[] directories = fileSystem.GetFileSystemEntries(_directoryPath);

            Assert.AreEqual(2, directories.Length);
            Assert.AreEqual(_directoryPath + "/InnerDirectory1", directories[0].Path);
            Assert.AreEqual(_directoryPath + "/InnerDirectory2", directories[1].Path);


            // with search pattern

            directories = fileSystem.GetFileSystemEntries(_directoryPath, "*1", false);

            Assert.AreEqual(1, directories.Length);
            Assert.AreEqual(_directoryPath + "/InnerDirectory1", directories[0].Path);


            // recursive

            fileSystem.CreateDirectory(_directoryPath + "/InnerDirectory1/DeepInnerDirectory1");
            fileSystem.CreateDirectory(_directoryPath + "/InnerDirectory1/DeepInnerDirectory2");

            directories = fileSystem.GetFileSystemEntries(_directoryPath, "*", true);

            Assert.AreEqual(4, directories.Length);
            Assert.AreEqual(_directoryPath + "/InnerDirectory1", directories[0].Path);
            Assert.AreEqual(_directoryPath + "/InnerDirectory1/DeepInnerDirectory1", directories[1].Path);
            Assert.AreEqual(_directoryPath + "/InnerDirectory1/DeepInnerDirectory2", directories[2].Path);
            Assert.AreEqual(_directoryPath + "/InnerDirectory2", directories[3].Path);


            fileSystem.Delete(_directoryPath);


            // exceptions

            Assert.Throws <ArgumentNullException>(() => fileSystem.GetFileSystemEntries(null));
            Assert.Throws <ArgumentException>(() => fileSystem.GetFileSystemEntries(String.Empty));
            Assert.Throws <ArgumentException>(() => fileSystem.GetFileSystemEntries(":"));
            Assert.Throws <ArgumentException>(() => fileSystem.GetFileSystemEntries("/NotExistingPath/"));
        }