use of org.ow2.proactive.scheduler.rest.ds.RemoteSource in project scheduling by ow2-proactive.
the class DataTransferTest method testListFilesRecursive.
@Test
public void testListFilesRecursive() throws Exception {
System.out.println("testListFilesRecursive");
createFilesInUserSpace("testListFilesRecursive");
// use standard client
IDataSpaceClient client = clientInstance();
RemoteSource source = new RemoteSource(USER, "testListFilesRecursive");
source.setIncludes("**");
ListFile listFile = client.list(source);
List<String> directories = listFile.getDirectoryListing();
System.out.println("Directories : " + directories);
assertEquals(1, directories.size());
assertEquals(DataTransferTest.TEMP_DIR_NAME, directories.get(0));
List<String> files = listFile.getFileListing();
System.out.println("Files : " + files);
assertEquals(2, files.size());
assertEquals(TEMP_FILE_TMP_PATH, files.get(0));
assertEquals(TEMP_FILE_TXT_NAME, files.get(1));
// use RemoteSpace API
List<String> foundFiles = client.getUserSpace().listFiles("testListFilesRecursive", "**");
System.out.println("Full : " + foundFiles);
assertEquals(3, foundFiles.size());
assertArrayEquals(new String[] { TEMP_DIR_NAME, TEMP_FILE_TMP_PATH, TEMP_FILE_TXT_NAME }, foundFiles.toArray(new String[0]));
}
use of org.ow2.proactive.scheduler.rest.ds.RemoteSource 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.RemoteSource 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.RemoteSource 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]));
}
use of org.ow2.proactive.scheduler.rest.ds.RemoteSource in project scheduling by ow2-proactive.
the class DataTransferTest method testListFilesRecursiveWithPattern.
@Test
public void testListFilesRecursiveWithPattern() throws Exception {
System.out.println("testListFilesRecursiveWithPattern");
createFilesInUserSpace("testListFilesRecursiveWithPattern");
// use standard client
IDataSpaceClient client = clientInstance();
RemoteSource source = new RemoteSource(USER, "testListFilesRecursiveWithPattern");
source.setIncludes("**/*.tmp");
ListFile listFile = client.list(source);
List<String> directories = listFile.getDirectoryListing();
System.out.println("Directories : " + directories);
assertEquals(0, directories.size());
List<String> files = listFile.getFileListing();
System.out.println("Files : " + files);
assertEquals(1, files.size());
assertEquals(TEMP_FILE_TMP_PATH, files.get(0));
// use RemoteSpace API
List<String> foundFiles = client.getUserSpace().listFiles("testListFilesRecursiveWithPattern", "**/*.tmp");
System.out.println("Full : " + foundFiles);
assertEquals(1, foundFiles.size());
assertArrayEquals(new String[] { TEMP_FILE_TMP_PATH }, foundFiles.toArray(new String[0]));
}
Aggregations