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

Jean-Noel Rouvignac
08.58.2014 28beddfaabda3e031ca4b0448c8f30e8a1067185
opendj3-server-dev/src/server/org/opends/server/crypto/CryptoManagerImpl.java
@@ -27,10 +27,10 @@
 */
package org.opends.server.crypto;
import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.security.*;
import java.security.cert.Certificate;
@@ -546,10 +546,7 @@
            final Entry entry = new Entry(entryDN, null, null, null);
            entry.addObjectClass(DirectoryServer.getTopObjectClass());
            entry.addObjectClass(ocCertRequest);
            AddOperation addOperation = icc.processAdd(entry.getName(),
                    entry.getObjectClasses(),
                    entry.getUserAttributes(),
                    entry.getOperationalAttributes());
            AddOperation addOperation = icc.processAdd(entry);
            if (ResultCode.SUCCESS != addOperation.getResultCode()) {
              throw new DirectoryException(
                      addOperation.getResultCode(),
@@ -681,10 +678,7 @@
        final Attribute certificateAttr = builder.toAttribute();
        entry.addAttribute(certificateAttr, new ArrayList<ByteString>(0));
        AddOperation addOperation = icc.processAdd(entry.getName(),
                entry.getObjectClasses(),
                entry.getUserAttributes(),
                entry.getOperationalAttributes());
        AddOperation addOperation = icc.processAdd(entry);
        if (ResultCode.SUCCESS != addOperation.getResultCode()) {
          throw new DirectoryException(
                  addOperation.getResultCode(),
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java
@@ -71,15 +71,20 @@
import org.opends.server.tools.LDAPModify;
import org.opends.server.types.*;
import org.opends.server.types.FilePermission;
import org.opends.server.types.InitializationException;
import org.opends.server.types.LDIFImportConfig;
import org.opends.server.types.Schema;
import org.opends.server.util.BuildVersion;
import org.opends.server.util.EmbeddedUtils;
import org.opends.server.util.LDIFReader;
import com.forgerock.opendj.util.OperatingSystem;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.opends.server.util.CollectionUtils.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
import static org.testng.Assert.*;
import com.forgerock.opendj.util.OperatingSystem;
/**
 * This class defines some utility functions which can be used by test cases.
@@ -473,7 +478,7 @@
      ConfigurationFramework.getInstance()
          .initialize(testInstallRoot.getAbsolutePath(),
              testInstanceRoot.getAbsolutePath());
      AccessLogger.getInstance().addLogPublisher(
          (AccessLogPublisher) TextAccessLogPublisher
              .getStartupTextAccessPublisher(ACCESS_TEXT_WRITER, false));
@@ -1928,17 +1933,17 @@
  public static <T> Set<T> newSet(T... elems)
  {
    return new HashSet<T>(Arrays.asList(elems));
    return newHashSet(elems);
  }
  public static <T> SortedSet<T> newSortedSet(T... elems)
  {
    return new TreeSet<T>(Arrays.asList(elems));
    return newTreeSet(elems);
  }
  public static <T> List<T> newList(T... elems)
  {
    return new ArrayList<T>(Arrays.asList(elems));
    return newArrayList(elems);
  }
  public static HashSet<PluginType> getPluginTypes(Entry e)
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/admin/server/ConstraintTest.java
@@ -26,14 +26,14 @@
 */
package org.opends.server.admin.server;
import java.util.List;
import javax.naming.OperationNotSupportedException;
import javax.naming.ldap.LdapName;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.TestCaseUtils;
import org.opends.server.admin.AdminTestCase;
import org.opends.server.admin.TestCfg;
@@ -42,25 +42,23 @@
import org.opends.server.admin.TestParentCfg;
import org.opends.server.admin.client.ldap.JNDIDirContextAdaptor;
import org.opends.server.admin.std.server.RootCfg;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.AddOperation;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.types.ConfigChangeResult;
import org.opends.server.types.Entry;
import org.forgerock.opendj.ldap.ResultCode;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.testng.Assert.*;
/**
 * Test cases for constraints on the server-side.
 */
public final class ConstraintTest extends AdminTestCase {
  // Child DN.
  /** Child DN. */
  private static final String TEST_CHILD_1_DN = "cn=test child 1,cn=test children,cn=test parent 1,cn=test parents,cn=config";
@@ -71,18 +69,16 @@
  private static class AddListener implements
      ConfigurationAddListener<TestChildCfg> {
    /**
     * {@inheritDoc}
     */
    /** {@inheritDoc} */
    @Override
    public ConfigChangeResult applyConfigurationAdd(TestChildCfg configuration) {
      return new ConfigChangeResult(ResultCode.SUCCESS, false);
    }
    /**
     * {@inheritDoc}
     */
    /** {@inheritDoc} */
    @Override
    public boolean isConfigurationAddAcceptable(TestChildCfg configuration,
        List<LocalizableMessage> unacceptableReasons) {
      return true;
@@ -98,9 +94,8 @@
  private static class DeleteListener implements
      ConfigurationDeleteListener<TestChildCfg> {
    /**
     * {@inheritDoc}
     */
    /** {@inheritDoc} */
    @Override
    public ConfigChangeResult applyConfigurationDelete(
        TestChildCfg configuration) {
      return new ConfigChangeResult(ResultCode.SUCCESS, false);
@@ -108,9 +103,8 @@
    /**
     * {@inheritDoc}
     */
    /** {@inheritDoc} */
    @Override
    public boolean isConfigurationDeleteAcceptable(TestChildCfg configuration,
        List<LocalizableMessage> unacceptableReasons) {
      return true;
@@ -126,9 +120,8 @@
  private static class ChangeListener implements
      ConfigurationChangeListener<TestChildCfg> {
    /**
     * {@inheritDoc}
     */
    /** {@inheritDoc} */
    @Override
    public ConfigChangeResult applyConfigurationChange(
        TestChildCfg configuration) {
      return new ConfigChangeResult(ResultCode.SUCCESS, false);
@@ -136,9 +129,8 @@
    /**
     * {@inheritDoc}
     */
    /** {@inheritDoc} */
    @Override
    public boolean isConfigurationChangeAcceptable(TestChildCfg configuration,
        List<LocalizableMessage> unacceptableReasons) {
      return true;
@@ -146,7 +138,7 @@
  }
  // Test child 1 LDIF.
  /** Test child 1 LDIF. */
  private static final String[] TEST_CHILD_1 = new String[] {
      "dn: cn=test child 1,cn=test children,cn=test parent 1,cn=test parents,cn=config",
      "objectclass: top",
@@ -158,7 +150,7 @@
      "ds-cfg-conflict-behavior: virtual-overrides-real"
  };
  // Test LDIF.
  /** Test LDIF. */
  private static final String[] TEST_LDIF = new String[] {
      // Base entries.
      "dn: cn=test parents,cn=config",
@@ -185,8 +177,8 @@
      "",
  };
  // JNDI LDAP context.
  private JNDIDirContextAdaptor adaptor = null;
  /** JNDI LDAP context. */
  private JNDIDirContextAdaptor adaptor;
@@ -243,12 +235,7 @@
      parent.getTestChild("test child 1");
    } finally {
      TestCfg.removeConstraint(constraint);
      try {
        deleteSubtree(TEST_CHILD_1_DN);
      } catch (Exception e) {
        // Do nothing.
      }
      deleteSubtreeNoException(TEST_CHILD_1_DN);
    }
  }
@@ -283,12 +270,7 @@
      }
    } finally {
      TestCfg.removeConstraint(constraint);
      try {
        deleteSubtree(TEST_CHILD_1_DN);
      } catch (Exception e) {
        // Do nothing.
      }
      deleteSubtreeNoException(TEST_CHILD_1_DN);
    }
  }
@@ -314,11 +296,7 @@
        // Add the entry.
        addEntry(ResultCode.SUCCESS, TEST_CHILD_1);
      } finally {
        try {
          deleteSubtree(TEST_CHILD_1_DN);
        } catch (Exception e) {
          // Do nothing.
        }
        deleteSubtreeNoException(TEST_CHILD_1_DN);
      }
    } finally {
      TestCfg.removeConstraint(constraint);
@@ -348,11 +326,7 @@
        // Add the entry.
        addEntry(ResultCode.UNWILLING_TO_PERFORM, TEST_CHILD_1);
      } finally {
        try {
          deleteSubtree(TEST_CHILD_1_DN);
        } catch (Exception e) {
          // Do nothing.
        }
        deleteSubtreeNoException(TEST_CHILD_1_DN);
      }
    } finally {
      TestCfg.removeConstraint(constraint);
@@ -386,13 +360,7 @@
    } finally {
      TestCfg.removeConstraint(constraint);
      parent.removeTestChildDeleteListener(listener);
      try {
        // Clean up.
        deleteSubtree(TEST_CHILD_1_DN);
      } catch (Exception e) {
        // Ignore.
      }
      deleteSubtreeNoException(TEST_CHILD_1_DN);
    }
  }
@@ -428,13 +396,7 @@
    } finally {
      TestCfg.removeConstraint(constraint);
      parent.removeTestChildDeleteListener(listener);
      try {
        // Clean up.
        deleteSubtree(TEST_CHILD_1_DN);
      } catch (Exception e) {
        // Ignore.
      }
      deleteSubtreeNoException(TEST_CHILD_1_DN);
    }
  }
@@ -478,11 +440,7 @@
      Assert.assertEquals(result, ResultCode.SUCCESS.intValue());
    } finally {
      TestCfg.removeConstraint(constraint);
      try {
        deleteSubtree(TEST_CHILD_1_DN);
      } catch (Exception e) {
        // Ignore.
      }
      deleteSubtreeNoException(TEST_CHILD_1_DN);
    }
  }
@@ -525,40 +483,35 @@
      Assert.assertEquals(result, ResultCode.UNWILLING_TO_PERFORM.intValue());
    } finally {
      TestCfg.removeConstraint(constraint);
      try {
        deleteSubtree(TEST_CHILD_1_DN);
      } catch (Exception e) {
        // Ignore.
      }
      deleteSubtreeNoException(TEST_CHILD_1_DN);
    }
  }
  // Add an entry and check its result.
  /** Add an entry and check its result. */
  private void addEntry(ResultCode expected, String... lines) throws Exception {
    Entry entry = TestCaseUtils.makeEntry(lines);
    InternalClientConnection conn = InternalClientConnection
        .getRootConnection();
    AddOperation add = conn.processAdd(entry.getName(), entry.getObjectClasses(),
        entry.getUserAttributes(), entry.getOperationalAttributes());
    Assert.assertEquals(add.getResultCode(), expected, add.getErrorMessage()
        .toString());
    AddOperation add = getRootConnection().processAdd(entry);
    assertEquals(add.getResultCode(), expected, add.getErrorMessage().toString());
  }
  private void deleteSubtreeNoException(String dn)
  {
    try
    {
      deleteSubtree(dn);
    }
    catch (Exception e)
    {
      // Ignore.
    }
  }
  // Deletes the named sub-tree.
  /** Deletes the named sub-tree. */
  private void deleteSubtree(String dn) throws Exception {
    getAdaptor().deleteSubtree(new LdapName(dn));
  }
  // Gets the JNDI connection for the test server instance.
  /** Gets the JNDI connection for the test server instance. */
  private synchronized JNDIDirContextAdaptor getAdaptor() throws Exception {
    if (adaptor == null) {
      adaptor = JNDIDirContextAdaptor.simpleSSLBind("127.0.0.1", TestCaseUtils
@@ -567,16 +520,12 @@
    return adaptor;
  }
  // Gets the named parent configuration.
  private TestParentCfg getParent(String name) throws IllegalArgumentException,
      ConfigException {
  /** Gets the named parent configuration. */
  private TestParentCfg getParent(String name) throws Exception {
    ServerManagementContext ctx = ServerManagementContext.getInstance();
    ServerManagedObject<RootCfg> root = ctx.getRootConfigurationManagedObject();
    TestParentCfg parent = root.getChild(
    return root.getChild(
        TestCfg.getTestOneToManyParentRelationDefinition(), name)
        .getConfiguration();
    return parent;
  }
}
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/api/PasswordValidatorTestCase.java
@@ -32,14 +32,12 @@
import java.util.ArrayList;
import java.util.Set;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.testng.annotations.AfterClass;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.TestCaseUtils;
import org.opends.server.core.AddOperation;
import org.opends.server.extensions.TestPasswordValidator;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.protocols.ldap.BindRequestProtocolOp;
import org.opends.server.protocols.ldap.BindResponseProtocolOp;
import org.opends.server.protocols.ldap.LDAPAttribute;
@@ -49,16 +47,15 @@
import org.opends.server.protocols.ldap.ModifyResponseProtocolOp;
import org.opends.server.tools.LDAPPasswordModify;
import org.opends.server.tools.LDAPWriter;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.Entry;
import org.forgerock.opendj.ldap.ModificationType;
import org.opends.server.types.RawModification;
import org.forgerock.opendj.ldap.ResultCode;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.testng.Assert.*;
/**
 * A set of generic test cases for password validators.
 */
@@ -131,12 +128,7 @@
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(),
                         userEntry.getUserAttributes(),
                         userEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(userEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -189,12 +181,7 @@
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(),
                         userEntry.getUserAttributes(),
                         userEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(userEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -251,13 +238,7 @@
         "ds-privilege-name: bypass-acl",
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(),
                         userEntry.getUserAttributes(),
                         userEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(userEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -309,12 +290,7 @@
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(),
                         userEntry.getUserAttributes(),
                         userEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(userEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -372,12 +348,7 @@
              "cn=Password Policies,cn=config");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(),
                         userEntry.getUserAttributes(),
                         userEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(userEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -434,12 +405,7 @@
              "cn=Password Policies,cn=config");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(),
                         userEntry.getUserAttributes(),
                         userEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(userEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -494,12 +460,7 @@
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(),
                         userEntry.getUserAttributes(),
                         userEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(userEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -572,12 +533,7 @@
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(),
                         userEntry.getUserAttributes(),
                         userEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(userEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -654,12 +610,7 @@
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(),
                         userEntry.getUserAttributes(),
                         userEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(userEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -743,12 +694,7 @@
              "cn=Password Policies,cn=config");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(),
                         userEntry.getUserAttributes(),
                         userEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(userEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -827,12 +773,7 @@
              "cn=Password Policies,cn=config");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(),
                         userEntry.getUserAttributes(),
                         userEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(userEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/core/AbandonOperationTestCase.java
@@ -34,6 +34,7 @@
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.DereferenceAliasesPolicy;
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.TestCaseUtils;
import org.opends.server.plugins.DelayPreOpPlugin;
@@ -43,11 +44,11 @@
import org.opends.server.tools.LDAPReader;
import org.opends.server.tools.LDAPWriter;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.util.StaticUtils;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.opends.server.util.ServerConstants.*;
import static org.testng.Assert.*;
@@ -402,11 +403,8 @@
         "objectClass: top",
         "objectClass: device",
         "cn: test");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -621,11 +619,8 @@
         "objectClass: top",
         "objectClass: device",
         "cn: test");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/core/AddOperationTestCase.java
@@ -1211,11 +1211,7 @@
    Map<AttributeType,List<Attribute>> userAttrs = entry.getUserAttributes();
    userAttrs.put(attrType, newArrayList(Attributes.empty(attrType)));
    InternalClientConnection conn = getRootConnection();
    AddOperation addOperation =
         conn.processAdd(entry.getName(), entry.getObjectClasses(), userAttrs,
                         entry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(entry);
    assertFalse(addOperation.getResultCode() == ResultCode.SUCCESS);
  }
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/core/BackendConfigManagerTestCase.java
@@ -26,32 +26,27 @@
 */
package org.opends.server.core;
import java.util.ArrayList;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.TestCaseUtils;
import org.opends.server.api.Backend;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.protocols.internal.InternalSearchOperation;
import org.opends.server.types.Attributes;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
import org.opends.server.types.Modification;
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.types.SearchFilter;
import org.forgerock.opendj.ldap.SearchScope;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import static org.testng.Assert.*;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.opends.server.util.StaticUtils.*;
import static org.testng.Assert.*;
/**
 * A set of generic test cases that cover adding, modifying, and removing
@@ -65,24 +60,20 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @BeforeClass()
  public void startServer()
         throws Exception
  @BeforeClass
  public void startServer() throws Exception
  {
    TestCaseUtils.startServer();
  }
  /**
   * Tests that the server will reject an attempt to register a base DN that is
   * already defined in the server.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testRegisterBaseThatAlreadyExists()
         throws Exception
  @Test
  public void testRegisterBaseThatAlreadyExists() throws Exception
  {
    TestCaseUtils.initializeTestBackend(false);
@@ -90,12 +81,7 @@
    String backendID = createBackendID(baseDN);
    Entry backendEntry = createBackendEntry(backendID, false, baseDN);
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(backendEntry.getName(), backendEntry.getObjectClasses(),
                         backendEntry.getUserAttributes(),
                         backendEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(backendEntry);
    assertFalse(addOperation.getResultCode() == ResultCode.SUCCESS);
  }
@@ -108,8 +94,7 @@
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test(expectedExceptions = { DirectoryException.class })
  public void testDeregisterNonExistentBaseDN()
         throws Exception
  public void testDeregisterNonExistentBaseDN() throws Exception
  {
    DirectoryServer.deregisterBaseDN(DN.valueOf("o=unregistered"));
  }
@@ -122,9 +107,8 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testRegisterBackendIDThatAlreadyExists()
         throws Exception
  @Test
  public void testRegisterBackendIDThatAlreadyExists() throws Exception
  {
    TestCaseUtils.initializeTestBackend(false);
@@ -132,12 +116,7 @@
    String backendID = "test";
    Entry backendEntry = createBackendEntry(backendID, false, baseDN);
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(backendEntry.getName(), backendEntry.getObjectClasses(),
                         backendEntry.getUserAttributes(),
                         backendEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(backendEntry);
    assertFalse(addOperation.getResultCode() == ResultCode.SUCCESS);
  }
@@ -149,25 +128,19 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testAddAndRemoveDisabledBackend()
         throws Exception
  @Test
  public void testAddAndRemoveDisabledBackend() throws Exception
  {
    DN baseDN = DN.valueOf("o=bcmtest");
    String backendID = createBackendID(baseDN);
    Entry backendEntry = createBackendEntry(backendID, false, baseDN);
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(backendEntry.getName(), backendEntry.getObjectClasses(),
                         backendEntry.getUserAttributes(),
                         backendEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(backendEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    assertNull(DirectoryServer.getBackend(backendID));
    assertNull(DirectoryServer.getBackendWithBaseDN(baseDN));
    DeleteOperation deleteOperation = conn.processDelete(backendEntry.getName());
    DeleteOperation deleteOperation = getRootConnection().processDelete(backendEntry.getName());
    assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS);
  }
@@ -179,23 +152,17 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testAddAndRemoveEnabledBackend()
         throws Exception
  @Test
  public void testAddAndRemoveEnabledBackend() throws Exception
  {
    DN baseDN = DN.valueOf("o=bcmtest");
    String backendID = createBackendID(baseDN);
    Entry backendEntry = createBackendEntry(backendID, true, baseDN);
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(backendEntry.getName(), backendEntry.getObjectClasses(),
                         backendEntry.getUserAttributes(),
                         backendEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(backendEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    Backend backend = DirectoryServer.getBackend(backendID);
    Backend<?> backend = DirectoryServer.getBackend(backendID);
    assertNotNull(backend);
    assertEquals(backend, DirectoryServer.getBackendWithBaseDN(baseDN));
    assertNull(backend.getParentBackend());
@@ -204,13 +171,11 @@
    assertTrue(DirectoryServer.isNamingContext(baseDN));
    Entry e = createEntry(baseDN);
    addOperation = conn.processAdd(e.getName(), e.getObjectClasses(),
                                   e.getUserAttributes(),
                                   e.getOperationalAttributes());
    addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    assertTrue(backend.entryExists(baseDN));
    DeleteOperation deleteOperation = conn.processDelete(backendEntry.getName());
    DeleteOperation deleteOperation = getRootConnection().processDelete(backendEntry.getName());
    assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS);
    assertNull(DirectoryServer.getBackend(backendID));
  }
@@ -224,26 +189,21 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testEnableAndDisableBackend()
         throws Exception
  @Test
  public void testEnableAndDisableBackend() throws Exception
  {
    // Create the backend and make it disabled.
    DN baseDN = DN.valueOf("o=bcmtest");
    String backendID = createBackendID(baseDN);
    Entry backendEntry = createBackendEntry(backendID, false, baseDN);
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(backendEntry.getName(), backendEntry.getObjectClasses(),
                         backendEntry.getUserAttributes(),
                         backendEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(backendEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    assertNull(DirectoryServer.getBackend(backendID));
    assertFalse(DirectoryServer.isNamingContext(baseDN));
    InternalClientConnection conn = getRootConnection();
    // Modify the backend to enable it.
    ArrayList<Modification> mods = new ArrayList<Modification>();
    mods.add(new Modification(ModificationType.REPLACE,
@@ -252,7 +212,7 @@
         conn.processModify(backendEntry.getName(), mods);
    assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS);
    Backend backend = DirectoryServer.getBackend(backendID);
    Backend<?> backend = DirectoryServer.getBackend(backendID);
    assertNotNull(backend);
    assertEquals(backend, DirectoryServer.getBackendWithBaseDN(baseDN));
    assertNull(backend.getParentBackend());
@@ -261,9 +221,7 @@
    assertTrue(DirectoryServer.isNamingContext(baseDN));
    Entry e = createEntry(baseDN);
    addOperation = conn.processAdd(e.getName(), e.getObjectClasses(),
                                   e.getUserAttributes(),
                                   e.getOperationalAttributes());
    addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    assertTrue(backend.entryExists(baseDN));
@@ -272,8 +230,7 @@
    mods = new ArrayList<Modification>();
    mods.add(new Modification(ModificationType.REPLACE,
        Attributes.create("ds-cfg-enabled", "false")));
    modifyOperation =
         conn.processModify(backendEntry.getName(), mods);
    modifyOperation = conn.processModify(backendEntry.getName(), mods);
    assertNull(DirectoryServer.getBackend(backendID));
    assertFalse(DirectoryServer.entryExists(baseDN));
    assertFalse(DirectoryServer.isNamingContext(baseDN));
@@ -292,9 +249,8 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testAddNestedBackendParentFirst()
         throws Exception
  @Test
  public void testAddNestedBackendParentFirst() throws Exception
  {
    // Create the parent backend and the corresponding base entry.
    DN parentBaseDN = DN.valueOf("o=parent");
@@ -302,16 +258,10 @@
    Entry parentBackendEntry = createBackendEntry(parentBackendID, true,
                                                  parentBaseDN);
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(parentBackendEntry.getName(),
                         parentBackendEntry.getObjectClasses(),
                         parentBackendEntry.getUserAttributes(),
                         parentBackendEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(parentBackendEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    Backend parentBackend = DirectoryServer.getBackend(parentBackendID);
    Backend<?> parentBackend = DirectoryServer.getBackend(parentBackendID);
    assertNotNull(parentBackend);
    assertEquals(parentBackend,
                 DirectoryServer.getBackendWithBaseDN(parentBaseDN));
@@ -321,9 +271,7 @@
    assertTrue(DirectoryServer.isNamingContext(parentBaseDN));
    Entry e = createEntry(parentBaseDN);
    addOperation = conn.processAdd(e.getName(), e.getObjectClasses(),
                                   e.getUserAttributes(),
                                   e.getOperationalAttributes());
    addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    assertTrue(parentBackend.entryExists(parentBaseDN));
@@ -334,14 +282,10 @@
    Entry childBackendEntry = createBackendEntry(childBackendID, true,
                                                 childBaseDN);
    addOperation =
         conn.processAdd(childBackendEntry.getName(),
                         childBackendEntry.getObjectClasses(),
                         childBackendEntry.getUserAttributes(),
                         childBackendEntry.getOperationalAttributes());
    addOperation = getRootConnection().processAdd(childBackendEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    Backend childBackend = DirectoryServer.getBackend(childBackendID);
    Backend<?> childBackend = DirectoryServer.getBackend(childBackendID);
    assertNotNull(childBackend);
    assertEquals(childBackend,
                 DirectoryServer.getBackendWithBaseDN(childBaseDN));
@@ -352,13 +296,12 @@
    assertFalse(DirectoryServer.isNamingContext(childBaseDN));
    e = createEntry(childBaseDN);
    addOperation = conn.processAdd(e.getName(), e.getObjectClasses(),
                                   e.getUserAttributes(),
                                   e.getOperationalAttributes());
    addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    assertTrue(childBackend.entryExists(childBaseDN));
    InternalClientConnection conn = getRootConnection();
    // Make sure that both entries exist.
    InternalSearchOperation internalSearch =
         conn.processSearch(parentBaseDN, SearchScope.WHOLE_SUBTREE,
@@ -394,9 +337,8 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testAddNestedBackendChildFirst()
         throws Exception
  @Test
  public void testAddNestedBackendChildFirst() throws Exception
  {
    // Create the child backend and the corresponding base entry (at the time
    // of the creation, it will be a naming context).
@@ -405,16 +347,10 @@
    Entry childBackendEntry = createBackendEntry(childBackendID, true,
                                                 childBaseDN);
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(childBackendEntry.getName(),
                         childBackendEntry.getObjectClasses(),
                         childBackendEntry.getUserAttributes(),
                         childBackendEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(childBackendEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    Backend childBackend = DirectoryServer.getBackend(childBackendID);
    Backend<?> childBackend = DirectoryServer.getBackend(childBackendID);
    assertNotNull(childBackend);
    assertEquals(childBackend,
                 DirectoryServer.getBackendWithBaseDN(childBaseDN));
@@ -424,9 +360,7 @@
    assertFalse(childBackend.entryExists(childBaseDN));
    Entry e = createEntry(childBaseDN);
    addOperation = conn.processAdd(e.getName(), e.getObjectClasses(),
                                   e.getUserAttributes(),
                                   e.getOperationalAttributes());
    addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    assertTrue(childBackend.entryExists(childBaseDN));
    assertTrue(DirectoryServer.isNamingContext(childBaseDN));
@@ -439,14 +373,10 @@
    Entry parentBackendEntry = createBackendEntry(parentBackendID, true,
                                                  parentBaseDN);
    addOperation =
         conn.processAdd(parentBackendEntry.getName(),
                         parentBackendEntry.getObjectClasses(),
                         parentBackendEntry.getUserAttributes(),
                         parentBackendEntry.getOperationalAttributes());
    addOperation = getRootConnection().processAdd(parentBackendEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    Backend parentBackend = DirectoryServer.getBackend(parentBackendID);
    Backend<?> parentBackend = DirectoryServer.getBackend(parentBackendID);
    assertNotNull(parentBackend);
    assertEquals(parentBackend,
                 DirectoryServer.getBackendWithBaseDN(parentBaseDN));
@@ -455,15 +385,14 @@
    assertTrue(parentBackend.getSubordinateBackends().length == 1);
    e = createEntry(parentBaseDN);
    addOperation = conn.processAdd(e.getName(), e.getObjectClasses(),
                                   e.getUserAttributes(),
                                   e.getOperationalAttributes());
    addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    assertTrue(parentBackend.entryExists(parentBaseDN));
    assertTrue(DirectoryServer.isNamingContext(parentBaseDN));
    assertFalse(DirectoryServer.isNamingContext(childBaseDN));
    InternalClientConnection conn = getRootConnection();
    // Verify that we can see both entries with a subtree search.
    InternalSearchOperation internalSearch =
         conn.processSearch(parentBaseDN, SearchScope.WHOLE_SUBTREE,
@@ -493,9 +422,8 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testInsertIntermediateBackend()
         throws Exception
  @Test
  public void testInsertIntermediateBackend() throws Exception
  {
    // Add the parent backend to the server and its corresponding base entry.
    DN parentBaseDN = DN.valueOf("o=parent");
@@ -503,16 +431,10 @@
    Entry parentBackendEntry = createBackendEntry(parentBackendID, true,
                                                  parentBaseDN);
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(parentBackendEntry.getName(),
                         parentBackendEntry.getObjectClasses(),
                         parentBackendEntry.getUserAttributes(),
                         parentBackendEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(parentBackendEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    Backend parentBackend = DirectoryServer.getBackend(parentBackendID);
    Backend<?> parentBackend = DirectoryServer.getBackend(parentBackendID);
    assertNotNull(parentBackend);
    assertEquals(parentBackend,
                 DirectoryServer.getBackendWithBaseDN(parentBaseDN));
@@ -521,9 +443,7 @@
    assertFalse(parentBackend.entryExists(parentBaseDN));
    Entry e = createEntry(parentBaseDN);
    addOperation = conn.processAdd(e.getName(), e.getObjectClasses(),
                                   e.getUserAttributes(),
                                   e.getOperationalAttributes());
    addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    assertTrue(parentBackend.entryExists(parentBaseDN));
    assertTrue(DirectoryServer.isNamingContext(parentBaseDN));
@@ -535,14 +455,10 @@
    Entry grandchildBackendEntry = createBackendEntry(grandchildBackendID, true,
                                                      grandchildBaseDN);
    addOperation =
         conn.processAdd(grandchildBackendEntry.getName(),
                         grandchildBackendEntry.getObjectClasses(),
                         grandchildBackendEntry.getUserAttributes(),
                         grandchildBackendEntry.getOperationalAttributes());
    addOperation = getRootConnection().processAdd(grandchildBackendEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    Backend grandchildBackend = DirectoryServer.getBackend(grandchildBackendID);
    Backend<?> grandchildBackend = DirectoryServer.getBackend(grandchildBackendID);
    assertNotNull(grandchildBackend);
    assertEquals(grandchildBackend,
                 DirectoryServer.getBackendWithBaseDN(grandchildBaseDN));
@@ -554,9 +470,7 @@
    // Verify that we can't create the grandchild base entry because its parent
    // doesn't exist.
    e = createEntry(grandchildBaseDN);
    addOperation = conn.processAdd(e.getName(), e.getObjectClasses(),
                                   e.getUserAttributes(),
                                   e.getOperationalAttributes());
    addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.NO_SUCH_OBJECT);
    assertFalse(grandchildBackend.entryExists(grandchildBaseDN));
@@ -567,14 +481,10 @@
    Entry childBackendEntry = createBackendEntry(childBackendID, true,
                                                 childBaseDN);
    addOperation =
         conn.processAdd(childBackendEntry.getName(),
                         childBackendEntry.getObjectClasses(),
                         childBackendEntry.getUserAttributes(),
                         childBackendEntry.getOperationalAttributes());
    addOperation = getRootConnection().processAdd(childBackendEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    Backend childBackend = DirectoryServer.getBackend(childBackendID);
    Backend<?> childBackend = DirectoryServer.getBackend(childBackendID);
    assertNotNull(childBackend);
    assertEquals(childBackend,
                 DirectoryServer.getBackendWithBaseDN(childBaseDN));
@@ -587,21 +497,18 @@
    assertEquals(grandchildBackend.getParentBackend(), childBackend);
    e = createEntry(childBaseDN);
    addOperation = conn.processAdd(e.getName(), e.getObjectClasses(),
                                   e.getUserAttributes(),
                                   e.getOperationalAttributes());
    addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    assertTrue(childBackend.entryExists(childBaseDN));
    // Now we can create the grandchild base entry.
    e = createEntry(grandchildBaseDN);
    addOperation = conn.processAdd(e.getName(), e.getObjectClasses(),
                                   e.getUserAttributes(),
                                   e.getOperationalAttributes());
    addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    assertTrue(grandchildBackend.entryExists(grandchildBaseDN));
    InternalClientConnection conn = getRootConnection();
    // Verify that a subtree search can see all three entries.
    InternalSearchOperation internalSearch =
         conn.processSearch(parentBaseDN, SearchScope.WHOLE_SUBTREE,
@@ -667,9 +574,7 @@
    // Add the child entry back into the server to get things back to the way
    // they were before we disabled the backend.
    e = createEntry(childBaseDN);
    addOperation = conn.processAdd(e.getName(), e.getObjectClasses(),
                                   e.getUserAttributes(),
                                   e.getOperationalAttributes());
    addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    assertTrue(childBackend.entryExists(childBaseDN));
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/core/BindOperationTestCase.java
@@ -33,6 +33,7 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.TestCaseUtils;
import org.opends.server.plugins.DisconnectClientPlugin;
import org.opends.server.plugins.InvocationCounterPlugin;
@@ -42,11 +43,11 @@
import org.opends.server.tools.*;
import org.opends.server.tools.LDAPReader;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.util.StaticUtils;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.opends.server.protocols.ldap.LDAPConstants.*;
import static org.opends.server.util.ServerConstants.*;
import static org.testng.Assert.*;
@@ -1714,13 +1715,8 @@
         "sn: User",
         "cn: Test User");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
//         new InternalClientConnection(new AuthenticationInfo());
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    InternalClientConnection conn = getRootConnection();
    AddOperation addOperation = conn.processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    BindOperation bindOperation =
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/core/CompareOperationTestCase.java
@@ -27,13 +27,13 @@
package org.opends.server.core;
import static org.testng.Assert.*;
import java.net.Socket;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.locks.Lock;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.TestCaseUtils;
import org.opends.server.controls.LDAPAssertionRequestControl;
import org.opends.server.controls.ProxiedAuthV1Control;
@@ -43,12 +43,12 @@
import org.opends.server.protocols.ldap.*;
import org.opends.server.tools.LDAPWriter;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.util.ServerConstants;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import static org.testng.Assert.*;
@SuppressWarnings("javadoc")
public class CompareOperationTestCase extends OperationTestCase
{
@@ -96,11 +96,7 @@
         "aci: (targetattr=\"*\")(version 3.0; acl \"Proxy Rights\"; " +
              "allow(proxy) userdn=\"ldap:///uid=proxy.user,o=test\";)"
    );
    AddOperation addOperation =
         connection.processAdd(entry.getName(),
                               entry.getObjectClasses(),
                               entry.getUserAttributes(),
                               entry.getOperationalAttributes());
    AddOperation addOperation = connection.processAdd(entry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    assertNotNull(DirectoryServer.getEntry(entry.getName()));
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/core/SearchOperationTestCase.java
@@ -33,6 +33,7 @@
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.DecodeException;
import org.forgerock.opendj.ldap.DereferenceAliasesPolicy;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.TestCaseUtils;
import org.opends.server.controls.MatchedValuesControl;
@@ -45,7 +46,6 @@
import org.opends.server.tools.LDAPModify;
import org.opends.server.tools.LDAPWriter;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.util.ServerConstants;
import org.opends.server.util.StaticUtils;
import org.testng.annotations.BeforeClass;
@@ -78,11 +78,7 @@
    if (DirectoryServer.getEntry(suffixDN) == null)
    {
      Entry suffixEntry = StaticUtils.createEntry(suffixDN);
      AddOperation addOperation =
           connection.processAdd(suffixEntry.getName(),
                                 suffixEntry.getObjectClasses(),
                                 suffixEntry.getUserAttributes(),
                                 suffixEntry.getOperationalAttributes());
      AddOperation addOperation = connection.processAdd(suffixEntry);
      assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
      assertNotNull(DirectoryServer.getEntry(suffixEntry.getName()));
    }
@@ -92,11 +88,7 @@
    if (DirectoryServer.getEntry(baseDN) == null)
    {
      Entry baseEntry = StaticUtils.createEntry(baseDN);
      AddOperation addOperation =
           connection.processAdd(baseEntry.getName(),
                                 baseEntry.getObjectClasses(),
                                 baseEntry.getUserAttributes(),
                                 baseEntry.getOperationalAttributes());
      AddOperation addOperation = connection.processAdd(baseEntry);
      assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
      assertNotNull(DirectoryServer.getEntry(baseEntry.getName()));
    }
@@ -105,11 +97,7 @@
    Entry ldapSubentry = TestCaseUtils.makeEntry(
         "dn: cn=subentry," + BASE,
         "objectclass: ldapsubentry");
    AddOperation addOperation =
         connection.processAdd(ldapSubentry.getName(),
                               ldapSubentry.getObjectClasses(),
                               ldapSubentry.getUserAttributes(),
                               ldapSubentry.getOperationalAttributes());
    AddOperation addOperation = connection.processAdd(ldapSubentry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    assertNotNull(DirectoryServer.getEntry(ldapSubentry.getName()));
@@ -153,11 +141,7 @@
    // The add operation changes the attributes, so let's duplicate the entry.
    Entry duplicateEntry = testEntry.duplicate(false);
    addOperation =
         connection.processAdd(duplicateEntry.getName(),
                               duplicateEntry.getObjectClasses(),
                               duplicateEntry.getUserAttributes(),
                               duplicateEntry.getOperationalAttributes());
    addOperation = connection.processAdd(duplicateEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    assertNotNull(DirectoryServer.getEntry(testEntry.getName()));
@@ -168,11 +152,7 @@
         "objectclass: referral",
         "ref: ldap://hostb/OU=People,O=MNN,C=US",
         "ref: ldap://hostc/OU=People,O=MNN,C=US");
    addOperation =
         connection.processAdd(referralEntry.getName(),
                               referralEntry.getObjectClasses(),
                               referralEntry.getUserAttributes(),
                               referralEntry.getOperationalAttributes());
    addOperation = connection.processAdd(referralEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    assertNotNull(DirectoryServer.getEntry(referralEntry.getName()));
@@ -181,11 +161,7 @@
        "objectclass: top",
        "objectclass: organizationalunit",
        "ou: level1");
    addOperation =
        connection.processAdd(level1Entry.getName(),
                              level1Entry.getObjectClasses(),
                              level1Entry.getUserAttributes(),
                              level1Entry.getOperationalAttributes());
    addOperation = connection.processAdd(level1Entry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    assertNotNull(DirectoryServer.getEntry(level1Entry.getName()));
@@ -194,11 +170,7 @@
        "objectclass: top",
        "objectclass: organizationalunit",
        "ou: level2");
    addOperation =
        connection.processAdd(level2Entry.getName(),
                              level2Entry.getObjectClasses(),
                              level2Entry.getUserAttributes(),
                              level2Entry.getOperationalAttributes());
    addOperation = connection.processAdd(level2Entry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    assertNotNull(DirectoryServer.getEntry(level2Entry.getName()));
@@ -209,11 +181,7 @@
        "ref: ldap://hostb/OU=People,O=MNN,C=US",
        "ref: ldap://hostc/OU=People,O=MNN,C=US",
        "ref: ldap://hostd/OU=People,O=MNN,C=US");
   addOperation =
        connection.processAdd(referral2Entry.getName(),
                              referral2Entry.getObjectClasses(),
                              referral2Entry.getUserAttributes(),
                              referral2Entry.getOperationalAttributes());
    addOperation = connection.processAdd(referral2Entry);
   assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
   assertNotNull(DirectoryServer.getEntry(referral2Entry.getName()));
  }
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/core/SubentryManagerTestCase.java
@@ -28,12 +28,13 @@
package org.opends.server.core;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.DereferenceAliasesPolicy;
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.TestCaseUtils;
import org.opends.server.protocols.internal.InternalClientConnection;
@@ -43,14 +44,26 @@
import org.opends.server.protocols.ldap.LDAPModification;
import org.opends.server.tools.LDAPDelete;
import org.opends.server.tools.LDAPModify;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.Control;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
import org.opends.server.types.RawModification;
import org.opends.server.types.SubEntry;
import org.opends.server.types.SubtreeSpecification;
import org.opends.server.util.StaticUtils;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import static org.assertj.core.api.Assertions.*;
import static org.forgerock.opendj.ldap.ModificationType.*;
import static org.opends.server.TestCaseUtils.*;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.opends.server.util.CollectionUtils.*;
import static org.opends.server.util.ServerConstants.*;
import static org.testng.Assert.*;
@@ -84,11 +97,9 @@
    SubentryManager manager = DirectoryServer.getSubentryManager();
    assertNotNull(manager);
    List<SubEntry> subentryList = manager.getSubentries(testEntry.getName());
    assertNotNull(subentryList);
    assertTrue(subentryList.isEmpty());
    assertThat(subentryList).isEmpty();
    subentryList = manager.getCollectiveSubentries(testEntry.getName());
    assertNotNull(subentryList);
    assertTrue(subentryList.isEmpty());
    assertThat(subentryList).isEmpty();
    TestCaseUtils.clearJEBackend(false, "userRoot", SUFFIX);
  }
@@ -104,62 +115,56 @@
  {
    SubentryManager manager = DirectoryServer.getSubentryManager();
    assertNotNull(manager);
    List<SubEntry> subentryList = manager.getSubentries(testEntry.getName());
    assertNotNull(subentryList);
    assertEquals(subentryList.size(), 2);
    assertEquals(subentryList.get(0).getDN(), ldapSubentry.getName());
    assertEquals(subentryList.get(1).getDN(), legacyLdapSubentry.getName());
    subentryList.clear();
    assertThat(getDns(subentryList)).containsExactly(ldapSubentry.getName(), legacyLdapSubentry.getName());
    subentryList = manager.getSubentries(testEntry);
    assertNotNull(subentryList);
    assertEquals(subentryList.size(), 2);
    assertEquals(subentryList.get(0).getEntry(), ldapSubentry);
    assertEquals(subentryList.get(1).getEntry(), legacyLdapSubentry);
    subentryList.clear();
    assertThat(getEntries(subentryList)).containsExactly(ldapSubentry, legacyLdapSubentry);
    subentryList = manager.getCollectiveSubentries(testEntry.getName());
    assertNotNull(subentryList);
    assertEquals(subentryList.size(), 1);
    assertEquals(subentryList.get(0).getDN(), collectiveSubentry.getName());
    subentryList.clear();
    assertThat(getDns(subentryList)).containsExactly(collectiveSubentry.getName());
    subentryList = manager.getCollectiveSubentries(testEntry);
    // FIXME following line does not work because server's Entry.equals() is not reflexive
    // assertThat(getEntries(subentryList)).containsExactly(collectiveSubentry);
    assertNotNull(subentryList);
    assertEquals(subentryList.size(), 1);
    assertEquals(subentryList.get(0).getEntry(), collectiveSubentry);
    subentryList.clear();
    subentryList = manager.getSubentries(legacyLdapSubentry.getName().parent());
    assertNotNull(subentryList);
    assertEquals(subentryList.size(), 1);
    assertEquals(subentryList.get(0).getEntry(), legacyLdapSubentry);
    subentryList.clear();
    assertThat(getEntries(subentryList)).containsExactly(legacyLdapSubentry);
    subentryList = manager.getSubentries(legacyLdapSubentry.getName().parent().parent());
    assertNotNull(subentryList);
    assertEquals(subentryList.size(), 0);
    assertThat(subentryList).isEmpty();
  }
  private List<Entry> getEntries(List<SubEntry> subentries)
  {
    final List<Entry> results = new ArrayList<Entry>();
    for (SubEntry subEntry : subentries)
    {
      results.add(subEntry.getEntry());
    }
    return results;
  }
  private List<DN> getDns(List<SubEntry> subentries)
  {
    final List<DN> results = new ArrayList<DN>();
    for (SubEntry subEntry : subentries)
    {
      results.add(subEntry.getDN());
    }
    return results;
  }
  @Test
  public void testCollectiveAttributes() throws Exception
  {
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    ArrayList<ByteString> values = new ArrayList<ByteString>();
    values.add(ByteString.valueOf("real-overrides-virtual"));
    LDAPAttribute attr = new LDAPAttribute(
            "collectiveConflictBehavior", values);
    ArrayList<RawModification> mods = new ArrayList<RawModification>();
    mods.add(new LDAPModification(ModificationType.REPLACE, attr));
    ModifyOperation modifyOperation =
         conn.processModify(ByteString.valueOf(
         collectiveSubentry.getName().toNormalizedString()), mods);
    assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS);
    Entry entry = DirectoryServer.getEntry(testEntry.getName());
    AttributeType attrType = DirectoryServer.getAttributeType("c-l");
    assertTrue(entry.hasAttribute(attrType));
    assertTrue(entry.hasValue(attrType, null, ByteString.valueOf("Savoie")));
    attrType = DirectoryServer.getAttributeType("preferredlanguage");
    assertTrue(entry.hasAttribute(attrType));
    assertTrue(entry.hasValue(attrType, null, ByteString.valueOf("fr")));
    replaceAttribute(collectiveSubentry, "collectiveConflictBehavior", "real-overrides-virtual");
    hasValues(testEntry.getName(), "c-l", "Savoie");
    hasValues(testEntry.getName(), "preferredlanguage", "fr");
  }
@@ -224,16 +229,14 @@
    try
    {
      // Normal user will not inherit the collective description attribute.
      Entry e = DirectoryServer.getEntry(DN
          .valueOf("uid=normal user,ou=people,o=test"));
      Entry e = DirectoryServer.getEntry(DN.valueOf("uid=normal user,ou=people,o=test"));
      assertNotNull(e);
      List<Attribute> description = e.getAttribute("description");
      assertNull(description);
      // Collective user will inherit the collective description attribute.
      e = DirectoryServer.getEntry(DN
          .valueOf("uid=collective user,ou=people,o=test"));
      e = DirectoryServer.getEntry(DN.valueOf("uid=collective user,ou=people,o=test"));
      assertNotNull(e);
      description = e.getAttribute("description");
@@ -255,9 +258,6 @@
  @Test
  public void testInheritedCollectiveAttributes() throws Exception
  {
    InternalClientConnection connection =
         InternalClientConnection.getRootConnection();
    // Add test inherited from DN collective subentry.
    Entry collectiveDNInheritedSubentry = TestCaseUtils.makeEntry(
         "dn: cn=Inherited From DN Collective Subentry," + SUFFIX,
@@ -269,14 +269,7 @@
         "inheritAttribute: postalAddress",
         "subtreeSpecification: {base \"ou=Test SubEntry Manager\"}",
         "cn: Inherited From DN Collective Subentry");
    AddOperation addOperation =
         connection.processAdd(collectiveDNInheritedSubentry.getName(),
             collectiveDNInheritedSubentry.getObjectClasses(),
             collectiveDNInheritedSubentry.getUserAttributes(),
             collectiveDNInheritedSubentry.getOperationalAttributes());
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    assertNotNull(DirectoryServer.getEntry(
            collectiveDNInheritedSubentry.getName()));
    addEntry(collectiveDNInheritedSubentry);
    // Add test inherited from RDN collective subentry.
    Entry collectiveRDNInheritedSubentry = TestCaseUtils.makeEntry(
@@ -291,26 +284,11 @@
         "inheritAttribute: telephoneNumber",
         "subtreeSpecification: {base \"ou=Test SubEntry Manager\"}",
         "cn: Inherited From RDN Collective Subentry");
    addOperation =
         connection.processAdd(collectiveRDNInheritedSubentry.getName(),
             collectiveRDNInheritedSubentry.getObjectClasses(),
             collectiveRDNInheritedSubentry.getUserAttributes(),
             collectiveRDNInheritedSubentry.getOperationalAttributes());
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    assertNotNull(DirectoryServer.getEntry(
            collectiveRDNInheritedSubentry.getName()));
    addEntry(collectiveRDNInheritedSubentry);
    // Test Inherited Collective Attributes on test entry.
    Entry entry = DirectoryServer.getEntry(testEntry.getName());
    AttributeType attrType = DirectoryServer.getAttributeType("postaladdress");
    assertTrue(entry.hasAttribute(attrType));
    assertTrue(entry.hasValue(attrType, null,
            ByteString.valueOf("Sub City, Collective Street, AK 47")));
    attrType = DirectoryServer.getAttributeType("telephonenumber");
    assertTrue(entry.hasAttribute(attrType));
    assertTrue(entry.hasValue(attrType, null,
            ByteString.valueOf("+1 999 999 9999")));
    hasValues(testEntry.getName(), "postaladdress", "Sub City, Collective Street, AK 47");
    hasValues(testEntry.getName(), "telephonenumber", "+1 999 999 9999");
    // Cleanup.
    TestCaseUtils.deleteEntry(collectiveRDNInheritedSubentry.getName());
@@ -320,99 +298,63 @@
  @Test
  public void testCollectiveAttributeConflict() throws Exception
  {
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    ArrayList<ByteString> values = new ArrayList<ByteString>();
    values.add(ByteString.valueOf("ja"));
    LDAPAttribute attr = new LDAPAttribute(
            "preferredLanguage", values);
    ArrayList<RawModification> mods = new ArrayList<RawModification>();
    mods.add(new LDAPModification(ModificationType.REPLACE, attr));
    ModifyOperation modifyOperation =
         conn.processModify(ByteString.valueOf(
         testEntry.getName().toNormalizedString()), mods);
    assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS);
    DN dn = testEntry.getName();
    replaceAttribute(testEntry, "preferredLanguage", "ja");
    // real-overrides-virtual.
    values = new ArrayList<ByteString>();
    values.add(ByteString.valueOf("real-overrides-virtual"));
    attr = new LDAPAttribute(
            "collectiveConflictBehavior", values);
    mods = new ArrayList<RawModification>();
    mods.add(new LDAPModification(ModificationType.REPLACE, attr));
    modifyOperation =
         conn.processModify(ByteString.valueOf(
         collectiveSubentry.getName().toNormalizedString()), mods);
    assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS);
    Entry entry = DirectoryServer.getEntry(testEntry.getName());
    AttributeType attrType = DirectoryServer.getAttributeType("preferredlanguage");
    assertTrue(entry.hasAttribute(attrType));
    assertTrue(entry.hasValue(attrType, null, ByteString.valueOf("ja")));
    assertFalse(entry.hasValue(attrType, null, ByteString.valueOf("fr")));
    replaceAttribute(collectiveSubentry, "collectiveConflictBehavior", "real-overrides-virtual");
    hasValues(dn, "preferredlanguage", "ja");
    doesNotHaveValues(dn, "preferredlanguage", "fr");
    // virtual-overrides-real.
    values = new ArrayList<ByteString>();
    values.add(ByteString.valueOf("virtual-overrides-real"));
    attr = new LDAPAttribute(
            "collectiveConflictBehavior", values);
    mods = new ArrayList<RawModification>();
    mods.add(new LDAPModification(ModificationType.REPLACE, attr));
    modifyOperation =
         conn.processModify(ByteString.valueOf(
         collectiveSubentry.getName().toNormalizedString()), mods);
    assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS);
    entry = DirectoryServer.getEntry(testEntry.getName());
    attrType = DirectoryServer.getAttributeType("preferredlanguage");
    assertTrue(entry.hasAttribute(attrType));
    assertTrue(entry.hasValue(attrType, null, ByteString.valueOf("fr")));
    assertFalse(entry.hasValue(attrType, null, ByteString.valueOf("ja")));
    replaceAttribute(collectiveSubentry, "collectiveConflictBehavior", "virtual-overrides-real");
    hasValues(dn, "preferredlanguage", "fr");
    doesNotHaveValues(dn, "preferredlanguage", "ja");
    // merge-real-and-virtual.
    values = new ArrayList<ByteString>();
    values.add(ByteString.valueOf("merge-real-and-virtual"));
    attr = new LDAPAttribute(
            "collectiveConflictBehavior", values);
    mods = new ArrayList<RawModification>();
    mods.add(new LDAPModification(ModificationType.REPLACE, attr));
    modifyOperation =
         conn.processModify(ByteString.valueOf(
         collectiveSubentry.getName().toNormalizedString()), mods);
    assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS);
    entry = DirectoryServer.getEntry(testEntry.getName());
    attrType = DirectoryServer.getAttributeType("preferredlanguage");
    assertTrue(entry.hasAttribute(attrType));
    assertTrue(entry.hasValue(attrType, null, ByteString.valueOf("ja")));
    assertTrue(entry.hasValue(attrType, null, ByteString.valueOf("fr")));
    replaceAttribute(collectiveSubentry, "collectiveConflictBehavior", "merge-real-and-virtual");
    hasValues(dn, "preferredlanguage", "ja", "fr");
    // cleanup.
    values = new ArrayList<ByteString>();
    values.add(ByteString.valueOf("ja"));
    attr = new LDAPAttribute(
            "preferredLanguage", values);
    mods = new ArrayList<RawModification>();
    mods.add(new LDAPModification(ModificationType.DELETE, attr));
    modifyOperation =
         conn.processModify(ByteString.valueOf(
         testEntry.getName().toNormalizedString()), mods);
    assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS);
    deleteAttribute(testEntry, "preferredLanguage", "ja");
  }
  private void hasValues(DN dn, String attrTypeLower, String... values) throws DirectoryException
  {
    Entry entry = DirectoryServer.getEntry(dn);
    AttributeType attrType = DirectoryServer.getAttributeType(attrTypeLower);
    assertTrue(entry.hasAttribute(attrType));
    for (String value : values)
    {
      assertTrue(entry.hasValue(attrType, null, ByteString.valueOf(value)));
    }
  }
  private void doesNotHaveValues(DN dn, String attrTypeLower, String... values) throws DirectoryException
  {
    Entry entry = DirectoryServer.getEntry(dn);
    AttributeType attrType = DirectoryServer.getAttributeType(attrTypeLower);
    assertTrue(entry.hasAttribute(attrType));
    for (String value : values)
    {
      assertFalse(entry.hasValue(attrType, null, ByteString.valueOf(value)));
    }
  }
  private void hasNoAttribute(DN dn, String lowerName) throws Exception
  {
    Entry entry = DirectoryServer.getEntry(dn);
    AttributeType attrType = DirectoryServer.getAttributeType(lowerName);
    assertFalse(entry.hasAttribute(attrType));
  }
  @Test
  public void testCollectiveAttributeSubentries() throws Exception
  {
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    LinkedHashSet<String> attributes = new LinkedHashSet<String>();
    attributes.add("collectiveAttributeSubentries");
    Set<String> attributes = newSet("collectiveAttributeSubentries");
    InternalSearchOperation searchOperation =
         new InternalSearchOperation(
              conn,
              InternalClientConnection.nextOperationID(),
              InternalClientConnection.nextMessageID(),
              getRootConnection(), nextOperationID(), nextMessageID(),
              new ArrayList<Control>(),
              ByteString.valueOf(testEntry.getName().toString()),
              SearchScope.BASE_OBJECT,
@@ -427,88 +369,55 @@
    assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS);
    assertEquals(searchOperation.getEntriesSent(), 1);
    AttributeType attrType = DirectoryServer.getAttributeType("collectiveattributesubentries");
    assertTrue(searchOperation.getSearchEntries().getFirst().hasValue(
            attrType, null, ByteString.valueOf(collectiveSubentry.getName())));
    Entry e = searchOperation.getSearchEntries().getFirst();
    assertTrue(e.hasValue(attrType, null, ByteString.valueOf(collectiveSubentry.getName())));
  }
  @Test
  public void testCollectiveExclusions() throws Exception
  {
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    DN dn = testEntry.getName();
    ArrayList<ByteString> values = new ArrayList<ByteString>();
    values.add(ByteString.valueOf("real-overrides-virtual"));
    LDAPAttribute attr = new LDAPAttribute(
            "collectiveConflictBehavior", values);
    ArrayList<RawModification> mods = new ArrayList<RawModification>();
    mods.add(new LDAPModification(ModificationType.REPLACE, attr));
    ModifyOperation modifyOperation =
         conn.processModify(ByteString.valueOf(
         collectiveSubentry.getName().toNormalizedString()), mods);
    assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS);
    values = new ArrayList<ByteString>();
    values.add(ByteString.valueOf("c-l"));
    attr = new LDAPAttribute("collectiveExclusions", values);
    mods = new ArrayList<RawModification>();
    mods.add(new LDAPModification(ModificationType.REPLACE, attr));
    modifyOperation =
         conn.processModify(ByteString.valueOf(
         testEntry.getName().toNormalizedString()), mods);
    assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS);
    replaceAttribute(collectiveSubentry, "collectiveConflictBehavior", "real-overrides-virtual");
    replaceAttribute(testEntry, "collectiveExclusions", "c-l");
    hasNoAttribute(dn, "c-l");
    hasValues(dn, "preferredlanguage", "fr");
    Entry entry = DirectoryServer.getEntry(testEntry.getName());
    AttributeType attrType = DirectoryServer.getAttributeType("c-l");
    assertFalse(entry.hasAttribute(attrType));
    attrType = DirectoryServer.getAttributeType("preferredlanguage");
    assertTrue(entry.hasAttribute(attrType));
    assertTrue(entry.hasValue(attrType, null, ByteString.valueOf("fr")));
    replaceAttribute(testEntry, "collectiveExclusions", "preferredLanguage");
    hasNoAttribute(dn, "preferredlanguage");
    hasValues(dn, "c-l", "Savoie");
    values = new ArrayList<ByteString>();
    values.add(ByteString.valueOf("preferredLanguage"));
    attr = new LDAPAttribute("collectiveExclusions", values);
    mods = new ArrayList<RawModification>();
    mods.add(new LDAPModification(ModificationType.REPLACE, attr));
    modifyOperation =
         conn.processModify(ByteString.valueOf(
         testEntry.getName().toNormalizedString()), mods);
    assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS);
    entry = DirectoryServer.getEntry(testEntry.getName());
    attrType = DirectoryServer.getAttributeType("preferredlanguage");
    assertFalse(entry.hasAttribute(attrType));
    attrType = DirectoryServer.getAttributeType("c-l");
    assertTrue(entry.hasAttribute(attrType));
    assertTrue(entry.hasValue(attrType, null, ByteString.valueOf("Savoie")));
    values = new ArrayList<ByteString>();
    values.add(ByteString.valueOf("excludeAllCollectiveAttributes"));
    attr = new LDAPAttribute("collectiveExclusions", values);
    mods = new ArrayList<RawModification>();
    mods.add(new LDAPModification(ModificationType.REPLACE, attr));
    modifyOperation =
         conn.processModify(ByteString.valueOf(
         testEntry.getName().toNormalizedString()), mods);
    assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS);
    entry = DirectoryServer.getEntry(testEntry.getName());
    attrType = DirectoryServer.getAttributeType("preferredlanguage");
    assertFalse(entry.hasAttribute(attrType));
    attrType = DirectoryServer.getAttributeType("c-l");
    assertFalse(entry.hasAttribute(attrType));
    replaceAttribute(testEntry, "collectiveExclusions", "excludeAllCollectiveAttributes");
    hasNoAttribute(dn, "preferredlanguage");
    hasNoAttribute(dn, "c-l");
    // cleanup.
    values = new ArrayList<ByteString>();
    values.add(ByteString.valueOf("excludeAllCollectiveAttributes"));
    attr = new LDAPAttribute("collectiveExclusions", values);
    mods = new ArrayList<RawModification>();
    mods.add(new LDAPModification(ModificationType.DELETE, attr));
    modifyOperation =
         conn.processModify(ByteString.valueOf(
         testEntry.getName().toNormalizedString()), mods);
    deleteAttribute(testEntry, "collectiveExclusions", "excludeAllCollectiveAttributes");
  }
  private void deleteAttribute(Entry e, String attrType, String oldValue)
  {
    InternalClientConnection conn = getRootConnection();
    List<RawModification> mods = newRawModifications(DELETE, attrType, oldValue);
    ModifyOperation modifyOperation = conn.processModify(ByteString.valueOf(e.getName().toNormalizedString()), mods);
    assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS);
  }
  private void replaceAttribute(Entry e, String attrType, String newValue)
  {
    InternalClientConnection conn = getRootConnection();
    List<RawModification> mods = newRawModifications(REPLACE, attrType, newValue);
    ModifyOperation modifyOperation = conn.processModify(ByteString.valueOf(e.getName().toNormalizedString()), mods);
    assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS);
  }
  private List<RawModification> newRawModifications(ModificationType modType, String attrType, String value)
  {
    ArrayList<ByteString> values = newArrayList(ByteString.valueOf(value));
    LDAPAttribute attr = new LDAPAttribute(attrType, values);
    return newList((RawModification) new LDAPModification(modType, attr));
  }
  @Test
  public void testSubtreeDelete() throws Exception
  {
@@ -526,7 +435,6 @@
    assertTrue(DirectoryServer.getSubentryManager().getCollectiveSubentries(
            DN.valueOf("uid=rogasawara," + BASE)).isEmpty());
    assertTrue(DirectoryServer.getSubentryManager().getSubentries(
            DN.valueOf("uid=rogasawara," + BASE)).isEmpty());
@@ -610,9 +518,6 @@
      }
    }
    InternalClientConnection connection =
         InternalClientConnection.getRootConnection();
    // Add Relative Spec test subentry.
    Entry relativeSubentry = TestCaseUtils.makeEntry(
         "dn: cn=Relative Subentry," + SUFFIX,
@@ -620,13 +525,7 @@
         "objectclass: subentry",
         "subtreeSpecification: {base \"ou=Test SubEntry Manager\", specificationFilter \"(objectClass=*)\"}",
         "cn: Subentry");
    AddOperation addOperation =
         connection.processAdd(relativeSubentry.getName(),
                               relativeSubentry.getObjectClasses(),
                               relativeSubentry.getUserAttributes(),
                               relativeSubentry.getOperationalAttributes());
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    assertNotNull(DirectoryServer.getEntry(relativeSubentry.getName()));
    addEntry(relativeSubentry);
    List<SubEntry> relativeSubList =
            DirectoryServer.getSubentryManager().getSubentries();
@@ -645,35 +544,18 @@
  private void addTestEntries() throws Exception
  {
    InternalClientConnection connection =
         InternalClientConnection.getRootConnection();
    // Add suffix entry.
    DN suffixDN = DN.valueOf(SUFFIX);
    if (DirectoryServer.getEntry(suffixDN) == null)
    {
      Entry suffixEntry = StaticUtils.createEntry(suffixDN);
      AddOperation addOperation =
           connection.processAdd(suffixEntry.getName(),
                                 suffixEntry.getObjectClasses(),
                                 suffixEntry.getUserAttributes(),
                                 suffixEntry.getOperationalAttributes());
      assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
      assertNotNull(DirectoryServer.getEntry(suffixEntry.getName()));
      addEntry(StaticUtils.createEntry(suffixDN));
    }
    // Add base entry.
    DN baseDN = DN.valueOf(BASE);
    if (DirectoryServer.getEntry(baseDN) == null)
    {
      Entry baseEntry = StaticUtils.createEntry(baseDN);
      AddOperation addOperation =
           connection.processAdd(baseEntry.getName(),
                                 baseEntry.getObjectClasses(),
                                 baseEntry.getUserAttributes(),
                                 baseEntry.getOperationalAttributes());
      assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
      assertNotNull(DirectoryServer.getEntry(baseEntry.getName()));
      addEntry(StaticUtils.createEntry(baseDN));
    }
    // Add role entry.
@@ -685,13 +567,7 @@
         "telephoneNumber: +1 999 999 9999",
         "cn: Sales"
    );
    AddOperation addOperation =
         connection.processAdd(roleEntry.getName(),
                               roleEntry.getObjectClasses(),
                               roleEntry.getUserAttributes(),
                               roleEntry.getOperationalAttributes());
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    assertNotNull(DirectoryServer.getEntry(roleEntry.getName()));
    addEntry(roleEntry);
    // Add test entry.
    testEntry = TestCaseUtils.makeEntry(
@@ -709,13 +585,7 @@
         "manager: cn=Sales," + BASE,
         "title: Sales"
    );
    addOperation =
         connection.processAdd(testEntry.getName(),
                               testEntry.getObjectClasses(),
                               testEntry.getUserAttributes(),
                               testEntry.getOperationalAttributes());
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    assertNotNull(DirectoryServer.getEntry(testEntry.getName()));
    addEntry(testEntry);
    // Add test subentry.
    ldapSubentry = TestCaseUtils.makeEntry(
@@ -724,13 +594,7 @@
         "objectclass: subentry",
         "subtreeSpecification: {base \"ou=Test SubEntry Manager\"}",
         "cn: Subentry");
    addOperation =
         connection.processAdd(ldapSubentry.getName(),
                               ldapSubentry.getObjectClasses(),
                               ldapSubentry.getUserAttributes(),
                               ldapSubentry.getOperationalAttributes());
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    assertNotNull(DirectoryServer.getEntry(ldapSubentry.getName()));
    addEntry(ldapSubentry);
    // Add test legacy subentry.
    legacyLdapSubentry = TestCaseUtils.makeEntry(
@@ -738,13 +602,7 @@
         "objectClass: top",
         "objectclass: ldapSubentry",
         "cn: Legacy Subentry");
    addOperation =
         connection.processAdd(legacyLdapSubentry.getName(),
                               legacyLdapSubentry.getObjectClasses(),
                               legacyLdapSubentry.getUserAttributes(),
                               legacyLdapSubentry.getOperationalAttributes());
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    assertNotNull(DirectoryServer.getEntry(legacyLdapSubentry.getName()));
    addEntry(legacyLdapSubentry);
    // Add test collective subentry.
    collectiveSubentry = TestCaseUtils.makeEntry(
@@ -757,12 +615,13 @@
         "preferredLanguage;collective: fr",
         "subtreeSpecification: {base \"ou=Test SubEntry Manager\"}",
         "cn: Collective Subentry");
    addOperation =
         connection.processAdd(collectiveSubentry.getName(),
                               collectiveSubentry.getObjectClasses(),
                               collectiveSubentry.getUserAttributes(),
                               collectiveSubentry.getOperationalAttributes());
    addEntry(collectiveSubentry);
  }
  private void addEntry(Entry e) throws DirectoryException
  {
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    assertNotNull(DirectoryServer.getEntry(collectiveSubentry.getName()));
    assertNotNull(DirectoryServer.getEntry(e.getName()));
  }
}
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/core/SubentryPasswordPolicyTestCase.java
@@ -26,33 +26,30 @@
 */
package org.opends.server.core;
import java.util.Collection;
import java.util.List;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.TestCaseUtils;
import org.opends.server.api.AuthenticationPolicy;
import org.opends.server.api.PasswordValidator;
import org.opends.server.types.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
import org.opends.server.util.StaticUtils;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.opends.server.TestCaseUtils;
import org.opends.server.api.AuthenticationPolicy;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.types.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.util.StaticUtils;
import org.testng.annotations.AfterClass;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.testng.Assert.*;
/**
 * A set of test cases for the Directory Server subentry password policy.
 */
@SuppressWarnings("javadoc")
public class SubentryPasswordPolicyTestCase
       extends CoreTestCase
{
@@ -65,19 +62,12 @@
    TestCaseUtils.startServer();
    TestCaseUtils.clearJEBackend(false, "userRoot", SUFFIX);
    InternalClientConnection connection =
         InternalClientConnection.getRootConnection();
    // Add suffix entry.
    DN suffixDN = DN.valueOf(SUFFIX);
    if (DirectoryServer.getEntry(suffixDN) == null)
    {
      Entry suffixEntry = StaticUtils.createEntry(suffixDN);
      AddOperation addOperation =
           connection.processAdd(suffixEntry.getName(),
                                 suffixEntry.getObjectClasses(),
                                 suffixEntry.getUserAttributes(),
                                 suffixEntry.getOperationalAttributes());
      AddOperation addOperation = getRootConnection().processAdd(suffixEntry);
      assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
      assertNotNull(DirectoryServer.getEntry(suffixEntry.getName()));
    }
@@ -87,11 +77,7 @@
    if (DirectoryServer.getEntry(baseDN) == null)
    {
      Entry baseEntry = StaticUtils.createEntry(baseDN);
      AddOperation addOperation =
           connection.processAdd(baseEntry.getName(),
                                 baseEntry.getObjectClasses(),
                                 baseEntry.getUserAttributes(),
                                 baseEntry.getOperationalAttributes());
      AddOperation addOperation = getRootConnection().processAdd(baseEntry);
      assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
      assertNotNull(DirectoryServer.getEntry(baseEntry.getName()));
    }
@@ -111,11 +97,7 @@
         "cn: Rodney Ogasawara",
         "title: Sales, Director"
    );
    AddOperation addOperation =
         connection.processAdd(testEntry.getName(),
                               testEntry.getObjectClasses(),
                               testEntry.getUserAttributes(),
                               testEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(testEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    assertNotNull(DirectoryServer.getEntry(testEntry.getName()));
  }
@@ -257,14 +239,7 @@
  public void testInvalidConfigurations(Entry e)
         throws Exception
  {
    InternalClientConnection connection =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         connection.processAdd(e.getName(),
                               e.getObjectClasses(),
                               e.getUserAttributes(),
                               e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertTrue(addOperation.getResultCode() != ResultCode.SUCCESS);
    assertNull(DirectoryServer.getEntry(e.getName()));
  }
@@ -306,14 +281,7 @@
         "pwdSafeModify: TRUE"
    );
    InternalClientConnection connection =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         connection.processAdd(policyEntry.getName(),
                               policyEntry.getObjectClasses(),
                               policyEntry.getUserAttributes(),
                               policyEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(policyEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    assertNotNull(DirectoryServer.getEntry(policyEntry.getName()));
@@ -333,8 +301,7 @@
    assertEquals(policy.getPasswordHistoryCount(), 5);
    assertEquals(policy.getPasswordExpirationWarningInterval(), 864000);
    assertEquals(policy.getGraceLoginCount(), 3);
    assertEquals(policy.getLockoutFailureExpirationInterval(),
            3600);
    assertEquals(policy.getLockoutFailureExpirationInterval(), 3600);
    assertEquals(policy.isAllowUserPasswordChanges(), false);
    assertEquals(policy.isPasswordChangeRequiresCurrentPassword(), true);
@@ -410,14 +377,7 @@
        "ds-cfg-password-validator: cn=Length-Based Password Validator,cn=Password Validators,cn=config"
    );
    InternalClientConnection connection =
        InternalClientConnection.getRootConnection();
    AddOperation addOperation =
        connection.processAdd(policyEntry.getName(),
            policyEntry.getObjectClasses(),
            policyEntry.getUserAttributes(),
            policyEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(policyEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    assertNotNull(DirectoryServer.getEntry(policyEntry.getName()));
@@ -492,14 +452,7 @@
         "pwdAttribute: userPassword"
        );
    InternalClientConnection connection =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         connection.processAdd(policyEntry.getName(),
                               policyEntry.getObjectClasses(),
                               policyEntry.getUserAttributes(),
                               policyEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(policyEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    assertNotNull(DirectoryServer.getEntry(policyEntry.getName()));
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/core/TestModifyDNOperation.java
@@ -27,11 +27,20 @@
 */
package org.opends.server.core;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeClass;
import static org.testng.Assert.*;
import java.net.Socket;
import java.util.Collections;
import java.util.Hashtable;
import java.util.List;
import java.util.concurrent.locks.Lock;
import javax.naming.Context;
import javax.naming.InvalidNameException;
import javax.naming.directory.DirContext;
import javax.naming.directory.InitialDirContext;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.TestCaseUtils;
import org.opends.server.api.ClientConnection;
import org.opends.server.controls.ProxiedAuthV1Control;
@@ -43,21 +52,12 @@
import org.opends.server.tools.LDAPModify;
import org.opends.server.tools.LDAPWriter;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.util.ServerConstants;
import org.opends.server.util.StaticUtils;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import java.net.Socket;
import java.util.Collections;
import java.util.Hashtable;
import java.util.List;
import java.util.concurrent.locks.Lock;
import javax.naming.Context;
import javax.naming.InvalidNameException;
import javax.naming.directory.DirContext;
import javax.naming.directory.InitialDirContext;
import static org.testng.Assert.*;
@SuppressWarnings("javadoc")
public class TestModifyDNOperation extends OperationTestCase
@@ -121,27 +121,15 @@
      "description: This is the description for Aaccf Amar."
    );
    AddOperation addOperation =
         connection.processAdd(exampleCom.getName(),
                               exampleCom.getObjectClasses(),
                               exampleCom.getUserAttributes(),
                               exampleCom.getOperationalAttributes());
    AddOperation addOperation = connection.processAdd(exampleCom);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    assertNotNull(DirectoryServer.getEntry(exampleCom.getName()));
    addOperation =
         connection.processAdd(people.getName(),
                               people.getObjectClasses(),
                               people.getUserAttributes(),
                               people.getOperationalAttributes());
    addOperation = connection.processAdd(people);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    assertNotNull(DirectoryServer.getEntry(people.getName()));
    addOperation =
         connection.processAdd(entry.getName(),
                               entry.getObjectClasses(),
                               entry.getUserAttributes(),
                               entry.getOperationalAttributes());
    addOperation = connection.processAdd(entry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    assertNotNull(DirectoryServer.getEntry(entry.getName()));
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/core/networkgroups/NetworkGroupTest.java
@@ -30,6 +30,7 @@
import java.util.Collections;
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.DirectoryServerTestCase;
import org.opends.server.TestCaseUtils;
@@ -37,9 +38,7 @@
import org.opends.server.api.ClientConnection;
import org.opends.server.core.*;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.protocols.ldap.LDAPFilter;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.util.StaticUtils;
import org.opends.server.workflowelement.WorkflowElement;
import org.testng.annotations.BeforeClass;
@@ -56,9 +55,7 @@
@SuppressWarnings("javadoc")
public class NetworkGroupTest extends DirectoryServerTestCase {
  //===========================================================================
  //
  //                      B E F O R E    C L A S S
  //
  //===========================================================================
  /**
@@ -75,9 +72,7 @@
  }
  //===========================================================================
  //
  //                      D A T A    P R O V I D E R
  //
  //===========================================================================
  /**
@@ -276,9 +271,7 @@
  }
  /**
   * Provides the priorities for 3 network groups
   */
  /** Provides the priorities for 3 network groups. */
  @DataProvider (name = "PrioritySet_0")
  public Object[][] initPrioritySet_0()
  {
@@ -314,9 +307,7 @@
  //===========================================================================
  //
  //                        T E S T   C A S E S
  //
  //===========================================================================
@@ -409,8 +400,6 @@
    doCheckNetworkGroup(defaultNG, dnToSearch, dnSubordinate, null,
            existsInDefault);
    // Dump the default network group
    dump(defaultNG, "defaultNetworkGroup> ");
    // let's get the admin network group -- it should always exist
    NetworkGroup adminNG = NetworkGroup.getAdminNetworkGroup();
@@ -420,8 +409,6 @@
    doCheckNetworkGroup(adminNG, dnToSearch, dnSubordinate, null,
            existsInAdmin);
    // Dump the default network group
    dump(adminNG, "adminNetworkGroup> ");
    // let's get the internal network group -- it should always exist
    NetworkGroup internalNG = NetworkGroup.getInternalNetworkGroup();
@@ -430,9 +417,6 @@
    // let's check the routing through the network group
    doCheckNetworkGroup(internalNG, dnToSearch, dnSubordinate, null,
            existsInInternal);
    // Dump the default network group
    dump(internalNG, "internalNetworkGroup> ");
  }
@@ -1068,15 +1052,10 @@
      int expectedNamingContexts
      ) throws Exception
  {
    SearchOperation search = connection.processSearch(
        DN.valueOf(""),
        SearchScope.SINGLE_LEVEL,
        LDAPFilter.decode("(objectClass=*)").toSearchFilter());
    SearchOperation search = connection.processSearch("", SearchScope.SINGLE_LEVEL, "(objectClass=*)");
    // Check the number of found naming context
    ResultCode expectedRC =
      (shouldExist ? ResultCode.SUCCESS : ResultCode.NO_SUCH_OBJECT);
    assertEquals(search.getResultCode(), expectedRC);
    assertEquals(search.getResultCode(), shouldExist ? ResultCode.SUCCESS : ResultCode.NO_SUCH_OBJECT);
    if (shouldExist)
    {
      assertEquals(search.getEntriesSent(), expectedNamingContexts);
@@ -1097,21 +1076,10 @@
      boolean shouldExist
      ) throws Exception
  {
    SearchOperation search = connection.processSearch(
        DN.valueOf(baseDN),
        SearchScope.BASE_OBJECT,
        LDAPFilter.decode("(objectClass=*)").toSearchFilter());
    SearchOperation search = connection.processSearch(baseDN, SearchScope.BASE_OBJECT, "(objectClass=*)");
    // Compare the result code with the expected one
    ResultCode resultCode = search.getResultCode();
    if (shouldExist)
    {
      assertEquals(resultCode, ResultCode.SUCCESS);
    }
    else
    {
      assertEquals(resultCode, ResultCode.NO_SUCH_OBJECT);
    }
    assertEquals(search.getResultCode(), shouldExist ? ResultCode.SUCCESS : ResultCode.NO_SUCH_OBJECT);
  }
@@ -1133,12 +1101,7 @@
        "objectClass: organization",
        "o: " + namingAttribute);
   AddOperation addOperation = connection.processAdd(
       e.getName(),
       e.getObjectClasses(),
       e.getUserAttributes(),
       e.getOperationalAttributes());
   AddOperation addOperation = connection.processAdd(e);
   assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
  }
@@ -1269,29 +1232,4 @@
    System.out.print(msg);
  }
  /**
   * Prints a text to System.out.
   */
  private void writeln(String msg)
  {
    write(msg + "\n");
  }
  /**
   * Dump the network group info to the console.
   */
  private void dump(NetworkGroup networkGroup, String prompt)
  {
    final boolean doDump = false;
    if (doDump)
    {
      StringBuilder sb = networkGroup.toString(prompt);
      writeln(sb.toString());
    }
  }
}
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/extensions/CRAMMD5SASLMechanismHandlerTestCase.java
@@ -26,38 +26,33 @@
 */
package org.opends.server.extensions;
import java.util.List;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.TestCaseUtils;
import org.opends.server.admin.server.AdminTestCaseUtils;
import org.opends.server.admin.std.meta.
            CramMD5SASLMechanismHandlerCfgDefn;
import org.opends.server.admin.std.server.
            CramMD5SASLMechanismHandlerCfg;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.admin.std.meta.CramMD5SASLMechanismHandlerCfgDefn;
import org.opends.server.admin.std.server.CramMD5SASLMechanismHandlerCfg;
import org.opends.server.core.AddOperation;
import org.opends.server.core.BindOperation;
import org.opends.server.core.DirectoryServer;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.tools.LDAPSearch;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.ByteString;
import static org.testng.Assert.*;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.opends.server.util.ServerConstants.*;
import static org.testng.Assert.*;
/**
 * A set of test cases for the CRAM-MD5 SASL mechanism handler.
 */
@SuppressWarnings("javadoc")
public class CRAMMD5SASLMechanismHandlerTestCase
       extends ExtensionsTestCase
{
@@ -66,23 +61,19 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @BeforeClass()
  public void startServer()
         throws Exception
  @BeforeClass
  public void startServer() throws Exception
  {
    TestCaseUtils.startServer();
  }
  /**
   * Retrieves a set of invalid configuration entries.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @DataProvider(name = "invalidConfigs")
  public Object[][] getInvalidConfigs()
         throws Exception
  public Object[][] getInvalidConfigs() throws Exception
  {
    List<Entry> entries = TestCaseUtils.makeEntries(
         "dn: cn=CRAM-MD5,cn=SASL Mechanisms,cn=config",
@@ -211,11 +202,7 @@
         "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," +
              "cn=Password Policies,cn=config");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(),
                         e.getUserAttributes(), e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    String[] args =
@@ -261,11 +248,7 @@
         "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," +
              "cn=Password Policies,cn=config");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(),
                         e.getUserAttributes(), e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    String[] args =
@@ -314,11 +297,7 @@
         "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," +
              "cn=Password Policies,cn=config");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(),
                         e.getUserAttributes(), e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    String[] args =
@@ -364,11 +343,7 @@
         "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," +
              "cn=Password Policies,cn=config");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(),
                         e.getUserAttributes(), e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    String[] args =
@@ -414,11 +389,7 @@
         "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," +
              "cn=Password Policies,cn=config");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(),
                         e.getUserAttributes(), e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    String[] args =
@@ -462,11 +433,7 @@
         "cn: Test User",
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(),
                         e.getUserAttributes(), e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    String[] args =
@@ -510,11 +477,7 @@
         "cn: Test User",
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(),
                         e.getUserAttributes(), e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    String[] args =
@@ -558,11 +521,7 @@
         "cn: Test User",
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(),
                         e.getUserAttributes(), e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    String[] args =
@@ -606,11 +565,7 @@
         "cn: Test User",
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(),
                         e.getUserAttributes(), e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    String[] args =
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/extensions/CancelExtendedOperationTestCase.java
@@ -28,21 +28,21 @@
import static org.opends.server.protocols.ldap.LDAPConstants.*;
import static org.opends.server.util.ServerConstants.OID_CANCEL_REQUEST;
import static org.opends.server.util.ServerConstants.OID_WHO_AM_I_REQUEST;
import static org.testng.Assert.assertEquals;
import java.net.Socket;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import org.forgerock.opendj.io.ASN1;
import org.forgerock.opendj.io.ASN1Writer;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ByteStringBuilder;
import org.forgerock.opendj.ldap.DereferenceAliasesPolicy;
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.TestCaseUtils;
import org.opends.server.core.AddOperation;
import org.opends.server.plugins.DelayPreOpPlugin;
import org.forgerock.opendj.io.ASN1;
import org.forgerock.opendj.io.ASN1Writer;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.protocols.ldap.AddRequestProtocolOp;
import org.opends.server.protocols.ldap.AddResponseProtocolOp;
import org.opends.server.protocols.ldap.BindRequestProtocolOp;
@@ -64,18 +64,16 @@
import org.opends.server.protocols.ldap.ModifyResponseProtocolOp;
import org.opends.server.protocols.ldap.SearchRequestProtocolOp;
import org.opends.server.protocols.ldap.SearchResultDoneProtocolOp;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ByteStringBuilder;
import org.forgerock.opendj.ldap.DereferenceAliasesPolicy;
import org.opends.server.types.Entry;
import org.forgerock.opendj.ldap.ModificationType;
import org.opends.server.types.RawAttribute;
import org.opends.server.types.RawModification;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.opends.server.protocols.ldap.LDAPConstants.*;
import static org.opends.server.util.ServerConstants.*;
import static org.testng.Assert.*;
/**
 * A set of test cases for the cancel extended operation handler.
@@ -292,11 +290,7 @@
         "objectClass: top",
         "objectClass: device",
         "cn: test");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -547,11 +541,7 @@
         "objectClass: top",
         "objectClass: device",
         "cn: test");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/extensions/DigestMD5SASLMechanismHandlerTestCase.java
@@ -28,11 +28,6 @@
import static org.opends.server.util.ServerConstants.SASL_MECHANISM_DIGEST_MD5;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
import java.util.List;
import org.forgerock.opendj.config.server.ConfigException;
@@ -57,7 +52,9 @@
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.opends.server.util.ServerConstants.*;
import static org.testng.Assert.*;
/**
 * A set of test cases for the DIGEST-MD5 SASL mechanism handler.
@@ -228,11 +225,7 @@
         "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," +
              "cn=Password Policies,cn=config");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(),
                         e.getUserAttributes(), e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    String[] args =
@@ -279,11 +272,7 @@
         "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," +
              "cn=Password Policies,cn=config");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(),
                         e.getUserAttributes(), e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    String[] args =
@@ -330,11 +319,7 @@
         "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," +
              "cn=Password Policies,cn=config");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(),
                         e.getUserAttributes(), e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    String[] args =
@@ -381,11 +366,7 @@
         "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," +
              "cn=Password Policies,cn=config");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(),
                         e.getUserAttributes(), e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    String[] args =
@@ -430,11 +411,7 @@
         "cn: Test User",
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(),
                         e.getUserAttributes(), e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    String[] args =
@@ -479,11 +456,7 @@
         "cn: Test User",
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(),
                         e.getUserAttributes(), e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    String[] args =
@@ -528,11 +501,7 @@
         "cn: Test User",
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(),
                         e.getUserAttributes(), e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    String[] args =
@@ -577,11 +546,7 @@
         "cn: Test User",
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(),
                         e.getUserAttributes(), e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    String[] args =
@@ -626,11 +591,7 @@
         "cn: Test User",
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(),
                         e.getUserAttributes(), e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    String[] args =
@@ -840,11 +801,7 @@
         "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," +
              "cn=Password Policies,cn=config");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(),
                         e.getUserAttributes(), e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    String[] args =
@@ -863,7 +820,7 @@
    assertEquals(LDAPSearch.mainSearch(args, false, null, System.err), 0);
    DeleteOperation deleteOperation = conn.processDelete(e.getName());
    DeleteOperation deleteOperation = getRootConnection().processDelete(e.getName());
    assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS);
  }
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/extensions/ExactMatchIdentityMapperTestCase.java
@@ -29,14 +29,15 @@
import java.util.ArrayList;
import java.util.List;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.TestCaseUtils;
import org.opends.server.admin.server.AdminTestCaseUtils;
import org.opends.server.admin.std.meta.ExactMatchIdentityMapperCfgDefn;
import org.opends.server.admin.std.server.ExactMatchIdentityMapperCfg;
import org.opends.server.api.IdentityMapper;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.AddOperation;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.ModifyOperation;
@@ -44,11 +45,11 @@
import org.opends.server.protocols.ldap.LDAPAttribute;
import org.opends.server.protocols.ldap.LDAPModification;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.testng.Assert.*;
/**
@@ -326,12 +327,7 @@
         "sn: Test",
         "cn: Test",
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(),
                         userEntry.getUserAttributes(),
                         userEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(userEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -392,12 +388,7 @@
         "sn: Test",
         "cn: Test",
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(),
                         userEntry.getUserAttributes(),
                         userEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(userEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -459,12 +450,7 @@
         "sn: Test",
         "cn: Test",
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(),
                         userEntry.getUserAttributes(),
                         userEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(userEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -522,12 +508,7 @@
         "sn: Test",
         "cn: Test",
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(),
                         userEntry.getUserAttributes(),
                         userEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(userEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -585,12 +566,7 @@
         "sn: Test",
         "cn: Test",
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(),
                         userEntry.getUserAttributes(),
                         userEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(userEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    userEntry = TestCaseUtils.makeEntry(
@@ -604,10 +580,7 @@
         "sn: Test",
         "cn: Test",
         "userPassword: password");
    addOperation =
         conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(),
                         userEntry.getUserAttributes(),
                         userEntry.getOperationalAttributes());
    addOperation = getRootConnection().processAdd(userEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -670,12 +643,7 @@
         "sn: Bar",
         "cn: Bar",
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(),
                         userEntry.getUserAttributes(),
                         userEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(userEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -736,12 +704,7 @@
         "sn: Bar",
         "cn: Bar",
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(),
                         userEntry.getUserAttributes(),
                         userEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(userEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -802,12 +765,7 @@
         "sn: Bar",
         "cn: Bar",
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(),
                         userEntry.getUserAttributes(),
                         userEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(userEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -852,12 +810,7 @@
         "sn: User",
         "cn: Test User",
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(),
                         userEntry.getUserAttributes(),
                         userEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(userEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -871,6 +824,7 @@
    assertNull(mappedEntry);
    InternalClientConnection conn = getRootConnection();
    // Create a modification to change the map attribute from uid to cn.
    ArrayList<ByteString> values = new ArrayList<ByteString>();
    values.add(ByteString.valueOf("cn"));
@@ -941,12 +895,7 @@
         "sn: User",
         "cn: Test User",
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(),
                         userEntry.getUserAttributes(),
                         userEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(userEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -956,6 +905,7 @@
    assertEquals(mappedEntry.getName(), DN.valueOf("uid=test,o=test"));
    InternalClientConnection conn = getRootConnection();
    // Create a modification to set the map base DN to "dc=example,dc=com".
    ArrayList<ByteString> values = new ArrayList<ByteString>();
    values.add(ByteString.valueOf("dc=example,dc=com"));
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/extensions/ExternalSASLMechanismHandlerTestCase.java
@@ -35,13 +35,14 @@
import java.util.ArrayList;
import java.util.List;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.TestCaseUtils;
import org.opends.server.admin.server.AdminTestCaseUtils;
import org.opends.server.admin.std.meta.ExternalSASLMechanismHandlerCfgDefn;
import org.opends.server.admin.std.server.ExternalSASLMechanismHandlerCfg;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.AddOperation;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.ModifyOperation;
@@ -53,16 +54,14 @@
import org.opends.server.tools.LDAPSearch;
import org.opends.server.tools.LDAPWriter;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.util.Base64;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.testng.Assert.*;
/**
 * A set of test cases for the EXTERNAL SASL mechanism handler.
 */
@@ -206,11 +205,7 @@
         "givenName: Test",
         "sn: User");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -262,11 +257,7 @@
         "givenName: Test",
         "sn: User");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -384,14 +375,11 @@
         "givenName: Test",
         "sn: User");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    InternalClientConnection conn = getRootConnection();
    String dnStr    = "cn=EXTERNAL,cn=SASL Mechanisms,cn=config";
    String attrName = "ds-cfg-certificate-validation-policy";
    ArrayList<Modification> mods = new ArrayList<Modification>();
@@ -466,11 +454,7 @@
         "sn: User",
         "userCertificate;binary:: " + Base64.encode(certBytes));
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -536,11 +520,7 @@
         "sn: User",
         "userCertificate;binary:: " + Certificate);
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -601,11 +581,8 @@
         "sn: User",
         "userCertificate;binary:: " + Base64.encode(certBytes));
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    InternalClientConnection conn = getRootConnection();
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -688,11 +665,8 @@
         "sn: User",
         "userCertificate;binary:: " + Certificate);
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    InternalClientConnection conn = getRootConnection();
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/extensions/PasswordModifyExtendedOperationTestCase.java
@@ -29,26 +29,27 @@
import java.util.ArrayList;
import java.util.List;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.io.ASN1;
import org.forgerock.opendj.io.ASN1Writer;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ByteStringBuilder;
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.TestCaseUtils;
import org.opends.server.admin.server.AdminTestCaseUtils;
import org.opends.server.admin.std.meta.PasswordModifyExtendedOperationHandlerCfgDefn;
import org.opends.server.admin.std.server.PasswordModifyExtendedOperationHandlerCfg;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.*;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.tools.LDAPPasswordModify;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import static org.opends.server.extensions.ExtensionsConstants.*;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.opends.server.util.ServerConstants.*;
import static org.testng.Assert.*;
@@ -349,12 +350,7 @@
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(),
                         userEntry.getUserAttributes(),
                         userEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(userEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -372,7 +368,7 @@
                 0);
    // Perform an internal bind to verify the password was actually changed.
    conn = new InternalClientConnection(new AuthenticationInfo());
    InternalClientConnection conn = new InternalClientConnection(new AuthenticationInfo());
    BindOperation bindOperation =
         conn.processSimpleBind(userEntry.getName(),
                                ByteString.valueOf("newPassword"));
@@ -414,12 +410,7 @@
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(),
                         userEntry.getUserAttributes(),
                         userEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(userEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -436,7 +427,7 @@
                 0);
    // Perform an internal bind to verify the password was actually changed.
    conn = new InternalClientConnection(new AuthenticationInfo());
    InternalClientConnection conn = new InternalClientConnection(new AuthenticationInfo());
    BindOperation bindOperation =
         conn.processSimpleBind(userEntry.getName(),
                                ByteString.valueOf("newPassword"));
@@ -478,12 +469,7 @@
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(),
                         userEntry.getUserAttributes(),
                         userEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(userEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -534,12 +520,7 @@
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(),
                         userEntry.getUserAttributes(),
                         userEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(userEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -557,7 +538,7 @@
                 0);
    // Perform an internal bind to verify the password was actually changed.
    conn = new InternalClientConnection(new AuthenticationInfo());
    InternalClientConnection conn = new InternalClientConnection(new AuthenticationInfo());
    BindOperation bindOperation =
         conn.processSimpleBind(userEntry.getName(),
                                ByteString.valueOf("newPassword"));
@@ -599,12 +580,7 @@
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(),
                         userEntry.getUserAttributes(),
                         userEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(userEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -622,7 +598,7 @@
                 0);
    // Perform an internal bind to verify the password was actually changed.
    conn = new InternalClientConnection(new AuthenticationInfo());
    InternalClientConnection conn = new InternalClientConnection(new AuthenticationInfo());
    BindOperation bindOperation =
         conn.processSimpleBind(userEntry.getName(),
                                ByteString.valueOf("newPassword"));
@@ -664,12 +640,7 @@
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(),
                         userEntry.getUserAttributes(),
                         userEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(userEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -687,7 +658,7 @@
                 0);
    // Perform an internal bind to verify the password was actually changed.
    conn = new InternalClientConnection(new AuthenticationInfo());
    InternalClientConnection conn = new InternalClientConnection(new AuthenticationInfo());
    BindOperation bindOperation =
         conn.processSimpleBind(userEntry.getName(),
                                ByteString.valueOf("newPassword"));
@@ -729,12 +700,7 @@
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(),
                         userEntry.getUserAttributes(),
                         userEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(userEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -752,7 +718,7 @@
                 0);
    // Perform an internal bind to verify the password was actually changed.
    conn = new InternalClientConnection(new AuthenticationInfo());
    InternalClientConnection conn = new InternalClientConnection(new AuthenticationInfo());
    BindOperation bindOperation =
         conn.processSimpleBind(userEntry.getName(),
                                ByteString.valueOf("newPassword"));
@@ -794,12 +760,7 @@
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(),
                         userEntry.getUserAttributes(),
                         userEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(userEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -816,7 +777,7 @@
                 0);
    // Perform an internal bind to verify the password was actually changed.
    conn = new InternalClientConnection(new AuthenticationInfo());
    InternalClientConnection conn = new InternalClientConnection(new AuthenticationInfo());
    BindOperation bindOperation =
         conn.processSimpleBind(userEntry.getName(),
                                ByteString.valueOf("newPassword"));
@@ -858,12 +819,7 @@
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(),
                         userEntry.getUserAttributes(),
                         userEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(userEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -880,7 +836,7 @@
                 0);
    // Perform an internal bind to verify the password was actually changed.
    conn = new InternalClientConnection(new AuthenticationInfo());
    InternalClientConnection conn = new InternalClientConnection(new AuthenticationInfo());
    BindOperation bindOperation =
         conn.processSimpleBind(userEntry.getName(),
                                ByteString.valueOf("newPassword"));
@@ -922,12 +878,7 @@
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(),
                         userEntry.getUserAttributes(),
                         userEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(userEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -945,7 +896,7 @@
                 0);
    // Perform an internal bind to verify the password was actually changed.
    conn = new InternalClientConnection(new AuthenticationInfo());
    InternalClientConnection conn = new InternalClientConnection(new AuthenticationInfo());
    BindOperation bindOperation =
         conn.processSimpleBind(userEntry.getName(),
                                ByteString.valueOf("newPassword"));
@@ -1169,12 +1120,7 @@
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(),
                         userEntry.getUserAttributes(),
                         userEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(userEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -1223,15 +1169,11 @@
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(),
                         userEntry.getUserAttributes(),
                         userEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(userEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    InternalClientConnection conn = getRootConnection();
    String dnStr = "cn=Default Password Policy,cn=Password Policies,cn=config";
    String attr  = "ds-cfg-allow-pre-encoded-passwords";
    ArrayList<Modification> mods = new ArrayList<Modification>();
@@ -1293,12 +1235,7 @@
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(),
                         userEntry.getUserAttributes(),
                         userEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(userEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    /* Make sure preEncoded passwords are rejected */
@@ -1307,8 +1244,7 @@
    ArrayList<Modification> mods = new ArrayList<Modification>();
    mods.add(new Modification(ModificationType.REPLACE,
        Attributes.create(attr, "false")));
    ModifyOperation modifyOperation =
        conn.processModify(DN.valueOf(dnStr), mods);
    ModifyOperation modifyOperation = getRootConnection().processModify(DN.valueOf(dnStr), mods);
    assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS);
    String[] args =
@@ -1355,12 +1291,7 @@
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(),
                         userEntry.getUserAttributes(),
                         userEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(userEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    /* Make sure preEncoded passwords are rejected */
@@ -1369,8 +1300,7 @@
    ArrayList<Modification> mods = new ArrayList<Modification>();
    mods.add(new Modification(ModificationType.REPLACE,
        Attributes.create(attr, "false")));
    ModifyOperation modifyOperation =
        conn.processModify(DN.valueOf(dnStr), mods);
    ModifyOperation modifyOperation = getRootConnection().processModify(DN.valueOf(dnStr), mods);
    assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS);
    String[] args =
@@ -1483,15 +1413,11 @@
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(),
                         userEntry.getUserAttributes(),
                         userEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(userEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    InternalClientConnection conn = getRootConnection();
    String dnStr = "cn=Default Password Policy,cn=Password Policies,cn=config";
    String attr  = "ds-cfg-allow-user-password-changes";
    ArrayList<Modification> mods = new ArrayList<Modification>();
@@ -1551,15 +1477,11 @@
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(),
                         userEntry.getUserAttributes(),
                         userEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(userEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    InternalClientConnection conn = getRootConnection();
    String dnStr = "cn=Default Password Policy,cn=Password Policies,cn=config";
    String attr  = "ds-cfg-allow-user-password-changes";
    ArrayList<Modification> mods = new ArrayList<Modification>();
@@ -1620,15 +1542,10 @@
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(),
                         userEntry.getUserAttributes(),
                         userEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(userEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    InternalClientConnection conn = getRootConnection();
    String dnStr = "cn=Default Password Policy,cn=Password Policies,cn=config";
    String attr  = "ds-cfg-password-change-requires-current-password";
    ArrayList<Modification> mods = new ArrayList<Modification>();
@@ -1689,15 +1606,11 @@
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(),
                         userEntry.getUserAttributes(),
                         userEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(userEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    InternalClientConnection conn = getRootConnection();
    String dnStr = "cn=Default Password Policy,cn=Password Policies,cn=config";
    String attr  = "ds-cfg-require-secure-authentication";
    ArrayList<Modification> mods = new ArrayList<Modification>();
@@ -1757,15 +1670,11 @@
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(),
                         userEntry.getUserAttributes(),
                         userEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(userEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    InternalClientConnection conn = getRootConnection();
    String dnStr = "cn=Default Password Policy,cn=Password Policies,cn=config";
    String attr  = "ds-cfg-require-secure-password-changes";
    ArrayList<Modification> mods = new ArrayList<Modification>();
@@ -1825,15 +1734,11 @@
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(),
                         userEntry.getUserAttributes(),
                         userEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(userEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    InternalClientConnection conn = getRootConnection();
    String dnStr = "cn=Default Password Policy,cn=Password Policies,cn=config";
    String attr  = "ds-cfg-require-secure-password-changes";
    ArrayList<Modification> mods = new ArrayList<Modification>();
@@ -1894,15 +1799,11 @@
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(),
                         userEntry.getUserAttributes(),
                         userEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(userEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    InternalClientConnection conn = getRootConnection();
    String dnStr = "cn=Default Password Policy,cn=Password Policies,cn=config";
    String attr  = "ds-cfg-min-password-age";
    ArrayList<Modification> mods = new ArrayList<Modification>();
@@ -1961,15 +1862,11 @@
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(),
                         userEntry.getUserAttributes(),
                         userEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(userEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    InternalClientConnection conn = getRootConnection();
    String dnStr = "cn=Default Password Policy,cn=Password Policies,cn=config";
    String attr  = "ds-cfg-min-password-age";
    ArrayList<Modification> mods = new ArrayList<Modification>();
@@ -2030,16 +1927,10 @@
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(),
                         userEntry.getUserAttributes(),
                         userEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(userEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    InternalClientConnection conn = getRootConnection();
    String dnStr = "cn=Default Password Policy,cn=Password Policies,cn=config";
    String attr1 = "ds-cfg-max-password-age";
    String attr2 = "ds-cfg-expire-passwords-without-warning";
@@ -2112,16 +2003,11 @@
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(),
                         userEntry.getUserAttributes(),
                         userEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(userEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    InternalClientConnection conn = getRootConnection();
    String dnStr = "cn=Default Password Policy,cn=Password Policies,cn=config";
    String attr1 = "ds-cfg-max-password-age";
    String attr2 = "ds-cfg-expire-passwords-without-warning";
@@ -2200,16 +2086,11 @@
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(),
                         userEntry.getUserAttributes(),
                         userEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(userEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    InternalClientConnection conn = getRootConnection();
    String dnStr = "cn=Default Password Policy,cn=Password Policies,cn=config";
    String attr = "ds-cfg-password-generator";
    ArrayList<Modification> mods = new ArrayList<Modification>();
@@ -2270,16 +2151,11 @@
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(),
                         userEntry.getUserAttributes(),
                         userEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(userEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    InternalClientConnection conn = getRootConnection();
    String dnStr = "cn=Default Password Policy,cn=Password Policies,cn=config";
    String attr = "ds-cfg-password-generator";
    ArrayList<Modification> mods = new ArrayList<Modification>();
@@ -2339,16 +2215,11 @@
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(),
                         userEntry.getUserAttributes(),
                         userEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(userEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    InternalClientConnection conn = getRootConnection();
    String dnStr = "cn=Default Password Policy,cn=Password Policies,cn=config";
    String attr = "ds-cfg-password-validator";
    String valDN =
@@ -2409,16 +2280,11 @@
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(),
                         userEntry.getUserAttributes(),
                         userEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(userEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    InternalClientConnection conn = getRootConnection();
    String dnStr = "cn=Default Password Policy,cn=Password Policies,cn=config";
    String attr = "ds-cfg-password-validator";
    String valDN =
@@ -2493,10 +2359,7 @@
    assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS);
    AddOperation addOperation =
         conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(),
                         userEntry.getUserAttributes(),
                         userEntry.getOperationalAttributes());
    AddOperation addOperation = conn.processAdd(userEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -2568,10 +2431,7 @@
    assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS);
    AddOperation addOperation =
         conn.processAdd(userEntry.getName(), userEntry.getObjectClasses(),
                         userEntry.getUserAttributes(),
                         userEntry.getOperationalAttributes());
    AddOperation addOperation = conn.processAdd(userEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/extensions/PlainSASLMechanismHandlerTestCase.java
@@ -28,6 +28,7 @@
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ByteStringBuilder;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.TestCaseUtils;
import org.opends.server.api.SASLMechanismHandler;
@@ -41,11 +42,11 @@
import org.opends.server.tools.LDAPSearch;
import org.opends.server.types.AuthenticationInfo;
import org.opends.server.types.Entry;
import org.forgerock.opendj.ldap.ResultCode;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.testng.Assert.*;
/**
@@ -71,14 +72,11 @@
  /**
   * Tests to ensure that the SASL PLAIN mechanism is loaded and available in
   * the server, and that it reports that it is password based and not secure.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testSASLPlainLoaded()
  {
    SASLMechanismHandler handler =
         DirectoryServer.getSASLMechanismHandler("PLAIN");
    SASLMechanismHandler<?> handler = DirectoryServer.getSASLMechanismHandler("PLAIN");
    assertNotNull(handler);
    assertTrue(handler.isPasswordBased("PLAIN"));
@@ -93,11 +91,9 @@
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testSASLPlainAdvertised()
         throws Exception
  public void testSASLPlainAdvertised() throws Exception
  {
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    InternalClientConnection conn = getRootConnection();
    InternalSearchOperation op =
         conn.processSearch(ByteString.empty(), SearchScope.BASE_OBJECT,
              LDAPFilter.decode("(supportedSASLMechanisms=PLAIN)"));
@@ -159,13 +155,9 @@
                   "givenName: Test",
                   "sn: User",
                   "cn: Test User",
                   "userPassword: " + password.toString());
                   "userPassword: " + password);
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation = conn.processAdd(e.getName(), e.getObjectClasses(),
                                                e.getUserAttributes(),
                                                e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -208,13 +200,9 @@
                   "givenName: Test",
                   "sn: User",
                   "cn: Test User",
                   "userPassword: " + password.toString());
                   "userPassword: " + password);
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation = conn.processAdd(e.getName(), e.getObjectClasses(),
                                                e.getUserAttributes(),
                                                e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -258,13 +246,9 @@
                   "givenName: Test",
                   "sn: User",
                   "cn: Test User",
                   "userPassword: " + password.toString());
                   "userPassword: " + password);
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation = conn.processAdd(e.getName(), e.getObjectClasses(),
                                                e.getUserAttributes(),
                                                e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -308,13 +292,9 @@
                   "givenName: Test",
                   "sn: User",
                   "cn: Test User",
                   "userPassword: " + password.toString());
                   "userPassword: " + password);
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation = conn.processAdd(e.getName(), e.getObjectClasses(),
                                                e.getUserAttributes(),
                                                e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -359,13 +339,9 @@
                   "givenName: Test",
                   "sn: User",
                   "cn: Test User",
                   "userPassword: " + password.toString());
                   "userPassword: " + password);
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation = conn.processAdd(e.getName(), e.getObjectClasses(),
                                                e.getUserAttributes(),
                                                e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -498,11 +474,8 @@
                   "cn: Test User",
                   "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation = conn.processAdd(e.getName(), e.getObjectClasses(),
                                                e.getUserAttributes(),
                                                e.getOperationalAttributes());
    InternalClientConnection.getRootConnection();
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/extensions/StartTLSExtendedOperationTestCase.java
@@ -26,25 +26,20 @@
 */
package org.opends.server.extensions;
import java.io.File;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.TestCaseUtils;
import org.opends.server.core.AddOperation;
import org.opends.server.core.DirectoryServer;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.tools.LDAPSearch;
import org.opends.server.types.Entry;
import org.forgerock.opendj.ldap.ResultCode;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.testng.Assert.*;
/**
 * A set of test cases for the StartTLS extended operation handler.
 */
@@ -196,11 +191,7 @@
         "givenName: Test",
         "sn: User");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -252,11 +243,7 @@
         "givenName: Test",
         "sn: User");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/extensions/WhoAmIExtendedOperationTestCase.java
@@ -26,17 +26,14 @@
 */
package org.opends.server.extensions;
import java.net.Socket;
import java.util.ArrayList;
import java.util.List;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.TestCaseUtils;
import org.opends.server.controls.ProxiedAuthV2Control;
import org.opends.server.core.AddOperation;
@@ -50,14 +47,16 @@
import org.opends.server.tools.LDAPAuthenticationHandler;
import org.opends.server.tools.LDAPReader;
import org.opends.server.tools.LDAPWriter;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.ByteString;
import static org.testng.Assert.*;
import org.opends.server.types.AuthenticationInfo;
import org.opends.server.types.Control;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.opends.server.util.ServerConstants.*;
import static org.testng.Assert.*;
/**
 * A set of test cases for the "Who Am I?" extended operation.
@@ -139,15 +138,11 @@
         "cn: Test User",
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOp = conn.processAdd(e.getName(), e.getObjectClasses(),
                                         e.getUserAttributes(),
                                         e.getOperationalAttributes());
    AddOperation addOp = getRootConnection().processAdd(e);
    assertEquals(addOp.getResultCode(), ResultCode.SUCCESS);
    conn = new InternalClientConnection(new AuthenticationInfo(e, false));
    InternalClientConnection conn = new InternalClientConnection(new AuthenticationInfo(e, false));
    ExtendedOperation extOp =
         conn.processExtendedOperation(OID_WHO_AM_I_REQUEST, null);
    assertEquals(extOp.getResultCode(), ResultCode.SUCCESS);
@@ -242,11 +237,7 @@
         "cn: Test User",
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOp = conn.processAdd(e.getName(), e.getObjectClasses(),
                                         e.getUserAttributes(),
                                         e.getOperationalAttributes());
    AddOperation addOp = getRootConnection().processAdd(e);
    assertEquals(addOp.getResultCode(), ResultCode.SUCCESS);
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/plugins/EntryUUIDPluginTestCase.java
@@ -28,34 +28,32 @@
import static org.testng.Assert.*;
import java.io.ByteArrayInputStream;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.UUID;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.TestCaseUtils;
import org.opends.server.admin.server.AdminTestCaseUtils;
import org.opends.server.admin.std.meta.EntryUUIDPluginCfgDefn;
import org.opends.server.admin.std.server.EntryUUIDPluginCfg;
import org.opends.server.api.plugin.PluginType;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.AddOperation;
import org.opends.server.core.DirectoryServer;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.types.AttributeType;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryConfig;
import org.opends.server.types.Entry;
import org.opends.server.types.LDIFImportConfig;
import org.forgerock.opendj.ldap.ResultCode;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.testng.Assert.*;
/**
 * This class defines a set of tests for the
@@ -343,11 +341,7 @@
                                      "objectClass: device",
                                      "cn: test");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    e = DirectoryConfig.getEntry(e.getName());
@@ -375,11 +369,7 @@
                                      "cn: test",
                                      "entryUUID: " + UUID.randomUUID());
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    e = DirectoryConfig.getEntry(e.getName());
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/plugins/LastModPluginTestCase.java
@@ -26,22 +26,18 @@
 */
package org.opends.server.plugins;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.TestCaseUtils;
import org.opends.server.admin.server.AdminTestCaseUtils;
import org.opends.server.admin.std.meta.LastModPluginCfgDefn;
import org.opends.server.admin.std.server.LastModPluginCfg;
import org.opends.server.api.plugin.PluginType;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.core.AddOperation;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.ModifyDNOperation;
@@ -49,18 +45,18 @@
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.types.AttributeType;
import org.opends.server.types.Attributes;
import org.opends.server.types.DirectoryConfig;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryConfig;
import org.opends.server.types.Entry;
import org.opends.server.types.Modification;
import org.forgerock.opendj.ldap.ModificationType;
import org.opends.server.types.RDN;
import org.forgerock.opendj.ldap.ResultCode;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.testng.Assert.*;
/**
 * This class defines a set of tests for the
 * org.opends.server.plugins.LastModPlugin class.
@@ -292,11 +288,7 @@
                                      "objectClass: device",
                                      "cn: test");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    e = DirectoryConfig.getEntry(e.getName());
@@ -352,16 +344,11 @@
                                      "objectClass: device",
                                      "cn: test");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    ModifyDNOperation modifyDNOperation =
         conn.processModifyDN(e.getName(), RDN.decode("cn=test2"), false);
        getRootConnection().processModifyDN(e.getName(), RDN.decode("cn=test2"), false);
    assertEquals(modifyDNOperation.getResultCode(), ResultCode.SUCCESS);
    e = DirectoryConfig.getEntry(DN.valueOf("cn=test2,o=test"));
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/protocols/internal/InternalClientConnectionTestCase.java
@@ -33,6 +33,7 @@
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.DereferenceAliasesPolicy;
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.TestCaseUtils;
import org.opends.server.core.AddOperation;
@@ -47,11 +48,11 @@
import org.opends.server.protocols.ldap.LDAPFilter;
import org.opends.server.protocols.ldap.LDAPModification;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.opends.server.util.ServerConstants.*;
import static org.testng.Assert.*;
@@ -67,7 +68,7 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @BeforeClass()
  @BeforeClass
  public void startServer()
         throws Exception
  {
@@ -294,7 +295,7 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  @Test
  public void testProcessAdd1()
         throws Exception
  {
@@ -313,9 +314,7 @@
    values.add(ByteString.valueOf("test"));
    attrs.add(new LDAPAttribute("cn", values));
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation = conn.processAdd(dn, attrs);
    AddOperation addOperation = getRootConnection().processAdd(dn, attrs);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
  }
@@ -327,7 +326,7 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  @Test
  public void testProcessAdd2()
         throws Exception
  {
@@ -338,11 +337,7 @@
                                      "objectClass: device",
                                      "cn: test");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation = conn.processAdd(e.getName(), e.getObjectClasses(),
                                                e.getUserAttributes(),
                                                e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
  }
@@ -354,12 +349,11 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  @Test
  public void testProcessSimpleBind1()
         throws Exception
  {
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    InternalClientConnection conn = getRootConnection();
    BindOperation bindOperation =
         conn.processSimpleBind(ByteString.valueOf("cn=Directory Manager"),
                                ByteString.valueOf("password"));
@@ -374,12 +368,11 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  @Test
  public void testProcessSimpleBind2()
         throws Exception
  {
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    InternalClientConnection conn = getRootConnection();
    BindOperation bindOperation =
         conn.processSimpleBind(DN.valueOf("cn=Directory Manager"),
                                ByteString.valueOf("password"));
@@ -394,15 +387,14 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  @Test
  public void testProcessSASLBind1()
         throws Exception
  {
    ByteString creds =
         ByteString.valueOf("\u0000dn:cn=Directory Manager\u0000password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    InternalClientConnection conn = getRootConnection();
    BindOperation bindOperation =
         conn.processSASLBind(ByteString.empty(), "PLAIN", creds);
    assertEquals(bindOperation.getResultCode(), ResultCode.SUCCESS);
@@ -416,15 +408,14 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  @Test
  public void testProcessSASLBind2()
         throws Exception
  {
    ByteString creds =
         ByteString.valueOf("\u0000dn:cn=Directory Manager\u0000password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    InternalClientConnection conn = getRootConnection();
    BindOperation bindOperation =
         conn.processSASLBind(DN.rootDN(), "PLAIN", creds);
    assertEquals(bindOperation.getResultCode(), ResultCode.SUCCESS);
@@ -438,7 +429,7 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  @Test
  public void testProcessCompare1()
         throws Exception
  {
@@ -449,14 +440,11 @@
                                      "objectClass: device",
                                      "cn: test");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation = conn.processAdd(e.getName(), e.getObjectClasses(),
                                                e.getUserAttributes(),
                                                e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    InternalClientConnection conn = getRootConnection();
    CompareOperation compareOperation =
         conn.processCompare(ByteString.valueOf("cn=test,o=test"), "cn",
                             ByteString.valueOf("test"));
@@ -471,7 +459,7 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  @Test
  public void testProcessCompare2()
         throws Exception
  {
@@ -482,14 +470,11 @@
                                      "objectClass: device",
                                      "cn: test");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation = conn.processAdd(e.getName(), e.getObjectClasses(),
                                                e.getUserAttributes(),
                                                e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    InternalClientConnection conn = getRootConnection();
    CompareOperation compareOperation =
         conn.processCompare(DN.valueOf("cn=test,o=test"),
                             DirectoryServer.getAttributeType("cn", true),
@@ -505,7 +490,7 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  @Test
  public void testProcessDelete1()
         throws Exception
  {
@@ -516,16 +501,12 @@
                                      "objectClass: device",
                                      "cn: test");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation = conn.processAdd(e.getName(), e.getObjectClasses(),
                                                e.getUserAttributes(),
                                                e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    DeleteOperation deleteOperation =
         conn.processDelete(ByteString.valueOf("cn=test,o=test"));
         getRootConnection().processDelete(ByteString.valueOf("cn=test,o=test"));
    assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS);
  }
@@ -537,7 +518,7 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  @Test
  public void testProcessDelete2()
         throws Exception
  {
@@ -548,16 +529,11 @@
                                      "objectClass: device",
                                      "cn: test");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation = conn.processAdd(e.getName(), e.getObjectClasses(),
                                                e.getUserAttributes(),
                                                e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    DeleteOperation deleteOperation =
         conn.processDelete(DN.valueOf("cn=test,o=test"));
         getRootConnection().processDelete(DN.valueOf("cn=test,o=test"));
    assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS);
  }
@@ -568,12 +544,11 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  @Test
  public void testProcessExtendedOperation()
         throws Exception
  {
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    InternalClientConnection conn = getRootConnection();
    ExtendedOperation extendedOperation =
         conn.processExtendedOperation(OID_WHO_AM_I_REQUEST, null);
    assertEquals(extendedOperation.getResultCode(), ResultCode.SUCCESS);
@@ -587,7 +562,7 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  @Test
  public void testProcessModify1()
         throws Exception
  {
@@ -598,11 +573,7 @@
                                      "objectClass: device",
                                      "cn: test");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation = conn.processAdd(e.getName(), e.getObjectClasses(),
                                                e.getUserAttributes(),
                                                e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -613,6 +584,7 @@
    mods.add(new LDAPModification(ModificationType.REPLACE,
                                  new LDAPAttribute("description", values)));
    InternalClientConnection conn = getRootConnection();
    ModifyOperation modifyOperation =
         conn.processModify(ByteString.valueOf("cn=test,o=test"), mods);
    assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS);
@@ -626,7 +598,7 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  @Test
  public void testProcessModify2()
         throws Exception
  {
@@ -637,18 +609,14 @@
                                      "objectClass: device",
                                      "cn: test");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation = conn.processAdd(e.getName(), e.getObjectClasses(),
                                                e.getUserAttributes(),
                                                e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    ArrayList<Modification> mods = new ArrayList<Modification>();
    mods.add(new Modification(ModificationType.REPLACE,
        Attributes.create("description", "This is a test")));
    InternalClientConnection conn = getRootConnection();
    ModifyOperation modifyOperation =
         conn.processModify(DN.valueOf("cn=test,o=test"), mods);
    assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS);
@@ -662,7 +630,7 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  @Test
  public void testProcessModifyDN1()
         throws Exception
  {
@@ -673,14 +641,10 @@
                                      "objectClass: device",
                                      "cn: test");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation = conn.processAdd(e.getName(), e.getObjectClasses(),
                                                e.getUserAttributes(),
                                                e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    InternalClientConnection conn = getRootConnection();
    ModifyDNOperation modifyDNOperation =
         conn.processModifyDN(ByteString.valueOf("cn=test,o=test"),
                              ByteString.valueOf("cn=test2"), true);
@@ -695,7 +659,7 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  @Test
  public void testProcessModifyDN2()
         throws Exception
  {
@@ -706,14 +670,10 @@
                                      "objectClass: device",
                                      "cn: test");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation = conn.processAdd(e.getName(), e.getObjectClasses(),
                                                e.getUserAttributes(),
                                                e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    InternalClientConnection conn = getRootConnection();
    ModifyDNOperation modifyDNOperation =
         conn.processModifyDN(ByteString.valueOf("cn=test,o=test"),
                              ByteString.valueOf("cn=test2"), true,
@@ -730,7 +690,7 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  @Test
  public void testProcessModifyDN3()
         throws Exception
  {
@@ -741,11 +701,8 @@
                                      "objectClass: device",
                                      "cn: test");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation = conn.processAdd(e.getName(), e.getObjectClasses(),
                                                e.getUserAttributes(),
                                                e.getOperationalAttributes());
    InternalClientConnection conn = getRootConnection();
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -763,7 +720,7 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  @Test
  public void testProcessModifyDN4()
         throws Exception
  {
@@ -774,11 +731,8 @@
                                      "objectClass: device",
                                      "cn: test");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation = conn.processAdd(e.getName(), e.getObjectClasses(),
                                                e.getUserAttributes(),
                                                e.getOperationalAttributes());
    InternalClientConnection conn = getRootConnection();
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -798,12 +752,11 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  @Test
  public void testProcessSearch1()
         throws Exception
  {
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    InternalClientConnection conn = getRootConnection();
    InternalSearchOperation searchOperation =
         conn.processSearch(ByteString.valueOf(""), SearchScope.BASE_OBJECT,
                            LDAPFilter.decode("(objectClass=*)"));
@@ -820,12 +773,11 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  @Test
  public void testProcessSearch2()
         throws Exception
  {
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    InternalClientConnection conn = getRootConnection();
    InternalSearchOperation searchOperation =
         conn.processSearch(ByteString.valueOf(""), SearchScope.BASE_OBJECT,
                            DereferenceAliasesPolicy.NEVER, 0, 0, false,
@@ -845,15 +797,14 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  @Test
  public void testProcessSearch3()
         throws Exception
  {
    TestInternalSearchListener searchListener =
         new TestInternalSearchListener();
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    InternalClientConnection conn = getRootConnection();
    InternalSearchOperation searchOperation =
         conn.processSearch(ByteString.valueOf(""), SearchScope.BASE_OBJECT,
                            DereferenceAliasesPolicy.NEVER, 0, 0, false,
@@ -872,12 +823,11 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  @Test
  public void testProcessSearch4()
         throws Exception
  {
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    InternalClientConnection conn = getRootConnection();
    InternalSearchOperation searchOperation =
         conn.processSearch(DN.rootDN(), SearchScope.BASE_OBJECT,
              SearchFilter.createFilterFromString("(objectClass=*)"));
@@ -894,12 +844,11 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  @Test
  public void testProcessSearch5()
         throws Exception
  {
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    InternalClientConnection conn = getRootConnection();
    InternalSearchOperation searchOperation =
         conn.processSearch(DN.rootDN(), SearchScope.BASE_OBJECT,
              DereferenceAliasesPolicy.NEVER, 0, 0, false,
@@ -919,15 +868,14 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  @Test
  public void testProcessSearch6()
         throws Exception
  {
    TestInternalSearchListener searchListener =
         new TestInternalSearchListener();
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    InternalClientConnection conn = getRootConnection();
    InternalSearchOperation searchOperation =
         conn.processSearch(DN.rootDN(), SearchScope.BASE_OBJECT,
              DereferenceAliasesPolicy.NEVER, 0, 0, false,
@@ -945,12 +893,11 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  @Test
  public void testSendSearchReference()
         throws Exception
  {
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    InternalClientConnection conn = getRootConnection();
    InternalSearchOperation searchOperation =
         conn.processSearch(ByteString.valueOf(""), SearchScope.BASE_OBJECT,
                            LDAPFilter.decode("(objectClass=*)"));
@@ -969,12 +916,10 @@
  /**
   * Tests the <CODE>sendIntermediateResponseMessage</CODE> method.
   */
  @Test()
  @Test
  public void testSendIntermediateResponseMessage()
  {
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    assertFalse(conn.sendIntermediateResponseMessage(null));
    assertFalse(getRootConnection().sendIntermediateResponseMessage(null));
  }
@@ -982,12 +927,10 @@
  /**
   * Tests the <CODE>disconnect</CODE> method.
   */
  @Test()
  @Test
  public void testDisconnect()
  {
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    conn.disconnect(DisconnectReason.OTHER, false,
    getRootConnection().disconnect(DisconnectReason.OTHER, false,
            LocalizableMessage.raw("testDisconnect"));
  }
@@ -998,12 +941,10 @@
  /**
   * Tests the <CODE>removeOperationInProgress</CODE> method.
   */
  @Test()
  @Test
  public void testRemoveOperationInProgress()
  {
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    assertFalse(conn.removeOperationInProgress(1));
    assertFalse(getRootConnection().removeOperationInProgress(1));
  }
@@ -1011,13 +952,11 @@
  /**
   * Tests the <CODE>cancelOperation</CODE> method.
   */
  @Test()
  @Test
  public void testCancelOperation()
  {
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    CancelResult cancelResult =
         conn.cancelOperation(1,
         getRootConnection().cancelOperation(1,
              new CancelRequest(true, LocalizableMessage.raw("testCancelOperation")));
    assertEquals(cancelResult.getResultCode(), ResultCode.CANNOT_CANCEL);
  }
@@ -1027,12 +966,10 @@
  /**
   * Tests the <CODE>cancelAllOperations</CODE> method.
   */
  @Test()
  @Test
  public void testCancelAllOperations()
  {
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    conn.cancelAllOperations(new CancelRequest(true,
    getRootConnection().cancelAllOperations(new CancelRequest(true,
            LocalizableMessage.raw("testCancelOperation")));
  }
@@ -1041,12 +978,10 @@
  /**
   * Tests the <CODE>cancelAllOperationsExcept</CODE> method.
   */
  @Test()
  @Test
  public void testCancelAllOperationsExcept()
  {
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    conn.cancelAllOperationsExcept(
    getRootConnection().cancelAllOperationsExcept(
            new CancelRequest(true, LocalizableMessage.raw("testCancelOperation")), 1);
  }
@@ -1055,16 +990,10 @@
  /**
   * Tests the <CODE>toString</CODE> method.
   */
  @Test()
  @Test
  public void testToString()
  {
    StringBuilder buffer = new StringBuilder();
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    conn.toString(buffer);
    assertFalse(buffer.toString().equals(""));
    assertFalse(getRootConnection().toString().equals(""));
  }
}
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/LDAPSyntaxTest.java
@@ -31,6 +31,10 @@
import java.util.LinkedHashSet;
import java.util.List;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.DereferenceAliasesPolicy;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.TestCaseUtils;
import org.opends.server.api.AttributeSyntax;
import org.opends.server.core.AddOperation;
@@ -38,16 +42,13 @@
import org.opends.server.protocols.internal.InternalSearchOperation;
import org.opends.server.protocols.ldap.LDAPFilter;
import org.opends.server.types.Attribute;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.types.DN;
import org.forgerock.opendj.ldap.DereferenceAliasesPolicy;
import org.opends.server.types.Entry;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.types.SearchResultEntry;
import org.forgerock.opendj.ldap.SearchScope;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.testng.Assert.*;
/**
@@ -57,18 +58,14 @@
public class LDAPSyntaxTest extends AttributeSyntaxTest
{
  /**
   * {@inheritDoc}
   */
  /** {@inheritDoc} */
  @Override
  protected AttributeSyntax<?> getRule()
  {
    return new LDAPSyntaxDescriptionSyntax();
  }
  /**
   * {@inheritDoc}
   */
  /** {@inheritDoc} */
  @Override
  @DataProvider(name="acceptableValues")
  public Object[][] createAcceptableValues()
@@ -343,13 +340,7 @@
      "cn: syntax-test",
      "sn: xyz",
      "test-attr-regex: invalid regex");
      InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation = conn.processAdd(entry.getName(),
                                     entry.getObjectClasses(),
                                     entry.getUserAttributes(),
                                     entry.getOperationalAttributes());
      AddOperation addOperation = getRootConnection().processAdd(entry);
    assertEquals(addOperation.getResultCode(),
            ResultCode.INVALID_ATTRIBUTE_SYNTAX);
@@ -446,13 +437,7 @@
      "cn: syntax-test",
      "sn: xyz",
      "test-attr-enum: arbit-day");
      InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation = conn.processAdd(entry.getName(),
                                     entry.getObjectClasses(),
                                     entry.getUserAttributes(),
                                     entry.getOperationalAttributes());
      AddOperation addOperation = getRootConnection().processAdd(entry);
    assertEquals(addOperation.getResultCode(),
            ResultCode.INVALID_ATTRIBUTE_SYNTAX);
@@ -596,29 +581,30 @@
  //Parses the OID from the syntax defitions.
  /** Parses the OID from the syntax defitions. */
  private String getOIDFromLdapSyntax(String valueStr)
  {
    int pos    = 0;
    int length = valueStr.length();
    while ((pos < length) && (valueStr.charAt(pos) == ' '))
    while (pos < length && valueStr.charAt(pos) == ' ')
    {
      pos++;
    }
    // The next character must be an open parenthesis.  If it is not, then that
    // is an error.
    char c = valueStr.charAt(pos++);
    assertEquals(valueStr.charAt(pos++), '(');
    // Skip over any spaces immediately following the opening parenthesis.
    while ((pos < length) && ((c = valueStr.charAt(pos)) == ' '))
    while (pos < length && valueStr.charAt(pos) == ' ')
    {
      pos++;
    }
    int oidStartPos = pos;
    while ((pos < length) && ((c = valueStr.charAt(pos)) != ' ')
          && (c = valueStr.charAt(pos)) != ')')
    while (pos < length
        && valueStr.charAt(pos) != ' '
        && valueStr.charAt(pos) != ')')
    {
      pos++;
    }
@@ -626,7 +612,7 @@
  }
  //Adds a substitutionsyntax to the schema.
  /** Adds a substitutionsyntax to the schema. */
  private void addSubtitutionSyntax() throws Exception
  {
    //Add the substitution syntax for an unimplemented syntax.
@@ -642,7 +628,7 @@
  //Deletes the substitutionSyntax from the schema.
  /** Deletes the substitutionSyntax from the schema. */
  private void deleteSubstitutionSyntax() throws Exception
  {
    //delete the substitution syntax.
@@ -657,7 +643,7 @@
  }
   //Adds a regex syntax to the schema.
  /** Adds a regex syntax to the schema. */
  private void addRegexSyntax() throws Exception
  {
    //Add the substitution syntax for an unimplemented syntax.
@@ -683,7 +669,7 @@
  //Deletes the regex syntax from the schema.
  /** Deletes the regex syntax from the schema. */
  private void deleteRegexSyntax() throws Exception
  {
    //delete the substitution syntax.
@@ -711,7 +697,7 @@
     //Adds an enum syntax to the schema.
  /** Adds an enum syntax to the schema. */
  private void addEnumSyntax() throws Exception
  {
    //Add the enum syntax.
@@ -737,7 +723,7 @@
  //Deletes the enum syntax from the schema.
  /** Deletes the enum syntax from the schema. */
  private void deleteEnumSyntax() throws Exception
  {
    int resultCode = TestCaseUtils.applyModifications(true,
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/tasks/TasksTestCase.java
@@ -28,6 +28,7 @@
import java.util.Set;
import org.assertj.core.api.SoftAssertions;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.DirectoryServerTestCase;
@@ -38,12 +39,14 @@
import org.opends.server.core.DirectoryServer;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.protocols.internal.InternalSearchOperation;
import org.opends.server.types.AttributeParser;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
import org.opends.server.types.SearchFilter;
import org.testng.annotations.Test;
import static org.opends.server.config.ConfigConstants.*;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.testng.Assert.*;
/**
@@ -54,20 +57,6 @@
  /**
   * Add a task definition and check that it completes with the expected state.
   * The task is expected to complete quickly and the timeout is set
   * accordingly.
   * @param taskEntry The task entry.
   * @param expectedState The expected completion state of the task.
   * @throws Exception If the test fails.
   */
  protected void testTask(Entry taskEntry, TaskState expectedState)
       throws Exception
  {
    testTask(taskEntry, expectedState, 30);
  }
  /**
   * Add a task definition and check that it completes with the expected state.
   * @param taskEntry The task entry.
   * @param expectedState The expected completion state of the task.
   * @param timeout The number of seconds to wait for the task to complete.
@@ -76,15 +65,10 @@
  protected void testTask(Entry taskEntry, TaskState expectedState, int timeout)
       throws Exception
  {
    InternalClientConnection connection =
         InternalClientConnection.getRootConnection();
    InternalClientConnection connection = getRootConnection();
    // Add the task.
    AddOperation addOperation =
         connection.processAdd(taskEntry.getName(),
                               taskEntry.getObjectClasses(),
                               taskEntry.getUserAttributes(),
                               taskEntry.getOperationalAttributes());
    AddOperation addOperation = connection.processAdd(taskEntry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS,
                 "Add of the task definition was not successful");
@@ -94,71 +78,52 @@
    Entry resultEntry = null;
    String completionTime = null;
    long startMillisecs = System.currentTimeMillis();
    boolean timedOut;
    do
    {
      Thread.sleep(100);
      InternalSearchOperation searchOperation =
           connection.processSearch(taskEntry.getName(),
                                    SearchScope.BASE_OBJECT,
                                    filter);
      try
      {
        resultEntry = searchOperation.getSearchEntries().getFirst();
      } catch (Exception e)
      {
        // FIXME How is this possible?  Must be issue 858.
//        fail("Task entry was not returned from the search.");
        continue;
      }
      completionTime = resultEntry.parseAttribute(
          ATTR_TASK_COMPLETION_TIME.toLowerCase()).asString();
      if (completionTime == null)
      {
        if (System.currentTimeMillis() - startMillisecs > 1000*timeout)
        {
          break;
        }
        Thread.sleep(10);
      }
    } while (completionTime == null);
    if (completionTime == null)
    {
      fail("The task had not completed after " + timeout + " seconds.");
      resultEntry = searchOperation.getSearchEntries().getFirst();
      completionTime = parseAttribute(resultEntry, ATTR_TASK_COMPLETION_TIME).asString();
      timedOut = System.currentTimeMillis() - startMillisecs > 1000 * timeout;
    }
    while (completionTime == null && timedOut);
    assertNotNull(completionTime, "The task had not completed after " + timeout + " seconds.");
    // Check that the task state is as expected.
    String stateString =
        resultEntry.parseAttribute(ATTR_TASK_STATE.toLowerCase()).asString();
    String stateString = parseAttribute(resultEntry, ATTR_TASK_STATE).asString();
    TaskState taskState = TaskState.fromString(stateString);
    assertEquals(taskState, expectedState,
                 "The task completed in an unexpected state");
    // Check that the task contains some log messages.
    Set<String> logMessages = resultEntry.parseAttribute(
        ATTR_TASK_LOG_MESSAGES.toLowerCase()).asSetOfString();
    if (taskState != TaskState.COMPLETED_SUCCESSFULLY &&
        logMessages.size() == 0)
    {
      fail("No log messages were written to the task entry on a failed task");
    }
    Set<String> logMessages = parseAttribute(resultEntry, ATTR_TASK_LOG_MESSAGES).asSetOfString();
    final String msg = "No log messages were written to the task entry on a failed task";
    SoftAssertions softly = new SoftAssertions();
    softly.assertThat(taskState).as(msg).isNotEqualTo(TaskState.COMPLETED_SUCCESSFULLY);
    softly.assertThat(logMessages).as(msg).isNotEmpty();
    softly.assertAll();
  }
  private AttributeParser parseAttribute(Entry resultEntry, String attrName)
  {
    return resultEntry.parseAttribute(attrName.toLowerCase());
  }
  /**
   * Retrieves the specified task from the server, regardless of its current
   * state.
   *
   * @param  taskEntryDN  The DN of the entry for the task to retrieve.
   *
   * @return  The requested task entry.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test(enabled=false) // This isn't a test method, but TestNG thinks it is.
  public static Task getTask(DN taskEntryDN)
         throws Exception
  public static Task getTask(DN taskEntryDN) throws Exception
  {
    TaskBackend taskBackend =
         (TaskBackend) DirectoryServer.getBackend(DN.valueOf("cn=tasks"));
@@ -166,19 +131,14 @@
    if (task == null)
    {
      long stopWaitingTime = System.currentTimeMillis() + 10000L;
      while ((task == null) && (System.currentTimeMillis() < stopWaitingTime))
      while (task == null && System.currentTimeMillis() < stopWaitingTime)
      {
        Thread.sleep(10);
        task = taskBackend.getScheduledTask(taskEntryDN);
      }
    }
    if (task == null)
    {
      throw new AssertionError("There is no such task " +
                               taskEntryDN.toString());
    }
    assertNotNull(task, "There is no such task " + taskEntryDN);
    return task;
  }
@@ -195,27 +155,21 @@
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test(enabled=false) // This isn't a test method, but TestNG thinks it is.
  public static Task getCompletedTask(DN taskEntryDN)
          throws Exception
  public static Task getCompletedTask(DN taskEntryDN) throws Exception
  {
    Task task = getTask(taskEntryDN);
    if (! TaskState.isDone(task.getTaskState()))
    {
      long stopWaitingTime = System.currentTimeMillis() + 20000L;
      while ((! TaskState.isDone(task.getTaskState())) &&
             (System.currentTimeMillis() < stopWaitingTime))
      while (! TaskState.isDone(task.getTaskState()) &&
             System.currentTimeMillis() < stopWaitingTime)
      {
        Thread.sleep(10);
      }
    }
    if (! TaskState.isDone(task.getTaskState()))
    {
      throw new AssertionError("Task " + taskEntryDN.toString() +
                               " did not complete in a timely manner.");
    }
    assertTrue(TaskState.isDone(task.getTaskState()), "Task " + taskEntryDN + " did not complete in a timely manner.");
    return task;
  }
}
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/tasks/TestBackupAndRestore.java
@@ -24,43 +24,42 @@
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014 ForgeRock AS.
 */
package org.opends.server.tasks;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.opends.server.api.TestTaskListener;
import java.io.File;
import java.util.UUID;
import org.opends.server.TestCaseUtils;
import org.opends.server.backends.task.TaskState;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.*;
import org.opends.server.TestCaseUtils;
import org.opends.server.types.Entry;
import org.opends.server.types.ObjectClass;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import static org.assertj.core.api.Assertions.*;
import static org.opends.server.api.TestTaskListener.*;
import static org.testng.Assert.*;
import java.util.UUID;
import java.io.File;
/**
 * Tests the backup and restore tasks.
 */
@SuppressWarnings("javadoc")
public class TestBackupAndRestore extends TasksTestCase
{
  @BeforeClass
  public final void setUp() throws Exception {
    TestCaseUtils.startServer();
    TestTaskListener.registerListeners();
    registerListeners();
  }
  @AfterClass
  public final void cleanUp() throws Exception {
    TestTaskListener.deregisterListeners();
    deregisterListeners();
  }
  /**
   * Backup and restore tasks test data provider.
   *
@@ -74,8 +73,7 @@
         {
              // A valid backup task.
              TestCaseUtils.makeEntry(
                   "dn: ds-task-id=" + UUID.randomUUID() +
                        ",cn=Scheduled Tasks,cn=Tasks",
                   "dn: ds-task-id=" + UUID.randomUUID() + ",cn=Scheduled Tasks,cn=Tasks",
                   "objectclass: top",
                   "objectclass: ds-task",
                   "objectclass: ds-task-backup",
@@ -89,8 +87,7 @@
              // Incompatible settings of backup-directory-path and
              // incremental-base-id.
              TestCaseUtils.makeEntry(
                   "dn: ds-task-id=" + UUID.randomUUID() +
                        ",cn=Scheduled Tasks,cn=Tasks",
                   "dn: ds-task-id=" + UUID.randomUUID() + ",cn=Scheduled Tasks,cn=Tasks",
                   "objectclass: top",
                   "objectclass: ds-task",
                   "objectclass: ds-task-backup",
@@ -104,8 +101,7 @@
         {
              // Incompatible settings for backend-id and backup-all.
              TestCaseUtils.makeEntry(
                   "dn: ds-task-id=" + UUID.randomUUID() +
                        ",cn=Scheduled Tasks,cn=Tasks",
                   "dn: ds-task-id=" + UUID.randomUUID() + ",cn=Scheduled Tasks,cn=Tasks",
                   "objectclass: top",
                   "objectclass: ds-task",
                   "objectclass: ds-task-backup",
@@ -118,8 +114,7 @@
         {
              // Neither of backend-id or backup-all specified.
              TestCaseUtils.makeEntry(
                   "dn: ds-task-id=" + UUID.randomUUID() +
                        ",cn=Scheduled Tasks,cn=Tasks",
                   "dn: ds-task-id=" + UUID.randomUUID() + ",cn=Scheduled Tasks,cn=Tasks",
                   "objectclass: top",
                   "objectclass: ds-task",
                   "objectclass: ds-task-backup",
@@ -130,8 +125,7 @@
         {
              // Incompatible settings for incremental and incremental-base-id.
              TestCaseUtils.makeEntry(
                   "dn: ds-task-id=" + UUID.randomUUID() +
                        ",cn=Scheduled Tasks,cn=Tasks",
                   "dn: ds-task-id=" + UUID.randomUUID() + ",cn=Scheduled Tasks,cn=Tasks",
                   "objectclass: top",
                   "objectclass: ds-task",
                   "objectclass: ds-task-backup",
@@ -145,8 +139,7 @@
         {
              // Incompatible settings for hash and sign-hash.
              TestCaseUtils.makeEntry(
                   "dn: ds-task-id=" + UUID.randomUUID() +
                        ",cn=Scheduled Tasks,cn=Tasks",
                   "dn: ds-task-id=" + UUID.randomUUID() + ",cn=Scheduled Tasks,cn=Tasks",
                   "objectclass: top",
                   "objectclass: ds-task",
                   "objectclass: ds-task-backup",
@@ -161,8 +154,7 @@
         {
              // Specified backend does not support backup.
              TestCaseUtils.makeEntry(
                   "dn: ds-task-id=" + UUID.randomUUID() +
                        ",cn=Scheduled Tasks,cn=Tasks",
                   "dn: ds-task-id=" + UUID.randomUUID() + ",cn=Scheduled Tasks,cn=Tasks",
                   "objectclass: top",
                   "objectclass: ds-task",
                   "objectclass: ds-task-backup",
@@ -174,22 +166,19 @@
         {
              // A valid restore task.
              TestCaseUtils.makeEntry(
                   "dn: ds-task-id=" + UUID.randomUUID() +
                        ",cn=Scheduled Tasks,cn=Tasks",
                   "dn: ds-task-id=" + UUID.randomUUID() + ",cn=Scheduled Tasks,cn=Tasks",
                   "objectclass: top",
                   "objectclass: ds-task",
                   "objectclass: ds-task-restore",
                   "ds-task-class-name: org.opends.server.tasks.RestoreTask",
                   "ds-backup-directory-path: bak" + File.separator +
                        "userRoot"
                   "ds-backup-directory-path: bak" + File.separator + "userRoot"
              ),
              TaskState.COMPLETED_SUCCESSFULLY
         },
         {
              // Non-existent restore directory-path.
              TestCaseUtils.makeEntry(
                   "dn: ds-task-id=" + UUID.randomUUID() +
                        ",cn=Scheduled Tasks,cn=Tasks",
                   "dn: ds-task-id=" + UUID.randomUUID() + ",cn=Scheduled Tasks,cn=Tasks",
                   "objectclass: top",
                   "objectclass: ds-task",
                   "objectclass: ds-task-restore",
@@ -201,8 +190,7 @@
         {
              // Invalid restore directory-path.
              TestCaseUtils.makeEntry(
                   "dn: ds-task-id=" + UUID.randomUUID() +
                        ",cn=Scheduled Tasks,cn=Tasks",
                   "dn: ds-task-id=" + UUID.randomUUID() + ",cn=Scheduled Tasks,cn=Tasks",
                   "objectclass: top",
                   "objectclass: ds-task",
                   "objectclass: ds-task-restore",
@@ -214,14 +202,12 @@
         {
              // Invalid restore backup-id.
              TestCaseUtils.makeEntry(
                   "dn: ds-task-id=" + UUID.randomUUID() +
                        ",cn=Scheduled Tasks,cn=Tasks",
                   "dn: ds-task-id=" + UUID.randomUUID() + ",cn=Scheduled Tasks,cn=Tasks",
                   "objectclass: top",
                   "objectclass: ds-task",
                   "objectclass: ds-task-restore",
                   "ds-task-class-name: org.opends.server.tasks.RestoreTask",
                   "ds-backup-directory-path: bak" + File.separator +
                        "userRoot",
                   "ds-backup-directory-path: bak" + File.separator + "userRoot",
                   "ds-backup-id: monday"
              ),
              TaskState.STOPPED_BY_ERROR
@@ -229,8 +215,6 @@
    };
  }
  /**
   * Test that various backup and restore task definitions complete with the
   * expected state.
@@ -238,38 +222,32 @@
   * @param expectedState The expected completion state of the task.
   */
  @Test(dataProvider = "backups")
  public void testBackups(Entry taskEntry, TaskState expectedState)
       throws Exception
  public void testBackups(Entry taskEntry, TaskState expectedState) throws Exception
  {
    int backupBeginCount  = TestTaskListener.backupBeginCount.get();
    int backupEndCount    = TestTaskListener.backupEndCount.get();
    int restoreBeginCount = TestTaskListener.restoreBeginCount.get();
    int restoreEndCount   = TestTaskListener.restoreEndCount.get();
    final int backupBeginCountStart = backupBeginCount.get();
    final int backupEndCountStart = backupEndCount.get();
    final int restoreBeginCountStart = restoreBeginCount.get();
    final int restoreEndCountStart = restoreEndCount.get();
    ObjectClass backupClass =
         DirectoryServer.getObjectClass("ds-task-backup", true);
    ObjectClass backupClass = DirectoryServer.getObjectClass("ds-task-backup", true);
    testTask(taskEntry, expectedState);
    if ((expectedState == TaskState.COMPLETED_SUCCESSFULLY) ||
        (expectedState == TaskState.COMPLETED_WITH_ERRORS))
    testTask(taskEntry, expectedState, 30);
    if (expectedState == TaskState.COMPLETED_SUCCESSFULLY ||
        expectedState == TaskState.COMPLETED_WITH_ERRORS)
    {
      if (taskEntry.hasObjectClass(backupClass))
      {
        // The backup task can back up multiple backends at the same time, so
        // we the count may be incremented by more than one in those cases.
        assertTrue(TestTaskListener.backupBeginCount.get() > backupBeginCount);
        assertTrue(TestTaskListener.backupEndCount.get() > backupEndCount);
        assertEquals(TestTaskListener.backupBeginCount.get(),
                     TestTaskListener.backupEndCount.get());
        assertThat(backupBeginCount.get()).isGreaterThan(backupBeginCountStart);
        assertThat(backupEndCount.get()).isGreaterThan(backupEndCountStart);
        assertEquals(backupBeginCount.get(), backupEndCount.get());
      }
      else
      {
        assertEquals(TestTaskListener.restoreBeginCount.get(),
                     (restoreBeginCount+1));
        assertEquals(TestTaskListener.restoreEndCount.get(),
                     (restoreEndCount+1));
        assertEquals(TestTaskListener.restoreBeginCount.get(),
                     TestTaskListener.restoreEndCount.get());
        assertEquals(restoreBeginCount.get(), restoreBeginCountStart + 1);
        assertEquals(restoreEndCount.get(), restoreEndCountStart + 1);
        assertEquals(restoreBeginCount.get(), restoreEndCount.get());
      }
    }
  }
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/tasks/TestImportAndExport.java
@@ -27,25 +27,24 @@
package org.opends.server.tasks;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.AfterClass;
import org.testng.annotations.DataProvider;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.AddOperation;
import org.opends.server.TestCaseUtils;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.api.TestTaskListener;
import org.opends.server.types.Entry;
import org.opends.server.types.ObjectClass;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.backends.task.TaskState;
import static org.testng.Assert.*;
import java.io.File;
import java.util.UUID;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.TestCaseUtils;
import org.opends.server.api.TestTaskListener;
import org.opends.server.backends.task.TaskState;
import org.opends.server.core.AddOperation;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.Entry;
import org.opends.server.types.ObjectClass;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.testng.Assert.*;
/**
 * Tests invocation of the import and export tasks, but does not aim to
@@ -408,15 +407,7 @@
  public void testBadTask(Entry taskEntry, ResultCode resultCode)
      throws Exception
  {
    InternalClientConnection connection =
        InternalClientConnection.getRootConnection();
    // Add the task.
    AddOperation addOperation =
        connection.processAdd(taskEntry.getName(),
                              taskEntry.getObjectClasses(),
                              taskEntry.getUserAttributes(),
                              taskEntry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(taskEntry);
    assertEquals(addOperation.getResultCode(), resultCode);
  }
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/tools/LDAPAuthenticationHandlerTestCase.java
@@ -26,8 +26,6 @@
 */
package org.opends.server.tools;
import java.io.File;
import java.net.InetAddress;
import java.net.Socket;
@@ -37,25 +35,26 @@
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.opends.server.TestCaseUtils;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.TestCaseUtils;
import org.opends.server.api.SASLMechanismHandler;
import org.opends.server.controls.PasswordPolicyRequestControl;
import org.opends.server.core.AddOperation;
import org.opends.server.core.DirectoryServer;
import org.opends.server.extensions.AnonymousSASLMechanismHandler;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.ByteString;
import static org.testng.Assert.*;
import org.opends.server.types.Control;
import org.opends.server.types.Entry;
import org.opends.server.types.LDAPException;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import com.forgerock.opendj.cli.ClientException;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.testng.Assert.*;
/**
 * A set of test cases for the LDAP authentication handler.
@@ -732,15 +731,11 @@
         "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," +
              "cn=Password Policies,cn=config");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    SASLMechanismHandler cramMD5Handler =
    SASLMechanismHandler<?> cramMD5Handler =
         DirectoryServer.getSASLMechanismHandler("CRAM-MD5");
    DirectoryServer.deregisterSASLMechanismHandler("CRAM-MD5");
@@ -804,11 +799,7 @@
         "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," +
              "cn=Password Policies,cn=config");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -952,11 +943,7 @@
         "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," +
              "cn=Password Policies,cn=config");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -1016,11 +1003,7 @@
         "cn: Test User",
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -1253,11 +1236,7 @@
         "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," +
              "cn=Password Policies,cn=config");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -1315,15 +1294,11 @@
         "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," +
              "cn=Password Policies,cn=config");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    SASLMechanismHandler digestMD5Handler =
    SASLMechanismHandler<?> digestMD5Handler =
         DirectoryServer.getSASLMechanismHandler("DIGEST-MD5");
    DirectoryServer.deregisterSASLMechanismHandler("DIGEST-MD5");
@@ -1392,11 +1367,7 @@
         "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," +
              "cn=Password Policies,cn=config");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -1454,11 +1425,7 @@
         "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," +
              "cn=Password Policies,cn=config");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -1768,11 +1735,7 @@
         "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," +
              "cn=Password Policies,cn=config");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -2241,11 +2204,7 @@
         "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," +
              "cn=Password Policies,cn=config");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -2310,11 +2269,7 @@
         "cn: Test User",
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -2382,11 +2337,7 @@
         "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," +
              "cn=Password Policies,cn=config");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -2443,15 +2394,11 @@
         "sn: User",
         "cn: Test User");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    SASLMechanismHandler externalHandler =
    SASLMechanismHandler<?> externalHandler =
         DirectoryServer.getSASLMechanismHandler("EXTERNAL");
    DirectoryServer.deregisterSASLMechanismHandler("EXTERNAL");
@@ -2519,11 +2466,7 @@
         "sn: User",
         "cn: Test User");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -2583,15 +2526,11 @@
         "sn: User",
         "cn: Test User");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    SASLMechanismHandler externalHandler =
    SASLMechanismHandler<?> externalHandler =
         DirectoryServer.getSASLMechanismHandler("EXTERNAL");
    DirectoryServer.deregisterSASLMechanismHandler("EXTERNAL");
@@ -2663,11 +2602,7 @@
         "sn: User",
         "cn: Test User");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -3307,15 +3242,11 @@
         "cn: Test User",
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    SASLMechanismHandler plainHandler =
    SASLMechanismHandler<?> plainHandler =
         DirectoryServer.getSASLMechanismHandler("PLAIN");
    DirectoryServer.deregisterSASLMechanismHandler("PLAIN");
@@ -3377,11 +3308,7 @@
         "cn: Test User",
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -3767,11 +3694,7 @@
         "cn: Test User",
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -3825,11 +3748,7 @@
         "cn: Test User",
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -3967,11 +3886,7 @@
         "cn: Test User",
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -4062,11 +3977,7 @@
         "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," +
              "cn=Password Policies,cn=config");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -4124,11 +4035,7 @@
         "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," +
              "cn=Password Policies,cn=config");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -4184,11 +4091,7 @@
         "sn: User",
         "cn: Test User");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -4250,11 +4153,7 @@
         "cn: Test User",
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/tools/LDAPCompareTestCase.java
@@ -26,21 +26,18 @@
 */
package org.opends.server.tools;
import java.io.File;
import java.io.FileWriter;
import java.util.ArrayList;
import java.util.concurrent.atomic.AtomicInteger;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.TestCaseUtils;
import org.opends.server.api.Backend;
import org.opends.server.core.AddOperation;
import org.opends.server.core.DirectoryServer;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.util.Base64;
import org.opends.server.util.StaticUtils;
import org.testng.annotations.AfterClass;
@@ -48,11 +45,10 @@
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.opends.server.protocols.ldap.LDAPResultCode.*;
import static org.testng.Assert.*;
/**
 * A set of test cases for the LDAPCompare tool.
 */
@@ -534,7 +530,7 @@
  public void testMultipleCompareAllTrue() throws Exception
  {
    TestCaseUtils.initializeTestBackend(true);
    Backend memoryBackend =
    Backend<?> memoryBackend =
        DirectoryServer.getBackend(TestCaseUtils.TEST_BACKEND_ID);
    String dn1 = "arg=success,o=test1,o=test";
    String dn2 = "arg=success,o=test2,o=test";
@@ -587,7 +583,7 @@
  public void testMultipleCompareOneCompareIsFalse() throws Exception
  {
    TestCaseUtils.initializeTestBackend(true);
    Backend memoryBackend =
    Backend<?> memoryBackend =
        DirectoryServer.getBackend(TestCaseUtils.TEST_BACKEND_ID);
    String dn1 = "arg=success,o=test1,o=test";
    String dn2 = "arg=fail,o=test2,o=test";
@@ -640,7 +636,7 @@
  public void testMultipleCompareOneNoSuchObject() throws Exception
  {
    TestCaseUtils.initializeTestBackend(true);
    Backend memoryBackend =
    Backend<?> memoryBackend =
        DirectoryServer.getBackend(TestCaseUtils.TEST_BACKEND_ID);
    String dn1 = "arg=success,o=test1,o=test";
    addEntriesUpToParentDN(memoryBackend, DN.valueOf(dn1));
@@ -681,8 +677,7 @@
  }
  private void addEntriesUpToParentDN(Backend backend, DN entryDN)
      throws Exception
  private void addEntriesUpToParentDN(Backend<?> backend, DN entryDN) throws Exception
  {
    if (!backend.entryExists(entryDN.parent()))
    {
@@ -904,11 +899,7 @@
         "ds-privilege-name: bypass-acl",
         "sn: User");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -977,11 +968,7 @@
         "ds-privilege-name: bypass-acl",
         "sn: User");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -1052,11 +1039,7 @@
         "ds-privilege-name: bypass-acl",
         "sn: User");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -1108,11 +1091,7 @@
         "ds-privilege-name: bypass-acl",
         "sn: User");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -1184,11 +1163,7 @@
         "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," +
              "cn=Password Policies,cn=config");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -1252,11 +1227,7 @@
         "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," +
              "cn=Password Policies,cn=config");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -1318,11 +1289,7 @@
         "cn: Test User",
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/tools/LDAPDeleteTestCase.java
@@ -26,28 +26,23 @@
 */
package org.opends.server.tools;
import java.io.File;
import java.io.FileWriter;
import java.util.ArrayList;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.TestCaseUtils;
import org.opends.server.core.AddOperation;
import org.opends.server.core.DirectoryServer;
import org.opends.server.protocols.ldap.LDAPResultCode;
import org.opends.server.types.Entry;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.opends.server.TestCaseUtils;
import org.opends.server.core.AddOperation;
import org.opends.server.core.DirectoryServer;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.protocols.ldap.LDAPResultCode;
import org.opends.server.types.Entry;
import org.forgerock.opendj.ldap.ResultCode;
import static org.testng.Assert.*;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.opends.server.util.ServerConstants.*;
import static org.testng.Assert.*;
/**
 * A set of test cases for the LDAPDelete tool.
@@ -506,9 +501,6 @@
  {
    TestCaseUtils.initializeTestBackend(true);
    String trustStorePath = DirectoryServer.getInstanceRoot() + File.separator +
                            "config" + File.separator + "client.truststore";
    String[] args =
    {
      "-h", "127.0.0.1",
@@ -603,11 +595,7 @@
         "cn: Test User",
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -730,11 +718,7 @@
         "cn: Test User",
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -786,11 +770,7 @@
         "cn: Test User",
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -833,11 +813,7 @@
         "cn: Test User",
         "userPassword: password");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/tools/LDAPModifyTestCase.java
@@ -32,23 +32,20 @@
import java.io.FileWriter;
import java.util.ArrayList;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.TestCaseUtils;
import org.opends.server.core.AddOperation;
import org.opends.server.core.DirectoryServer;
import org.opends.server.protocols.ldap.LDAPResultCode;
import org.opends.server.types.Entry;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.opends.server.TestCaseUtils;
import org.opends.server.core.AddOperation;
import org.opends.server.core.DirectoryServer;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.protocols.ldap.LDAPResultCode;
import org.opends.server.types.Entry;
import org.forgerock.opendj.ldap.ResultCode;
import static org.testng.Assert.*;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.opends.server.util.ServerConstants.*;
import static org.testng.Assert.*;
/**
@@ -552,11 +549,7 @@
         "ds-privilege-name: bypass-acl",
         "sn: User");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -606,11 +599,7 @@
         "ds-privilege-name: bypass-acl",
         "sn: User");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -661,11 +650,7 @@
         "ds-privilege-name: bypass-acl",
         "sn: User");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -716,11 +701,7 @@
         "ds-privilege-name: bypass-acl",
         "sn: User");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -773,11 +754,7 @@
         "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," +
              "cn=Password Policies,cn=config");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -823,11 +800,7 @@
         "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," +
              "cn=Password Policies,cn=config");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -1210,11 +1183,7 @@
         "objectClass: organizationalUnit",
         "ou: People");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(),
                         e.getUserAttributes(), e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    String path = TestCaseUtils.createTempFile(
@@ -1258,11 +1227,7 @@
         "objectClass: organizationalUnit",
         "ou: People");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(),
                         e.getUserAttributes(), e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    String path = TestCaseUtils.createTempFile(
@@ -1393,11 +1358,7 @@
         "objectClass: organizationalUnit",
         "ou: People");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(),
                         e.getUserAttributes(), e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    String path = TestCaseUtils.createTempFile("dn: ou=People,o=test",
@@ -1526,11 +1487,7 @@
         "objectClass: organizationalUnit",
         "ou: People");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(),
                         e.getUserAttributes(), e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    String path = TestCaseUtils.createTempFile("dn: ou=People,o=test",
@@ -1663,11 +1620,7 @@
         "objectClass: organizationalUnit",
         "ou: People");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(),
                         e.getUserAttributes(), e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    String path = TestCaseUtils.createTempFile("dn: ou=People,o=test",
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/tools/LDAPSearchTestCase.java
@@ -32,22 +32,19 @@
import java.util.Arrays;
import java.util.List;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.TestCaseUtils;
import org.opends.server.core.AddOperation;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.Entry;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.opends.server.TestCaseUtils;
import org.opends.server.core.AddOperation;
import org.opends.server.core.DirectoryServer;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.types.Entry;
import org.forgerock.opendj.ldap.ResultCode;
import static org.testng.Assert.*;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.opends.server.util.ServerConstants.*;
import static org.testng.Assert.*;
/**
 * A set of test cases for the LDAPSearch tool.
@@ -633,11 +630,7 @@
         "givenName: Test",
         "sn: User");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -688,11 +681,7 @@
         "givenName: Test",
         "sn: User");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -744,11 +733,7 @@
         "givenName: Test",
         "sn: User");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -800,11 +785,7 @@
         "givenName: Test",
         "sn: User");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -858,11 +839,7 @@
         "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," +
              "cn=Password Policies,cn=config");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -909,11 +886,7 @@
         "ds-pwp-password-policy-dn: cn=Clear UserPassword Policy," +
              "cn=Password Policies,cn=config");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
@@ -1478,11 +1451,7 @@
                                      "objectClass: ldapSubEntry",
                                      "cn: test");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperation addOperation =
         conn.processAdd(e.getName(), e.getObjectClasses(), e.getUserAttributes(),
                         e.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(e);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    String[] args =
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/types/PrivilegeTestCase.java
@@ -470,10 +470,7 @@
      "sn: Root",
      "userPassword: password");
    AddOperation addOperation =
         conn.processAdd(entry.getName(), entry.getObjectClasses(),
                         entry.getUserAttributes(),
                         entry.getOperationalAttributes());
    AddOperation addOperation = conn.processAdd(entry);
    assertPrivilege(addOperation.getResultCode(), hasPrivilege);
    DN dnToRemove = entry.getName();
@@ -598,10 +595,7 @@
      "l;collective: Test",
      "subtreeSpecification: {}");
    AddOperation addOperation =
         conn.processAdd(entry.getName(), entry.getObjectClasses(),
                         entry.getUserAttributes(),
                         entry.getOperationalAttributes());
    AddOperation addOperation = conn.processAdd(entry);
    assertPrivilege(addOperation.getResultCode(), hasPrivilege);
    DN dnToRemove = entry.getName();
@@ -959,10 +953,7 @@
      "ds-task-class-name: org.opends.server.tasks.AddSchemaFileTask",
      "ds-task-schema-file-name: 05-" + identifier + ".ldif");
    AddOperation addOperation =
         conn.processAdd(taskEntry.getName(), taskEntry.getObjectClasses(),
                         taskEntry.getUserAttributes(),
                         taskEntry.getOperationalAttributes());
    AddOperation addOperation = conn.processAdd(taskEntry);
    assertPrivilege(addOperation.getResultCode(), hasPrivilege);
    if (hasPrivilege)
@@ -1007,10 +998,7 @@
      "ds-backup-directory-path: bak",
      "ds-task-backup-all: TRUE");
    AddOperation addOperation =
         conn.processAdd(taskEntry.getName(), taskEntry.getObjectClasses(),
                         taskEntry.getUserAttributes(),
                         taskEntry.getOperationalAttributes());
    AddOperation addOperation = conn.processAdd(taskEntry);
    assertPrivilege(addOperation.getResultCode(), hasPrivilege);
    if (hasPrivilege)
@@ -1051,10 +1039,7 @@
      "ds-task-class-name: org.opends.server.tasks.RestoreTask",
      "ds-backup-directory-path: bak" + File.separator + "userRoot");
    AddOperation addOperation =
         conn.processAdd(taskEntry.getName(), taskEntry.getObjectClasses(),
                         taskEntry.getUserAttributes(),
                         taskEntry.getOperationalAttributes());
    AddOperation addOperation = conn.processAdd(taskEntry);
    assertPrivilege(addOperation.getResultCode(), hasPrivilege);
    if (hasPrivilege)
@@ -1098,10 +1083,7 @@
      "ds-task-export-backend-id: userRoot",
      "ds-task-export-ldif-file: " + tempFilePath);
    AddOperation addOperation =
         conn.processAdd(taskEntry.getName(), taskEntry.getObjectClasses(),
                         taskEntry.getUserAttributes(),
                         taskEntry.getOperationalAttributes());
    AddOperation addOperation = conn.processAdd(taskEntry);
    assertPrivilege(addOperation.getResultCode(), hasPrivilege);
    if (hasPrivilege)
@@ -1149,10 +1131,7 @@
      "ds-task-import-backend-id: userRoot",
      "ds-task-import-ldif-file: " + path);
    AddOperation addOperation =
         conn.processAdd(taskEntry.getName(), taskEntry.getObjectClasses(),
                         taskEntry.getUserAttributes(),
                         taskEntry.getOperationalAttributes());
    AddOperation addOperation = conn.processAdd(taskEntry);
    assertPrivilege(addOperation.getResultCode(), hasPrivilege);
    if (hasPrivilege)
@@ -1189,10 +1168,7 @@
      "ds-task-rebuild-base-dn: dc=example,dc=com",
      "ds-task-rebuild-index: cn");
    AddOperation addOperation =
         conn.processAdd(taskEntry.getName(), taskEntry.getObjectClasses(),
                         taskEntry.getUserAttributes(),
                         taskEntry.getOperationalAttributes());
    AddOperation addOperation = conn.processAdd(taskEntry);
    assertPrivilege(addOperation.getResultCode(), hasPrivilege);
    if (hasPrivilege)