/// <exception cref="System.Exception"/> public virtual void TestRead() { HdfsFileStatus status = nn.GetRpcServer().GetFileInfo("/tmp/bar"); long dirId = status.GetFileId(); FileHandle handle = new FileHandle(dirId); READ3Request readReq = new READ3Request(handle, 0, 5); XDR xdr_req = new XDR(); readReq.Serialize(xdr_req); // Attempt by an unpriviledged user should fail. READ3Response response1 = nfsd.Read(xdr_req.AsReadOnlyWrap(), securityHandlerUnpriviledged , new IPEndPoint("localhost", 1234)); NUnit.Framework.Assert.AreEqual("Incorrect return code:", Nfs3Status.Nfs3errAcces , response1.GetStatus()); // Attempt by a priviledged user should pass. READ3Response response2 = nfsd.Read(xdr_req.AsReadOnlyWrap(), securityHandler, new IPEndPoint("localhost", 1234)); NUnit.Framework.Assert.AreEqual("Incorrect return code:", Nfs3Status.Nfs3Ok, response2 .GetStatus()); }
/// <exception cref="System.Exception"/> private byte[] GetFileContentsUsingNfs(string fileName, int len) { HdfsFileStatus status = nn.GetRpcServer().GetFileInfo(fileName); long dirId = status.GetFileId(); FileHandle handle = new FileHandle(dirId); READ3Request readReq = new READ3Request(handle, 0, len); XDR xdr_req = new XDR(); readReq.Serialize(xdr_req); READ3Response response = nfsd.Read(xdr_req.AsReadOnlyWrap(), securityHandler, new IPEndPoint("localhost", 1234)); NUnit.Framework.Assert.AreEqual("Incorrect return code: ", Nfs3Status.Nfs3Ok, response .GetStatus()); NUnit.Framework.Assert.IsTrue("expected full read", response.IsEof()); return((byte[])response.GetData().Array()); }