You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by gn...@apache.org on 2009/12/15 17:23:46 UTC
svn commit: r890868 -
/mina/sshd/trunk/sshd-core/src/test/java/org/apache/sshd/ScpTest.java
Author: gnodet
Date: Tue Dec 15 16:23:46 2009
New Revision: 890868
URL: http://svn.apache.org/viewvc?rev=890868&view=rev
Log:
SSHD-61: ScpTest fails randomly
Rewrite the tests to ensure that the streams are created before the channel is connected to make sure that
we don't loose any bytes. Also reorder some ack reads correctly.
Modified:
mina/sshd/trunk/sshd-core/src/test/java/org/apache/sshd/ScpTest.java
Modified: mina/sshd/trunk/sshd-core/src/test/java/org/apache/sshd/ScpTest.java
URL: http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-core/src/test/java/org/apache/sshd/ScpTest.java?rev=890868&r1=890867&r2=890868&view=diff
==============================================================================
--- mina/sshd/trunk/sshd-core/src/test/java/org/apache/sshd/ScpTest.java (original)
+++ mina/sshd/trunk/sshd-core/src/test/java/org/apache/sshd/ScpTest.java Tue Dec 15 16:23:46 2009
@@ -159,10 +159,10 @@
protected String readFile(String path) throws Exception {
ChannelExec c = (ChannelExec) session.openChannel("exec");
- c.setCommand("scp -f " + path);
- c.connect();
OutputStream os = c.getOutputStream();
InputStream is = c.getInputStream();
+ c.setCommand("scp -f " + path);
+ c.connect();
String header = readLine(is);
assertEquals("C0644 11 out.txt", header);
int length = Integer.parseInt(header.substring(6, header.indexOf(' ', 6)));
@@ -182,10 +182,10 @@
protected String readDir(String path) throws Exception {
ChannelExec c = (ChannelExec) session.openChannel("exec");
- c.setCommand("scp -r -f " + path);
- c.connect();
OutputStream os = c.getOutputStream();
InputStream is = c.getInputStream();
+ c.setCommand("scp -r -f " + path);
+ c.connect();
String header = readLine(is);
assertTrue(header.startsWith("D0755 0 "));
os.write(0);
@@ -210,10 +210,10 @@
protected String readFileError(String path) throws Exception {
ChannelExec c = (ChannelExec) session.openChannel("exec");
- c.setCommand("scp -f " + path);
- c.connect();
OutputStream os = c.getOutputStream();
InputStream is = c.getInputStream();
+ c.setCommand("scp -f " + path);
+ c.connect();
assertEquals(2, is.read());
c.disconnect();
return null;
@@ -222,9 +222,10 @@
protected void sendFile(String path, String name, String data) throws Exception {
ChannelExec c = (ChannelExec) session.openChannel("exec");
c.setCommand("scp -t " + path);
- c.connect();
OutputStream os = c.getOutputStream();
InputStream is = c.getInputStream();
+ c.connect();
+ assertEquals(0, is.read());
os.write(("C7777 "+ data.length() + " " + name + "\n").getBytes());
os.flush();
assertEquals(0, is.read());
@@ -239,14 +240,12 @@
protected void sendFileError(String path, String name, String data) throws Exception {
ChannelExec c = (ChannelExec) session.openChannel("exec");
- c.setCommand("scp -t " + path);
- c.connect();
OutputStream os = c.getOutputStream();
InputStream is = c.getInputStream();
- os.write(("C7777 "+ data.length() + " " + name + "\n").getBytes());
- os.flush();
+ c.setCommand("scp -t " + path);
+ c.connect();
assertEquals(0, is.read());
- os.write(data.getBytes());
+ os.write(("C7777 "+ data.length() + " " + name + "\n").getBytes());
os.flush();
assertEquals(2, is.read());
c.disconnect();
@@ -254,11 +253,11 @@
protected void sendDir(String path, String dirName, String fileName, String data) throws Exception {
ChannelExec c = (ChannelExec) session.openChannel("exec");
- c.setCommand("scp -t -r " + path);
- c.connect();
OutputStream os = c.getOutputStream();
InputStream is = c.getInputStream();
-
+ c.setCommand("scp -t -r " + path);
+ c.connect();
+ assertEquals(0, is.read());
os.write(("D0755 0 " + dirName + "\n").getBytes());
os.flush();
assertEquals(0, is.read());
@@ -271,6 +270,7 @@
os.write(0);
os.flush();
os.write("E\n".getBytes());
+ os.flush();
assertEquals(0, is.read());
}