Added test of command on linux system

Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
This commit is contained in:
Emmanuel Bigeon 2018-10-26 15:39:54 -04:00
parent ab9a4c474b
commit 80242c79e8

View File

@ -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,19 +58,21 @@ 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");
} 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 (CommandRunException e) {
} catch (final CommandRunException e) {
// ok
}
}
}
}