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 2016/12/27 12:17:18 UTC
mina-sshd git commit: [SSHD-722] Do not fail the Nio2ServiceTest if
O/S ignores the requested option value
Repository: mina-sshd
Updated Branches:
refs/heads/master e834e893c -> 1c22cc388
[SSHD-722] Do not fail the Nio2ServiceTest if O/S ignores the requested option value
Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/1c22cc38
Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/1c22cc38
Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/1c22cc38
Branch: refs/heads/master
Commit: 1c22cc3881b9e83a6a6de895c22848a0e46b1dbe
Parents: e834e89
Author: Goldstein Lyor <ly...@c-b4.com>
Authored: Tue Dec 27 14:17:12 2016 +0200
Committer: Goldstein Lyor <ly...@c-b4.com>
Committed: Tue Dec 27 14:17:12 2016 +0200
----------------------------------------------------------------------
.../sshd/common/io/nio2/Nio2ServiceTest.java | 22 +++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/1c22cc38/sshd-core/src/test/java/org/apache/sshd/common/io/nio2/Nio2ServiceTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/io/nio2/Nio2ServiceTest.java b/sshd-core/src/test/java/org/apache/sshd/common/io/nio2/Nio2ServiceTest.java
index eae0bc8..996c54e 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/io/nio2/Nio2ServiceTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/io/nio2/Nio2ServiceTest.java
@@ -19,13 +19,16 @@
package org.apache.sshd.common.io.nio2;
+import java.io.Flushable;
import java.net.Socket;
import java.net.SocketOption;
import java.nio.channels.AsynchronousSocketChannel;
import java.util.Collection;
import java.util.Collections;
+import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
+import java.util.Objects;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
@@ -73,6 +76,7 @@ public class Nio2ServiceTest extends BaseTestSupport {
}
Semaphore sigSem = new Semaphore(0, true);
+ Map<SocketOption<?>, Pair<Object, Object>> actualOptionValues = new HashMap<>(expectedOptions.size());
sshd.setSessionFactory(new SessionFactory(sshd) {
@Override
protected ServerSessionImpl doCreateSession(IoSession ioSession) throws Exception {
@@ -102,7 +106,7 @@ public class Nio2ServiceTest extends BaseTestSupport {
}
Object actValue = socket.getOption(option);
- assertEquals("Mismatched value for " + propName + "/" + option, expValue, actValue);
+ actualOptionValues.put(option, new Pair<>(expValue, actValue));
}
}
});
@@ -117,6 +121,22 @@ public class Nio2ServiceTest extends BaseTestSupport {
} finally {
sshd.stop();
}
+
+ // NOTE: we do not fail the test since some O/S implementations treat the value as a recommendation - i.e., they might ignore it
+ for (Map.Entry<SocketOption<?>, Pair<Object, Object>> mme : actualOptionValues.entrySet()) {
+ SocketOption<?> option = mme.getKey();
+ Pair<?, ?> vp = mme.getValue();
+ Object expValue = vp.getKey();
+ Object actValue = vp.getValue();
+ Appendable output = Objects.equals(expValue, actValue) ? System.out : System.err;
+ output.append('\t').append(option.name())
+ .append(": expected=").append(Objects.toString(expValue))
+ .append(", actual=").append(Objects.toString(actValue))
+ .append(System.lineSeparator());
+ if (output instanceof Flushable) {
+ ((Flushable) output).flush();
+ }
+ }
}
}
}