Search in sources :

Example 1 with LocalFileProxy

use of org.eclipse.linuxtools.internal.profiling.launch.LocalFileProxy in project linuxtools by eclipse.

the class FileProxyTest method testLocalFileProxy.

@Test
public void testLocalFileProxy() {
    IRemoteFileProxy fileProxy = null;
    try {
        fileProxy = proxyManager.getFileProxy(localProject.getProject());
        assertTrue("Should have returned a remote launcher", fileProxy instanceof LocalFileProxy);
    } catch (CoreException e) {
        fail("Should have returned a launcher: " + e.getCause());
    }
    /*
		 * Test getDirectorySeparator()
		 */
    String ds = fileProxy.getDirectorySeparator();
    assertNotNull(ds);
    /*
		 *  Test getResource()
		 */
    IFileStore actualFileStore = fileProxy.getResource(localProject.getProject().getLocation().toOSString());
    assertNotNull(actualFileStore);
    IFileStore expectedFileStore = null;
    try {
        expectedFileStore = EFS.getStore(localProject.getLocationURI());
    } catch (CoreException e) {
        fail("Unabled to get FileStore to local project: " + e.getMessage());
    }
    assertEquals("FileStore to local project folder diverge", expectedFileStore, actualFileStore);
    assertTrue(actualFileStore.fetchInfo().isDirectory());
    actualFileStore = fileProxy.getResource("/filenotexits");
    assertNotNull(actualFileStore);
    IFileInfo fileInfo = actualFileStore.fetchInfo();
    assertNotNull(fileInfo);
    assertFalse(fileInfo.exists());
    /*
		 * Test getWorkingDir()
		 */
    URI workingDir = fileProxy.getWorkingDir();
    assertNotNull(workingDir);
    assertEquals(localProject.getLocationURI(), workingDir);
    /*
		 * Test toPath()
		 */
    assertEquals(localProject.getProject().getLocation().toOSString(), fileProxy.toPath(localProject.getLocationURI()));
}
Also used : LocalFileProxy(org.eclipse.linuxtools.internal.profiling.launch.LocalFileProxy) IFileInfo(org.eclipse.core.filesystem.IFileInfo) CoreException(org.eclipse.core.runtime.CoreException) IRemoteFileProxy(org.eclipse.linuxtools.profiling.launch.IRemoteFileProxy) IFileStore(org.eclipse.core.filesystem.IFileStore) URI(java.net.URI) AbstractProxyTest(org.eclipse.linuxtools.remote.proxy.tests.AbstractProxyTest) Test(org.junit.Test)

Example 2 with LocalFileProxy

use of org.eclipse.linuxtools.internal.profiling.launch.LocalFileProxy in project linuxtools by eclipse.

the class RemoteProxyManagerTest method testGetFileProxy.

@Test
public void testGetFileProxy() {
    IRemoteFileProxy fp;
    try {
        /*
			 * Test the proxy for local URIs and project
			 */
        fp = proxyManager.getFileProxy(URI.create("/path/to/file"));
        assertTrue("Should return a local file proxy", fp instanceof LocalFileProxy);
        fp = proxyManager.getFileProxy(URI.create("file:/path/to/file"));
        assertTrue("Should return a local file proxy", fp instanceof LocalFileProxy);
        fp = proxyManager.getFileProxy(localProject.getLocationURI());
        assertTrue("Should return a local file proxy", fp instanceof LocalFileProxy);
        fp = proxyManager.getFileProxy(localProject.getProject());
        assertTrue("Should return a local file proxy", fp instanceof LocalFileProxy);
        /*
			 * Test the proxy for remote URIs and project
			 */
        fp = proxyManager.getFileProxy(URI.create("ssh://" + CONNECTION_NAME + "/path/to/file"));
        assertTrue("Should have returned a remote file proxy", fp instanceof RDTFileProxy);
        fp = proxyManager.getFileProxy(syncProject.getProject());
        assertTrue("Should have returned a remote file proxy", fp instanceof RDTFileProxy);
        /*
			 * Test the proxy for jsch connection scheme
			 */
        fp = proxyManager.getFileProxy(URI.create("jsch://" + USERNAME + "@" + HOST + ":22/path/to/file"));
        assertTrue("Should have returned a remote file proxy", fp instanceof SSHFileProxy);
    } catch (CoreException e) {
        fail("Should have returned a file proxy: " + e.getCause());
    }
    /*
		 * Test the proxy for unsupported URIs
		 */
    try {
        // As of org.eclipse.remote 2.0, remotetools scheme is no longer
        // support
        fp = proxyManager.getFileProxy(URI.create("remotetools://MyConnection/path/to/file"));
        fail("remotetools scheme should not be recognized");
    } catch (CoreException e) {
        assertTrue(e.getMessage(), true);
    }
}
Also used : LocalFileProxy(org.eclipse.linuxtools.internal.profiling.launch.LocalFileProxy) CoreException(org.eclipse.core.runtime.CoreException) SSHFileProxy(org.eclipse.linuxtools.internal.ssh.proxy.SSHFileProxy) IRemoteFileProxy(org.eclipse.linuxtools.profiling.launch.IRemoteFileProxy) RDTFileProxy(org.eclipse.linuxtools.internal.rdt.proxy.RDTFileProxy) AbstractProxyTest(org.eclipse.linuxtools.remote.proxy.tests.AbstractProxyTest) Test(org.junit.Test)

Aggregations

CoreException (org.eclipse.core.runtime.CoreException)2 LocalFileProxy (org.eclipse.linuxtools.internal.profiling.launch.LocalFileProxy)2 IRemoteFileProxy (org.eclipse.linuxtools.profiling.launch.IRemoteFileProxy)2 AbstractProxyTest (org.eclipse.linuxtools.remote.proxy.tests.AbstractProxyTest)2 Test (org.junit.Test)2 URI (java.net.URI)1 IFileInfo (org.eclipse.core.filesystem.IFileInfo)1 IFileStore (org.eclipse.core.filesystem.IFileStore)1 RDTFileProxy (org.eclipse.linuxtools.internal.rdt.proxy.RDTFileProxy)1 SSHFileProxy (org.eclipse.linuxtools.internal.ssh.proxy.SSHFileProxy)1