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

Matthew Swift
04.42.2013 fa134ddc24346bbb579197f38a491d86695f0dd0
Remove TestCaseUtils.clearJEBackend2() and use existing clearJEBackend() method.

* all impacted tests pass.
5 files modified
76 ■■■■ changed files
opends/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java 58 ●●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/InitOnLineTest.java 6 ●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ReSyncTest.java 4 ●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/FractionalReplicationTest.java 4 ●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/StateMachineTest.java 4 ●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java
@@ -50,7 +50,6 @@
import org.opends.server.core.AddOperation;
import org.opends.server.core.DeleteOperation;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.LockFileManager;
import org.opends.server.extensions.ConfigFileHandler;
import org.opends.server.loggers.*;
import org.opends.server.loggers.debug.DebugLogger;
@@ -64,7 +63,6 @@
import org.opends.server.protocols.ldap.BindResponseProtocolOp;
import org.opends.server.protocols.ldap.LDAPMessage;
import org.opends.server.protocols.ldap.LDAPReader;
import org.opends.server.tasks.TaskUtils;
import org.opends.server.tools.LDAPModify;
import org.opends.server.tools.dsconfig.DSConfig;
import org.opends.server.types.*;
@@ -953,62 +951,6 @@
  }
  /**
   * Clears all the entries from the JE backend determined by the be id passed
   * into the method.
   *
   * @param createBaseEntry
   *          Indicate whether to automatically create the base entry and add it
   *          to the backend.
   * @param beID
   *          The be id to clear.
   * @param dn
   *          The suffix of the backend to create if the the createBaseEntry
   *          boolean is true.
   * @throws Exception
   *           If an unexpected problem occurs.
   */
  public static void clearJEBackend2(boolean createBaseEntry, String beID, String dn)
      throws Exception
  {
    BackendImpl backend = (BackendImpl) DirectoryServer.getBackend(beID);
    // FIXME Should setBackendEnabled be part of TaskUtils ?
    TaskUtils.disableBackend(beID);
    try
    {
      String lockFile = LockFileManager.getBackendLockFileName(backend);
      StringBuilder failureReason = new StringBuilder();
      if (!LockFileManager.acquireExclusiveLock(lockFile, failureReason))
      {
        throw new RuntimeException(failureReason.toString());
      }
      try
      {
        backend.clearBackend();
      }
      finally
      {
        LockFileManager.releaseLock(lockFile, failureReason);
      }
    }
    finally
    {
      TaskUtils.enableBackend(beID);
    }
    if (createBaseEntry)
    {
      DN baseDN = DN.decode(dn);
      Entry e = createEntry(baseDN);
      backend = (BackendImpl) DirectoryServer.getBackend(beID);
      backend.addEntry(e, null);
    }
  }
  /**
   * This was used to track down which test was trashing the indexes. We left it
   * here because it might be useful again.
   */
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/InitOnLineTest.java
@@ -159,7 +159,7 @@
    // (like the test backend we use in every tests): backend is disabled then
    // re-enabled and this clears the backend reference and thus the underlying
    // data. So for this particular test, we use a classical backend.
    TestCaseUtils.clearJEBackend2(false, "userRoot", EXAMPLE_DN);
    TestCaseUtils.clearJEBackend(false, "userRoot", EXAMPLE_DN);
    // For most tests, a limited number of entries is enough
    updatedEntries = newLDIFEntries(2);
@@ -602,7 +602,7 @@
    + (heartbeat>0?"ds-cfg-heartbeat-interval: "+heartbeat+" ms\n":"")
    + "ds-cfg-window-size: " + WINDOW_SIZE;
    TestCaseUtils.clearJEBackend2(false, "userRoot", EXAMPLE_DN);
    TestCaseUtils.clearJEBackend(false, "userRoot", EXAMPLE_DN);
    synchroServerEntry = TestCaseUtils.entryFromLdifString(synchroServerLdif);
    DirectoryServer.getConfigHandler().addEntry(synchroServerEntry, null);
@@ -1541,7 +1541,7 @@
    callParanoiaCheck = false;
    super.classCleanUp();
    TestCaseUtils.clearJEBackend2(false, "userRoot", EXAMPLE_DN);
    TestCaseUtils.clearJEBackend(false, "userRoot", EXAMPLE_DN);
    paranoiaCheck();
  }
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ReSyncTest.java
@@ -93,7 +93,7 @@
    // re-enabled and this clears the backend reference and thus the underlying
    // data. So for this particular test, we use a classical backend. Let's
    // clear it and create the root entry
    TestCaseUtils.clearJEBackend2(false, "userRoot", EXAMPLE_DN);
    TestCaseUtils.clearJEBackend(false, "userRoot", EXAMPLE_DN);
    addEntry("dn: dc=example,dc=com\n" + "objectClass: top\n"
        + "objectClass: domain\n");
@@ -265,7 +265,7 @@
    callParanoiaCheck = false;
    super.classCleanUp();
    TestCaseUtils.clearJEBackend2(false, "userRoot", EXAMPLE_DN);
    TestCaseUtils.clearJEBackend(false, "userRoot", EXAMPLE_DN);
    TestCaseUtils.deleteDirectory(reSyncTempDir);
    paranoiaCheck();
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/FractionalReplicationTest.java
@@ -1006,7 +1006,7 @@
    // We need a backend with a real configuration in cn=config as at import time
    // the real domain will check for backend existence in cn=config. So we use
    // dc=example,dc=com for this particular test.
    clearJEBackend2(false, "userRoot", TEST2_ROOT_DN_STRING);
    clearJEBackend(false, "userRoot", TEST2_ROOT_DN_STRING);
    try
    {
@@ -1244,7 +1244,7 @@
    // We need a backend with a real configuration in cn=config as at import time
    // the real domain will check for backend existence in cn=config. So we use
    // dc=example,dc=com for this particular test.
    clearJEBackend2(false, "userRoot", TEST2_ROOT_DN_STRING);
    clearJEBackend(false, "userRoot", TEST2_ROOT_DN_STRING);
    try
    {
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/StateMachineTest.java
@@ -720,7 +720,7 @@
    // going into degraded status, we need to send a lot of updates. This makes
    // the memory test backend crash with OutOfMemoryError. So we prefer here
    // a backend backed up with a file
    TestCaseUtils.clearJEBackend2(false, "userRoot", EXAMPLE_DN);
    TestCaseUtils.clearJEBackend(false, "userRoot", EXAMPLE_DN);
  }
@@ -736,7 +736,7 @@
    callParanoiaCheck = false;
    super.classCleanUp();
    TestCaseUtils.clearJEBackend2(false, "userRoot", EXAMPLE_DN);
    TestCaseUtils.clearJEBackend(false, "userRoot", EXAMPLE_DN);
    paranoiaCheck();
  }