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

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


            // valid parameters

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

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

            fileSystem.Delete(_directoryPath);


            // exceptions

            Assert.Throws <ArgumentNullException>(() => fileSystem.GetParent(null));
            Assert.Throws <ArgumentException>(() => fileSystem.GetParent(String.Empty));
            Assert.Throws <ArgumentException>(() => fileSystem.GetParent(":"));
            Assert.Throws <ArgumentException>(() => fileSystem.GetParent("/NotExistingPath/"));
        }
示例#2
0
        public void HadoopFileSystemGetParentTest()
        {
            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.GetParent("/").ShouldBeNull();
            fileSystem.GetParent(this.directoryPath).ShouldBe("/");
            fileSystem.GetParent(this.directoryPath + "/").ShouldBe("/");
            fileSystem.GetParent(this.directoryPath + "/InternalDirectory").ShouldBe(this.directoryPath);
            fileSystem.GetParent(this.directoryPath + "/InternalDirectory/").ShouldBe(this.directoryPath);

            fileSystem.Delete(this.directoryPath);

            // exceptions

            Should.Throw <ArgumentNullException>(() => fileSystem.GetParent(null));
            Should.Throw <ArgumentException>(() => fileSystem.GetParent(String.Empty));
            Should.Throw <ArgumentException>(() => fileSystem.GetParent(":"));
            Should.Throw <ArgumentException>(() => fileSystem.GetParent("/NotExistingPath/"));
        }