This is the mail archive of the mauve-discuss@sourceware.org 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]

patch to ensure hostnames w/ extra spaces are recognized


hello there,

pls. find attached a patch to InetAddress.getAllByName that tests for 
hostname strings with extra space characters.

the corresponding ChangeLog entry follows:

2006-01-01  Raif S. Naffah  <raif@swiftdsl.com.au>

	* gnu/testlet/java/net/InetAddress/getAllByName.java (test):
	  Ensure hostname strings with extra spaces are recognized.


cheers;
rsn
Index: getAllByName.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/java/net/InetAddress/getAllByName.java,v
retrieving revision 1.1
diff -u -r1.1 getAllByName.java
--- getAllByName.java	13 Aug 2004 21:59:26 -0000	1.1
+++ getAllByName.java	1 Jan 2006 23:28:56 -0000
@@ -42,5 +42,61 @@
     {
       harness.fail(x.toString());
     }
+
+    // getAllByName("") also should return the loopback address
+    try
+      {
+        InetAddress[] addr = InetAddress.getAllByName("");
+        harness.check(addr != null);
+        InetAddress loopback = addr[0];
+        harness.check(loopback != null);
+        harness.check(loopback.isLoopbackAddress());
+      }
+    catch (UnknownHostException x)
+      {
+        harness.fail(x.toString());
+      }
+
+    // so should getAllByName("  ")
+    try
+      {
+        InetAddress[] addr = InetAddress.getAllByName("  ");
+        harness.check(addr != null);
+        InetAddress loopback = addr[0];
+        harness.check(loopback != null);
+        harness.check(loopback.isLoopbackAddress());
+      }
+    catch (UnknownHostException x)
+      {
+        harness.fail(x.toString());
+      }
+
+    // so should getAllByName("localhost")
+    try
+      {
+        InetAddress[] addr = InetAddress.getAllByName("localhost");
+        harness.check(addr != null);
+        InetAddress loopback = addr[0];
+        harness.check(loopback != null);
+        harness.check(loopback.isLoopbackAddress());
+      }
+    catch (UnknownHostException x)
+      {
+        harness.fail(x.toString());
+      }
+
+    // so should getAllByName("  localhost  ")
+    try
+      {
+        InetAddress[] addr = InetAddress.getAllByName("  localhost  ");
+        harness.check(addr != null);
+        InetAddress loopback = addr[0];
+        harness.check(loopback != null);
+        harness.check(loopback.isLoopbackAddress());
+      }
+    catch (UnknownHostException x)
+      {
+        harness.fail(x.toString());
+      }
   }
 }

Attachment: pgp00000.pgp
Description: PGP signature


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