Add test with long execution command
Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
This commit is contained in:
parent
7a2991acc1
commit
ba61efaa4a
@ -101,7 +101,7 @@ public class ExecSystemCommand extends Command {
|
||||
try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os))) {
|
||||
while (th.isAlive()) {
|
||||
final String user = in.prompt();
|
||||
// Avoid interruption being sent to process.
|
||||
// Forward to process if not empty.
|
||||
if (!user.isEmpty()) {
|
||||
writer.write(user + EOL);
|
||||
}
|
||||
|
@ -79,4 +79,26 @@ public class ExecSystemCommandTest {
|
||||
}
|
||||
}
|
||||
|
||||
/** Test the execution of the command.
|
||||
*
|
||||
* @throws CommandRunException if the command fails */
|
||||
@Test
|
||||
public void testLongExecute() throws CommandRunException {
|
||||
final ConsoleOutput out = SinkOutput.INSTANCE;
|
||||
final ConsoleInput in = EmptyInput.INSTANCE;
|
||||
|
||||
final ExecSystemCommand cmd = new ExecSystemCommand();
|
||||
if (System.getProperty("os.name").contains("indows")) {
|
||||
cmd.execute(out, in, "cmd", "/C", "dir", "/s");
|
||||
} else if (System.getProperty("os.name").contains("inux")) {
|
||||
cmd.execute(out, in, "ls", "-R");
|
||||
}
|
||||
try {
|
||||
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