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 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/")); }
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 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")); }
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 TestGetChildren() { // Make a directory var remoteDirectory = GetTempUri(); _fileSystem.CreateDirectory(remoteDirectory); // Check that it is empty Assert.AreEqual(message: "The directory should be empty.", expected: 0, actual: _fileSystem.GetChildren(remoteDirectory).Count()); // Upload some localfile there var localTempFile = FileSystemTestUtilities.MakeLocalTempFile(); var remoteUri = new Uri(remoteDirectory, Path.GetFileName(localTempFile)); _fileSystem.CopyFromLocal(localTempFile, remoteUri); // Check that it is on the listing var uriInResult = _fileSystem.GetChildren(remoteUri).First(); Assert.AreEqual(remoteUri, uriInResult); // Download the file and make sure it is the same as before var downloadedFileName = localTempFile + ".downloaded"; _fileSystem.CopyToLocal(uriInResult, downloadedFileName); FileSystemTestUtilities.HaveSameContent(localTempFile, downloadedFileName); File.Delete(localTempFile); File.Delete(downloadedFileName); // Delete the file _fileSystem.Delete(remoteUri); // Check that the folder is empty again Assert.AreEqual(message: "The directory should be empty.", expected: 0, actual: _fileSystem.GetChildren(remoteDirectory).Count()); // Delete the folder _fileSystem.DeleteDirectory(remoteDirectory); }
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/")); }