use of org.apache.hadoop.hive.io.HdfsUtils.HadoopFileStatus in project hive by apache.
the class TestHadoopFileStatus method testHadoopFileStatusAclEntries.
/*
* HdfsUtils.setFullFileStatus(..) is called from multiple parallel threads. If AclEntries
* is modifiable the method will not be thread safe and could cause random concurrency issues
* This test case checks if the aclEntries returned from HadoopFileStatus is thread-safe or not
*/
@Test(expected = UnsupportedOperationException.class)
public void testHadoopFileStatusAclEntries() throws IOException {
FileSystem mockDfs = Mockito.mock(DistributedFileSystem.class);
Path mockPath = Mockito.mock(Path.class);
List<AclEntry> aclEntries = Lists.newArrayList();
aclEntries.add(newAclEntry(AclEntryScope.ACCESS, AclEntryType.USER, FsAction.ALL));
aclEntries.add(newAclEntry(AclEntryScope.ACCESS, AclEntryType.GROUP, FsAction.READ_EXECUTE));
aclEntries.add(newAclEntry(AclEntryScope.ACCESS, AclEntryType.OTHER, FsAction.NONE));
AclStatus aclStatus = new AclStatus.Builder().owner("dummyOwner").group("dummyGroup").stickyBit(true).addEntries(aclEntries).build();
FileStatus mockFileStatus = Mockito.mock(FileStatus.class);
Mockito.when(mockDfs.getAclStatus(mockPath)).thenReturn(aclStatus);
Mockito.when(mockDfs.getFileStatus(mockPath)).thenReturn(mockFileStatus);
sourceStatus = new HadoopFileStatus(hiveConf, mockDfs, mockPath);
Assert.assertNotNull(sourceStatus.getAclEntries());
Assert.assertTrue(sourceStatus.getAclEntries().size() == 3);
Iterables.removeIf(sourceStatus.getAclEntries(), new Predicate<AclEntry>() {
@Override
public boolean apply(AclEntry input) {
if (input.getName() == null) {
return true;
}
return false;
}
});
}
Aggregations