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

Jean-Noel Rouvignac
10.56.2013 585d35b94a797fa403ad080c4bffec73b910eee6
*Test*.java:
Code cleanup.
Used InternalClientConnection.process*() methods.
9 files modified
351 ■■■■ changed files
opends/tests/unit-tests-testng/src/server/org/opends/server/backends/SchemaBackendTestCase.java 50 ●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/InitOnLineTest.java 14 ●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ProtocolWindowTest.java 21 ●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ReSyncTest.java 13 ●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/SchemaReplicationTest.java 18 ●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/StressTest.java 21 ●●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/AssuredReplicationPluginTest.java 18 ●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/FractionalReplicationTest.java 9 ●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/types/PrivilegeTestCase.java 187 ●●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/backends/SchemaBackendTestCase.java
@@ -27,50 +27,28 @@
 */
package org.opends.server.backends;
import java.io.File;
import java.util.Map;
import org.opends.server.TestCaseUtils;
import org.opends.server.config.ConfigException;
import org.opends.server.core.AddOperationBasis;
import org.opends.server.core.DeleteOperationBasis;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.ModifyDNOperationBasis;
import org.opends.server.core.SchemaConfigManager;
import org.opends.server.core.*;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.protocols.internal.InternalSearchOperation;
import org.opends.server.tools.LDAPModify;
import org.opends.server.types.AttributeType;
import org.opends.server.types.AttributeValue;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.DITContentRule;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
import org.opends.server.types.ExistingFileBehavior;
import org.opends.server.types.InitializationException;
import org.opends.server.types.LDIFExportConfig;
import org.opends.server.types.LDIFImportConfig;
import org.opends.server.types.MatchingRuleUse;
import org.opends.server.types.ObjectClass;
import org.opends.server.types.ResultCode;
import org.opends.server.types.SearchFilter;
import org.opends.server.types.SearchScope;
import org.opends.server.types.*;
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 test cases for the schema backend.
 */
@SuppressWarnings("javadoc")
public class SchemaBackendTestCase
       extends BackendTestCase
public class SchemaBackendTestCase extends BackendTestCase
{
  /** A reference to the schema backend. */
  private SchemaBackend schemaBackend;
@@ -79,12 +57,9 @@
  /**
   * Ensures that the Directory Server is running and gets a reference to the
   * schema backend.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @BeforeClass()
  public void startServer()
         throws Exception
  public void startServer() throws Exception
  {
    TestCaseUtils.startServer();
@@ -256,19 +231,10 @@
   * exception.
   */
  @Test(expectedExceptions = { DirectoryException.class })
  public void testAddEntry()
         throws Exception
  public void testAddEntry() throws Exception
  {
    Entry entry = createEntry(DN.decode("cn=schema"));
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    AddOperationBasis addOperation =
         new AddOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(),
                          null, entry.getDN(), entry.getObjectClasses(),
                          entry.getUserAttributes(),
                          entry.getOperationalAttributes());
    AddOperation addOperation = getRootConnection().processAdd(entry);
    schemaBackend.addEntry(entry, addOperation);
  }
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/InitOnLineTest.java
@@ -36,7 +36,6 @@
import org.opends.server.TestCaseUtils;
import org.opends.server.backends.task.TaskState;
import org.opends.server.core.AddOperation;
import org.opends.server.core.AddOperationBasis;
import org.opends.server.core.DirectoryServer;
import org.opends.server.loggers.debug.DebugTracer;
import org.opends.server.protocols.internal.InternalClientConnection;
@@ -85,16 +84,13 @@
 */
@SuppressWarnings("javadoc")
public class InitOnLineTest extends ReplicationTestCase
 {
{
  /**
   * The tracer object for the debug logger
   */
  private static final DebugTracer TRACER = getTracer();
  private static final int WINDOW_SIZE = 10;
  /**
   * A "person" entry
   */
  private Entry taskInitFromS2;
  private Entry taskInitTargetS2;
  private Entry taskInitTargetAll;
@@ -331,13 +327,7 @@
  private void addTestEntryToDB(final Entry entry)
  {
    AddOperation addOp =
        new AddOperationBasis(connection, InternalClientConnection
            .nextOperationID(), InternalClientConnection.nextMessageID(), null,
            entry.getDN(), entry.getObjectClasses(), entry.getUserAttributes(),
            entry.getOperationalAttributes());
    addOp.setInternalOperation(true);
    addOp.run();
    AddOperation addOp = connection.processAdd(entry);
    if (addOp.getResultCode() != ResultCode.SUCCESS)
    {
      log("addEntry: Failed" + addOp.getResultCode());
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ProtocolWindowTest.java
@@ -36,11 +36,10 @@
import org.opends.messages.Message;
import org.opends.messages.Severity;
import org.opends.server.TestCaseUtils;
import org.opends.server.core.AddOperationBasis;
import org.opends.server.core.DeleteOperationBasis;
import org.opends.server.core.AddOperation;
import org.opends.server.core.DeleteOperation;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.ModifyOperation;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.protocols.internal.InternalSearchOperation;
import org.opends.server.replication.protocol.AddMsg;
import org.opends.server.replication.protocol.ReplicationMsg;
@@ -130,12 +129,7 @@
      // Create an Entry (add operation) that will be later used in the test.
      Entry tmp = personEntry.duplicate(false);
      AddOperationBasis addOp = new AddOperationBasis(connection,
          InternalClientConnection.nextOperationID(), InternalClientConnection
          .nextMessageID(), null, tmp.getDN(),
          tmp.getObjectClasses(), tmp.getUserAttributes(),
          tmp.getOperationalAttributes());
      addOp.run();
      AddOperation addOp = connection.processAdd(tmp);
      assertEquals(addOp.getResultCode(), ResultCode.SUCCESS);
      assertTrue(DirectoryServer.entryExists(personEntry.getDN()),
        "The Add Entry operation failed");
@@ -186,12 +180,9 @@
      DN dn = repDomainEntry.getDN();
      try
      {
        DeleteOperationBasis op = new DeleteOperationBasis(connection,
          InternalClientConnection.nextOperationID(),
          InternalClientConnection.nextMessageID(), null, dn);
        op.run();
        if ((op.getResultCode() != ResultCode.SUCCESS) &&
          (op.getResultCode() != ResultCode.NO_SUCH_OBJECT))
        DeleteOperation op = connection.processDelete(dn);
        if (op.getResultCode() != ResultCode.SUCCESS
            && op.getResultCode() != ResultCode.NO_SUCH_OBJECT)
        {
          logError(Message.raw(Category.SYNC, Severity.NOTICE,
          "saturateQueueAndRestart: error cleaning config entry: " + dn));
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ReSyncTest.java
@@ -34,9 +34,8 @@
import org.opends.messages.Message;
import org.opends.messages.Severity;
import org.opends.server.TestCaseUtils;
import org.opends.server.core.AddOperationBasis;
import org.opends.server.core.AddOperation;
import org.opends.server.loggers.debug.DebugTracer;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
import org.opends.server.types.ResultCode;
@@ -136,13 +135,7 @@
  private ResultCode addEntry(String entryString) throws Exception
  {
    Entry entry = TestCaseUtils.entryFromLdifString(entryString);
    AddOperationBasis addOp = new AddOperationBasis(connection,
       InternalClientConnection.nextOperationID(), InternalClientConnection
       .nextMessageID(), null, entry.getDN(), entry.getObjectClasses(),
       entry.getUserAttributes(), entry.getOperationalAttributes());
    addOp.setInternalOperation(true);
    addOp.run();
    AddOperation addOp = connection.processAdd(entry);
    entriesToCleanup.add(entry.getDN());
    return addOp.getResultCode();
  }
@@ -250,7 +243,7 @@
  {
    callParanoiaCheck = false;
    // Do not try to remove non leaves
    // Do not try to remove non leaves
    entriesToCleanup.remove(DN.decode(EXAMPLE_DN));
    super.classCleanUp();
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/SchemaReplicationTest.java
@@ -41,7 +41,6 @@
import org.opends.server.api.SynchronizationProvider;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.ModifyOperation;
import org.opends.server.core.ModifyOperationBasis;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.replication.common.CSNGenerator;
import org.opends.server.replication.plugin.EntryHistorical;
@@ -68,9 +67,6 @@
  /**
   * Set up the environment for performing the tests in this Class.
   *
   * @throws Exception
   *           If the environment could not be set up.
   */
  @Override
  @BeforeClass
@@ -133,12 +129,7 @@
      List<Modification> mods = new ArrayList<Modification>();
      Modification mod = new Modification(ModificationType.ADD, attr);
      mods.add(mod);
      ModifyOperationBasis modOp = new ModifyOperationBasis(connection,
          InternalClientConnection.nextOperationID(), InternalClientConnection
          .nextMessageID(), null, baseDN, mods);
      modOp.setInternalOperation(true);
      modOp.run();
      ModifyOperation modOp = connection.processModify(baseDN, mods);
      assertEquals(modOp.getResultCode(), ResultCode.SUCCESS,
          "The original operation failed");
@@ -167,12 +158,7 @@
      mod = new Modification(ModificationType.DELETE, attr);
      mods.clear();
      mods.add(mod);
      modOp = new ModifyOperationBasis(connection,
          InternalClientConnection.nextOperationID(), InternalClientConnection
          .nextMessageID(), null, baseDN, mods);
      modOp.setInternalOperation(true);
      modOp.run();
      modOp = connection.processModify(baseDN, mods);
      assertEquals(modOp.getResultCode(), ResultCode.SUCCESS,
          "The original operation failed");
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/StressTest.java
@@ -30,6 +30,7 @@
import java.util.LinkedList;
import java.util.List;
import org.assertj.core.api.Assertions;
import org.opends.messages.Category;
import org.opends.messages.Message;
import org.opends.messages.Severity;
@@ -37,7 +38,7 @@
import org.opends.server.admin.std.server.MonitorProviderCfg;
import org.opends.server.api.MonitorProvider;
import org.opends.server.config.ConfigException;
import org.opends.server.core.AddOperationBasis;
import org.opends.server.core.AddOperation;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.ModifyOperation;
import org.opends.server.protocols.internal.InternalClientConnection;
@@ -97,27 +98,19 @@
      // Create an Entry (add operation) that will be later used in the test.
      Entry tmp = personEntry.duplicate(false);
      AddOperationBasis addOp = new AddOperationBasis(connection,
          InternalClientConnection.nextOperationID(), InternalClientConnection
          .nextMessageID(), null, tmp.getDN(),
          tmp.getObjectClasses(), tmp.getUserAttributes(),
          tmp.getOperationalAttributes());
      addOp.run();
      AddOperation addOp = connection.processAdd(tmp);
      assertTrue(DirectoryServer.entryExists(personEntry.getDN()),
        "The Add Entry operation failed");
      if (ResultCode.SUCCESS == addOp.getResultCode())
      {
        // Check if the client has received the msg
        ReplicationMsg msg = broker.receive();
        assertTrue(msg instanceof AddMsg,
        "The received replication message is not an ADD msg");
        Assertions.assertThat(msg).isInstanceOf(AddMsg.class);
        AddMsg addMsg =  (AddMsg) msg;
        Operation receivedOp = addMsg.createOperation(connection);
        assertTrue(OperationType.ADD.compareTo(receivedOp.getOperationType()) == 0,
        assertEquals(receivedOp.getOperationType(), OperationType.ADD,
        "The received replication message is not an ADD msg");
        assertEquals(addMsg.getDN(), personEntry.getDN(),
        "The received ADD replication message is not for the excepted DN");
      }
@@ -292,7 +285,7 @@
        synchronized (this)
        {
          finished = true;
          this.notify();
          notify();
        }
      }
    }
@@ -310,7 +303,7 @@
        {
          try
          {
            this.wait(6000);
            wait(6000);
          } catch (InterruptedException e)
          {
            return -1;
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/AssuredReplicationPluginTest.java
@@ -40,11 +40,10 @@
import org.opends.messages.Message;
import org.opends.messages.Severity;
import org.opends.server.TestCaseUtils;
import org.opends.server.core.AddOperationBasis;
import org.opends.server.core.DeleteOperationBasis;
import org.opends.server.core.AddOperation;
import org.opends.server.core.DeleteOperation;
import org.opends.server.core.DirectoryServer;
import org.opends.server.loggers.debug.DebugTracer;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.protocols.internal.InternalSearchOperation;
import org.opends.server.replication.ReplicationTestCase;
import org.opends.server.replication.common.*;
@@ -176,12 +175,7 @@
  private void addEntry(Entry entry) throws Exception
  {
    debugInfo("AddEntry " + entry.getDN());
    AddOperationBasis addOp = new AddOperationBasis(connection,
      InternalClientConnection.nextOperationID(), InternalClientConnection.
      nextMessageID(), null, entry.getDN(), entry.getObjectClasses(),
      entry.getUserAttributes(), entry.getOperationalAttributes());
    addOp.setInternalOperation(true);
    addOp.run();
    AddOperation addOp = connection.processAdd(entry);
    waitOpResult(addOp, ResultCode.SUCCESS);
    assertNotNull(getEntry(entry.getDN(), 1000, true));
  }
@@ -1493,11 +1487,7 @@
  private void deleteEntry(String dn) throws Exception
  {
    DN realDN = DN.decode(dn);
    DeleteOperationBasis delOp = new DeleteOperationBasis(connection,
      InternalClientConnection.nextOperationID(),
      InternalClientConnection.nextMessageID(), null, realDN);
    delOp.setInternalOperation(true);
    delOp.run();
    DeleteOperation delOp = connection.processDelete(realDN);
    waitOpResult(delOp, ResultCode.SUCCESS);
    assertNull(DirectoryServer.getEntry(realDN));
  }
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/FractionalReplicationTest.java
@@ -40,10 +40,8 @@
import org.opends.messages.Severity;
import org.opends.server.TestCaseUtils;
import org.opends.server.config.ConfigException;
import org.opends.server.core.AddOperationBasis;
import org.opends.server.core.DirectoryServer;
import org.opends.server.loggers.debug.DebugTracer;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.replication.ReplicationTestCase;
import org.opends.server.replication.common.CSNGenerator;
import org.opends.server.replication.common.ServerStatus;
@@ -765,12 +763,7 @@
   */
  private void addEntry(Entry entry) throws Exception
  {
    AddOperationBasis addOp = new AddOperationBasis(connection,
      InternalClientConnection.nextOperationID(), InternalClientConnection.
      nextMessageID(), null, entry.getDN(), entry.getObjectClasses(),
      entry.getUserAttributes(), entry.getOperationalAttributes());
    addOp.setInternalOperation(true);
    addOp.run();
    connection.processAdd(entry);
    assertNotNull(getEntry(entry.getDN(), 1000, true));
  }
opends/tests/unit-tests-testng/src/server/org/opends/server/types/PrivilegeTestCase.java
@@ -27,8 +27,6 @@
 */
package org.opends.server.types;
import static org.testng.Assert.*;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
@@ -57,6 +55,10 @@
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.opends.server.types.ResultCode.*;
import static org.testng.Assert.*;
/**
 * This class provides a set of test cases for the Directory Server privilege
 * subsystem.
@@ -271,57 +273,31 @@
   * @throws  Exception  If an unexpected problem occurs.
   */
  @AfterClass()
  public void cleanUp()
         throws Exception
  public void cleanUp() throws Exception
  {
   TestCaseUtils.dsconfig(
    TestCaseUtils.dsconfig(
            "set-sasl-mechanism-handler-prop",
            "--handler-name", "DIGEST-MD5",
            "--remove", "server-fqdn:" + "127.0.0.1");
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    DeleteOperation deleteOperation =
         conn.processDelete(
              DN.decode("cn=Unprivileged Root,cn=Root DNs,cn=config"));
    assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS);
    deleteOperation =
      conn.processDelete(
           DN.decode("cn=Proxy Root,cn=Root DNs,cn=config"));
    assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS);
    deleteOperation =
      conn.processDelete(
           DN.decode("cn=Privileged User,o=test"));
    assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS);
    deleteOperation =
      conn.processDelete(
           DN.decode("cn=UnPrivileged User,o=test"));
    assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS);
    deleteOperation =
      conn.processDelete(
           DN.decode("cn=PWReset Target,o=test"));
    assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS);
    deleteOperation = conn.processDelete(DN
        .decode("cn=test1 user,dc=unindexed,dc=jeb"));
    assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS);
    deleteOperation = conn.processDelete(DN
        .decode("cn=test2 user,dc=unindexed,dc=jeb"));
    assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS);
    deleteOperation = conn.processDelete(DN
        .decode("dc=unindexed,dc=jeb"));
    assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS);
    assertDeleteSuccessfully("cn=Unprivileged Root,cn=Root DNs,cn=config");
    assertDeleteSuccessfully("cn=Proxy Root,cn=Root DNs,cn=config");
    assertDeleteSuccessfully("cn=Privileged User,o=test");
    assertDeleteSuccessfully("cn=UnPrivileged User,o=test");
    assertDeleteSuccessfully("cn=PWReset Target,o=test");
    assertDeleteSuccessfully("cn=test1 user,dc=unindexed,dc=jeb");
    assertDeleteSuccessfully("cn=test2 user,dc=unindexed,dc=jeb");
    assertDeleteSuccessfully("dc=unindexed,dc=jeb");
    TestCaseUtils.disableBackend("unindexedRoot");
  }
  private void assertDeleteSuccessfully(String dn) throws DirectoryException
  {
    DeleteOperation deleteOperation = getRootConnection().processDelete(DN.decode(dn));
    assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS);
  }
  /**
@@ -371,9 +347,8 @@
  {
    assertEquals(conn.hasPrivilege(Privilege.CONFIG_READ, null), hasPrivilege);
    InternalSearchOperation searchOperation =
         conn.processSearch(DN.decode("cn=config"), SearchScope.BASE_OBJECT,
              SearchFilter.createFilterFromString("(objectClass=*)"));
    InternalSearchOperation searchOperation = conn.processSearch(
        "cn=config", SearchScope.BASE_OBJECT, "(objectClass=*)");
    assertPrivilege(searchOperation.getResultCode(), hasPrivilege);
  }
@@ -395,9 +370,8 @@
  {
    assertEquals(conn.hasPrivilege(Privilege.UNINDEXED_SEARCH, null), hasPrivilege);
    InternalSearchOperation searchOperation =
        conn.processSearch(DN.decode("dc=unindexed,dc=jeb"), SearchScope.WHOLE_SUBTREE,
             SearchFilter.createFilterFromString("(carLicense=test*)"));
    InternalSearchOperation searchOperation = conn.processSearch(
        "dc=unindexed,dc=jeb", SearchScope.WHOLE_SUBTREE, "(carLicense=test*)");
    assertPrivilege(searchOperation.getResultCode(), hasPrivilege);
  }
@@ -1261,14 +1235,12 @@
      "sn: Test");
    List<Control> controls = new ArrayList<Control>(1);
    controls.add(new ProxiedAuthV1Control(
                          DN.decode("cn=PWReset Target,o=test")));
    controls.add(new ProxiedAuthV1Control(DN.decode("cn=PWReset Target,o=test")));
    // Try to add the entry.  If this fails with the proxy control, then add it
    // with a root connection so we can do other things with it.
    AddOperationBasis addOperation =
         new AddOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(),
    AddOperation addOperation = new AddOperationBasis(conn, nextOperationID(), nextMessageID(),
                          controls, e.getDN(), e.getObjectClasses(),
                          e.getUserAttributes(), e.getOperationalAttributes());
    addOperation.run();
@@ -1285,17 +1257,15 @@
    mods.add(new Modification(ModificationType.REPLACE,
        Attributes.create("description", "foo")));
    ModifyOperationBasis modifyOperation =
         new ModifyOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(),
    ModifyOperation modifyOperation = new ModifyOperationBasis(conn, nextOperationID(), nextMessageID(),
                             controls, e.getDN(), mods);
    modifyOperation.run();
    assertProxyPrivilege(modifyOperation.getResultCode(), hasProxyPrivilege);
    // Try to rename the entry.
    ModifyDNOperationBasis modifyDNOperation =
         new ModifyDNOperationBasis(conn, InternalClientConnection.nextOperationID(),
                               InternalClientConnection.nextMessageID(), controls, e.getDN(),
    ModifyDNOperation modifyDNOperation = new ModifyDNOperationBasis(conn, nextOperationID(),
                               nextMessageID(), controls, e.getDN(),
                               RDN.decode("cn=Proxy V1 Test"), true, null);
    modifyDNOperation.run();
    assertProxyPrivilege(modifyOperation.getResultCode(), hasProxyPrivilege);
@@ -1309,17 +1279,14 @@
    // Try to delete the operation.  If this fails, then delete it with a root
    // connection so it gets cleaned up.
    DeleteOperationBasis deleteOperation =
         new DeleteOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(),
    DeleteOperation deleteOperation = new DeleteOperationBasis(conn, nextOperationID(), nextMessageID(),
                             controls, newEntryDN);
    deleteOperation.run();
    assertProxyPrivilege(deleteOperation.getResultCode(), hasProxyPrivilege);
    if (!hasProxyPrivilege)
    {
      InternalClientConnection rootConnection =
           InternalClientConnection.getRootConnection();
      DeleteOperation delOp = rootConnection.processDelete(newEntryDN);
      DeleteOperation delOp = getRootConnection().processDelete(newEntryDN);
      assertEquals(delOp.getResultCode(), ResultCode.SUCCESS);
    }
  }
@@ -1355,28 +1322,26 @@
    // Test a compare operation against the PWReset Target user.
    CompareOperationBasis compareOperation =
         new CompareOperationBasis(conn, InternalClientConnection.nextOperationID(),
                              InternalClientConnection.nextMessageID(), controls, targetDN,
    CompareOperation compareOperation = new CompareOperationBasis(conn,
                              nextOperationID(), nextMessageID(),
                              controls, targetDN,
                              DirectoryServer.getAttributeType("cn", true),
             ByteString.valueOf("PWReset Target"));
                              ByteString.valueOf("PWReset Target"));
    compareOperation.run();
    if (hasProxyPrivilege)
    {
      assertEquals(compareOperation.getResultCode(), ResultCode.COMPARE_TRUE);
      assertEquals(compareOperation.getResultCode(), COMPARE_TRUE);
    }
    else
    {
      assertEquals(compareOperation.getResultCode(),
                   ResultCode.AUTHORIZATION_DENIED);
      assertEquals(compareOperation.getResultCode(), AUTHORIZATION_DENIED);
    }
    // Test a search operation against the PWReset Target user.
    InternalSearchOperation searchOperation =
         new InternalSearchOperation(conn, InternalClientConnection.nextOperationID(),
                  InternalClientConnection.nextMessageID(), controls, targetDN,
    InternalSearchOperation searchOperation = new InternalSearchOperation(conn,
                  nextOperationID(), nextMessageID(), controls, targetDN,
                  SearchScope.BASE_OBJECT,
                  DereferencePolicy.NEVER_DEREF_ALIASES, 0, 0, false,
                  SearchFilter.createFilterFromString("(objectClass=*)"), null,
@@ -1421,14 +1386,13 @@
      "sn: Test");
    List<Control> controls = new ArrayList<Control>(1);
    controls.add(new ProxiedAuthV2Control(
        ByteString.valueOf("dn:cn=PWReset Target,o=test")));
    controls.add(new ProxiedAuthV2Control(ByteString.valueOf("dn:cn=PWReset Target,o=test")));
    // Try to add the entry.  If this fails with the proxy control, then add it
    // with a root connection so we can do other things with it.
    AddOperationBasis addOperation =
         new AddOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(),
    AddOperation addOperation =
         new AddOperationBasis(conn, nextOperationID(), nextMessageID(),
                          controls, e.getDN(), e.getObjectClasses(),
                          e.getUserAttributes(), e.getOperationalAttributes());
    addOperation.run();
@@ -1445,17 +1409,16 @@
    mods.add(new Modification(ModificationType.REPLACE,
        Attributes.create("description", "foo")));
    ModifyOperationBasis modifyOperation =
         new ModifyOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(),
    ModifyOperation modifyOperation =
         new ModifyOperationBasis(conn, nextOperationID(), nextMessageID(),
                             controls, e.getDN(), mods);
    modifyOperation.run();
    assertProxyPrivilege(modifyOperation.getResultCode(), hasProxyPrivilege);
    // Try to rename the entry.
    ModifyDNOperationBasis modifyDNOperation =
         new ModifyDNOperationBasis(conn, InternalClientConnection.nextOperationID(),
                               InternalClientConnection.nextMessageID(), controls, e.getDN(),
    ModifyDNOperation modifyDNOperation = new ModifyDNOperationBasis(conn, nextOperationID(),
                               nextMessageID(), controls, e.getDN(),
                               RDN.decode("cn=Proxy V2 Test"), true, null);
    modifyDNOperation.run();
    assertProxyPrivilege(modifyDNOperation.getResultCode(), hasProxyPrivilege);
@@ -1469,17 +1432,14 @@
    // Try to delete the operation.  If this fails, then delete it with a root
    // connection so it gets cleaned up.
    DeleteOperationBasis deleteOperation =
         new DeleteOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(),
    DeleteOperationBasis deleteOperation = new DeleteOperationBasis(conn, nextOperationID(), nextMessageID(),
                             controls, newEntryDN);
    deleteOperation.run();
    assertProxyPrivilege(deleteOperation.getResultCode(), hasProxyPrivilege);
    if (!hasProxyPrivilege)
    {
      InternalClientConnection rootConnection =
           InternalClientConnection.getRootConnection();
      DeleteOperation delOp = rootConnection.processDelete(newEntryDN);
      DeleteOperation delOp = getRootConnection().processDelete(newEntryDN);
      assertEquals(delOp.getResultCode(), ResultCode.SUCCESS);
    }
  }
@@ -1511,33 +1471,29 @@
    DN targetDN = DN.decode("cn=PWReset Target,o=test");
    List<Control> controls = new ArrayList<Control>(1);
    controls.add(new ProxiedAuthV2Control(
         ByteString.valueOf("dn:" + targetDN)));
    controls.add(new ProxiedAuthV2Control(ByteString.valueOf("dn:" + targetDN)));
    // Test a compare operation against the PWReset Target user.
    CompareOperationBasis compareOperation =
         new CompareOperationBasis(conn, InternalClientConnection.nextOperationID(),
                              InternalClientConnection.nextMessageID(), controls, targetDN,
    CompareOperation compareOperation = new CompareOperationBasis(conn, nextOperationID(),
                              nextMessageID(), controls, targetDN,
                              DirectoryServer.getAttributeType("cn", true),
             ByteString.valueOf("PWReset Target"));
    compareOperation.run();
    if (hasProxyPrivilege)
    {
      assertEquals(compareOperation.getResultCode(), ResultCode.COMPARE_TRUE);
      assertEquals(compareOperation.getResultCode(), COMPARE_TRUE);
    }
    else
    {
      assertEquals(compareOperation.getResultCode(),
                   ResultCode.AUTHORIZATION_DENIED);
      assertEquals(compareOperation.getResultCode(), AUTHORIZATION_DENIED);
    }
    // Test a search operation against the PWReset Target user.
    InternalSearchOperation searchOperation =
         new InternalSearchOperation(conn, InternalClientConnection.nextOperationID(),
                  InternalClientConnection.nextMessageID(), controls, targetDN,
    InternalSearchOperation searchOperation = new InternalSearchOperation(conn, nextOperationID(),
                  nextMessageID(), controls, targetDN,
                  SearchScope.BASE_OBJECT,
                  DereferencePolicy.NEVER_DEREF_ALIASES, 0, 0, false,
                  SearchFilter.createFilterFromString("(objectClass=*)"), null,
@@ -2416,8 +2372,7 @@
      assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS);
      assertFalse(testConnection.hasPrivilege(Privilege.CONFIG_READ, null));
      DeleteOperation deleteOperation = rootConnection.processDelete(DN
          .decode("cn=Test User,o=test"));
      DeleteOperation deleteOperation = rootConnection.processDelete("cn=Test User,o=test");
      assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS);
    }
    finally
@@ -2435,8 +2390,7 @@
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testUpdateRootPrivileges()
         throws Exception
  public void testUpdateRootPrivileges() throws Exception
  {
    // Make sure that a root connection doesn't  have the proxied auth
    // privilege.
@@ -2449,16 +2403,13 @@
    // Update the set of root privileges to include proxied auth.
    InternalClientConnection internalRootConn =
         InternalClientConnection.getRootConnection();
    InternalClientConnection internalRootConn = getRootConnection();
    List<Modification> mods = new ArrayList<Modification>();
    mods.add(new Modification(ModificationType.ADD,
        Attributes.create("ds-cfg-default-root-privilege-name",
                                    "proxied-auth")));
    ModifyOperation modifyOperation =
         internalRootConn.processModify(DN.decode("cn=Root DNs,cn=config"),
                                        mods);
    ModifyOperation modifyOperation = internalRootConn.processModify(DN.decode("cn=Root DNs,cn=config"), mods);
    assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS);
@@ -2474,9 +2425,7 @@
    mods.add(new Modification(ModificationType.DELETE,
        Attributes.create("ds-cfg-default-root-privilege-name",
                                    "proxied-auth")));
    modifyOperation =
         internalRootConn.processModify(DN.decode("cn=Root DNs,cn=config"),
                                        mods);
    modifyOperation = internalRootConn.processModify(DN.decode("cn=Root DNs,cn=config"), mods);
    assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS);
@@ -2546,8 +2495,7 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  private Task getCompletedTask(DN taskEntryDN)
          throws Exception
  private Task getCompletedTask(DN taskEntryDN) throws Exception
  {
    TaskBackend taskBackend =
         (TaskBackend) DirectoryServer.getBackend(DN.decode("cn=tasks"));
@@ -2562,10 +2510,7 @@
      }
    }
    if (task == null)
    {
      throw new AssertionError("There is no such task " + taskEntryDN);
    }
    assertNotNull(task, "There is no such task " + taskEntryDN);
    if (! TaskState.isDone(task.getTaskState()))
    {
@@ -2576,12 +2521,8 @@
        Thread.sleep(10);
      }
    }
    if (! TaskState.isDone(task.getTaskState()))
    {
      throw new AssertionError("Task " + taskEntryDN +
                               " did not complete in a timely manner.");
    }
    assertTrue(TaskState.isDone(task.getTaskState()),
        "Task " + taskEntryDN + " did not complete in a timely manner.");
    return task;
  }