mirror of https://github.com/apache/jclouds.git
more realistic test of ssh channel
This commit is contained in:
parent
e39fc48901
commit
d67aa3bbf5
|
@ -27,6 +27,7 @@ import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.PrintStream;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
|
|
||||||
import org.jclouds.compute.domain.ExecChannel;
|
import org.jclouds.compute.domain.ExecChannel;
|
||||||
|
@ -169,12 +170,17 @@ public class JschSshClientLiveTest {
|
||||||
: sshHost);
|
: sshHost);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testExecChannelHostname() throws IOException {
|
public void testExecChannelTakesStdinAndEchosBack() throws IOException {
|
||||||
ExecChannel response = setupClient().execChannel("hostname");
|
ExecChannel response = setupClient().execChannel("cat <<EOF");
|
||||||
|
assertEquals(response.getExitStatus().get(), null);
|
||||||
try {
|
try {
|
||||||
|
PrintStream printStream = new PrintStream(response.getInput());
|
||||||
|
printStream.append("foo\n");
|
||||||
|
printStream.append("EOF\n");
|
||||||
|
printStream.close();
|
||||||
assertEquals(Strings2.toStringAndClose(response.getError()), "");
|
assertEquals(Strings2.toStringAndClose(response.getError()), "");
|
||||||
assertEquals(Strings2.toStringAndClose(response.getOutput()).trim(), "localhost".equals(sshHost) ? InetAddress
|
// local echo
|
||||||
.getLocalHost().getHostName() : sshHost);
|
assertEquals(Strings2.toStringAndClose(response.getOutput()), "foo\r\nEOF\r\n");
|
||||||
} finally {
|
} finally {
|
||||||
Closeables.closeQuietly(response);
|
Closeables.closeQuietly(response);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.PrintStream;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
|
|
||||||
import org.jclouds.compute.domain.ExecChannel;
|
import org.jclouds.compute.domain.ExecChannel;
|
||||||
|
@ -169,12 +170,17 @@ public class SshjSshClientLiveTest {
|
||||||
: sshHost);
|
: sshHost);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testExecChannelHostname() throws IOException {
|
public void testExecChannelTakesStdinAndEchosBack() throws IOException {
|
||||||
ExecChannel response = setupClient().execChannel("hostname");
|
ExecChannel response = setupClient().execChannel("cat <<EOF");
|
||||||
|
assertEquals(response.getExitStatus().get(), null);
|
||||||
try {
|
try {
|
||||||
|
PrintStream printStream = new PrintStream(response.getInput());
|
||||||
|
printStream.append("foo\n");
|
||||||
|
printStream.append("EOF\n");
|
||||||
|
printStream.close();
|
||||||
assertEquals(Strings2.toStringAndClose(response.getError()), "");
|
assertEquals(Strings2.toStringAndClose(response.getError()), "");
|
||||||
assertEquals(Strings2.toStringAndClose(response.getOutput()).trim(), "localhost".equals(sshHost) ? InetAddress
|
// local echo
|
||||||
.getLocalHost().getHostName() : sshHost);
|
assertEquals(Strings2.toStringAndClose(response.getOutput()), "foo\r\nEOF\r\n");
|
||||||
} finally {
|
} finally {
|
||||||
Closeables.closeQuietly(response);
|
Closeables.closeQuietly(response);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue