public inbox for mauve-discuss@sourceware.org
 help / color / mirror / Atom feed
* SocketTest cleanup
@ 2002-04-05  6:52 Mark Wielaard
  0 siblings, 0 replies; only message in thread
From: Mark Wielaard @ 2002-04-05  6:52 UTC (permalink / raw)
  To: mauve-discuss

[-- Attachment #1: Type: text/plain, Size: 661 bytes --]

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

[-- Attachment #2: SocketTest.patch --]
[-- Type: text/x-patch, Size: 2359 bytes --]

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();

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-04-05 14:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-05  6:52 SocketTest cleanup Mark Wielaard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).