From 75778303e7058b439622bce97f4f2c831b91b99b Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Wed, 06 Apr 2016 11:46:05 +0000
Subject: [PATCH] Fixed test errors related to HostPort not able to parse "Not connected"

---
 opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/ReplicationServerFailoverTest.java |   69 ++-------
 opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/TopologyViewTest.java              |  163 ++++++++--------------
 opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/GroupIdHandshakeTest.java          |   93 ++----------
 opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/StateMachineTest.java              |    2 
 opendj-server-legacy/src/test/java/org/opends/server/replication/server/ReplicationServerTest.java         |    6 
 opendj-server-legacy/src/test/java/org/opends/server/replication/ReplicationTestCase.java                  |   71 ++++++++--
 6 files changed, 154 insertions(+), 250 deletions(-)

diff --git a/opendj-server-legacy/src/test/java/org/opends/server/replication/ReplicationTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/replication/ReplicationTestCase.java
index b88ea77..d3a7130 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/replication/ReplicationTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/replication/ReplicationTestCase.java
@@ -31,6 +31,7 @@
 import org.forgerock.opendj.adapter.server3x.Converters;
 import org.forgerock.opendj.config.server.ConfigException;
 import org.forgerock.opendj.ldap.ByteString;
+import org.forgerock.opendj.ldap.DN;
 import org.forgerock.opendj.ldap.ModificationType;
 import org.forgerock.opendj.ldap.ResultCode;
 import org.forgerock.opendj.ldap.SearchScope;
@@ -38,7 +39,6 @@
 import org.forgerock.opendj.ldap.requests.Requests;
 import org.opends.server.DirectoryServerTestCase;
 import org.opends.server.TestCaseUtils;
-import org.forgerock.opendj.server.config.server.ReplicationDomainCfg;
 import org.opends.server.backends.task.TaskState;
 import org.opends.server.core.AddOperation;
 import org.opends.server.core.DeleteOperation;
@@ -60,8 +60,8 @@
 import org.opends.server.replication.service.ReplicationBroker;
 import org.opends.server.types.Attribute;
 import org.opends.server.types.Attributes;
-import org.forgerock.opendj.ldap.DN;
 import org.opends.server.types.Entry;
+import org.opends.server.types.HostPort;
 import org.opends.server.types.Modification;
 import org.opends.server.types.SearchResultEntry;
 import org.opends.server.util.TestTimer;
@@ -112,8 +112,6 @@
   protected Entry synchroServerEntry;
   protected Entry replServerEntry;
 
-  private static final String REPLICATION_DB_IMPL_PROPERTY = "org.opends.test.replicationDbImpl";
-
   /** Replication monitor stats. */
   private DN monitorDN;
   private String monitorAttr;
@@ -207,18 +205,13 @@
       int serverId, int windowSize, int port, int timeout,
       long generationId) throws Exception
   {
-    DomainFakeCfg config = newFakeCfg(baseDN, serverId, port);
+    final DomainFakeCfg config = newFakeCfg(baseDN, serverId, port);
     config.setWindowSize(windowSize);
-    return openReplicationSession(config, port, timeout, generationId);
-  }
 
-  protected ReplicationBroker openReplicationSession(ReplicationDomainCfg config,
-      int port, int timeout, long generationId) throws Exception
-  {
     final ReplicationBroker broker = new ReplicationBroker(
         new DummyReplicationDomain(generationId), new ServerState(),
         config, getReplSessionSecurity());
-    connect(broker, port, timeout);
+    connect(broker, timeout);
     return broker;
   }
 
@@ -230,11 +223,11 @@
     return fakeCfg;
   }
 
-  protected void connect(ReplicationBroker broker, int port, int timeout) throws Exception
+  protected void connect(ReplicationBroker broker, int timeout) throws Exception
   {
     broker.start();
     // give some time to the broker to connect to the replicationServer.
-    checkConnection(30, broker, port);
+    checkConnection(30, broker);
 
     if (timeout != 0)
     {
@@ -246,7 +239,7 @@
    * Check connection of the provided ds to the replication server. Waits for connection to be ok up
    * to secTimeout seconds before failing.
    */
-  protected void checkConnection(int secTimeout, final ReplicationBroker rb, int rsPort) throws Exception
+  protected void checkConnection(int secTimeout, final ReplicationBroker rb) throws Exception
   {
     TestTimer timer = new TestTimer.Builder()
       .maxSleep(secTimeout, SECONDS)
@@ -919,4 +912,54 @@
       }
     });
   }
+
+  protected void waitConnected(int dsId, int rsId, int rsPort, LDAPReplicationDomain rd, String msg) throws InterruptedException
+  {
+    final int secTimeout = 30;
+    int nSec = 0;
+
+    // Go out of the loop only if connection is verified or if timeout occurs
+    while (true)
+    {
+      boolean connected = rd.isConnected();
+      int rdPort = -1;
+      boolean rightPort = false;
+      if (connected)
+      {
+        String rsUrl = rd.getReplicationServer();
+        try {
+          rdPort = HostPort.valueOf(rsUrl).getPort();
+          rightPort = rdPort == rsPort;
+        }
+        catch (IllegalArgumentException notConnectedYet)
+        {
+          // wait a bit more
+        }
+      }
+      if (connected && rightPort)
+      {
+        // Connection verified
+        String s = "checkConnection: connection from domain " + dsId
+            + " to replication server " + rsId + " obtained after " + nSec + " seconds.";
+        logger.error(LocalizableMessage.raw(s));
+        if (logger.isTraceEnabled())
+        {
+          logger.trace("*** TEST *** " + s);
+        }
+        return;
+      }
+
+      Thread.sleep(1000);
+      nSec++;
+
+      if (nSec > secTimeout)
+      {
+        // Timeout reached, end with error
+        fail("checkConnection: could not verify connection from domain " + dsId
+            + " to replication server " + rsId + " after " + secTimeout + " seconds."
+            + " Domain connected: " + connected + ", connection port: " + rdPort
+            + " (should be: " + rsPort + "). [" + msg + "]");
+      }
+    }
+  }
 }
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/GroupIdHandshakeTest.java b/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/GroupIdHandshakeTest.java
index cf471f4..f386650 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/GroupIdHandshakeTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/GroupIdHandshakeTest.java
@@ -25,12 +25,11 @@
 
 import org.forgerock.i18n.LocalizableMessage;
 import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.forgerock.opendj.ldap.DN;
 import org.opends.server.TestCaseUtils;
 import org.opends.server.replication.ReplicationTestCase;
 import org.opends.server.replication.server.ReplServerFakeConfiguration;
 import org.opends.server.replication.server.ReplicationServer;
-import org.forgerock.opendj.ldap.DN;
-import org.opends.server.types.HostPort;
 import org.testng.annotations.Test;
 
 /**
@@ -104,8 +103,7 @@
    * replication server. Waits for connection to be ok up to secTimeout seconds
    * before failing.
    */
-  private void checkConnection(int secTimeout, int dsId, int rsId, String msg)
-      throws Exception
+  private void checkConnection(int dsId, int rsId, String msg) throws Exception
   {
 
     int rsPort = -1;
@@ -137,51 +135,10 @@
         fail("Unknown replication server id.");
     }
 
-    int nSec = 0;
-
-    // Go out of the loop only if connection is verified or if timeout occurs
-    while (true)
-    {
-      // Test connection
-      boolean connected = rd.isConnected();
-      int rdPort = -1;
-      boolean rightPort = false;
-      if (connected)
-      {
-        String serverStr = rd.getReplicationServer();
-        rdPort = HostPort.valueOf(serverStr).getPort();
-        if (rdPort == rsPort)
-        {
-          rightPort = true;
-        }
-      }
-      if (connected && rightPort)
-      {
-        // Connection verified
-        debugInfo("checkConnection: connection from domain " + dsId + " to" +
-          " replication server " + rsId + " obtained after "
-          + nSec + " seconds.");
-        return;
-      }
-
-      // Sleep 1 second
-      Thread.sleep(1000);
-      nSec++;
-
-      if (nSec > secTimeout)
-      {
-        // Timeout reached, end with error
-        fail("checkConnection: could not verify connection from domain " + dsId
-          + " to replication server " + rsId + " after " + secTimeout + " seconds."
-          + " Domain connected: " + connected + ", connection port: " + rdPort
-          + " (should be: " + rsPort + "). [" + msg + "]");
-      }
-    }
+    waitConnected(dsId, rsId, rsPort, rd, msg);
   }
 
-  /**
-   * Find needed free TCP ports.
-   */
+  /** Find needed free TCP ports. */
   private void findFreePorts() throws IOException
   {
     int[] ports = TestCaseUtils.findFreePorts(3);
@@ -400,7 +357,6 @@
 
     try
     {
-
       /**
        * Start RS1 with GID=1 and RS2 with GID=2
        */
@@ -414,8 +370,7 @@
        */
       // Start DS1
       rd1 = createReplicationDomain(DS1_ID, 2, testCase);
-      checkConnection(30, DS1_ID, RS2_ID,
-        "Start DS1 with GID=2, should connect to RS2 with GID=2");
+      checkConnection(DS1_ID, RS2_ID, "Start DS1 with GID=2, should connect to RS2 with GID=2");
 
       /**
        * Start DS2 with GID=3, should connect to either RS1 or RS2 (no GID=3
@@ -433,8 +388,8 @@
       rs3 = createReplicationServer(RS3_ID, 3, testCase);
       // Sleep to insure start is done and DS2 has time to detect to server
       // arrival and reconnect
-      checkConnection(30, DS2_ID, RS3_ID,
-        "Start RS3 with GID=3, DS2 with GID=3 should detect server with his GID and connect to RS3");
+      checkConnection(DS2_ID, RS3_ID,
+          "Start RS3 with GID=3, DS2 with GID=3 should detect server with his GID and connect to RS3");
 
 
       /**
@@ -446,10 +401,8 @@
       // Simulate RS3 failure
       rs3.remove();
       // Sleep to insure shutdowns are ok and DS1 and DS2 reconnect to RS1
-      checkConnection(30, DS1_ID, RS1_ID,
-        "Stop RS2 and RS3, DS1 should failover to RS1 with GID=1");
-      checkConnection(30, DS2_ID, RS1_ID,
-        "Stop RS2 and RS3, DS2 should failover to RS1 with GID=1");
+      checkConnection(DS1_ID, RS1_ID, "Stop RS2 and RS3, DS1 should failover to RS1 with GID=1");
+      checkConnection(DS2_ID, RS1_ID, "Stop RS2 and RS3, DS2 should failover to RS1 with GID=1");
 
       /**
        * Restart RS2 and RS3, DS1 should reconnect to RS2 (with GID=2, his GID)
@@ -461,10 +414,8 @@
       rs3 = createReplicationServer(RS3_ID, 3, testCase);
       // Sleep to insure restarts are ok and DS1 and DS2 reconnect to the RS with
       // their group id
-      checkConnection(30, DS1_ID, RS2_ID,
-        "Restart RS2 and RS3, DS1 should reconnect to RS2 (with GID=2, his GID)");
-      checkConnection(30, DS2_ID, RS3_ID,
-        "Restart RS2 and RS3, DS2 should reconnect to RS3 (with GID=3, his GID)");
+      checkConnection(DS1_ID, RS2_ID, "Restart RS2 and RS3, DS1 should reconnect to RS2 (with GID=2, his GID)");
+      checkConnection(DS2_ID, RS3_ID, "Restart RS2 and RS3, DS2 should reconnect to RS3 (with GID=3, his GID)");
 
       //
       // ENTERING CHANGE CONFIG TEST PART
@@ -479,10 +430,8 @@
       rd1.applyConfigurationChange(domainConfWithNewGid);
       domainConfWithNewGid = new DomainFakeCfg(baseDn, DS2_ID, replServers, 1);
       rd2.applyConfigurationChange(domainConfWithNewGid);
-      checkConnection(30, DS1_ID, RS1_ID,
-        "Change GID of DS1 to 1, it should reconnect to RS1 with GID=1");
-      checkConnection(30, DS2_ID, RS1_ID,
-        "Change GID of DS2 to 1, it should reconnect to RS1 with GID=1");
+      checkConnection(DS1_ID, RS1_ID, "Change GID of DS1 to 1, it should reconnect to RS1 with GID=1");
+      checkConnection(DS2_ID, RS1_ID, "Change GID of DS2 to 1, it should reconnect to RS1 with GID=1");
 
       /**
        * Change group id of RS3 to 1
@@ -505,10 +454,8 @@
       rsConfWithNewGid =
           new ReplServerFakeConfiguration(rs1Port, dir, 0, RS1_ID, 0, 100, otherReplServers, 3, 1000, 5000);
       rs1.applyConfigurationChange(rsConfWithNewGid);
-      checkConnection(30, DS1_ID, RS3_ID,
-        "Change GID of RS3 to 1 and RS1 to 3, DS1 should reconnect to RS3 with GID=1");
-      checkConnection(30, DS2_ID, RS3_ID,
-        "Change GID of RS3 to 1 and RS1 to 3, DS2 should reconnect to RS3 with GID=1");
+      checkConnection(DS1_ID, RS3_ID, "Change GID of RS3 to 1 and RS1 to 3, DS1 should reconnect to RS3 with GID=1");
+      checkConnection(DS2_ID, RS3_ID, "Change GID of RS3 to 1 and RS1 to 3, DS2 should reconnect to RS3 with GID=1");
 
       /**
        * Change group id of DS1 and DS2 to 3 : they should reconnect to RS1
@@ -517,12 +464,10 @@
       rd1.applyConfigurationChange(domainConfWithNewGid);
       domainConfWithNewGid = new DomainFakeCfg(baseDn, DS2_ID, replServers, 3);
       rd2.applyConfigurationChange(domainConfWithNewGid);
-      checkConnection(30, DS1_ID, RS1_ID,
-        "Change GID of DS1 to 3, it should reconnect to RS1 with GID=3");
-      checkConnection(30, DS2_ID, RS1_ID,
-        "Change GID of DS2 to 3, it should reconnect to RS1 with GID=3");
-
-    } finally
+      checkConnection(DS1_ID, RS1_ID, "Change GID of DS1 to 3, it should reconnect to RS1 with GID=3");
+      checkConnection(DS2_ID, RS1_ID, "Change GID of DS2 to 3, it should reconnect to RS1 with GID=3");
+    }
+    finally
     {
       endTest();
     }
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/ReplicationServerFailoverTest.java b/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/ReplicationServerFailoverTest.java
index 18ffde0..4fbad98 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/ReplicationServerFailoverTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/ReplicationServerFailoverTest.java
@@ -26,11 +26,11 @@
 import org.forgerock.i18n.LocalizableMessage;
 import org.forgerock.i18n.slf4j.LocalizedLogger;
 import org.forgerock.opendj.config.server.ConfigException;
+import org.forgerock.opendj.ldap.DN;
 import org.opends.server.TestCaseUtils;
 import org.opends.server.replication.ReplicationTestCase;
 import org.opends.server.replication.server.ReplServerFakeConfiguration;
 import org.opends.server.replication.server.ReplicationServer;
-import org.forgerock.opendj.ldap.DN;
 import org.opends.server.types.HostPort;
 import org.testng.annotations.Test;
 
@@ -139,7 +139,7 @@
         // Let time for failover to happen
         // DS1 connected to RS2 ?
         msg = "After " + RS1_ID + " failure";
-        checkConnection(30, DS1_ID, RS2_ID, msg);
+        checkConnection(DS1_ID, RS2_ID, msg);
       }
       else if (rsPort == rs2Port)
       { // Simulate RS2 failure
@@ -148,7 +148,7 @@
         rs2.remove();
         // DS1 connected to RS1 ?
         msg = "After " + RS2_ID + " failure";
-        checkConnection(30, DS1_ID, RS1_ID, msg);
+        checkConnection(DS1_ID, RS1_ID, msg);
       }
       else {
         fail("DS1 is not connected to a RS");
@@ -202,36 +202,36 @@
 
       // DS1 connected to RS2 ?
       String msg = "After " + RS1_ID + " failure";
-      checkConnection(30, DS1_ID, RS2_ID, msg);
+      checkConnection(DS1_ID, RS2_ID, msg);
       // DS2 connected to RS2 ?
-      checkConnection(30, DS2_ID, RS2_ID, msg);
+      checkConnection(DS2_ID, RS2_ID, msg);
 
       // Restart RS1
       rs1 = createReplicationServer(RS1_ID, testCase);
 
       // DS1 connected to RS2 ?
       msg = "Before " + RS2_ID + " failure";
-      checkConnection(30, DS1_ID, RS2_ID, msg);
+      checkConnection(DS1_ID, RS2_ID, msg);
       // DS2 connected to RS2 ?
-      checkConnection(30, DS2_ID, RS2_ID, msg);
+      checkConnection(DS2_ID, RS2_ID, msg);
 
       // Simulate RS2 failure
       rs2.remove();
 
       // DS1 connected to RS1 ?
       msg = "After " + RS2_ID + " failure";
-      checkConnection(30, DS1_ID, RS1_ID, msg);
+      checkConnection(DS1_ID, RS1_ID, msg);
       // DS2 connected to RS1 ?
-      checkConnection(30, DS2_ID, RS1_ID, msg);
+      checkConnection(DS2_ID, RS1_ID, msg);
 
       // Restart RS2
       rs2 = createReplicationServer(RS2_ID, testCase);
 
       // DS1 connected to RS1 ?
       msg = "After " + RS2_ID + " restart";
-      checkConnection(30, DS1_ID, RS1_ID, msg);
+      checkConnection(DS1_ID, RS1_ID, msg);
       // DS2 connected to RS1 ?
-      checkConnection(30, DS2_ID, RS1_ID, msg);
+      checkConnection(DS2_ID, RS1_ID, msg);
 
       debugInfo(testCase + " successfully ended.");
     } finally
@@ -245,7 +245,7 @@
    * replication server. Waits for connection to be ok up to secTimeout seconds
    * before failing.
    */
-  private void checkConnection(int secTimeout, int dsId, int rsId, String msg)
+  private void checkConnection(int dsId, int rsId, String msg)
       throws Exception
   {
     LDAPReplicationDomain rd = null;
@@ -274,51 +274,10 @@
         fail("Unknown replication server id.");
     }
 
-    int nSec = 0;
-
-    // Go out of the loop only if connection is verified or if timeout occurs
-    while (true)
-    {
-      // Test connection
-      boolean connected = rd.isConnected();
-      int rdPort = -1;
-      boolean rightPort = false;
-      if (connected)
-      {
-        String serverStr = rd.getReplicationServer();
-        rdPort = HostPort.valueOf(serverStr).getPort();
-        if (rdPort == rsPort)
-        {
-          rightPort = true;
-        }
-      }
-      if (connected && rightPort)
-      {
-        // Connection verified
-        debugInfo("checkConnection: connection from domain " + dsId + " to" +
-          " replication server " + rsId + " obtained after "
-          + nSec + " seconds.");
-        return;
-      }
-
-      // Sleep 1 second
-      Thread.sleep(1000);
-      nSec++;
-
-      if (nSec > secTimeout)
-      {
-        // Timeout reached, end with error
-        fail("checkConnection: could not verify connection from domain " + dsId
-          + " to replication server " + rsId + " after " + secTimeout + " seconds."
-          + " Domain connected: " + connected + ", connection port: " + rdPort
-          + " (should be: " + rsPort + "). [" + msg + "]");
-      }
-    }
+    waitConnected(dsId, rsId, rsPort, rd, msg);
   }
 
-  /**
-   * Find needed free TCP ports.
-   */
+  /** Find needed free TCP ports. */
   private void findFreePorts() throws IOException
   {
     int[] ports = TestCaseUtils.findFreePorts(2);
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/StateMachineTest.java b/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/StateMachineTest.java
index 2ec5135..197ea7d 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/StateMachineTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/StateMachineTest.java
@@ -222,7 +222,7 @@
     ReplicationBroker broker = new ReplicationBroker(
         new DummyReplicationDomain(generationId), state, fakeCfg, security);
     broker.start();
-    checkConnection(30, broker, rs1Port);
+    checkConnection(30, broker);
     return broker;
   }
 
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/TopologyViewTest.java b/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/TopologyViewTest.java
index 269a89f..1272b7a 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/TopologyViewTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/TopologyViewTest.java
@@ -31,8 +31,9 @@
 import org.forgerock.i18n.LocalizableMessage;
 import org.forgerock.i18n.slf4j.LocalizedLogger;
 import org.forgerock.opendj.config.server.ConfigException;
-import org.opends.server.TestCaseUtils;
+import org.forgerock.opendj.ldap.DN;
 import org.forgerock.opendj.server.config.meta.ReplicationDomainCfgDefn.AssuredType;
+import org.opends.server.TestCaseUtils;
 import org.opends.server.replication.ReplicationTestCase;
 import org.opends.server.replication.common.AssuredMode;
 import org.opends.server.replication.common.DSInfo;
@@ -41,8 +42,6 @@
 import org.opends.server.replication.protocol.ProtocolVersion;
 import org.opends.server.replication.server.ReplServerFakeConfiguration;
 import org.opends.server.replication.server.ReplicationServer;
-import org.forgerock.opendj.ldap.DN;
-import org.opends.server.types.HostPort;
 import org.testng.annotations.Test;
 
 /**
@@ -210,8 +209,7 @@
    * replication server. Waits for connection to be ok up to secTimeout seconds
    * before failing.
    */
-  private void checkConnection(int secTimeout, int dsId, int rsId)
-      throws Exception
+  private void checkConnection(int dsId, int rsId) throws Exception
   {
     int rsPort = -1;
     LDAPReplicationDomain rd = null;
@@ -254,51 +252,10 @@
         fail("Unknown replication server id.");
     }
 
-    int nSec = 0;
-
-    // Go out of the loop only if connection is verified or if timeout occurs
-    while (true)
-    {
-      // Test connection
-      boolean connected = rd.isConnected();
-      int rdPort = -1;
-      boolean rightPort = false;
-      if (connected)
-      {
-        String serverStr = rd.getReplicationServer();
-        rdPort = HostPort.valueOf(serverStr).getPort();
-        if (rdPort == rsPort)
-        {
-          rightPort = true;
-        }
-      }
-      if (connected && rightPort)
-      {
-        // Connection verified
-        debugInfo("checkConnection: connection from domain " + dsId + " to" +
-          " replication server " + rsId + " obtained after "
-          + nSec + " seconds.");
-        return;
-      }
-
-      // Sleep 1 second
-      Thread.sleep(1000);
-      nSec++;
-
-      if (nSec > secTimeout)
-      {
-        // Timeout reached, end with error
-        fail("checkConnection: could not verify connection from domain " + dsId
-          + " to replication server " + rsId + " after " + secTimeout + " seconds."
-          + " Domain connected: " + connected + ", connection port: " + rdPort
-          + " (should be: " + rsPort + ")");
-      }
-    }
+    waitConnected(dsId, rsId, rsPort, rd, "");
   }
 
-  /**
-   * Find needed free TCP ports.
-   */
+  /** Find needed free TCP ports. */
   private void findFreePorts() throws Exception
   {
     int[] ports = TestCaseUtils.findFreePorts(3);
@@ -537,7 +494,7 @@
        */
       debugInfo("*** STEP 1 ***");
       rd1 = createReplicationDomain(DS1_ID);
-      checkConnection(30, DS1_ID, RS1_ID);
+      checkConnection(DS1_ID, RS1_ID);
       theoricalTopoView = createTheoreticalTopoViewForStep(STEP_1);
       checkTopoView(new int[] {DS1_ID}, theoricalTopoView);
 
@@ -547,8 +504,8 @@
       debugInfo("*** STEP 2 ***");
       rd2 = createReplicationDomain(DS2_ID);
       Thread.sleep(500); // Let time to topo msgs being propagated through the network
-      checkConnection(30, DS1_ID, RS1_ID);
-      checkConnection(30, DS2_ID, RS1_ID);
+      checkConnection(DS1_ID, RS1_ID);
+      checkConnection(DS2_ID, RS1_ID);
       theoricalTopoView = createTheoreticalTopoViewForStep(STEP_2);
       checkTopoView(new int[] {DS1_ID, DS2_ID}, theoricalTopoView);
 
@@ -558,8 +515,8 @@
       debugInfo("*** STEP 3 ***");
       rs2 = createReplicationServer(RS2_ID, testCase);
       Thread.sleep(1000); // Let time to topo msgs being propagated through the network
-      checkConnection(30, DS1_ID, RS1_ID);
-      checkConnection(30, DS2_ID, RS1_ID);
+      checkConnection(DS1_ID, RS1_ID);
+      checkConnection(DS2_ID, RS1_ID);
       theoricalTopoView = createTheoreticalTopoViewForStep(STEP_3);
       checkTopoView(new int[] {DS1_ID, DS2_ID}, theoricalTopoView);
 
@@ -569,9 +526,9 @@
       debugInfo("*** STEP 4 ***");
       rd3 = createReplicationDomain(DS3_ID);
       Thread.sleep(500); // Let time to topo msgs being propagated through the network
-      checkConnection(30, DS1_ID, RS1_ID);
-      checkConnection(30, DS2_ID, RS1_ID);
-      checkConnection(30, DS3_ID, RS2_ID);
+      checkConnection(DS1_ID, RS1_ID);
+      checkConnection(DS2_ID, RS1_ID);
+      checkConnection(DS3_ID, RS2_ID);
       theoricalTopoView = createTheoreticalTopoViewForStep(STEP_4);
       checkTopoView(new int[] {DS1_ID, DS2_ID, DS3_ID}, theoricalTopoView);
 
@@ -581,10 +538,10 @@
       debugInfo("*** STEP 5 ***");
       rd4 = createReplicationDomain(DS4_ID);
       Thread.sleep(500); // Let time to topo msgs being propagated through the network
-      checkConnection(30, DS1_ID, RS1_ID);
-      checkConnection(30, DS2_ID, RS1_ID);
-      checkConnection(30, DS3_ID, RS2_ID);
-      checkConnection(30, DS4_ID, RS2_ID);
+      checkConnection(DS1_ID, RS1_ID);
+      checkConnection(DS2_ID, RS1_ID);
+      checkConnection(DS3_ID, RS2_ID);
+      checkConnection(DS4_ID, RS2_ID);
       theoricalTopoView = createTheoreticalTopoViewForStep(STEP_5);
       checkTopoView(new int[] {DS1_ID, DS2_ID, DS3_ID, DS4_ID},
         theoricalTopoView);
@@ -595,11 +552,11 @@
       debugInfo("*** STEP 6 ***");
       rd5 = createReplicationDomain(DS5_ID);
       Thread.sleep(500); // Let time to topo msgs being propagated through the network
-      checkConnection(30, DS1_ID, RS1_ID);
-      checkConnection(30, DS2_ID, RS1_ID);
-      checkConnection(30, DS3_ID, RS2_ID);
-      checkConnection(30, DS4_ID, RS2_ID);
-      checkConnection(30, DS5_ID, RS2_ID);
+      checkConnection(DS1_ID, RS1_ID);
+      checkConnection(DS2_ID, RS1_ID);
+      checkConnection(DS3_ID, RS2_ID);
+      checkConnection(DS4_ID, RS2_ID);
+      checkConnection(DS5_ID, RS2_ID);
       theoricalTopoView = createTheoreticalTopoViewForStep(STEP_6);
       checkTopoView(new int[] {DS1_ID, DS2_ID, DS3_ID, DS4_ID, DS5_ID},
         theoricalTopoView);
@@ -611,11 +568,11 @@
       debugInfo("*** STEP 7 ***");
       rs3 = createReplicationServer(RS3_ID, testCase);
       Thread.sleep(500); // Let time to topo msgs being propagated through the network
-      checkConnection(30, DS1_ID, RS1_ID);
-      checkConnection(30, DS2_ID, RS1_ID);
-      checkConnection(30, DS3_ID, RS2_ID);
-      checkConnection(30, DS4_ID, RS2_ID);
-      checkConnection(30, DS5_ID, RS3_ID);
+      checkConnection(DS1_ID, RS1_ID);
+      checkConnection(DS2_ID, RS1_ID);
+      checkConnection(DS3_ID, RS2_ID);
+      checkConnection(DS4_ID, RS2_ID);
+      checkConnection(DS5_ID, RS3_ID);
       theoricalTopoView = createTheoreticalTopoViewForStep(STEP_7);
       checkTopoView(new int[] {DS1_ID, DS2_ID, DS3_ID, DS4_ID, DS5_ID},
         theoricalTopoView);
@@ -628,12 +585,12 @@
       debugInfo("*** STEP 8 ***");
       rd6 = createReplicationDomain(DS6_ID);
       Thread.sleep(500); // Let time to topo msgs being propagated through the network
-      checkConnection(30, DS1_ID, RS1_ID);
-      checkConnection(30, DS2_ID, RS1_ID);
-      checkConnection(30, DS3_ID, RS2_ID);
-      checkConnection(30, DS4_ID, RS2_ID);
-      checkConnection(30, DS5_ID, RS3_ID);
-      checkConnection(30, DS6_ID, RS3_ID);
+      checkConnection(DS1_ID, RS1_ID);
+      checkConnection(DS2_ID, RS1_ID);
+      checkConnection(DS3_ID, RS2_ID);
+      checkConnection(DS4_ID, RS2_ID);
+      checkConnection(DS5_ID, RS3_ID);
+      checkConnection(DS6_ID, RS3_ID);
       theoricalTopoView = createTheoreticalTopoViewForStep(STEP_8);
       checkTopoView(new int[] {DS1_ID, DS2_ID, DS3_ID, DS4_ID, DS5_ID, DS6_ID},
         theoricalTopoView);
@@ -645,11 +602,11 @@
       debugInfo("*** STEP 9 ***");
       rd6.disable();
       Thread.sleep(500); // Let time to topo msgs being propagated through the network
-      checkConnection(30, DS1_ID, RS1_ID);
-      checkConnection(30, DS2_ID, RS1_ID);
-      checkConnection(30, DS3_ID, RS2_ID);
-      checkConnection(30, DS4_ID, RS2_ID);
-      checkConnection(30, DS5_ID, RS3_ID);
+      checkConnection(DS1_ID, RS1_ID);
+      checkConnection(DS2_ID, RS1_ID);
+      checkConnection(DS3_ID, RS2_ID);
+      checkConnection(DS4_ID, RS2_ID);
+      checkConnection(DS5_ID, RS3_ID);
       assertFalse(rd6.isConnected());
       theoricalTopoView = createTheoreticalTopoViewForStep(STEP_9);
       checkTopoView(new int[] {DS1_ID, DS2_ID, DS3_ID, DS4_ID, DS5_ID},
@@ -663,12 +620,12 @@
       debugInfo("*** STEP 10 ***");
       rd6.enable();
       Thread.sleep(500); // Let time to topo msgs being propagated through the network
-      checkConnection(30, DS1_ID, RS1_ID);
-      checkConnection(30, DS2_ID, RS1_ID);
-      checkConnection(30, DS3_ID, RS2_ID);
-      checkConnection(30, DS4_ID, RS2_ID);
-      checkConnection(30, DS5_ID, RS3_ID);
-      checkConnection(30, DS6_ID, RS3_ID);
+      checkConnection(DS1_ID, RS1_ID);
+      checkConnection(DS2_ID, RS1_ID);
+      checkConnection(DS3_ID, RS2_ID);
+      checkConnection(DS4_ID, RS2_ID);
+      checkConnection(DS5_ID, RS3_ID);
+      checkConnection(DS6_ID, RS3_ID);
       theoricalTopoView = createTheoreticalTopoViewForStep(STEP_10);
       checkTopoView(new int[] {DS1_ID, DS2_ID, DS3_ID, DS4_ID, DS5_ID, DS6_ID},
         theoricalTopoView);
@@ -681,12 +638,12 @@
       debugInfo("*** STEP 11 ***");
       rs3.remove();
       Thread.sleep(500); // Let time to topo msgs being propagated through the network
-      checkConnection(30, DS1_ID, RS1_ID);
-      checkConnection(30, DS2_ID, RS1_ID);
-      checkConnection(30, DS3_ID, RS2_ID);
-      checkConnection(30, DS4_ID, RS2_ID);
-      checkConnection(30, DS5_ID, RS2_ID);
-      checkConnection(30, DS6_ID, RS2_ID);
+      checkConnection(DS1_ID, RS1_ID);
+      checkConnection(DS2_ID, RS1_ID);
+      checkConnection(DS3_ID, RS2_ID);
+      checkConnection(DS4_ID, RS2_ID);
+      checkConnection(DS5_ID, RS2_ID);
+      checkConnection(DS6_ID, RS2_ID);
       theoricalTopoView = createTheoreticalTopoViewForStep(STEP_11);
       checkTopoView(new int[] {DS1_ID, DS2_ID, DS3_ID, DS4_ID, DS5_ID, DS6_ID},
         theoricalTopoView);
@@ -699,12 +656,12 @@
       debugInfo("*** STEP 12 ***");
       rs3 = createReplicationServer(RS3_ID, testCase);
       Thread.sleep(500); // Let time to topo msgs being propagated through the network
-      checkConnection(30, DS1_ID, RS1_ID);
-      checkConnection(30, DS2_ID, RS1_ID);
-      checkConnection(30, DS3_ID, RS2_ID);
-      checkConnection(30, DS4_ID, RS2_ID);
-      checkConnection(30, DS5_ID, RS3_ID);
-      checkConnection(30, DS6_ID, RS3_ID);
+      checkConnection(DS1_ID, RS1_ID);
+      checkConnection(DS2_ID, RS1_ID);
+      checkConnection(DS3_ID, RS2_ID);
+      checkConnection(DS4_ID, RS2_ID);
+      checkConnection(DS5_ID, RS3_ID);
+      checkConnection(DS6_ID, RS3_ID);
       theoricalTopoView = createTheoreticalTopoViewForStep(STEP_12);
       checkTopoView(new int[] {DS1_ID, DS2_ID, DS3_ID, DS4_ID, DS5_ID, DS6_ID},
         theoricalTopoView);
@@ -718,10 +675,10 @@
       debugInfo("*** STEP 13 ***");
       rs2.remove();
       Thread.sleep(500); // Let time to topo msgs being propagated through the network
-      checkConnection(30, DS1_ID, RS1_ID);
-      checkConnection(30, DS2_ID, RS1_ID);
-      checkConnection(30, DS5_ID, RS3_ID);
-      checkConnection(30, DS6_ID, RS3_ID);
+      checkConnection(DS1_ID, RS1_ID);
+      checkConnection(DS2_ID, RS1_ID);
+      checkConnection(DS5_ID, RS3_ID);
+      checkConnection(DS6_ID, RS3_ID);
       theoricalTopoView = createTheoreticalTopoViewForStep(STEP_13);
       checkTopoView(new int[] {DS1_ID, DS2_ID, DS5_ID, DS6_ID},
         theoricalTopoView);
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/replication/server/ReplicationServerTest.java b/opendj-server-legacy/src/test/java/org/opends/server/replication/server/ReplicationServerTest.java
index 76bd528..a70f74b 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/replication/server/ReplicationServerTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/replication/server/ReplicationServerTest.java
@@ -28,6 +28,8 @@
 import org.assertj.core.api.Assertions;
 import org.forgerock.i18n.slf4j.LocalizedLogger;
 import org.forgerock.opendj.config.server.ConfigException;
+import org.forgerock.opendj.ldap.DN;
+import org.forgerock.opendj.ldap.RDN;
 import org.opends.server.TestCaseUtils;
 import org.opends.server.api.SynchronizationProvider;
 import org.opends.server.core.DirectoryServer;
@@ -59,13 +61,11 @@
 import org.opends.server.replication.service.ReplicationBroker;
 import org.opends.server.types.Attribute;
 import org.opends.server.types.Attributes;
-import org.forgerock.opendj.ldap.DN;
 import org.opends.server.types.DirectoryConfig;
 import org.opends.server.types.DirectoryException;
 import org.opends.server.types.Entry;
 import org.opends.server.types.HostPort;
 import org.opends.server.types.Modification;
-import org.forgerock.opendj.ldap.RDN;
 import org.opends.server.util.TimeThread;
 import org.opends.server.workflowelement.localbackend.LocalBackendModifyDNOperation;
 import org.testng.annotations.AfterClass;
@@ -358,7 +358,7 @@
       broker = new ReplicationBroker(new DummyReplicationDomain(generationId),
           state, newFakeCfg(TEST_ROOT_DN, 3, replicationServerPort),
           getReplSessionSecurity());
-      connect(broker, replicationServerPort, 5000);
+      connect(broker, 5000);
 
       ReplicationMsg receivedMsg = broker.receive();
       broker.updateWindowAfterReplay();

--
Gitblit v1.10.0