mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Jean-Noel Rouvignac
25.52.2013 2c7af8129bbd29fb3c7c29923b438475a9e928dd
ReplicationServerLoadBalancingTest.java:
Extracted method stopRs() to improve expressiveness again.
1 files modified
39 ■■■■■ changed files
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/ReplicationServerLoadBalancingTest.java 39 ●●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/ReplicationServerLoadBalancingTest.java
@@ -135,8 +135,7 @@
    {
      if (rs[i] != null)
      {
        rs[i].clearDb();
        rs[i].remove();
        stopRs(i);
        StaticUtils.recursiveDelete(new File(DirectoryServer.getInstanceRoot(),
                 rs[i].getDbDirName()));
        rs[i] = null;
@@ -744,13 +743,7 @@
      /**
       * Stop RS2 and RS4, we must end up with RS1 has 4 DSs, and RS3 has 16 DSs
       */
      // Stop RS2
      rs[1].clearDb();
      rs[1].remove();
      // Stop RS4
      rs[3].clearDb();
      rs[3].remove();
      stopRs(1, 3);
      checkForCorrectNumbersOfConnectedDSs(new int[][]{new int[] {4, -1, 16, -1}},
        "Stopped RS2 and RS4");
@@ -772,10 +765,7 @@
       * Stop RS3, we must end up with RS1 has 3 DSs, and RS2 has 7 DSs and
       * RS4 has 10 DSs
       */
      // Stop RS3
      rs[2].clearDb();
      rs[2].remove();
      stopRs(2);
      checkForCorrectNumbersOfConnectedDSs(new int[][]{
        new int[] {2, 8, -1, 10},
@@ -801,16 +791,7 @@
      /**
       * Stop RS1, RS2 and RS3, all DSs should be connected to RS4
       */
      // Stop RS1
      rs[0].clearDb();
      rs[0].remove();
      // Stop RS2
      rs[1].clearDb();
      rs[1].remove();
      // Stop RS3
      rs[2].clearDb();
      rs[2].remove();
      stopRs(0, 1, 2);
      checkForCorrectNumbersOfConnectedDSs(new int[][]{new int[] {-1, -1, -1, 20}},
        "Stopped RS1, RS2 and RS3");
@@ -821,6 +802,18 @@
    }
  }
  private void stopRs(int... rsIndexes)
  {
    for (int rsIndex : rsIndexes)
    {
      if (rs[rsIndex] != null)
      {
        rs[rsIndex].clearDb();
        rs[rsIndex].remove();
      }
    }
  }
  /** Translate an int array into a human readable string */
  private static String intArrayToString(int[] ints)
  {