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());
}
}
Aggregations