You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by lg...@apache.org on 2018/08/13 11:15:52 UTC

[1/3] mina-sshd git commit: Make sure same dependency version is used throughout - including 3rd party transitive ones

Repository: mina-sshd
Updated Branches:
  refs/heads/master a02a9bf56 -> d296fd6ba


Make sure same dependency version is used throughout - including 3rd party transitive ones


Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/d296fd6b
Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/d296fd6b
Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/d296fd6b

Branch: refs/heads/master
Commit: d296fd6ba49ef4804b03025ba5d0e77c13fb721e
Parents: 5b2ef0a
Author: Goldstein Lyor <ly...@c-b4.com>
Authored: Mon Aug 13 14:15:20 2018 +0300
Committer: Goldstein Lyor <ly...@c-b4.com>
Committed: Mon Aug 13 14:15:46 2018 +0300

----------------------------------------------------------------------
 pom.xml | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/d296fd6b/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 859da4f..5bac023 100644
--- a/pom.xml
+++ b/pom.xml
@@ -114,6 +114,8 @@
         <spring.version>5.0.7.RELEASE</spring.version>
         <jgit.version>5.0.1.201806211838-r</jgit.version>
         <junit.version>4.12</junit.version>
+        <bytebuddy.version>1.8.15</bytebuddy.version>
+
         <surefire.plugin.version>2.22.0</surefire.plugin.version>
         <!-- See https://pmd.github.io/ for available latest version -->
         <pmd.version>6.5.0</pmd.version>
@@ -410,6 +412,23 @@
                 <version>1.1.3</version>
             </dependency>
 
+                <!-- Transitive dependencies by various 3rd party packages -->
+            <dependency>
+                <groupId>commons-io</groupId>
+                <artifactId>commons-io</artifactId>
+                <version>2.6</version>
+            </dependency>
+            <dependency>
+                <groupId>commons-lang</groupId>
+                <artifactId>commons-lang</artifactId>
+                <version>2.6</version>
+            </dependency>
+            <dependency>
+                <groupId>commons-collections</groupId>
+                <artifactId>commons-collections</artifactId>
+                <version>3.2.2</version>
+            </dependency>
+
             <dependency>
                 <groupId>org.springframework</groupId>
                 <artifactId>spring-framework-bom</artifactId>
@@ -454,11 +473,24 @@
                 <artifactId>junit</artifactId>
                 <version>${junit.version}</version>
             </dependency>
+
             <dependency>
                 <groupId>org.mockito</groupId>
                 <artifactId>mockito-core</artifactId>
                 <version>2.20.0</version>
             </dependency>
+                <!-- Used by mockito -->
+            <dependency>
+                <groupId>net.bytebuddy</groupId>
+                <artifactId>byte-buddy</artifactId>
+                <version>${bytebuddy.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>net.bytebuddy</groupId>
+                <artifactId>byte-buddy-agent</artifactId>
+                <version>${bytebuddy.version}</version>
+            </dependency>
+            
             <dependency>
                 <groupId>net.sf.jpam</groupId>
                 <artifactId>jpam</artifactId>


[3/3] mina-sshd git commit: Added unit tests for NoCloseInput/OutputStream and NoCloseReader/Writer

Posted by lg...@apache.org.
Added unit tests for NoCloseInput/OutputStream and NoCloseReader/Writer


Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/b222a67b
Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/b222a67b
Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/b222a67b

Branch: refs/heads/master
Commit: b222a67b38fd54afe72b2b575e70d439fb4c569a
Parents: a02a9bf
Author: Goldstein Lyor <ly...@c-b4.com>
Authored: Mon Aug 13 09:55:40 2018 +0300
Committer: Goldstein Lyor <ly...@c-b4.com>
Committed: Mon Aug 13 14:15:46 2018 +0300

----------------------------------------------------------------------
 .../common/util/io/NoCloseInputStreamTest.java  | 89 ++++++++++++++++++
 .../common/util/io/NoCloseOutputStreamTest.java | 69 ++++++++++++++
 .../sshd/common/util/io/NoCloseReaderTest.java  | 95 ++++++++++++++++++++
 .../sshd/common/util/io/NoCloseWriterTest.java  | 73 +++++++++++++++
 .../apache/sshd/util/test/BaseTestSupport.java  | 13 +++
 5 files changed, 339 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/b222a67b/sshd-core/src/test/java/org/apache/sshd/common/util/io/NoCloseInputStreamTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/util/io/NoCloseInputStreamTest.java b/sshd-core/src/test/java/org/apache/sshd/common/util/io/NoCloseInputStreamTest.java
new file mode 100644
index 0000000..2990fa6
--- /dev/null
+++ b/sshd-core/src/test/java/org/apache/sshd/common/util/io/NoCloseInputStreamTest.java
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.sshd.common.util.io;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Date;
+
+import org.apache.sshd.util.test.BaseTestSupport;
+import org.apache.sshd.util.test.NoIoTestCase;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runners.MethodSorters;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+@Category({ NoIoTestCase.class })
+public class NoCloseInputStreamTest extends BaseTestSupport {
+    public NoCloseInputStreamTest() {
+        super();
+    }
+
+    @Test
+    public void testCanKeepReadingAfterClose() throws IOException {
+        byte[] expected = (getClass().getName() + "#" + getCurrentTestName() + "@" + new Date()).getBytes(StandardCharsets.UTF_8);
+        Path dir = createTempClassFolder();
+        Path file = Files.write(dir.resolve(getCurrentTestName() + ".txt"), expected);
+        try (InputStream fileStream = Files.newInputStream(file);
+             InputStream shielded = new NoCloseInputStream(fileStream)) {
+            int index = 0;
+
+            for (; index < (expected.length / 2); index++) {
+                shielded.close();
+
+                int readValue = shielded.read();
+                if (readValue == -1) {
+                    fail("Premature EOF after shield read of " + index + " bytes");
+                }
+
+                byte expValue = expected[index];
+                byte actValue = (byte) (readValue & 0xFF);
+                if (expValue != actValue) {
+                    fail("Mismatched shielded read value after " + index + " bytes");
+                }
+            }
+
+            for (; index < expected.length; index++) {
+                int readValue = fileStream.read();
+                if (readValue == -1) {
+                    fail("Premature EOF after original read of " + index + " bytes");
+                }
+                byte expValue = expected[index];
+                byte actValue = (byte) (readValue & 0xFF);
+                if (expValue != actValue) {
+                    fail("Mismatched original read value after " + index + " bytes");
+                }
+            }
+
+            int readValue = shielded.read();
+            assertEquals("Shielded EOF not signalled", -1, readValue);
+
+            readValue = fileStream.read();
+            assertEquals("Original EOF not signalled", -1, readValue);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/b222a67b/sshd-core/src/test/java/org/apache/sshd/common/util/io/NoCloseOutputStreamTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/util/io/NoCloseOutputStreamTest.java b/sshd-core/src/test/java/org/apache/sshd/common/util/io/NoCloseOutputStreamTest.java
new file mode 100644
index 0000000..fc211c3
--- /dev/null
+++ b/sshd-core/src/test/java/org/apache/sshd/common/util/io/NoCloseOutputStreamTest.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.sshd.common.util.io;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Date;
+
+import org.apache.sshd.util.test.BaseTestSupport;
+import org.apache.sshd.util.test.NoIoTestCase;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runners.MethodSorters;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+@Category({ NoIoTestCase.class })
+public class NoCloseOutputStreamTest extends BaseTestSupport {
+    public NoCloseOutputStreamTest() {
+        super();
+    }
+
+    @Test
+    public void testCanKeepWritingAfterClose() throws IOException {
+        Path dir = createTempClassFolder();
+        Path file = dir.resolve(getCurrentTestName() + ".txt");
+        Files.deleteIfExists(file);
+
+        String expectedOutput = getClass().getName() + "#" + getCurrentTestName() + "@" + new Date();
+        byte[] expected = expectedOutput.getBytes(StandardCharsets.UTF_8);
+        try (OutputStream fileStream = Files.newOutputStream(file);
+             OutputStream shielded = new NoCloseOutputStream(fileStream)) {
+            int index = 0;
+            for (; index < (expected.length / 2); index++) {
+                shielded.close();
+                shielded.write(expected[index] & 0xFF);
+            }
+
+            fileStream.write(expected, index, expected.length - index);
+        }
+
+        byte[] actual = Files.readAllBytes(file);
+        String actualOutput = new String(actual, StandardCharsets.UTF_8);
+        assertEquals(expectedOutput, actualOutput);
+    }
+}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/b222a67b/sshd-core/src/test/java/org/apache/sshd/common/util/io/NoCloseReaderTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/util/io/NoCloseReaderTest.java b/sshd-core/src/test/java/org/apache/sshd/common/util/io/NoCloseReaderTest.java
new file mode 100644
index 0000000..193aabd
--- /dev/null
+++ b/sshd-core/src/test/java/org/apache/sshd/common/util/io/NoCloseReaderTest.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.sshd.common.util.io;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Date;
+
+import org.apache.sshd.util.test.BaseTestSupport;
+import org.apache.sshd.util.test.NoIoTestCase;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runners.MethodSorters;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+@Category({ NoIoTestCase.class })
+public class NoCloseReaderTest extends BaseTestSupport {
+    public NoCloseReaderTest() {
+        super();
+    }
+
+    @Test
+    public void testCanKeepReadingAfterClose() throws IOException {
+        String expected = getClass().getName() + "#" + getCurrentTestName() + "@" + new Date();
+        Path dir = createTempClassFolder();
+        Path file = Files.write(dir.resolve(getCurrentTestName() + ".txt"), expected.getBytes(StandardCharsets.UTF_8));
+        try (InputStream fileStream = Files.newInputStream(file);
+             Reader rdr = new InputStreamReader(fileStream, StandardCharsets.UTF_8);
+             Reader shielded = new NoCloseReader(rdr)) {
+            int index = 0;
+
+            int availLen = expected.length();
+            for (; index < (availLen / 2); index++) {
+                shielded.close();
+
+                int readValue = shielded.read();
+                if (readValue == -1) {
+                    fail("Premature EOF after shield read of " + index + " bytes");
+                }
+
+                char expValue = expected.charAt(index);
+                char actValue = (char) (readValue & 0xFFFF);
+                if (expValue != actValue) {
+                    fail("Mismatched shielded read value after " + index + " bytes");
+                }
+            }
+
+            for (; index < availLen; index++) {
+                int readValue = rdr.read();
+                if (readValue == -1) {
+                    fail("Premature EOF after original read of " + index + " bytes");
+                }
+
+                char expValue = expected.charAt(index);
+                char actValue = (char) (readValue & 0xFFFF);
+                if (expValue != actValue) {
+                    fail("Mismatched original read value after " + index + " bytes");
+                }
+            }
+
+            int readValue = shielded.read();
+            assertEquals("Shielded EOF not signalled", -1, readValue);
+
+            readValue = rdr.read();
+            assertEquals("Original EOF not signalled", -1, readValue);
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/b222a67b/sshd-core/src/test/java/org/apache/sshd/common/util/io/NoCloseWriterTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/util/io/NoCloseWriterTest.java b/sshd-core/src/test/java/org/apache/sshd/common/util/io/NoCloseWriterTest.java
new file mode 100644
index 0000000..efc6a91
--- /dev/null
+++ b/sshd-core/src/test/java/org/apache/sshd/common/util/io/NoCloseWriterTest.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.sshd.common.util.io;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Date;
+
+import org.apache.sshd.util.test.BaseTestSupport;
+import org.apache.sshd.util.test.NoIoTestCase;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runners.MethodSorters;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+@Category({ NoIoTestCase.class })
+public class NoCloseWriterTest extends BaseTestSupport {
+    public NoCloseWriterTest() {
+        super();
+    }
+
+    @Test
+    public void testCanKeepWritingAfterClose() throws IOException {
+        Path dir = createTempClassFolder();
+        Path file = dir.resolve(getCurrentTestName() + ".txt");
+        Files.deleteIfExists(file);
+
+        String expected = getClass().getName() + "#" + getCurrentTestName() + "@" + new Date();
+        try (OutputStream fileStream = Files.newOutputStream(file);
+             Writer w = new OutputStreamWriter(fileStream, StandardCharsets.UTF_8);
+                Writer shielded = new NoCloseWriter(w)) {
+            int index = 0;
+            int availLen = expected.length();
+            for (; index < (availLen / 2); index++) {
+                shielded.close();
+                shielded.write(expected.charAt(index));
+            }
+
+            w.write(expected, index, availLen - index);
+        }
+
+        byte[] actualBytes = Files.readAllBytes(file);
+        String actual = new String(actualBytes, StandardCharsets.UTF_8);
+        assertEquals(expected, actual);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/b222a67b/sshd-core/src/test/java/org/apache/sshd/util/test/BaseTestSupport.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/util/test/BaseTestSupport.java b/sshd-core/src/test/java/org/apache/sshd/util/test/BaseTestSupport.java
index 911328a..ba58c5e 100644
--- a/sshd-core/src/test/java/org/apache/sshd/util/test/BaseTestSupport.java
+++ b/sshd-core/src/test/java/org/apache/sshd/util/test/BaseTestSupport.java
@@ -223,6 +223,19 @@ public abstract class BaseTestSupport extends Assert {
         return targetFolder;
     }
 
+    /**
+     * Creates a folder bearing the class's simple name under the project's target temporary folder
+     *
+     * @return The created folder {@link Path}
+     * @throws IOException If failed to detect or create the folder's location
+     * @see #detectTargetFolder() detectTargetFolder
+     * @see #assertHierarchyTargetFolderExists(Path, LinkOption...) assertHierarchyTargetFolderExists
+     */
+    protected Path createTempClassFolder() throws IOException {
+        Path tmpDir = detectTargetFolder();
+        return assertHierarchyTargetFolderExists(tmpDir.resolve(getClass().getSimpleName()));
+    }
+
     protected Path detectSourcesFolder() throws IllegalStateException {
         Path target = detectTargetFolder();
         Path parent = target.getParent();


[2/3] mina-sshd git commit: Added unit tests for NullInput/OutputStream

Posted by lg...@apache.org.
Added unit tests for NullInput/OutputStream


Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/5b2ef0ae
Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/5b2ef0ae
Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/5b2ef0ae

Branch: refs/heads/master
Commit: 5b2ef0aec8000545e9ae839ed793135393855e58
Parents: b222a67
Author: Goldstein Lyor <ly...@c-b4.com>
Authored: Mon Aug 13 10:35:25 2018 +0300
Committer: Goldstein Lyor <ly...@c-b4.com>
Committed: Mon Aug 13 14:15:46 2018 +0300

----------------------------------------------------------------------
 .../sshd/common/util/io/NullInputStream.java    |  11 +-
 .../sshd/common/util/io/NullOutputStream.java   |   7 +-
 .../common/util/io/NullInputStreamTest.java     | 118 +++++++++++++++++++
 .../common/util/io/NullOutputStreamTest.java    |  80 +++++++++++++
 4 files changed, 208 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/5b2ef0ae/sshd-core/src/main/java/org/apache/sshd/common/util/io/NullInputStream.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/util/io/NullInputStream.java b/sshd-core/src/main/java/org/apache/sshd/common/util/io/NullInputStream.java
index 5ac7f3e..eb21383 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/util/io/NullInputStream.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/util/io/NullInputStream.java
@@ -19,6 +19,7 @@
 
 package org.apache.sshd.common.util.io;
 
+import java.io.EOFException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.nio.channels.Channel;
@@ -43,7 +44,7 @@ public class NullInputStream extends InputStream implements Channel {
     @Override
     public int read() throws IOException {
         if (!isOpen()) {
-            throw new IOException("Stream is closed for reading one value");
+            throw new EOFException("Stream is closed for reading one value");
         }
         return -1;
     }
@@ -51,7 +52,7 @@ public class NullInputStream extends InputStream implements Channel {
     @Override
     public int read(byte[] b, int off, int len) throws IOException {
         if (!isOpen()) {
-            throw new IOException("Stream is closed for reading " + len + " bytes");
+            throw new EOFException("Stream is closed for reading " + len + " bytes");
         }
         return -1;
     }
@@ -59,7 +60,7 @@ public class NullInputStream extends InputStream implements Channel {
     @Override
     public long skip(long n) throws IOException {
         if (!isOpen()) {
-            throw new IOException("Stream is closed for skipping " + n + " bytes");
+            throw new EOFException("Stream is closed for skipping " + n + " bytes");
         }
         return 0L;
     }
@@ -67,7 +68,7 @@ public class NullInputStream extends InputStream implements Channel {
     @Override
     public int available() throws IOException {
         if (!isOpen()) {
-            throw new IOException("Stream is closed for availability query");
+            throw new EOFException("Stream is closed for availability query");
         }
         return 0;
     }
@@ -75,7 +76,7 @@ public class NullInputStream extends InputStream implements Channel {
     @Override
     public synchronized void reset() throws IOException {
         if (!isOpen()) {
-            throw new IOException("Stream is closed for reset");
+            throw new EOFException("Stream is closed for reset");
         }
     }
 

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/5b2ef0ae/sshd-core/src/main/java/org/apache/sshd/common/util/io/NullOutputStream.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/util/io/NullOutputStream.java b/sshd-core/src/main/java/org/apache/sshd/common/util/io/NullOutputStream.java
index 5e3b719..67fa2d0 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/util/io/NullOutputStream.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/util/io/NullOutputStream.java
@@ -19,6 +19,7 @@
 
 package org.apache.sshd.common.util.io;
 
+import java.io.EOFException;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.nio.channels.Channel;
@@ -43,21 +44,21 @@ public class NullOutputStream extends OutputStream implements Channel {
     @Override
     public void write(int b) throws IOException {
         if (!isOpen()) {
-            throw new IOException("Stream is closed for writing one byte");
+            throw new EOFException("Stream is closed for writing one byte");
         }
     }
 
     @Override
     public void write(byte[] b, int off, int len) throws IOException {
         if (!isOpen()) {
-            throw new IOException("Stream is closed for writing " + len + " bytes");
+            throw new EOFException("Stream is closed for writing " + len + " bytes");
         }
     }
 
     @Override
     public void flush() throws IOException {
         if (!isOpen()) {
-            throw new IOException("Stream is closed for flushing");
+            throw new EOFException("Stream is closed for flushing");
         }
     }
 

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/5b2ef0ae/sshd-core/src/test/java/org/apache/sshd/common/util/io/NullInputStreamTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/util/io/NullInputStreamTest.java b/sshd-core/src/test/java/org/apache/sshd/common/util/io/NullInputStreamTest.java
new file mode 100644
index 0000000..bc97b9c
--- /dev/null
+++ b/sshd-core/src/test/java/org/apache/sshd/common/util/io/NullInputStreamTest.java
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.sshd.common.util.io;
+
+import java.io.EOFException;
+import java.io.IOException;
+
+import org.apache.sshd.util.test.BaseTestSupport;
+import org.apache.sshd.util.test.NoIoTestCase;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runners.MethodSorters;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+@Category({ NoIoTestCase.class })
+public class NullInputStreamTest extends BaseTestSupport {
+    private static final NullInputStream INSTANCE = new NullInputStream();
+
+    public NullInputStreamTest() {
+        super();
+    }
+
+    @Test
+    public void testReadOneChar() throws IOException {
+        assertEquals(-1, INSTANCE.read());
+    }
+
+    @Test
+    public void testReadFullBuffer() throws IOException {
+        assertEquals(-1, INSTANCE.read(new byte[Byte.SIZE]));
+    }
+
+    @Test
+    public void testReadPartialBuffer() throws IOException {
+        byte[] buf = new byte[Byte.SIZE];
+        assertEquals(-1, INSTANCE.read(buf, buf.length / 2, (buf.length / 2) - 1));
+    }
+
+    @Test
+    public void testSkip() throws IOException {
+        assertEquals(0L, INSTANCE.skip(Long.SIZE));
+    }
+
+    @Test
+    public void testAvailable() throws IOException {
+        assertEquals(0, INSTANCE.available());
+    }
+
+    @Test
+    public void testNotAllowedToAccessAfterClose() throws IOException {
+        NullInputStream stream = new NullInputStream();
+        stream.close();
+        assertFalse("Stream not marked as closed", stream.isOpen());
+
+        try {
+            int nRead = stream.read();
+            fail("Unexpected single byte read: " + nRead);
+        } catch (EOFException e) {
+            // expected
+        }
+
+        byte[] buf = new byte[Byte.SIZE];
+        try {
+            int nRead = stream.read(buf);
+            fail("Unexpected full buffer read: " + nRead);
+        } catch (EOFException e) {
+            // expected
+        }
+
+        try {
+            int nRead = stream.read(buf, buf.length / 2, (buf.length / 2) - 1);
+            fail("Unexpected partial buffer read: " + nRead);
+        } catch (EOFException e) {
+            // expected
+        }
+
+        try {
+            long skip = stream.skip(Long.SIZE);
+            fail("Unexpected skip result: " + skip);
+        } catch (EOFException e) {
+            // expected
+        }
+
+        try {
+            int nRead = stream.available();
+            fail("Unexpected available count: " + nRead);
+        } catch (IOException e) {
+            // expected
+        }
+        try {
+            stream.reset();
+            fail("Unexpected reset success");
+        } catch (EOFException e) {
+            // expected
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/5b2ef0ae/sshd-core/src/test/java/org/apache/sshd/common/util/io/NullOutputStreamTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/util/io/NullOutputStreamTest.java b/sshd-core/src/test/java/org/apache/sshd/common/util/io/NullOutputStreamTest.java
new file mode 100644
index 0000000..b6a0230
--- /dev/null
+++ b/sshd-core/src/test/java/org/apache/sshd/common/util/io/NullOutputStreamTest.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.sshd.common.util.io;
+
+import java.io.EOFException;
+import java.io.IOException;
+import java.util.Arrays;
+
+import org.apache.sshd.util.test.BaseTestSupport;
+import org.apache.sshd.util.test.NoIoTestCase;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runners.MethodSorters;
+
+/**
+ * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
+ */
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+@Category({ NoIoTestCase.class })
+public class NullOutputStreamTest extends BaseTestSupport {
+    public NullOutputStreamTest() {
+        super();
+    }
+
+    @Test
+    public void testNoAccessAllowedAfterClose() throws IOException {
+        NullOutputStream stream = new NullOutputStream();
+        stream.close();
+        assertFalse("Stream not marked as closed", stream.isOpen());
+
+        try {
+            stream.write('a');
+            fail("Unexpected single value write success");
+        } catch (EOFException e) {
+            // expected
+        }
+
+        byte[] buf = new byte[Byte.SIZE];
+        try {
+            Arrays.fill(buf, (byte) 0x41);
+            stream.write(buf);
+            fail("Unexpected full buffer write success");
+        } catch (EOFException e) {
+            // expected
+        }
+
+        try {
+            Arrays.fill(buf, (byte) 0x42);
+            stream.write(buf, buf.length / 2, (buf.length / 2) - 1);
+            fail("Unexpected partial buffer write success");
+        } catch (EOFException e) {
+            // expected
+        }
+
+        try {
+            stream.flush();
+            fail("Unexpected flush success");
+        } catch (EOFException e) {
+            // expected
+        }
+    }
+}