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

Jean-Noel Rouvignac
10.44.2014 1c96d0d3ccaf68bf59270a3b27426515652d91ab
Additions to r11101.

TestCaseUtils.java:
In addEntry(), returned the loaded entry.

Removed all checks for DirectoryServer.entryExists() when TestCaseUtils.addEntry() was used before since it already includes this check.
6 files modified
194 ■■■■■ changed files
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java 7 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/backends/LDIFBackendTestCase.java 112 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/backends/task/TaskBackendTestCase.java 22 ●●●● patch | view | raw | blame | history
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/core/ModifyOperationTestCase.java 9 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/protocols/jmx/JmxPrivilegeTestCase.java 32 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/NamingConflictTest.java 12 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java
@@ -1364,12 +1364,13 @@
   */
  public static Entry addEntry(String... lines) throws Exception
  {
    Entry entry = makeEntry(lines);
    final Entry entry = makeEntry(lines);
    AddOperation addOperation = getRootConnection().processAdd(entry);
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS,
        addOperation.getErrorMessage().toString());
    assertNotNull(DirectoryServer.getEntry(entry.getName()));
    return entry;
    final Entry e = DirectoryServer.getEntry(entry.getName());
    assertNotNull(e);
    return e;
  }
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/backends/LDIFBackendTestCase.java
@@ -126,7 +126,7 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  @Test
  public void testAddAndDelete()
         throws Exception
  {
@@ -216,7 +216,7 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  @Test
  public void testAddAlreadyExists()
         throws Exception
  {
@@ -238,7 +238,7 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  @Test
  public void testAddNoParent()
         throws Exception
  {
@@ -262,9 +262,8 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testAddBaseEntry()
         throws Exception
  @Test
  public void testAddBaseEntry() throws Exception
  {
    assertTrue(DirectoryServer.entryExists(DN.valueOf("o=ldif")));
    assertTrue(DirectoryServer.entryExists(
@@ -310,7 +309,7 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  @Test
  public void testBind()
         throws Exception
  {
@@ -336,12 +335,10 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testCompare()
         throws Exception
  @Test
  public void testCompare() throws Exception
  {
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    InternalClientConnection conn = getRootConnection();
    CompareOperation compareOperation =
         conn.processCompare("uid=user.1,ou=People,o=ldif", "uid", "user.1");
    assertEquals(compareOperation.getResultCode(), ResultCode.COMPARE_TRUE);
@@ -354,9 +351,8 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testModify()
         throws Exception
  @Test
  public void testModify() throws Exception
  {
    String path = TestCaseUtils.createTempFile(
      "dn: o=ldif",
@@ -382,7 +378,7 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  @Test
  public void testSimpleModifyDN()
         throws Exception
  {
@@ -398,8 +394,7 @@
    assertTrue(DirectoryServer.entryExists(beforeDN));
    assertFalse(DirectoryServer.entryExists(afterDN));
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    InternalClientConnection conn = getRootConnection();
    ModifyDNOperation modifyDNOperation =
      conn.processModifyDN("ou=leaf before,o=ldif", "ou=leaf after", true);
    assertEquals(modifyDNOperation.getResultCode(), ResultCode.SUCCESS);
@@ -419,7 +414,7 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  @Test
  public void testModifyDNTargetAlreadyExists()
         throws Exception
  {
@@ -428,10 +423,8 @@
      "objectClass: top",
      "objectClass: organizationalUnit",
      "ou: new entry");
    assertTrue(DirectoryServer.entryExists(DN.valueOf("ou=new entry,o=ldif")));
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    InternalClientConnection conn = getRootConnection();
    ModifyDNOperation modifyDNOperation =
         conn.processModifyDN("ou=new entry,o=ldif", "ou=People", true);
    assertEquals(modifyDNOperation.getResultCode(),
@@ -451,7 +444,7 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  @Test
  public void testModifyDNWithNewSuperior()
         throws Exception
  {
@@ -467,8 +460,7 @@
    assertTrue(DirectoryServer.entryExists(beforeDN));
    assertFalse(DirectoryServer.entryExists(afterDN));
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    InternalClientConnection conn = getRootConnection();
    ModifyDNOperation modifyDNOperation =
      conn.processModifyDN("ou=leaf before,o=ldif", "ou=leaf after", true,
                           "ou=People,o=ldif");
@@ -489,7 +481,7 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  @Test
  public void testModifyDNSubtreeRename()
         throws Exception
  {
@@ -504,8 +496,7 @@
    assertTrue(DirectoryServer.entryExists(childBeforeDN));
    assertFalse(DirectoryServer.entryExists(childAfterDN));
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    InternalClientConnection conn = getRootConnection();
    ModifyDNOperation modifyDNOperation =
      conn.processModifyDN("ou=People,o=ldif", "ou=Users", true);
    assertEquals(modifyDNOperation.getResultCode(), ResultCode.SUCCESS);
@@ -533,15 +524,11 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testBaseSearch()
         throws Exception
  @Test
  public void testBaseSearch() throws Exception
  {
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    InternalSearchOperation searchOperation =
         conn.processSearch("o=ldif", SearchScope.BASE_OBJECT,
                         "(objectClass=*)");
        getRootConnection().processSearch("o=ldif", SearchScope.BASE_OBJECT, "(objectClass=*)");
    assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS);
    assertEquals(searchOperation.getSearchEntries().size(), 1);
  }
@@ -554,15 +541,11 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testBaseSearchNonMatchingFilter()
         throws Exception
  @Test
  public void testBaseSearchNonMatchingFilter() throws Exception
  {
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    InternalSearchOperation searchOperation =
         conn.processSearch("o=ldif", SearchScope.BASE_OBJECT,
                         "(o=not ldif)");
        getRootConnection().processSearch("o=ldif", SearchScope.BASE_OBJECT, "(o=not ldif)");
    assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS);
    assertEquals(searchOperation.getSearchEntries().size(), 0);
  }
@@ -575,12 +558,10 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testBaseSearchNoSuchEntry()
         throws Exception
  @Test
  public void testBaseSearchNoSuchEntry() throws Exception
  {
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    InternalClientConnection conn = getRootConnection();
    InternalSearchOperation searchOperation =
         conn.processSearch("o=nonexistent2,o=nonexistent1,o=ldif",
                            SearchScope.BASE_OBJECT, "(objectClass=*)");
@@ -595,12 +576,11 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  @Test
  public void testSingleLevelSearch()
         throws Exception
  {
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    InternalClientConnection conn = getRootConnection();
    InternalSearchOperation searchOperation =
         conn.processSearch("o=ldif", SearchScope.SINGLE_LEVEL,
                         "(objectClass=*)");
@@ -615,12 +595,10 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testSubtreeSearch()
         throws Exception
  @Test
  public void testSubtreeSearch() throws Exception
  {
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    InternalClientConnection conn = getRootConnection();
    InternalSearchOperation searchOperation =
         conn.processSearch("o=ldif", SearchScope.WHOLE_SUBTREE,
                            "(uid=user.1)");
@@ -636,12 +614,10 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testSubordinateSubtreeSearch()
         throws Exception
  @Test
  public void testSubordinateSubtreeSearch() throws Exception
  {
    InternalClientConnection conn =
         InternalClientConnection.getRootConnection();
    InternalClientConnection conn = getRootConnection();
    InternalSearchOperation searchOperation =
         conn.processSearch("o=ldif", SearchScope.SUBORDINATES,
                            "(uid=user.1)");
@@ -656,11 +632,11 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  @Test
  public void testHasSubordinates()
         throws Exception
  {
    Backend b = DirectoryServer.getBackend("ldifRoot");
    Backend<?> b = DirectoryServer.getBackend("ldifRoot");
    assertNotNull(b);
    assertTrue(b instanceof LDIFBackend);
@@ -687,11 +663,11 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  @Test
  public void testNumSubordinates()
         throws Exception
  {
    Backend b = DirectoryServer.getBackend("ldifRoot");
    Backend<?> b = DirectoryServer.getBackend("ldifRoot");
    assertNotNull(b);
    assertTrue(b instanceof LDIFBackend);
@@ -721,11 +697,11 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  @Test
  public void testLDIFExport()
         throws Exception
  {
    Backend b = DirectoryServer.getBackend("ldifRoot");
    Backend<?> b = DirectoryServer.getBackend("ldifRoot");
    assertNotNull(b);
    assertTrue(b instanceof LDIFBackend);
    assertTrue(b.supportsLDIFExport());
@@ -755,11 +731,11 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  @Test
  public void testMiscellaneousBackendMethods()
         throws Exception
  {
    Backend b = DirectoryServer.getBackend("ldifRoot");
    Backend<?> b = DirectoryServer.getBackend("ldifRoot");
    assertNotNull(b);
    assertTrue(b instanceof LDIFBackend);
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/backends/task/TaskBackendTestCase.java
@@ -30,23 +30,21 @@
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.TimeZone;
import java.util.UUID;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.TestCaseUtils;
import org.opends.server.backends.BackendTestCase;
import org.opends.server.core.DirectoryServer;
import org.opends.server.tasks.TasksTestCase;
import org.opends.server.types.DN;
import org.forgerock.opendj.ldap.ResultCode;
import static org.testng.Assert.*;
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.util.ServerConstants.*;
import static org.testng.Assert.*;
/**
 * A set of test cases that can be used to test the task backend.
@@ -118,7 +116,6 @@
      "ds-task-class-name: org.opends.server.tasks.DummyTask",
      "ds-task-scheduled-start-time: " + startTimeStr,
      "ds-task-dummy-sleep-time: 30000");
    assertTrue(DirectoryServer.entryExists(DN.valueOf(taskDN)));
    Task task = TasksTestCase.getTask(DN.valueOf(taskDN));
    assertTrue(TaskState.isPending(task.getTaskState()));
@@ -155,7 +152,6 @@
      "ds-task-id: " + taskID,
      "ds-task-class-name: org.opends.server.tasks.DummyTask",
      "ds-task-dummy-sleep-time: 300000");
    assertTrue(DirectoryServer.entryExists(DN.valueOf(taskDN)));
    // Wait until we're sure that the task has started running.
@@ -204,7 +200,6 @@
      "objectClass: extensibleObject",
      "ds-task-id: " + taskID,
      "ds-task-class-name: org.opends.server.tasks.DummyTask");
    assertTrue(DirectoryServer.entryExists(DN.valueOf(taskDN)));
    // Wait until the task has completed.
@@ -252,7 +247,6 @@
      "ds-task-class-name: org.opends.server.tasks.DummyTask",
      "ds-task-scheduled-start-time: " + startTimeStr,
      "ds-task-dummy-sleep-time: 30000");
    assertTrue(DirectoryServer.entryExists(DN.valueOf(taskDN)));
    Task task = TasksTestCase.getTask(DN.valueOf(taskDN));
    assertTrue(TaskState.isPending(task.getTaskState()));
@@ -306,8 +300,6 @@
      "ds-task-id: " + taskID,
      "ds-task-class-name: org.opends.server.tasks.DummyTask",
      "ds-task-dummy-sleep-time: 300000");
    assertTrue(DirectoryServer.entryExists(DN.valueOf(taskDN)));
    // Wait until we're sure that the task has started running.
    long startTime = System.currentTimeMillis();
@@ -379,8 +371,6 @@
      "objectClass: extensibleObject",
      "ds-task-id: " + taskID,
      "ds-task-class-name: org.opends.server.tasks.DummyTask");
    assertTrue(DirectoryServer.entryExists(DN.valueOf(taskDN)));
    // Wait until the task has completed.
    Task task = TasksTestCase.getCompletedTask(DN.valueOf(taskDN));
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/core/ModifyOperationTestCase.java
@@ -3454,8 +3454,9 @@
  public void testModifyDelEncryptedAddOnePasswordAttribute(String baseDN)
         throws Exception
  {
    TestCaseUtils.addEntry(
         "dn: uid=testPassword03.user," + baseDN,
    String dn = "uid=testPassword03.user," + baseDN;
    Entry e = TestCaseUtils.addEntry(
         "dn: " + dn,
         "objectClass: top",
         "objectClass: person",
         "objectClass: organizationalPerson",
@@ -3467,8 +3468,6 @@
         "displayName: Test User",
         "userPassword: password");
    Entry e = DirectoryServer.getEntry(
            DN.valueOf("uid=testPassword03.user," + baseDN));
    List<Attribute> attrList =
         e.getAttribute(DirectoryServer.getAttributeType("userpassword", true));
    assertNotNull(attrList);
@@ -3484,7 +3483,7 @@
    assertNotNull(passwd);
    String path = TestCaseUtils.createTempFile(
         "dn: uid=testPassword03.user," + baseDN,
         "dn: " + dn,
         "changetype: modify",
         "delete: userPassword",
         "userPassword: " + passwd,
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/protocols/jmx/JmxPrivilegeTestCase.java
@@ -37,6 +37,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.backends.task.Task;
@@ -60,13 +61,13 @@
import org.opends.server.protocols.internal.InternalSearchOperation;
import org.opends.server.protocols.ldap.LDAPFilter;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import static org.opends.messages.ProtocolMessages.*;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.testng.Assert.*;
/**
@@ -1485,15 +1486,15 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  public void testUpdateUserPrivileges()
         throws Exception
  @Test
  public void testUpdateUserPrivileges() throws Exception
  {
    InternalClientConnection rootConnection =
      InternalClientConnection.getRootConnection();
    InternalClientConnection rootConnection = getRootConnection();
    TestCaseUtils.addEntry(
      "dn: cn=Test User,o=test",
    final String dnStr = "cn=Test User,o=test";
    final DN dn = DN.valueOf(dnStr);
    Entry testEntry = TestCaseUtils.addEntry(
      "dn: " + dnStr,
      "objectClass: top",
      "objectClass: person",
      "objectClass: organizationalPerson",
@@ -1503,9 +1504,6 @@
      "sn: User",
      "userPassword: password");
    Entry testEntry =
               DirectoryServer.getEntry(DN.valueOf("cn=Test User,o=test"));
    AuthenticationInfo authInfo = new AuthenticationInfo(testEntry, false);
    JmxConnectionHandler jmxCtx = getJmxConnectionHandler();
    JmxClientConnection testConnection =
@@ -1524,8 +1522,7 @@
    ArrayList<Modification> mods = new ArrayList<Modification>();
    mods.add(new Modification(ModificationType.ADD,
        Attributes.create("ds-privilege-name", "jmx-read")));
    ModifyOperation modifyOperation =
         rootConnection.processModify(DN.valueOf("cn=Test User,o=test"), mods);
    ModifyOperation modifyOperation = rootConnection.processModify(dn, mods);
    assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS);
    assertTrue(testConnection.hasPrivilege(Privilege.JMX_READ, null));
@@ -1535,14 +1532,11 @@
    mods.clear();
    mods.add(new Modification(ModificationType.DELETE,
        Attributes.create("ds-privilege-name", "jmx-read")));
    modifyOperation =
         rootConnection.processModify(DN.valueOf("cn=Test User,o=test"), mods);
    modifyOperation = rootConnection.processModify(dn, mods);
    assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS);
    assertFalse(testConnection.hasPrivilege(Privilege.JMX_READ, null));
    DeleteOperation deleteOperation =
         rootConnection.processDelete(DN.valueOf("cn=Test User,o=test"));
    DeleteOperation deleteOperation = rootConnection.processDelete(dn);
    assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS);
  }
@@ -1554,7 +1548,7 @@
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test()
  @Test
  public void testUpdateRootPrivileges()
         throws Exception
  {
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/NamingConflictTest.java
@@ -30,6 +30,7 @@
import java.util.TreeSet;
import java.util.concurrent.atomic.AtomicBoolean;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.TestCaseUtils;
import org.opends.server.admin.std.meta.ReplicationDomainCfgDefn.IsolationPolicy;
import org.opends.server.core.DirectoryServer;
@@ -41,8 +42,10 @@
import org.opends.server.replication.protocol.AddMsg;
import org.opends.server.replication.protocol.DeleteMsg;
import org.opends.server.replication.protocol.ModifyDNMsg;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.types.Attribute;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
import org.opends.server.types.RDN;
import org.testng.annotations.Test;
import static org.opends.server.TestCaseUtils.*;
@@ -462,11 +465,6 @@
      TestCaseUtils.addEntry(parentEntry);
      TestCaseUtils.addEntry(childEntry);
      assertTrue(DirectoryServer.entryExists(parentEntry.getName()),
      "Parent entry expected to exist.");
      assertTrue(DirectoryServer.entryExists(childEntry.getName()),
      "Child  entry expected to be exist.");
      String parentUUID = getEntryUUID(parentEntry.getName());
      String childUUID = getEntryUUID(childEntry.getName());