This is the mail archive of the
mauve-discuss@sources.redhat.com
mailing list for the Mauve project.
RE: SeverSocket.toString() not specified
- From: Mark Wielaard <mark at klomp dot org>
- To: "Koster, K.J." <K dot J dot Koster at kpn dot com>
- Cc: mauve-discuss at sources dot redhat dot com
- Date: 05 Apr 2002 16:26:43 +0200
- Subject: RE: SeverSocket.toString() not specified
- References: <59063B5B4D98D311BC0D0001FA7E452205FDA575@l04.research.kpn.com>
Hi,
On Fri, 2002-04-05 at 15:33, Koster, K.J. wrote:
> While I agree that it's not formally specified, I think that the
> representation of IP addresses as strings is pretty much written in stone by
> now. I think it will be safe to assume what the returned format is going to
> be. Anyone writing an implementation of InetAddress that returns the IP
> address for example in hexadecimal notation better make that their #1 FAQ
> item.
I have noticed the toString() methods do vary a little bit, do they
contain a [] around the returned string, do they actually resolve the
hostname, sometimes there is an extra space somewhere, etc.
But I agree that if it does not even contain the InetAddress as dotted
decimals then the user might be very confused. Maybe changing the test
as follows might be more correct.
* gnu/testlet/java/net/ServerSocket/ServerSocketTest.java
(test_params): Make toString() tests less strict, just check if they
contain the ip number.
What do you think?
Cheers,
Mark
Index: gnu/testlet/java/net/ServerSocket/ServerSocketTest.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/java/net/ServerSocket/ServerSocketTest.java,v
retrieving revision 1.2
diff -u -r1.2 ServerSocketTest.java
--- ServerSocketTest.java 1999/07/12 16:26:14 1.2
+++ ServerSocketTest.java 2002/04/05 14:23:36
@@ -165,15 +165,13 @@
}
catch ( Exception e ){}
+
+ String ip = "0.0.0.0";
+ harness.check(sock.toString().indexOf(ip) != -1,
+ "toString() should contain IP");
+ harness.check(sock.getInetAddress().toString().indexOf(ip) != -1,
+ "InetAddress toString() should contain IP");
- if ( !sock.toString().equals(
-"ServerSocket[addr=all-zeros-broadcast/0.0.0.0,port=0,localport=30000]"))
- harness.fail("Error : test_params failed - 4" + "toString did not return proper values " );
-
- if ( !sock.getInetAddress().toString().equals(
- "all-zeros-broadcast/0.0.0.0"))
- harness.fail("Error : test_params failed - 5" + "getInetAddress did not return proper values " );
-
sock.setSocketFactory( null );
}