|
@@ -23,11 +23,12 @@ import org.slf4j.LoggerFactory;
|
|
import org.apache.hadoop.fs.permission.FsPermission;
|
|
import org.apache.hadoop.fs.permission.FsPermission;
|
|
import org.apache.hadoop.fs.permission.PermissionStatus;
|
|
import org.apache.hadoop.fs.permission.PermissionStatus;
|
|
import org.apache.hadoop.hdfs.DFSUtil;
|
|
import org.apache.hadoop.hdfs.DFSUtil;
|
|
-import org.apache.hadoop.hdfs.protocol.QuotaExceededException;
|
|
|
|
import org.apache.hadoop.hdfs.server.namenode.snapshot.SnapshotManager;
|
|
import org.apache.hadoop.hdfs.server.namenode.snapshot.SnapshotManager;
|
|
import org.junit.Test;
|
|
import org.junit.Test;
|
|
import org.mockito.Mockito;
|
|
import org.mockito.Mockito;
|
|
|
|
|
|
|
|
+import java.io.FileNotFoundException;
|
|
|
|
+
|
|
import static org.junit.Assert.assertFalse;
|
|
import static org.junit.Assert.assertFalse;
|
|
import static org.junit.Assert.assertTrue;
|
|
import static org.junit.Assert.assertTrue;
|
|
import static org.mockito.Mockito.when;
|
|
import static org.mockito.Mockito.when;
|
|
@@ -40,7 +41,8 @@ public class TestFSDirAttrOp {
|
|
LoggerFactory.getLogger(TestFSDirAttrOp.class);
|
|
LoggerFactory.getLogger(TestFSDirAttrOp.class);
|
|
|
|
|
|
private boolean unprotectedSetTimes(long atime, long atime0, long precision,
|
|
private boolean unprotectedSetTimes(long atime, long atime0, long precision,
|
|
- long mtime, boolean force) throws QuotaExceededException {
|
|
|
|
|
|
+ long mtime, boolean force)
|
|
|
|
+ throws FileNotFoundException {
|
|
FSNamesystem fsn = Mockito.mock(FSNamesystem.class);
|
|
FSNamesystem fsn = Mockito.mock(FSNamesystem.class);
|
|
SnapshotManager ssMgr = Mockito.mock(SnapshotManager.class);
|
|
SnapshotManager ssMgr = Mockito.mock(SnapshotManager.class);
|
|
FSDirectory fsd = Mockito.mock(FSDirectory.class);
|
|
FSDirectory fsd = Mockito.mock(FSDirectory.class);
|
|
@@ -131,4 +133,16 @@ public class TestFSDirAttrOp {
|
|
assertTrue("SetTimes should update access time",
|
|
assertTrue("SetTimes should update access time",
|
|
unprotectedSetTimes(100, 0, 1000, 1, false));
|
|
unprotectedSetTimes(100, 0, 1000, 1, false));
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Test(expected = FileNotFoundException.class)
|
|
|
|
+ public void testUnprotectedSetTimesFNFE()
|
|
|
|
+ throws FileNotFoundException {
|
|
|
|
+ FSDirectory fsd = Mockito.mock(FSDirectory.class);
|
|
|
|
+ INodesInPath iip = Mockito.mock(INodesInPath.class);
|
|
|
|
+
|
|
|
|
+ when(fsd.hasWriteLock()).thenReturn(Boolean.TRUE);
|
|
|
|
+ when(iip.getLastINode()).thenReturn(null);
|
|
|
|
+
|
|
|
|
+ FSDirAttrOp.unprotectedSetTimes(fsd, iip, 0, 0, false);
|
|
|
|
+ }
|
|
}
|
|
}
|