Added test of command on linux system
Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
This commit is contained in:
parent
ab9a4c474b
commit
80242c79e8
@ -33,8 +33,9 @@ package net.bigeon.gclc.system;
|
|||||||
* knowledge of the CeCILL license and that you accept its terms.
|
* knowledge of the CeCILL license and that you accept its terms.
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
@ -48,7 +49,7 @@ public class ExecSystemCommandTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testExecSystemCommand() {
|
public void testExecSystemCommand() {
|
||||||
ExecSystemCommand cmd = new ExecSystemCommand("test");
|
final ExecSystemCommand cmd = new ExecSystemCommand("test");
|
||||||
assertEquals("Name should be preserved", "test", cmd.getCommandName());
|
assertEquals("Name should be preserved", "test", cmd.getCommandName());
|
||||||
assertNotNull("tip should be defined", cmd.tip());
|
assertNotNull("tip should be defined", cmd.tip());
|
||||||
assertNotNull("usage should be defined", cmd.usagePattern());
|
assertNotNull("usage should be defined", cmd.usagePattern());
|
||||||
@ -57,18 +58,20 @@ public class ExecSystemCommandTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testExecute() throws CommandRunException {
|
public void testExecute() throws CommandRunException {
|
||||||
ConsoleOutput out = SinkOutput.INSTANCE;
|
final ConsoleOutput out = SinkOutput.INSTANCE;
|
||||||
ConsoleInput in = EmptyInput.INSTANCE;
|
final ConsoleInput in = EmptyInput.INSTANCE;
|
||||||
|
|
||||||
ExecSystemCommand cmd = new ExecSystemCommand();
|
final ExecSystemCommand cmd = new ExecSystemCommand();
|
||||||
if (System.getProperty("os.name").contains("indows")) {
|
if (System.getProperty("os.name").contains("indows")) {
|
||||||
cmd.execute(out, in, "cmd", "/C", "dir");
|
cmd.execute(out, in, "cmd", "/C", "dir");
|
||||||
try {
|
} else if (System.getProperty("os.name").contains("inux")) {
|
||||||
cmd.execute(out, in, "inexistent");
|
cmd.execute(out, in, "ls");
|
||||||
fail("Able to execute inexistent command in system");
|
}
|
||||||
} catch (CommandRunException e) {
|
try {
|
||||||
// ok
|
cmd.execute(out, in, "inexistent");
|
||||||
}
|
fail("Able to execute inexistent command in system");
|
||||||
|
} catch (final CommandRunException e) {
|
||||||
|
// ok
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user