Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWainer dos Santos Moschetta2015-06-02 16:09:35 -0400
committerWainer dos Santos Moschetta2015-06-03 14:04:43 -0400
commit76d41f9f07cb5069859bdf3add7bbf11417445f9 (patch)
treecbe4891e093bf111236a16762e6e7a0c45ba2ed3
parent78e12f3592103e25c37ce01b2334eb2a15e652e2 (diff)
downloadorg.eclipse.linuxtools-76d41f9f07cb5069859bdf3add7bbf11417445f9.tar.gz
org.eclipse.linuxtools-76d41f9f07cb5069859bdf3add7bbf11417445f9.tar.xz
org.eclipse.linuxtools-76d41f9f07cb5069859bdf3add7bbf11417445f9.zip
Bug 469184 - add test cases
Added RemoteProxyEnvManagerTest to test getEnv() method. Change-Id: I4a9349586ff0ba32589daa468c9ceb7bfe402ab0 Signed-off-by: Wainer dos Santos Moschetta <wainersm@linux.vnet.ibm.com> Reviewed-on: https://git.eclipse.org/r/49250 (cherry picked from commit b06f083ba67b1c957732df6e9034637994f076f4) Reviewed-on: https://git.eclipse.org/r/49373 Tested-by: Hudson CI
-rw-r--r--profiling/org.eclipse.linuxtools.remote.proxy.tests/src/org/eclipse/linuxtools/remote/proxy/tests/RemoteProxyEnvManagerTest.java66
1 files changed, 66 insertions, 0 deletions
diff --git a/profiling/org.eclipse.linuxtools.remote.proxy.tests/src/org/eclipse/linuxtools/remote/proxy/tests/RemoteProxyEnvManagerTest.java b/profiling/org.eclipse.linuxtools.remote.proxy.tests/src/org/eclipse/linuxtools/remote/proxy/tests/RemoteProxyEnvManagerTest.java
new file mode 100644
index 0000000000..50e74fd19f
--- /dev/null
+++ b/profiling/org.eclipse.linuxtools.remote.proxy.tests/src/org/eclipse/linuxtools/remote/proxy/tests/RemoteProxyEnvManagerTest.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2015 IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wainer dos Santos Moschetta (IBM Corporation) - initial implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.remote.proxy.tests;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+import static org.junit.Assert.assertTrue;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.linuxtools.profiling.launch.IRemoteEnvProxyManager;
+import org.eclipse.linuxtools.profiling.launch.RemoteEnvProxyManager;
+import org.junit.Test;
+
+/**
+ * @author wainersm
+ *
+ */
+public class RemoteProxyEnvManagerTest extends AbstractProxyTest {
+ @Test
+ public void testGetEnv() {
+ Map<String, String> actualEnv = new HashMap<String, String>();
+ Map<String, String> expectedEnv = new HashMap<String, String>();
+ IRemoteEnvProxyManager proxy = new RemoteEnvProxyManager();
+
+ /*
+ * Get local environment to compare with returned by the proxy
+ */
+ expectedEnv= System.getenv();
+ try {
+ actualEnv = proxy.getEnv(localProject);
+ } 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);
+ } 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("^\\("));
+ }
+ }
+
+}

Back to the top