tomaswolf commented on code in PR #242:
URL: https://github.com/apache/mina-sshd/pull/242#discussion_r967617775
##########
sshd-core/src/test/java/org/apache/sshd/client/ClientTest.java:
##########
@@ -1530,6 +1532,29 @@ public void testConnectUsingIPv6Address() throws
IOException {
}
}
+ @Test // see SSHD-1295
+ public void testConnectTimeout() throws Exception {
+ client.start();
+ try {
+ ConnectFuture future = client.connect(getCurrentTestName(),
TEST_LOCALHOST, port);
+ try {
+ future.verify(1);
+ fail("Timeout expected");
+ } catch (InterruptedIOException | SshException e) {
+ ClientSession session = null;
+ try {
+ session = future.verify(CONNECT_TIMEOUT).getSession();
+ } catch (SshException e2) {
+ assertTrue("Expected a timeout, got " + e2,
e2.getMessage().contains("timeout"));
+ }
+
+ assertNull("Session should not set since client timeout",
session);
Review Comment:
What is missing in this test now is a verification that the session, if one
got created, was indeed closed.
Maybe install a SessionListener on the client before starting it. That
sessionListener gets invoked whenever a ClientSession is created and can store
that session. Then check here that all sessions that got created are closed or
closing.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]