commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1080434 - in /commons/proper/net/trunk/src/test/java/org/apache/commons/net/telnet: TelnetClientTest.java TelnetTestSimpleServer.java
Date Fri, 11 Mar 2011 03:21:53 GMT
Author: sebb
Date: Fri Mar 11 03:21:53 2011
New Revision: 1080434

URL: http://svn.apache.org/viewvc?rev=1080434&view=rev
Log:
Avoid spurious errors when some ports are busy

Modified:
    commons/proper/net/trunk/src/test/java/org/apache/commons/net/telnet/TelnetClientTest.java
    commons/proper/net/trunk/src/test/java/org/apache/commons/net/telnet/TelnetTestSimpleServer.java

Modified: commons/proper/net/trunk/src/test/java/org/apache/commons/net/telnet/TelnetClientTest.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/test/java/org/apache/commons/net/telnet/TelnetClientTest.java?rev=1080434&r1=1080433&r2=1080434&view=diff
==============================================================================
--- commons/proper/net/trunk/src/test/java/org/apache/commons/net/telnet/TelnetClientTest.java
(original)
+++ commons/proper/net/trunk/src/test/java/org/apache/commons/net/telnet/TelnetClientTest.java
Fri Mar 11 03:21:53 2011
@@ -76,8 +76,9 @@ extends TestCase implements TelnetNotifi
     @Override
     protected void setUp() throws Exception 
     {
+        int socket = 0;
         super.setUp();
-        for (int port = 3333, socket = 0; socket < NUM_CONNECTIONS && port <
4000; port++) 
+        for (int port = 3333; socket < NUM_CONNECTIONS && port < 4000; port++)

         {
             TelnetTestSimpleServer server = null;
             TelnetClient client = null;
@@ -131,9 +132,11 @@ extends TestCase implements TelnetNotifi
                socket++;
            } catch (IOException e) {
                closeConnection(server, client, port);
-               System.err.println("failed to open client-server connection on port " + port);
            }
        }
+       if (socket < NUM_CONNECTIONS) {
+           System.err.println("Only created "+socket+" clients; wanted "+NUM_CONNECTIONS);
+       }
        Thread.sleep(1000);
     }
     

Modified: commons/proper/net/trunk/src/test/java/org/apache/commons/net/telnet/TelnetTestSimpleServer.java
URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/test/java/org/apache/commons/net/telnet/TelnetTestSimpleServer.java?rev=1080434&r1=1080433&r2=1080434&view=diff
==============================================================================
--- commons/proper/net/trunk/src/test/java/org/apache/commons/net/telnet/TelnetTestSimpleServer.java
(original)
+++ commons/proper/net/trunk/src/test/java/org/apache/commons/net/telnet/TelnetTestSimpleServer.java
Fri Mar 11 03:21:53 2011
@@ -101,6 +101,9 @@ public class TelnetTestSimpleServer impl
      ***/
     public void disconnect()
     {
+        if (clientSocket == null) {
+            return;
+        }
         synchronized (clientSocket)
         {
             try



Mime
View raw message