internal static void CheckInvalidPath(string s, Configuration conf) { System.Console.Out.WriteLine("\ncheckInvalidPath: " + s); Path p = new Path(s); try { p.GetFileSystem(conf); NUnit.Framework.Assert.Fail(p + " is an invalid path."); } catch (IOException) { } }
public virtual void TestMakeQualifiedPath() { // Construct a valid har file system path with authority that // contains userinfo and port. The userinfo and port are useless // in local fs uri. They are only used to verify har file system // can correctly preserve the information for the underlying file system. string harPathWithUserinfo = "har://*****:*****@localhost:80" + harPath.ToUri ().GetPath().ToString(); Path path = new Path(harPathWithUserinfo); Path qualifiedPath = path.GetFileSystem(conf).MakeQualified(path); Assert.True(string.Format("The qualified path (%s) did not match the expected path (%s)." , qualifiedPath.ToString(), harPathWithUserinfo), qualifiedPath.ToString().Equals (harPathWithUserinfo)); }
// 4MB /// <seealso cref="NUnit.Framework.TestCase.SetUp()"/> /// <exception cref="System.IO.IOException"/> protected override void SetUp() { conf = new Configuration(); Path rootPath = new Path(TestRootDir); path = new Path(rootPath, "TestGetFileBlockLocations"); fs = rootPath.GetFileSystem(conf); FSDataOutputStream fsdos = fs.Create(path, true); byte[] buffer = new byte[1024]; while (fsdos.GetPos() < FileLength) { fsdos.Write(buffer); } fsdos.Close(); random = new Random(Runtime.NanoTime()); }
/// <summary>Test getLocalPathToRead() returns correct filename and "file" schema.</summary> /// <exception cref="System.IO.IOException"/> public virtual void TestGetLocalPathToRead() { Assume.AssumeTrue(!isWindows); string dir = BuildBufferDir(Root, 0); try { conf.Set(Context, dir); Assert.True(localFs.Mkdirs(new Path(dir))); FilePath f1 = dirAllocator.CreateTmpFileForWrite(Filename, SmallFileSize, conf); Path p1 = dirAllocator.GetLocalPathToRead(f1.GetName(), conf); Assert.Equal(f1.GetName(), p1.GetName()); Assert.Equal("file", p1.GetFileSystem(conf).GetUri().GetScheme ()); } finally { Shell.ExecCommand(Shell.GetSetPermissionCommand("u+w", false, BufferDirRoot)); RmBufferDirs(); } }
/// <exception cref="URISyntaxException"/> /// <exception cref="System.IO.IOException"/> public virtual void TestURI() { URI uri = new URI("file:///bar#baz"); Path path = new Path(uri); Assert.True(uri.Equals(new URI(path.ToString()))); FileSystem fs = path.GetFileSystem(new Configuration()); Assert.True(uri.Equals(new URI(fs.MakeQualified(path).ToString( )))); // uri without hash URI uri2 = new URI("file:///bar/baz"); Assert.True(uri2.Equals(new URI(fs.MakeQualified(new Path(uri2) ).ToString()))); Assert.Equal("foo://bar/baz#boo", new Path("foo://bar/", new Path (new URI("/baz#boo"))).ToString()); Assert.Equal("foo://bar/baz/fud#boo", new Path(new Path(new URI ("foo://bar/baz#bud")), new Path(new URI("fud#boo"))).ToString()); // if the child uri is absolute path Assert.Equal("foo://bar/fud#boo", new Path(new Path(new URI("foo://bar/baz#bud" )), new Path(new URI("/fud#boo"))).ToString()); }