Skip to content

Commit

Permalink
#12 better tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Yegor Bugayenko committed Dec 14, 2014
1 parent 49227a7 commit 964354c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/jcabi/ssh/Shell.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public int exec(final String command, final InputStream stdin,
final int exit = this.origin.exec(command, stdin, stdout, stderr);
if (exit != 0) {
throw new IllegalArgumentException(
String.format("exit code #%d: %s", exit, command)
String.format("non-zero exit code #%d: %s", exit, command)
);
}
return exit;
Expand Down
12 changes: 8 additions & 4 deletions src/test/java/com/jcabi/ssh/SSHDTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ public void executeCommandOnServer() throws Exception {
final SSHD sshd = new SSHD(this.temp.newFolder());
try {
MatcherAssert.assertThat(
new Shell.Plain(sshd.connect()).exec("echo one"),
new Shell.Plain(
new Shell.Safe(sshd.connect())
).exec("echo one"),
Matchers.startsWith("one")
);
} finally {
Expand All @@ -90,9 +92,11 @@ public void executeCommandOnServerWithManualConfig() throws Exception {
try {
MatcherAssert.assertThat(
new Shell.Plain(
new SSH(
sshd.host(), sshd.port(), sshd.login(),
this.getClass().getResource("id_rsa")
new Shell.Safe(
new SSH(
sshd.host(), sshd.port(), sshd.login(),
this.getClass().getResource("id_rsa")
)
)
).exec("echo 'how are you'"),
Matchers.startsWith("how are")
Expand Down

0 comments on commit 964354c

Please sign in to comment.