use of org.ow2.proactive.resourcemanager.authentication.Client in project scheduling by ow2-proactive.
the class DataTransferTest method testCreateFolder.
@Test
public void testCreateFolder() throws Exception {
URI srcDirPath = URI.create(getScheduler().getUserSpaceURIs().get(0));
String testFolderName = "testcreatefolder";
System.out.println(testFolderName);
RemoteSource source = new RemoteSource(USER, testFolderName);
source.setType(FileType.FOLDER);
IDataSpaceClient client = clientInstance();
assertTrue(client.create(source));
File expectedFile = new File(srcDirPath.getPath(), testFolderName);
assertTrue(expectedFile.exists());
assertTrue(expectedFile.isDirectory());
}
use of org.ow2.proactive.resourcemanager.authentication.Client in project scheduling by ow2-proactive.
the class DataTransferTest method testDownloadArchiveFile.
private void testDownloadArchiveFile(String archiveFileName, URL archiveSource) throws Exception {
String srcDirPath = URI.create(getScheduler().getUserSpaceURIs().get(0)).getPath();
File srcFile = new File(srcDirPath, archiveFileName);
if (srcFile.exists()) {
assertTrue(srcFile.delete());
}
FileUtils.copyInputStreamToFile(archiveSource.openStream(), srcFile);
File tmpFile = tmpDir.newFile(archiveFileName);
if (tmpFile.exists()) {
assertTrue(tmpFile.delete());
}
// use standard client
IDataSpaceClient client = clientInstance();
RemoteSource source = new RemoteSource(USER, archiveFileName);
LocalDestination dest = new LocalDestination(tmpFile);
assertTrue(client.download(source, dest));
assertTrue(Files.equal(srcFile, tmpFile));
// use RemoteSpace API
FileUtils.deleteQuietly(tmpFile);
File downloadedFile = client.getUserSpace().pullFile(archiveFileName, tmpFile);
assertTrue(Files.equal(srcFile, downloadedFile));
}
use of org.ow2.proactive.resourcemanager.authentication.Client in project scheduling by ow2-proactive.
the class DataTransferTest method testUploadArchiveFile.
private void testUploadArchiveFile(String archiveFileName, URL archiveFileSource, String testFolderName) throws Exception {
File tmpZipFile = tmpDir.newFile(archiveFileName);
FileUtils.copyInputStreamToFile(archiveFileSource.openStream(), tmpZipFile);
// use standard client
IDataSpaceClient client = clientInstance();
LocalFileSource source = new LocalFileSource(tmpZipFile);
RemoteDestination dest = new RemoteDestination(USER, testFolderName + "/" + archiveFileName);
assertTrue(client.upload(source, dest));
String destDirPath = URI.create(getScheduler().getUserSpaceURIs().get(0)).getPath();
File destFile = new File(destDirPath, testFolderName + "/" + archiveFileName);
assertTrue(Files.equal(tmpZipFile, destFile));
// use RemoteSpace API
FileUtils.deleteQuietly(destFile);
client.getUserSpace().pushFile(tmpZipFile, testFolderName + "/" + archiveFileName);
assertTrue(Files.equal(tmpZipFile, destFile));
}
use of org.ow2.proactive.resourcemanager.authentication.Client in project scheduling by ow2-proactive.
the class DataTransferTest method testCreateFile.
@Test
public void testCreateFile() throws Exception {
URI srcDirPath = URI.create(getScheduler().getUserSpaceURIs().get(0));
String filename = TEMP_FILE_TMP_NAME;
RemoteSource source = new RemoteSource(USER, filename);
source.setType(FileType.FILE);
IDataSpaceClient client = clientInstance();
assertTrue(client.create(source));
File expectedFile = new File(srcDirPath.getPath(), filename);
assertTrue(expectedFile.exists());
assertTrue(expectedFile.isFile());
}
use of org.ow2.proactive.resourcemanager.authentication.Client in project scheduling by ow2-proactive.
the class SchedulerNodeClient method connect.
/**
* Connects to the scheduler at the specified schedulerRestUrl, using the current user credentials
* @param url schedulerRestUrl of the scheduler
* @throws Exception
*/
public void connect(String url) throws Exception {
CredData userCreds = decrypter.decrypt();
if (client == null) {
client = SchedulerClient.createInstance();
}
if (client.isConnected()) {
return;
}
client.init(new ConnectionInfo(url, userCreds.getLogin(), userCreds.getPassword(), null, true));
}
Aggregations