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/11/19 17:03:49 UTC

svn commit: r882185 - in /mina/sshd/trunk/sshd-core/src/test/java/org/apache/sshd: ClientTest.java ScpTest.java ServerTest.java

Author: gnodet
Date: Thu Nov 19 16:03:48 2009
New Revision: 882185

URL: http://svn.apache.org/viewvc?rev=882185&view=rev
Log:
Try to make tests a bit more reliable

Modified:
    mina/sshd/trunk/sshd-core/src/test/java/org/apache/sshd/ClientTest.java
    mina/sshd/trunk/sshd-core/src/test/java/org/apache/sshd/ScpTest.java
    mina/sshd/trunk/sshd-core/src/test/java/org/apache/sshd/ServerTest.java

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=882185&r1=882184&r2=882185&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 Thu Nov 19 16:03:48 2009
@@ -67,7 +67,7 @@
     @After
     public void tearDown() throws Exception {
         if (sshd != null) {
-            sshd.stop();
+            sshd.stop(true);
             Thread.sleep(50);
         }
     }

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=882185&r1=882184&r2=882185&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 Thu Nov 19 16:03:48 2009
@@ -233,6 +233,7 @@
         assertEquals(0, is.read());
         os.write(0);
         os.flush();
+        Thread.sleep(100);
         c.disconnect();
     }
 

Modified: mina/sshd/trunk/sshd-core/src/test/java/org/apache/sshd/ServerTest.java
URL: http://svn.apache.org/viewvc/mina/sshd/trunk/sshd-core/src/test/java/org/apache/sshd/ServerTest.java?rev=882185&r1=882184&r2=882185&view=diff
==============================================================================
--- mina/sshd/trunk/sshd-core/src/test/java/org/apache/sshd/ServerTest.java (original)
+++ mina/sshd/trunk/sshd-core/src/test/java/org/apache/sshd/ServerTest.java Thu Nov 19 16:03:48 2009
@@ -19,6 +19,7 @@
 package org.apache.sshd;
 
 import java.net.ServerSocket;
+import java.util.concurrent.TimeoutException;
 
 import org.apache.mina.core.session.IoSession;
 import org.apache.sshd.client.SessionFactory;
@@ -42,6 +43,7 @@
 public class ServerTest {
 
     private SshServer sshd;
+    private SshClient client;
     private int port;
 
     @Before
@@ -60,7 +62,12 @@
 
     @After
     public void tearDown() throws Exception {
-        sshd.stop();
+        if (sshd != null) {
+            sshd.stop(true);
+        }
+        if (client != null) {
+            client.stop();
+        }
     }
 
     /**
@@ -71,7 +78,7 @@
     public void testFailAuthentication() throws Exception {
         sshd.getProperties().put(SshServer.MAX_AUTH_REQUESTS, "10");
 
-        SshClient client = SshClient.setUpDefaultClient();
+        client = SshClient.setUpDefaultClient();
         client.start();
         ClientSession s = client.connect("localhost", port).await().getSession();
         int nbTrials = 0;
@@ -79,7 +86,10 @@
         while ((res & ClientSession.CLOSED) == 0) {
             nbTrials ++;
             s.authPassword("smx", "buggy");
-            res = s.waitFor(ClientSession.CLOSED | ClientSession.WAIT_AUTH, 0);
+            res = s.waitFor(ClientSession.CLOSED | ClientSession.WAIT_AUTH, 5000);
+            if (res == ClientSession.TIMEOUT) {
+                throw new TimeoutException();
+            }
         }
         Assert.assertTrue(nbTrials > 10);
     }
@@ -88,7 +98,7 @@
     public void testAuthenticationTimeout() throws Exception {
         sshd.getProperties().put(SshServer.AUTH_TIMEOUT, "1000");
 
-        SshClient client = SshClient.setUpDefaultClient();
+        client = SshClient.setUpDefaultClient();
         client.start();
         ClientSession s = client.connect("localhost", port).await().getSession();
         int res = s.waitFor(ClientSession.CLOSED, 5000);
@@ -97,7 +107,7 @@
 
     @Test
     public void testLanguage() throws Exception {
-        SshClient client = SshClient.setUpDefaultClient();
+        client = SshClient.setUpDefaultClient();
         client.setSessionFactory(new SessionFactory() {
             @Override
             protected AbstractSession createSession(IoSession ioSession) throws Exception {
@@ -127,4 +137,5 @@
         sshd.start();
         Thread.sleep(100000);
     }
+
 }