From 5e4d023e9667ac9e5c750beba869e2966d7c1310 Mon Sep 17 00:00:00 2001
From: Ludovic Poitou <ludovic.poitou@forgerock.com>
Date: Thu, 09 Jan 2014 14:09:35 +0000
Subject: [PATCH] frontport fix to OPENDJ-1268 to the opendj3-server-dev branch.

---
 opendj3-server-dev/src/server/org/opends/server/types/HostPort.java                             |    8 +++++---
 opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/types/HostPortTest.java |   21 ++++++++++++++++++++-
 2 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/opendj3-server-dev/src/server/org/opends/server/types/HostPort.java b/opendj3-server-dev/src/server/org/opends/server/types/HostPort.java
index f18abac..e413158 100644
--- a/opendj3-server-dev/src/server/org/opends/server/types/HostPort.java
+++ b/opendj3-server-dev/src/server/org/opends/server/types/HostPort.java
@@ -22,7 +22,7 @@
  *
  *
  *      Copyright 2006-2008 Sun Microsystems, Inc.
- *      Portions Copyright 2013 ForgeRock AS
+ *      Portions Copyright 2013-2014 ForgeRock AS
  */
 package org.opends.server.types;
 
@@ -260,7 +260,7 @@
               + hostPort + "'. The only allowed format for providing IPv6 "
               + "addresses is '[IPv6 address]:port'");
     }
-    String host = sepIndex != -1 ? hostPort.substring(0, sepIndex) : hostPort;
+    String host = hostPort.substring(0, sepIndex);
     int port = Integer.parseInt(hostPort.substring(sepIndex + 1));
     return new HostPort(host, port);
   }
@@ -426,7 +426,7 @@
       }
       return hostName + ":" + port;
     }
-    return ":" + port;
+    return WILDCARD_ADDRESS + ":" + port;
   }
 
   /**
@@ -510,8 +510,10 @@
 
     HostPort other = (HostPort) obj;
     if (normalizedHost == null)
+    {
       if (other.normalizedHost != null)
         return false;
+    }
     else if (!normalizedHost.equals(other.normalizedHost))
       return false;
 
diff --git a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/types/HostPortTest.java b/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/types/HostPortTest.java
index 6c7c98e..f775ed6 100644
--- a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/types/HostPortTest.java
+++ b/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/types/HostPortTest.java
@@ -21,7 +21,7 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2013 ForgeRock AS
+ *      Copyright 2013-2014 ForgeRock AS
  */
 package org.opends.server.types;
 
@@ -142,4 +142,23 @@
     }
   }
 
+  @Test
+  public void allAddressesNullHost() {
+    HostPort hp = HostPort.allAddresses(1);
+    assertThat(hp.getHost()).isNull();
+    assertThat(hp.getPort()).isEqualTo(1);
+  }
+
+  @Test
+  public void allAddressesToString() {
+    HostPort hp = HostPort.allAddresses(1636);
+    assertThat(hp.toString()).isEqualTo(HostPort.WILDCARD_ADDRESS + ":1636");
+  }
+
+  @Test
+  public void allAddressesEquals() {
+    HostPort hp1 = HostPort.allAddresses(1389);
+    HostPort hp2 = HostPort.allAddresses(1389);
+    assertThat(hp1).isEqualTo(hp2);
+  }
 }

--
Gitblit v1.10.0