use of org.ow2.proactive.scheduler.rest.ds.IDataSpaceClient in project scheduling by ow2-proactive.
the class DataTransferTest method testUploadAllFilesInDirectory.
@Test
public void testUploadAllFilesInDirectory() throws Exception {
// entire folder
TestFilesToUploadCreator testFiles = new TestFilesToUploadCreator().invoke();
File tempTextFile = testFiles.getTempTextFile();
File tempFile = testFiles.getTempFile();
// use standard client
IDataSpaceClient client = clientInstance();
LocalDirSource source = new LocalDirSource(tmpDir.getRoot());
RemoteDestination dest = new RemoteDestination(USER, "testUploadAllFilesInDirectory");
assertTrue(client.upload(source, dest));
String destRootUri = URI.create(getScheduler().getUserSpaceURIs().get(0)).getPath();
assertTrue(Files.equal(tempTextFile, new File(destRootUri, "testUploadAllFilesInDirectory/" + TEMP_FILE_TXT_NAME)));
assertTrue(Files.equal(tempFile, new File(destRootUri, "testUploadAllFilesInDirectory/" + TEMP_FILE_TMP_PATH)));
// use RemoteSpace API
FileUtils.deleteDirectory(new File(destRootUri, "testUploadAllFilesInDirectory"));
client.getUserSpace().pushFile(tmpDir.getRoot(), "testUploadAllFilesInDirectory");
assertTrue(Files.equal(tempTextFile, new File(destRootUri, "testUploadAllFilesInDirectory/" + TEMP_FILE_TXT_NAME)));
assertTrue(Files.equal(tempFile, new File(destRootUri, "testUploadAllFilesInDirectory/" + TEMP_FILE_TMP_PATH)));
}
use of org.ow2.proactive.scheduler.rest.ds.IDataSpaceClient in project scheduling by ow2-proactive.
the class DataTransferTest method testDownloadAllFilesInDirectory.
@Test
public void testDownloadAllFilesInDirectory() throws Exception {
String srcDirPath = URI.create(getScheduler().getUserSpaceURIs().get(0)).getPath();
String dirName = "testDownloadAllFilesInDirectory";
TestFilesToDownloadCreator testFilesToDownloadCreator = new TestFilesToDownloadCreator(srcDirPath, dirName).invoke();
File srcTextFile = testFilesToDownloadCreator.getSrcTextFile();
File srcTempFile = testFilesToDownloadCreator.getSrcTempFile();
File destTempDir = tmpDir.newFolder(TEMP_DIR_NAME);
// use standard client
IDataSpaceClient client = clientInstance();
RemoteSource source = new RemoteSource(USER, "testDownloadAllFilesInDirectory");
LocalDestination dest = new LocalDestination(destTempDir);
assertTrue(client.download(source, dest));
assertTrue(Files.equal(srcTextFile, new File(destTempDir, TEMP_FILE_TXT_NAME)));
assertTrue(Files.equal(srcTempFile, new File(destTempDir, TEMP_FILE_TMP_PATH)));
// use RemoteSpace API
File destTempDir2 = tmpDir.newFolder(TEMP_DIR2_NAME);
client.getUserSpace().pullFile("testDownloadAllFilesInDirectory", destTempDir2);
assertTrue(Files.equal(srcTextFile, new File(destTempDir2, TEMP_FILE_TXT_NAME)));
assertTrue(Files.equal(srcTempFile, new File(destTempDir2, TEMP_FILE_TMP_PATH)));
}
use of org.ow2.proactive.scheduler.rest.ds.IDataSpaceClient in project scheduling by ow2-proactive.
the class DataTransferTest method testListFilesNonRecursive.
@Test
public void testListFilesNonRecursive() throws Exception {
System.out.println("testListFilesNonRecursive");
createFilesInUserSpace("testListFilesNonRecursive");
// use standard client
IDataSpaceClient client = clientInstance();
RemoteSource source = new RemoteSource(USER, "testListFilesNonRecursive");
source.setIncludes("*");
ListFile listFile = client.list(source);
List<String> directories = listFile.getDirectoryListing();
System.out.println("Directories : " + directories);
assertEquals(1, directories.size());
assertEquals(TEMP_DIR_NAME, directories.get(0));
List<String> files = listFile.getFileListing();
System.out.println("Files : " + files);
assertEquals(1, files.size());
assertEquals(TEMP_FILE_TXT_NAME, files.get(0));
// use RemoteSpace API
List<String> foundFiles = client.getUserSpace().listFiles("testListFilesNonRecursive", "*");
System.out.println("Full : " + foundFiles);
assertEquals(2, foundFiles.size());
assertArrayEquals(new String[] { TEMP_DIR_NAME, TEMP_FILE_TXT_NAME }, foundFiles.toArray(new String[0]));
}
use of org.ow2.proactive.scheduler.rest.ds.IDataSpaceClient in project scheduling by ow2-proactive.
the class DataTransferTest method testUploadSelectedFilesUsingGlobPattern.
@Test
public void testUploadSelectedFilesUsingGlobPattern() throws Exception {
TestFilesToUploadCreator testFiles = new TestFilesToUploadCreator().invoke();
File tempTextFile = testFiles.getTempTextFile();
File tempFile = testFiles.getTempFile();
// use standard client
IDataSpaceClient client = clientInstance();
LocalDirSource source = new LocalDirSource(tmpDir.getRoot());
source.setIncludes("*.txt");
RemoteDestination dest = new RemoteDestination(USER, "testUploadSelectedFilesUsingGlobPattern");
assertTrue(client.upload(source, dest));
String destRootUri = URI.create(getScheduler().getUserSpaceURIs().get(0)).getPath();
File[] destRootFiles = new File(destRootUri, "testUploadSelectedFilesUsingGlobPattern").listFiles();
assertEquals(1, destRootFiles.length);
assertTrue(Files.equal(tempTextFile, destRootFiles[0]));
// use RemoteSpace API
FileUtils.deleteDirectory(new File(destRootUri, "testUploadSelectedFilesUsingGlobPattern"));
client.getUserSpace().pushFiles(tmpDir.getRoot(), "*.txt", "testUploadSelectedFilesUsingGlobPattern");
destRootFiles = new File(destRootUri, "testUploadSelectedFilesUsingGlobPattern").listFiles();
assertEquals(1, destRootFiles.length);
assertTrue(Files.equal(tempTextFile, destRootFiles[0]));
}
use of org.ow2.proactive.scheduler.rest.ds.IDataSpaceClient in project scheduling by ow2-proactive.
the class DataTransferTest method testDownloadSelectedFilesUsingGlobPattern.
@Test
public void testDownloadSelectedFilesUsingGlobPattern() throws Exception {
String srcDirPath = URI.create(getScheduler().getUserSpaceURIs().get(0)).getPath();
String dirName = "testDownloadSelectedFilesUsingGlobPattern";
TestFilesToDownloadCreator testFilesToDownloadCreator = new TestFilesToDownloadCreator(srcDirPath, dirName).invoke();
File srcTextFile = testFilesToDownloadCreator.getSrcTextFile();
File srcTempFile = testFilesToDownloadCreator.getSrcTempFile();
File destTempDir = tmpDir.newFolder(TEMP_DIR_NAME);
// use standard client
IDataSpaceClient client = clientInstance();
RemoteSource source = new RemoteSource(USER, dirName);
source.setIncludes("*.txt");
LocalDestination dest = new LocalDestination(destTempDir);
assertTrue(client.download(source, dest));
File[] listFiles = destTempDir.listFiles();
assertEquals(1, listFiles.length);
assertTrue(Files.equal(srcTextFile, listFiles[0]));
// use RemoteSpace API
File destTempDir2 = tmpDir.newFolder(TEMP_DIR2_NAME);
client.getUserSpace().pullFiles(dirName, "*.txt", destTempDir2);
listFiles = destTempDir2.listFiles();
assertEquals(1, listFiles.length);
assertTrue(Files.equal(srcTextFile, listFiles[0]));
}
Aggregations