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 TestExists() { var remoteUri = GetTempUri(); Assert.False(_fileSystem.Exists(remoteUri), "The file should not exist yet"); var localFile = FileSystemTestUtilities.MakeLocalTempFile(); _fileSystem.CopyFromLocal(localFile, remoteUri); Assert.True(_fileSystem.Exists(remoteUri), "The file should now exist"); _fileSystem.Delete(remoteUri); Assert.False(_fileSystem.Exists(remoteUri), "The file should no longer exist"); File.Delete(localFile); }
public void TearDown() { HadoopFileSystem fileSystem = new HadoopFileSystem(_hostname, _portNumber, _authentication); // remove the test directory if (fileSystem.IsConnected && fileSystem.Exists(_directoryPath)) { fileSystem.Delete(_directoryPath); } }
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 HadoopFileSystemOpenFileTest() { HadoopFileSystem fileSystem = new HadoopFileSystem(this.hostname, this.portNumber, this.authentication); if (!fileSystem.IsConnected) { Assert.Inconclusive(); } if (!fileSystem.Exists(this.directoryPath + "TestFile.txt")) { Assert.Inconclusive(); } // read existing file Stream fileStream = fileSystem.OpenFile(this.directoryPath + "TestFile.txt", FileMode.Open, FileAccess.Read); fileSystem.ShouldNotBeNull(); StreamReader reader = new StreamReader(fileStream); reader.ReadToEnd().Length.ShouldBeGreaterThan(0); }
public void HadoopFileSystemOpenFileTest() { HadoopFileSystem fileSystem = new HadoopFileSystem(_hostname, _portNumber, _authentication); if (!fileSystem.IsConnected) { Assert.Inconclusive(); } if (!fileSystem.Exists(_directoryPath + "TestFile.txt")) { Assert.Inconclusive(); } // read existing file Stream fileStream = fileSystem.OpenFile(_directoryPath + "TestFile.txt", FileMode.Open, FileAccess.Read); Assert.IsNotNull(fileSystem); StreamReader reader = new StreamReader(fileStream); Assert.IsTrue(reader.ReadToEnd().Length > 0); }