use of org.apache.hadoop.fs.permission.AclStatus in project hive by apache.
the class TestHdfsUtils method testSetFullFileStatusFailInheritAcls.
/**
* Tests that {@link HdfsUtils#setFullFileStatus(Configuration, HdfsUtils.HadoopFileStatus, FileSystem, Path, boolean)}
* does not thrown an exception when setting ACLs and without recursion.
*/
@Test
public void testSetFullFileStatusFailInheritAcls() throws IOException {
Configuration conf = new Configuration();
conf.set("dfs.namenode.acls.enabled", "true");
HdfsUtils.HadoopFileStatus mockHadoopFileStatus = mock(HdfsUtils.HadoopFileStatus.class);
FileStatus mockSourceStatus = mock(FileStatus.class);
AclStatus mockAclStatus = mock(AclStatus.class);
FileSystem mockFs = mock(FileSystem.class);
when(mockSourceStatus.getPermission()).thenReturn(new FsPermission((short) 777));
when(mockAclStatus.toString()).thenReturn("");
when(mockHadoopFileStatus.getFileStatus()).thenReturn(mockSourceStatus);
when(mockHadoopFileStatus.getAclEntries()).thenReturn(new ArrayList<AclEntry>());
when(mockHadoopFileStatus.getAclStatus()).thenReturn(mockAclStatus);
doThrow(RuntimeException.class).when(mockFs).setAcl(any(Path.class), any(List.class));
HdfsUtils.setFullFileStatus(conf, mockHadoopFileStatus, mockFs, new Path("fakePath"), false);
verify(mockFs).setAcl(any(Path.class), any(List.class));
}
Aggregations