From 80242c79e8f9500a9e53a51a5183a2559692d5bd Mon Sep 17 00:00:00 2001 From: Emmanuel Bigeon Date: Fri, 26 Oct 2018 15:39:54 -0400 Subject: [PATCH] Added test of command on linux system Signed-off-by: Emmanuel Bigeon --- .../gclc/system/ExecSystemCommandTest.java | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/gclc.system/src/test/java/net/bigeon/gclc/system/ExecSystemCommandTest.java b/gclc.system/src/test/java/net/bigeon/gclc/system/ExecSystemCommandTest.java index 7277d4b..619231d 100644 --- a/gclc.system/src/test/java/net/bigeon/gclc/system/ExecSystemCommandTest.java +++ b/gclc.system/src/test/java/net/bigeon/gclc/system/ExecSystemCommandTest.java @@ -33,8 +33,9 @@ package net.bigeon.gclc.system; * knowledge of the CeCILL license and that you accept its terms. * #L% */ - -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; import org.junit.Test; @@ -48,7 +49,7 @@ public class ExecSystemCommandTest { @Test public void testExecSystemCommand() { - ExecSystemCommand cmd = new ExecSystemCommand("test"); + final ExecSystemCommand cmd = new ExecSystemCommand("test"); assertEquals("Name should be preserved", "test", cmd.getCommandName()); assertNotNull("tip should be defined", cmd.tip()); assertNotNull("usage should be defined", cmd.usagePattern()); @@ -57,18 +58,20 @@ public class ExecSystemCommandTest { @Test public void testExecute() throws CommandRunException { - ConsoleOutput out = SinkOutput.INSTANCE; - ConsoleInput in = EmptyInput.INSTANCE; + final ConsoleOutput out = SinkOutput.INSTANCE; + final ConsoleInput in = EmptyInput.INSTANCE; - ExecSystemCommand cmd = new ExecSystemCommand(); + final ExecSystemCommand cmd = new ExecSystemCommand(); if (System.getProperty("os.name").contains("indows")) { cmd.execute(out, in, "cmd", "/C", "dir"); - try { - cmd.execute(out, in, "inexistent"); - fail("Able to execute inexistent command in system"); - } catch (CommandRunException e) { - // ok - } + } else if (System.getProperty("os.name").contains("inux")) { + cmd.execute(out, in, "ls"); + } + try { + cmd.execute(out, in, "inexistent"); + fail("Able to execute inexistent command in system"); + } catch (final CommandRunException e) { + // ok } }