commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwins...@apache.org
Subject svn commit: r922782 - /commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net/telnet/TelnetClientTest.java
Date Sun, 14 Mar 2010 08:05:16 GMT
Author: rwinston
Date: Sun Mar 14 08:05:16 2010
New Revision: 922782

URL: http://svn.apache.org/viewvc?rev=922782&view=rev
Log:
Solved elusive read() problem

Modified:
    commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net/telnet/TelnetClientTest.java

Modified: commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net/telnet/TelnetClientTest.java
URL: http://svn.apache.org/viewvc/commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net/telnet/TelnetClientTest.java?rev=922782&r1=922781&r2=922782&view=diff
==============================================================================
--- commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net/telnet/TelnetClientTest.java
(original)
+++ commons/proper/net/branches/NET_2_0/src/test/java/org/apache/commons/net/telnet/TelnetClientTest.java
Sun Mar 14 08:05:16 2010
@@ -22,6 +22,7 @@ import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.PipedInputStream;
 import java.io.PipedOutputStream;
+import java.util.Arrays;
 
 /***
  * JUnit test class for TelnetClient.s
@@ -792,8 +793,16 @@ extends TestCase implements TelnetNotifi
 
        // if(is1.available() == 6)
         //{
-            is1.read(buffread1);
-
+            int read = 0;
+            int pos = 0; 
+            
+            byte[] tmp = new byte[16];
+            while ( pos < 5 ) {
+            	read = is1.read(tmp); 
+            	System.arraycopy(tmp, 0, buffread1, pos, read);
+            	pos+=read;
+            }
+            
             if(equalBytes(buffread1, expected1))
                 negotiation1_ok = true;
         //}
@@ -806,6 +815,13 @@ extends TestCase implements TelnetNotifi
         os2.write(send1);
         os2.flush();
         Thread.sleep(1000);
+        
+        tmp = new byte[16];
+        while ( pos < 5 ) {
+        	read = is2.read(tmp); 
+        	System.arraycopy(tmp, 0, buffread1, pos, read);
+        	pos+=read;
+        }
         //if(is2.available() == 6)
         //{
             is2.read(buffread1);



Mime
View raw message