use of org.apache.hadoop.fs.FileStatus in project hadoop by apache.
the class TestFind method createPathData.
private PathData createPathData(String name) throws IOException {
Path path = new Path(name);
FileStatus fstat = mock(FileStatus.class);
when(fstat.getPath()).thenReturn(path);
when(fstat.toString()).thenReturn("fileStatus:" + name);
when(mockFs.getFileStatus(eq(path))).thenReturn(fstat);
PathData item = new PathData(path.toString(), conf);
return item;
}
use of org.apache.hadoop.fs.FileStatus in project hadoop by apache.
the class ViewFileSystemBaseTest method testListOnInternalDirsOfMountTableInternal.
private void testListOnInternalDirsOfMountTableInternal(boolean located) throws IOException {
// list on Slash
FileStatus[] dirPaths = listStatusInternal(located, new Path("/"));
FileStatus fs;
verifyRootChildren(dirPaths);
// list on internal dir
dirPaths = listStatusInternal(located, new Path("/internalDir"));
Assert.assertEquals(2, dirPaths.length);
fs = fileSystemTestHelper.containsPath(fsView, "/internalDir/internalDir2", dirPaths);
Assert.assertNotNull(fs);
Assert.assertTrue("A mount should appear as symlink", fs.isDirectory());
fs = fileSystemTestHelper.containsPath(fsView, "/internalDir/linkToDir2", dirPaths);
Assert.assertNotNull(fs);
Assert.assertTrue("A mount should appear as symlink", fs.isSymlink());
}
use of org.apache.hadoop.fs.FileStatus in project hadoop by apache.
the class ViewFileSystemBaseTest method testCheckOwnerWithFileStatus.
@Test
public void testCheckOwnerWithFileStatus() throws IOException, InterruptedException {
final UserGroupInformation userUgi = UserGroupInformation.createUserForTesting("user@HADOOP.COM", new String[] { "hadoop" });
userUgi.doAs(new PrivilegedExceptionAction<Object>() {
@Override
public Object run() throws IOException {
UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
String doAsUserName = ugi.getUserName();
assertEquals(doAsUserName, "user@HADOOP.COM");
FileSystem vfs = FileSystem.get(FsConstants.VIEWFS_URI, conf);
FileStatus stat = vfs.getFileStatus(new Path("/internalDir"));
assertEquals(userUgi.getShortUserName(), stat.getOwner());
return null;
}
});
}
use of org.apache.hadoop.fs.FileStatus in project hadoop by apache.
the class ViewFileSystemBaseTest method testCreateNonRecursive.
@Test
public void testCreateNonRecursive() throws IOException {
Path path = fileSystemTestHelper.getTestRootPath(fsView, "/user/foo");
fsView.createNonRecursive(path, false, 1024, (short) 1, 1024L, null);
FileStatus status = fsView.getFileStatus(new Path("/user/foo"));
Assert.assertTrue("Created file should be type file", fsView.isFile(new Path("/user/foo")));
Assert.assertTrue("Target of created file should be type file", fsTarget.isFile(new Path(targetTestRoot, "user/foo")));
}
use of org.apache.hadoop.fs.FileStatus in project hadoop by apache.
the class ViewFileSystemBaseTest method testListOnMountTargetDirsInternal.
private void testListOnMountTargetDirsInternal(boolean located) throws IOException {
final Path dataPath = new Path("/data");
FileStatus[] dirPaths = listStatusInternal(located, dataPath);
FileStatus fs;
Assert.assertEquals(0, dirPaths.length);
// add a file
long len = fileSystemTestHelper.createFile(fsView, "/data/foo");
dirPaths = listStatusInternal(located, dataPath);
Assert.assertEquals(1, dirPaths.length);
fs = fileSystemTestHelper.containsPath(fsView, "/data/foo", dirPaths);
Assert.assertNotNull(fs);
Assert.assertTrue("Created file shoudl appear as a file", fs.isFile());
Assert.assertEquals(len, fs.getLen());
// add a dir
fsView.mkdirs(fileSystemTestHelper.getTestRootPath(fsView, "/data/dirX"));
dirPaths = listStatusInternal(located, dataPath);
Assert.assertEquals(2, dirPaths.length);
fs = fileSystemTestHelper.containsPath(fsView, "/data/foo", dirPaths);
Assert.assertNotNull(fs);
Assert.assertTrue("Created file shoudl appear as a file", fs.isFile());
fs = fileSystemTestHelper.containsPath(fsView, "/data/dirX", dirPaths);
Assert.assertNotNull(fs);
Assert.assertTrue("Created dir should appear as a dir", fs.isDirectory());
}
Aggregations