Search in sources :

Example 11 with RemoteSource

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]));
}
Also used : ListFile(org.ow2.proactive_grid_cloud_portal.dataspace.dto.ListFile) Test(org.junit.Test)

Example 12 with RemoteSource

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)));
}
Also used : ListFile(org.ow2.proactive_grid_cloud_portal.dataspace.dto.ListFile) File(java.io.File) Test(org.junit.Test)

Example 13 with RemoteSource

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]));
}
Also used : ListFile(org.ow2.proactive_grid_cloud_portal.dataspace.dto.ListFile) Test(org.junit.Test)

Example 14 with RemoteSource

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]));
}
Also used : ListFile(org.ow2.proactive_grid_cloud_portal.dataspace.dto.ListFile) File(java.io.File) Test(org.junit.Test)

Example 15 with RemoteSource

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]));
}
Also used : ListFile(org.ow2.proactive_grid_cloud_portal.dataspace.dto.ListFile) Test(org.junit.Test)

Aggregations

ListFile (org.ow2.proactive_grid_cloud_portal.dataspace.dto.ListFile)10 Test (org.junit.Test)9 File (java.io.File)8 RemoteSource (org.ow2.proactive.scheduler.rest.ds.RemoteSource)5 URI (java.net.URI)4 NotConnectedException (org.ow2.proactive.scheduler.common.exception.NotConnectedException)3 PermissionException (org.ow2.proactive.scheduler.common.exception.PermissionException)3 IOException (java.io.IOException)2 AwaitedJob (org.ow2.proactive.scheduler.smartproxy.common.AwaitedJob)2 AwaitedTask (org.ow2.proactive.scheduler.smartproxy.common.AwaitedTask)2 Path (java.nio.file.Path)1 HashSet (java.util.HashSet)1 OutputSelector (org.ow2.proactive.scheduler.common.task.dataspaces.OutputSelector)1 LocalDestination (org.ow2.proactive.scheduler.rest.ds.LocalDestination)1