Search in sources :

Example 1 with IRemoteEnvProxyManager

use of org.eclipse.linuxtools.profiling.launch.IRemoteEnvProxyManager in project linuxtools by eclipse.

the class RemoteProxyEnvManagerTest method testGetEnv.

@Test
public void testGetEnv() {
    Map<String, String> actualEnv = new HashMap<>();
    Map<String, String> expectedEnv = new HashMap<>();
    IRemoteEnvProxyManager proxy = new RemoteEnvProxyManager();
    /*
		 * Get local environment to compare with returned by the proxy
		 */
    expectedEnv = System.getenv();
    try {
        actualEnv = proxy.getEnv(localProject.getProject());
    } catch (CoreException e) {
        fail("Failed to get environment variables: " + e.getMessage());
    }
    assertEquals(expectedEnv.size(), actualEnv.size());
    assertEquals(expectedEnv.keySet(), actualEnv.keySet());
    assertEquals(expectedEnv.values(), actualEnv.values());
    /*
		 * Get remote environment to compare with returned by the proxy
		 */
    try {
        actualEnv = proxy.getEnv(syncProject.getProject());
    } catch (CoreException e) {
        fail("Failed to get remote environment variables: " + e.getMessage());
    }
    assertTrue(!actualEnv.isEmpty());
    // Bug 469184 - it should be able to filter out some variables
    for (Entry<String, String> entry : actualEnv.entrySet()) {
        assertTrue("It should not hold exported functions: " + entry.getKey(), !entry.getKey().matches("BASH_FUNC_.*"));
        assertTrue("It should not hold exported functions: " + entry.getKey(), !entry.getValue().matches("^\\("));
    }
    /*
		 * Test it opens connection to get the env
		 */
    IRemoteConnection conn = getConnection();
    assertNotNull(conn);
    conn.close();
    assertFalse(conn.isOpen());
    proxy = new RemoteEnvProxyManager();
    try {
        actualEnv = proxy.getEnv(syncProject.getProject());
        assertTrue(actualEnv.size() > 0);
    } catch (CoreException e) {
        fail("Failed to get env when connection is closed: " + e.getMessage());
    }
}
Also used : RemoteEnvProxyManager(org.eclipse.linuxtools.profiling.launch.RemoteEnvProxyManager) IRemoteEnvProxyManager(org.eclipse.linuxtools.profiling.launch.IRemoteEnvProxyManager) CoreException(org.eclipse.core.runtime.CoreException) HashMap(java.util.HashMap) IRemoteEnvProxyManager(org.eclipse.linuxtools.profiling.launch.IRemoteEnvProxyManager) IRemoteConnection(org.eclipse.remote.core.IRemoteConnection) Test(org.junit.Test)

Aggregations

HashMap (java.util.HashMap)1 CoreException (org.eclipse.core.runtime.CoreException)1 IRemoteEnvProxyManager (org.eclipse.linuxtools.profiling.launch.IRemoteEnvProxyManager)1 RemoteEnvProxyManager (org.eclipse.linuxtools.profiling.launch.RemoteEnvProxyManager)1 IRemoteConnection (org.eclipse.remote.core.IRemoteConnection)1 Test (org.junit.Test)1