mina-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r1039551 - in /mina/sshd/trunk/sshd-core/src: main/java/org/apache/sshd/client/channel/ChannelSession.java test/java/org/apache/sshd/ClientTest.java
Date Fri, 26 Nov 2010 20:23:05 GMT
Author: gnodet
Date: Fri Nov 26 20:23:05 2010
New Revision: 1039551

URL: http://svn.apache.org/viewvc?rev=1039551&view=rev
Log:
[SSHD-89] EOF is not sent from the client

Modified:
    mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelSession.java
    mina/sshd/trunk/sshd-core/src/test/java/org/apache/sshd/ClientTest.java

Modified: mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelSession.java
URL: http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelSession.java?rev=1039551&r1=1039550&r2=1039551&view=diff
==============================================================================
--- mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelSession.java
(original)
+++ mina/sshd/trunk/sshd-core/src/main/java/org/apache/sshd/client/channel/ChannelSession.java
Fri Nov 26 20:23:05 2010
@@ -86,6 +86,9 @@ public class ChannelSession extends Abst
                     remoteWindow.waitAndConsume(len);
                     log.debug("Send SSH_MSG_CHANNEL_DATA on channel {}", id);
                     session.writePacket(buffer);
+                } else {
+                    sendEof();
+                    break;
                 }
             }
         } catch (Exception e) {

Modified: mina/sshd/trunk/sshd-core/src/test/java/org/apache/sshd/ClientTest.java
URL: http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-core/src/test/java/org/apache/sshd/ClientTest.java?rev=1039551&r1=1039550&r2=1039551&view=diff
==============================================================================
--- mina/sshd/trunk/sshd-core/src/test/java/org/apache/sshd/ClientTest.java (original)
+++ mina/sshd/trunk/sshd-core/src/test/java/org/apache/sshd/ClientTest.java Fri Nov 26 20:23:05
2010
@@ -90,7 +90,6 @@ public class ClientTest {
         session.authPassword("smx", "smx").await().isSuccess();
         ClientChannel channel = session.createChannel(ClientChannel.CHANNEL_SHELL);
 
-        
         ByteArrayOutputStream sent = new ByteArrayOutputStream();
         PipedOutputStream pipedIn = new TeePipedOutputStream(sent);
         channel.setIn(new PipedInputStream(pipedIn));
@@ -122,6 +121,44 @@ public class ClientTest {
     }
 
     @Test
+    public void testClientClosingStream() throws Exception {
+        SshClient client = SshClient.setUpDefaultClient();
+        client.start();
+        ClientSession session = client.connect("localhost", port).await().getSession();
+        session.authPassword("smx", "smx").await().isSuccess();
+        ClientChannel channel = session.createChannel(ClientChannel.CHANNEL_SHELL);
+
+
+        ByteArrayOutputStream sent = new ByteArrayOutputStream();
+        PipedOutputStream pipedIn = new TeePipedOutputStream(sent);
+        channel.setIn(new PipedInputStream(pipedIn));
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        ByteArrayOutputStream err = new ByteArrayOutputStream();
+        channel.setOut(out);
+        channel.setErr(err);
+        channel.open();
+
+        pipedIn.write("this is my command\n".getBytes());
+        pipedIn.flush();
+
+        StringBuilder sb = new StringBuilder();
+        for (int i = 0; i < 1000; i++) {
+            sb.append("0123456789");
+        }
+        sb.append("\n");
+        pipedIn.write(sb.toString().getBytes());
+
+        pipedIn.close();
+
+        channel.waitFor(ClientChannel.CLOSED, 0);
+
+        channel.close(false);
+        client.stop();
+
+        assertArrayEquals(sent.toByteArray(), out.toByteArray());
+    }
+
+    @Test
     public void testClientWithLengthyDialog() throws Exception {
         SshClient client = SshClient.setUpDefaultClient();
         // Reduce window size and packet size



Mime
View raw message