//Do Nothing
        /// <exception cref="System.Exception"/>
        public virtual void TestWebHdfsDoAs()
        {
            WebHdfsTestUtil.Log.Info("START: testWebHdfsDoAs()");
            WebHdfsTestUtil.Log.Info("ugi.getShortUserName()=" + ugi.GetShortUserName());
            WebHdfsFileSystem webhdfs = WebHdfsTestUtil.GetWebHdfsFileSystemAs(ugi, config, WebHdfsFileSystem
                                                                               .Scheme);
            Path root = new Path("/");

            cluster.GetFileSystem().SetPermission(root, new FsPermission((short)0x1ff));
            Whitebox.SetInternalState(webhdfs, "ugi", proxyUgi);
            {
                Path responsePath = webhdfs.GetHomeDirectory();
                WebHdfsTestUtil.Log.Info("responsePath=" + responsePath);
                NUnit.Framework.Assert.AreEqual(webhdfs.GetUri() + "/user/" + ProxyUser, responsePath
                                                .ToString());
            }
            Path f = new Path("/testWebHdfsDoAs/a.txt");
            {
                FSDataOutputStream @out = webhdfs.Create(f);
                @out.Write(Sharpen.Runtime.GetBytesForString("Hello, webhdfs user!"));
                @out.Close();
                FileStatus status = webhdfs.GetFileStatus(f);
                WebHdfsTestUtil.Log.Info("status.getOwner()=" + status.GetOwner());
                NUnit.Framework.Assert.AreEqual(ProxyUser, status.GetOwner());
            }
            {
                FSDataOutputStream @out = webhdfs.Append(f);
                @out.Write(Sharpen.Runtime.GetBytesForString("\nHello again!"));
                @out.Close();
                FileStatus status = webhdfs.GetFileStatus(f);
                WebHdfsTestUtil.Log.Info("status.getOwner()=" + status.GetOwner());
                WebHdfsTestUtil.Log.Info("status.getLen()  =" + status.GetLen());
                NUnit.Framework.Assert.AreEqual(ProxyUser, status.GetOwner());
            }
        }
Пример #2
0
        public virtual void TestWebHdfsCustomUriPortWithCustomDefaultPorts()
        {
            URI uri = URI.Create("webhdfs://localhost:789");
            WebHdfsFileSystem fs = (WebHdfsFileSystem)FileSystem.Get(uri, conf);

            NUnit.Framework.Assert.AreEqual(123, fs.GetDefaultPort());
            NUnit.Framework.Assert.AreEqual(uri, fs.GetUri());
            NUnit.Framework.Assert.AreEqual("127.0.0.1:789", fs.GetCanonicalServiceName());
        }