abhishekdas99 commented on a change in pull request #2019:
URL: https://github.com/apache/hadoop/pull/2019#discussion_r434320447
##########
File path:
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewfsFileStatus.java
##########
@@ -56,38 +69,71 @@ public void testFileStatusSerialziation()
File infile = new File(TEST_DIR, testfilename);
final byte[] content = "dingos".getBytes();
- FileOutputStream fos = null;
- try {
- fos = new FileOutputStream(infile);
+ try (FileOutputStream fos = new FileOutputStream(infile)) {
fos.write(content);
- } finally {
- if (fos != null) {
- fos.close();
- }
}
assertEquals((long)content.length, infile.length());
Configuration conf = new Configuration();
ConfigUtil.addLink(conf, "/foo/bar/baz", TEST_DIR.toURI());
- FileSystem vfs = FileSystem.get(FsConstants.VIEWFS_URI, conf);
- assertEquals(ViewFileSystem.class, vfs.getClass());
- Path path = new Path("/foo/bar/baz", testfilename);
- FileStatus stat = vfs.getFileStatus(path);
- assertEquals(content.length, stat.getLen());
- ContractTestUtils.assertNotErasureCoded(vfs, path);
- assertTrue(path + " should have erasure coding unset in " +
- "FileStatus#toString(): " + stat,
- stat.toString().contains("isErasureCoded=false"));
-
- // check serialization/deserialization
- DataOutputBuffer dob = new DataOutputBuffer();
- stat.write(dob);
- DataInputBuffer dib = new DataInputBuffer();
- dib.reset(dob.getData(), 0, dob.getLength());
- FileStatus deSer = new FileStatus();
- deSer.readFields(dib);
- assertEquals(content.length, deSer.getLen());
- assertFalse(deSer.isErasureCoded());
+ try (FileSystem vfs = FileSystem.get(FsConstants.VIEWFS_URI, conf)) {
+ assertEquals(ViewFileSystem.class, vfs.getClass());
+ Path path = new Path("/foo/bar/baz", testfilename);
+ FileStatus stat = vfs.getFileStatus(path);
+ assertEquals(content.length, stat.getLen());
+ ContractTestUtils.assertNotErasureCoded(vfs, path);
+ assertTrue(path + " should have erasure coding unset in " +
+ "FileStatus#toString(): " + stat,
+ stat.toString().contains("isErasureCoded=false"));
+
+ // check serialization/deserialization
+ DataOutputBuffer dob = new DataOutputBuffer();
+ stat.write(dob);
+ DataInputBuffer dib = new DataInputBuffer();
+ dib.reset(dob.getData(), 0, dob.getLength());
+ FileStatus deSer = new FileStatus();
+ deSer.readFields(dib);
+ assertEquals(content.length, deSer.getLen());
+ assertFalse(deSer.isErasureCoded());
+ }
+ }
+
+ @Test
+ public void testListStatusACL()
+ throws IOException, URISyntaxException {
+ String testfilename = "testFileACL";
+ String childDirectoryName = "testDirectoryACL";
+ TEST_DIR.mkdirs();
+ File infile = new File(TEST_DIR, testfilename);
+ final byte[] content = "dingos".getBytes();
+
+ try (FileOutputStream fos = new FileOutputStream(infile)) {
+ fos.write(content);
+ }
+ assertEquals((long)content.length, infile.length());
+ File childDir = new File(TEST_DIR, childDirectoryName);
+ childDir.mkdirs();
+
+ Configuration conf = new Configuration();
+ ConfigUtil.addLink(conf, "/file", infile.toURI());
+ ConfigUtil.addLink(conf, "/dir", childDir.toURI());
+
+ try (FileSystem vfs = FileSystem.get(FsConstants.VIEWFS_URI, conf)) {
+ assertEquals(ViewFileSystem.class, vfs.getClass());
+ FileStatus[] statuses = vfs.listStatus(new Path("/"));
+
+ FileSystem localFs = FileSystem.getLocal(conf);
+ FileStatus fileStat = localFs.getFileStatus(new Path(infile.getPath()));
+ FileStatus dirStat = localFs.getFileStatus(new Path(childDir.getPath()));
+
+ for (FileStatus status : statuses) {
+ if (status.getPath().getName().equals("file")) {
+ assertEquals(fileStat.getPermission(), status.getPermission());
+ } else {
Review comment:
Done
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]