Make remote CommandShellTest run on Mac
authorMarc-Andre Laperle <marc-andre.laperle@ericsson.com>
Mon, 13 Apr 2015 18:33:09 +0000 (14:33 -0400)
committerMarc-Andre Laperle <marc-andre.laperle@ericsson.com>
Tue, 14 Apr 2015 14:51:47 +0000 (10:51 -0400)
The tests are skipped if the platform is not Linux but they can run on Mac.

Change-Id: Idcface3299f44e32c232d0ae5939d5cf5b703b3f
Signed-off-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/45772
Reviewed-by: Hudson CI
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
org.eclipse.tracecompass.tmf.remote.core.tests/src/org/eclipse/tracecompass/tmf/remote/core/tests/shell/CommandShellTest.java

index 925d4b29eaebcb81f0d2371ca6db6c0f24ada810..d52468078198c35aba72bb08703aa36bdc3377f7 100644 (file)
@@ -21,6 +21,7 @@ import java.util.Arrays;
 
 import org.eclipse.core.commands.ExecutionException;
 import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Platform;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.remote.core.IRemoteConnection;
 import org.eclipse.tracecompass.internal.tmf.remote.core.shell.CommandShell;
@@ -36,11 +37,11 @@ import org.junit.Test;
  */
 public class CommandShellTest {
 
-    private static final boolean IS_LINUX = System.getProperty("os.name").contains("Linux") ? true : false; //$NON-NLS-1$ //$NON-NLS-2$
+    private static final boolean IS_UNIX = !Platform.getOS().equals(Platform.OS_WIN32);
 
-    private static final @NonNull String[] CMD_INPUT_LINUX = { "ls", "-l" };
-    private static final @NonNull String[] CMD_ERROR_INPUT_LINUX = { "ls", "blablablabla" };
-    private static final @NonNull String[] CMD_UNKNOWN_COMMAND_LINUX = { "blablablabla" };
+    private static final @NonNull String[] CMD_INPUT_UNIX = { "ls", "-l" };
+    private static final @NonNull String[] CMD_ERROR_INPUT_UNIX = { "ls", "blablablabla" };
+    private static final @NonNull String[] CMD_UNKNOWN_COMMAND_UNIX = { "blablablabla" };
 
     private static final IRemoteConnection LOCAL_CONNECTION = TmfRemoteConnectionFactory.getLocalConnection();
     private static final RemoteSystemProxy LOCAL_PROXY = new RemoteSystemProxy(checkNotNull(LOCAL_CONNECTION));
@@ -52,12 +53,12 @@ public class CommandShellTest {
      */
     @Test
     public void testExecuteSuccess() throws ExecutionException {
-        assumeTrue(IS_LINUX);
+        assumeTrue(IS_UNIX);
         LOCAL_PROXY.connect(new NullProgressMonitor());
         ICommandShell shell = LOCAL_PROXY.createCommandShell();
 
         ICommandInput command = shell.createCommand();
-        command.addAll(checkNotNull(Arrays.asList(CMD_INPUT_LINUX)));
+        command.addAll(checkNotNull(Arrays.asList(CMD_INPUT_UNIX)));
         ICommandResult result = shell.executeCommand(command, new NullProgressMonitor());
         assertEquals(0, result.getResult());
     }
@@ -69,13 +70,13 @@ public class CommandShellTest {
      */
     @Test
     public void testExecuteError() throws ExecutionException {
-        assumeTrue(IS_LINUX);
+        assumeTrue(IS_UNIX);
 
         LOCAL_PROXY.connect(new NullProgressMonitor());
         ICommandShell shell = LOCAL_PROXY.createCommandShell();
 
         ICommandInput command = shell.createCommand();
-        command.addAll(checkNotNull(Arrays.asList(CMD_ERROR_INPUT_LINUX)));
+        command.addAll(checkNotNull(Arrays.asList(CMD_ERROR_INPUT_UNIX)));
         ICommandResult result = shell.executeCommand(command, new NullProgressMonitor());
         assertTrue(result.getResult() > 0);
     }
@@ -87,14 +88,14 @@ public class CommandShellTest {
      */
     @Test (expected=ExecutionException.class)
     public void testExecuteException() throws ExecutionException {
-        if (!IS_LINUX) {
+        if (!IS_UNIX) {
             throw new ExecutionException("");
         }
         LOCAL_PROXY.connect(new NullProgressMonitor());
         ICommandShell shell = LOCAL_PROXY.createCommandShell();
 
         ICommandInput command = shell.createCommand();
-        command.addAll(checkNotNull(Arrays.asList(CMD_UNKNOWN_COMMAND_LINUX)));
+        command.addAll(checkNotNull(Arrays.asList(CMD_UNKNOWN_COMMAND_UNIX)));
         ICommandResult result = shell.executeCommand(command, new NullProgressMonitor());
         assertTrue(result.getResult() > 0);
     }
This page took 0.038862 seconds and 5 git commands to generate.