public inbox for mauve-discuss@sourceware.org
 help / color / mirror / Atom feed
* RE: SeverSocket.toString() not specified
@ 2002-04-05  6:40 Koster, K.J.
  0 siblings, 0 replies; 4+ messages in thread
From: Koster, K.J. @ 2002-04-05  6:40 UTC (permalink / raw)
  To: 'Mark Wielaard'; +Cc: mauve-discuss

Dear Mark,

> 
> 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.
>
Hmm... If the tests get messy I'd say just slash it. You're right.

    Kees Jan

=====================================================
 You can't have everything.  Where would you put it?
                                     [Steven Wright]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: SeverSocket.toString() not specified
  2002-04-05  5:33 Koster, K.J.
@ 2002-04-05  6:26 ` Mark Wielaard
  0 siblings, 0 replies; 4+ messages in thread
From: Mark Wielaard @ 2002-04-05  6:26 UTC (permalink / raw)
  To: Koster, K.J.; +Cc: mauve-discuss

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

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

[-- Attachment #2: ServerSocketTest.patch2 --]
[-- Type: text/x-patch, Size: 1156 bytes --]

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: SeverSocket.toString() not specified
@ 2002-04-05  5:33 Koster, K.J.
  2002-04-05  6:26 ` Mark Wielaard
  0 siblings, 1 reply; 4+ messages in thread
From: Koster, K.J. @ 2002-04-05  5:33 UTC (permalink / raw)
  To: 'Mark Wielaard'; +Cc: mauve-discuss

Dear Mark,

> 
> InetAddress.toString() also does not have a specification of the
> returned String format:
> 	Converts this IP address to a String.
> 
> So I propose to drop both tests.
> 
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.

    Kees Jan

=====================================================
 You can't have everything.  Where would you put it?
                                     [Steven Wright]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* SeverSocket.toString() not specified
@ 2002-04-05  5:23 Mark Wielaard
  0 siblings, 0 replies; 4+ messages in thread
From: Mark Wielaard @ 2002-04-05  5:23 UTC (permalink / raw)
  To: mauve-discuss

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

Hi,

The spec for ServerSocket.toString() only says:
    Returns the implementation address and implementation port of this
    socket as a String.

So no valid test can be made for that method.

InetAddress.toString() also does not have a specification of the
returned String format:
	Converts this IP address to a String.

So I propose to drop both tests.

        * gnu/testlet/java/net/ServerSocket/ServerSocketTest.java
        (test_params): Drop unspecified toString() tests.

Any objections?

Cheers,

Mark

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

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 13:19:33
@@ -166,14 +166,6 @@
 			}
 			catch ( Exception e ){}
 
-			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 );
 			
 		}

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-04-05 14:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-05  6:40 SeverSocket.toString() not specified Koster, K.J.
  -- strict thread matches above, loose matches on Subject: below --
2002-04-05  5:33 Koster, K.J.
2002-04-05  6:26 ` Mark Wielaard
2002-04-05  5:23 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).