use of org.apache.commons.vfs2.util.PosixPermissions in project pentaho-kettle by pentaho.
the class SftpFileObjectWithWindowsSupportTest method getLinuxFileObject.
private static FileObject getLinuxFileObject(boolean posixReadable, boolean posixWritable) throws Exception {
GenericFileName fileName = mock(GenericFileName.class);
doReturn(PATH).when(fileName).getPath();
Session session = mock(Session.class);
SftpFileSystemWindows sftpFileSystem = spy(new SftpFileSystemWindows(fileName, session, null));
doReturn(false).when(sftpFileSystem).isRemoteHostWindows();
int permissions = 0;
if (posixReadable) {
permissions += 256;
}
if (posixWritable) {
permissions += 128;
}
PosixPermissions posixPermissions = new PosixPermissions(permissions, true, true);
return new SftpFileObjectWithWindowsSupport(fileName, sftpFileSystem) {
@Override
public PosixPermissions getPermissions(boolean checkIds) {
return posixPermissions;
}
@Override
public FileType getType() {
return FileType.FILE;
}
};
}
use of org.apache.commons.vfs2.util.PosixPermissions in project pentaho-kettle by pentaho.
the class SftpFileObjectWithWindowsSupportTest method getWindowsFileObject.
private static FileObject getWindowsFileObject(boolean windowsReadable, boolean windowsWritable) throws Exception {
GenericFileName fileName = mock(GenericFileName.class);
Session session = mock(Session.class);
doReturn(PATH).when(fileName).getPath();
SftpFileSystemWindows sftpFileSystem = spy(new SftpFileSystemWindows(fileName, session, null));
doReturn(true).when(sftpFileSystem).isRemoteHostWindows();
List<String> groups = new ArrayList<>();
groups.add(USERS);
doReturn(groups).when(sftpFileSystem).getUserGroups();
HashMap<String, String> permissions = new HashMap<>();
doReturn(permissions).when(sftpFileSystem).getFilePermission(PATH);
if (windowsReadable) {
permissions.put(USERS, PERMISSION_READ);
}
if (windowsWritable) {
permissions.put(USERS, PERMISSION_WRITE);
}
PosixPermissions posixPermissions = new PosixPermissions(0, true, true);
return new SftpFileObjectWithWindowsSupport(fileName, sftpFileSystem) {
@Override
public PosixPermissions getPermissions(boolean checkIds) {
return posixPermissions;
}
@Override
public FileType getType() {
return FileType.FILE;
}
};
}
Aggregations