Author: jfclere Date: Fri Aug 22 01:08:53 2008 New Revision: 688013 URL: http://svn.apache.org/viewvc?rev=688013&view=rev Log: Improve the test.
Modified: tomcat/connectors/trunk/jni/test/org/apache/tomcat/jni/SocketServerTestBind.java Modified: tomcat/connectors/trunk/jni/test/org/apache/tomcat/jni/SocketServerTestBind.java URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jni/test/org/apache/tomcat/jni/SocketServerTestBind.java?rev=688013&r1=688012&r2=688013&view=diff ============================================================================== --- tomcat/connectors/trunk/jni/test/org/apache/tomcat/jni/SocketServerTestBind.java (original) +++ tomcat/connectors/trunk/jni/test/org/apache/tomcat/jni/SocketServerTestBind.java Fri Aug 22 01:08:53 2008 @@ -23,6 +23,7 @@ import junit.framework.TestCase; import java.io.OutputStream; +import java.io.InputStream; import java.net.NetworkInterface; import java.net.InetAddress; import java.util.*; @@ -70,11 +71,17 @@ while (running) { /* Accept it */ long clientSock = Socket.accept(serverSock); + Socket.timeoutSet(clientSock, 10000); byte [] buf = new byte[1]; while (Socket.recv(clientSock, buf, 0, 1) == 1) { + if (buf[0] == 'A') { + buf[0] = 'Z'; + Socket.send(clientSock, buf, 0, 1); + } } - if (buf[0] != 'A') - break; + Socket.close(clientSock); + if (buf[0] != 'Z') + running = false; } client.join(); Library.terminate(); @@ -95,11 +102,15 @@ InetAddress ia = (InetAddress)addrs.nextElement(); System.out.println("Trying: " + ia.getHostAddress()); java.net.Socket sock = new java.net.Socket(ia, port); + sock.setSoTimeout(10000); OutputStream ou = sock.getOutputStream(); + InputStream in = sock.getInputStream(); ou.write('A'); ou.flush(); - java.lang.Thread.sleep(10000); - ou.close(); + int rep = in.read(); + sock.close(); + if (rep != 'Z') + throw new Exception("Read wrong data"); } } } catch(Exception ex ) { @@ -112,8 +123,7 @@ OutputStream ou = sock.getOutputStream(); ou.write('E'); ou.flush(); - java.lang.Thread.sleep(10000); - ou.close(); + sock.close(); } catch(Exception ex ) { ex.printStackTrace(); } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]