This is the mail archive of the mauve-discuss@sources.redhat.com mailing list for the Mauve project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

SocketTest cleanup


Hi,

Here is a cleanup for Socket test. The most important change is the host
names that the test uses. Hopefully the gnu machines will be around for
a long, long time. It also makes an available() and two toString()
checks less strict since the specification gives no hard guarantees. It
also drops one test that I think is not specified to work.

    * gnu/testlet/java/net/Socket/SocketTest.java (test_BasicServer): 
    Make available() test less strict. 
    (test_params): Use well known hosts. Make toString() tests less
    strict. Drop comparison with getLocalHost() which is invalid if
    machine has multiple interfaces.

Objections?

Cheers,

Mark
Index: gnu/testlet/java/net/Socket/SocketTest.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/java/net/Socket/SocketTest.java,v
retrieving revision 1.5
diff -u -r1.5 SocketTest.java
--- SocketTest.java	2001/11/05 02:10:20	1.5
+++ SocketTest.java	2002/04/05 14:39:51
@@ -143,9 +143,9 @@
    is.skip(2);
 
    int len=is.available();  // deterministic after blocking for skip
-   if (len!=9) { //"hello buddy" len
+   if (len <= 0) { //"hello buddy" len
     harness.fail("Error : test_BasicServer failed - 7 " +
-     "len returned is not correct.  " + len );
+     "no more data available.  " );
    }
 
    is.read(data,0,3);
@@ -189,7 +189,9 @@
  {
   harness.checkPoint("params");
   try {
-   Socket sock = new Socket( "www.cygnus.com" , 7  );
+   String host = "mail.gnu.org";
+   int port = 25;
+   Socket sock = new Socket( host , port  );
 
    if ( sock.getLocalPort() <= 0 )
     harness.fail("Error : test_params failed - 1 " +
@@ -220,18 +222,14 @@
    if ( sock.getSoLinger() != -1 )
     harness.fail("Error : test_params failed - 5"  );
 
-   if ( sock.getPort() != 7 )
+   if ( sock.getPort() != port )
     harness.fail("Error : test_params failed - 6"  );
 
-   if (! (   (sock.getInetAddress().toString().equals(
-    "www.cygnus.com/205.180.83.41"))))
-    harness.fail("Error : test_params failed - 7"  );
+   harness.check(sock.getInetAddress().toString().indexOf(host) != -1,
+     "getInetAddress().toString() should contain host " + host);
+   harness.check(sock.toString().indexOf(host) != -1,
+     "toString() should contain host " + host);
 
-   if ( !sock.getLocalAddress().toString().equals(InetAddress.getLocalHost().toString()) )
-    harness.fail("Error : test_params failed - 8"  );
-
-   if ( !( (sock.toString().equals("Socket[addr=www.cygnus.com/205.180.83.41,port=7,localport="+sock.getLocalPort()+"]"))))
-    harness.fail("Error : test_params failed - 9 " + " toString did not return the expected string " );
    try {
        Socket.setSocketImplFactory( null );
    }
@@ -296,7 +294,7 @@
 
   // host inet given
   try {
-   Socket s = new Socket ( "mothership.cygnus.com" , 13 );
+   Socket s = new Socket ( "www.gnu.org" , 13 );
   }
   catch ( Exception e ){
      e.printStackTrace();

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]