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

Matthew Swift
12.41.2015 870930ab008b106540456b3efe47e7ec613c174d
Add tests for pluggable JEBackend

It's disabled at the moment because the rebuild index test is hanging.
1 files added
2 files modified
103 ■■■■■ changed files
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/EntryContainer.java 36 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/test/java/org/opends/server/backends/jeb/JETestCase.java 57 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/test/java/org/opends/server/backends/pluggable/PluggableBackendImplTestCase.java 10 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/EntryContainer.java
@@ -2500,7 +2500,14 @@
        @Override
        public void run(WriteableTransaction txn) throws Exception
        {
          clear0(txn);
          for (Tree tree : listTrees())
          {
            tree.delete(txn);
            if (tree instanceof Index)
            {
              ((Index) tree).setTrusted(txn, true);
            }
          }
        }
      });
    }
@@ -2510,33 +2517,6 @@
    }
  }
  private void clear0(WriteableTransaction txn) throws StorageRuntimeException
  {
    final List<Tree> allTrees = listTrees();
    try
    {
      for (Tree tree : allTrees)
      {
        tree.delete(txn);
      }
    }
    finally
    {
      for(Tree tree : allTrees)
      {
        tree.open(txn, true);
      }
      for (Tree tree : allTrees)
      {
        if (tree instanceof Index)
        {
          ((Index) tree).setTrusted(txn, true);
        }
      }
    }
  }
  List<Tree> listTrees()
  {
    final List<Tree> allTrees = new ArrayList<>();
opendj-server-legacy/src/test/java/org/opends/server/backends/jeb/JETestCase.java
New file
@@ -0,0 +1,57 @@
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 *
 *
 *      Copyright 2015 ForgeRock AS
 */
package org.opends.server.backends.jeb;
import static org.mockito.Mockito.when;
import static org.opends.server.ConfigurationMock.legacyMockCfg;
import org.opends.server.admin.std.server.JEBackendCfg;
import org.opends.server.backends.pluggable.PluggableBackendImplTestCase;
import org.testng.annotations.Test;
/** JEBackend Tester. */
@Test
public class JETestCase extends PluggableBackendImplTestCase<JEBackendCfg>
{
  @Override
  protected JEBackend createBackend()
  {
    return new JEBackend();
  }
  @Override
  protected JEBackendCfg createBackendCfg()
  {
    JEBackendCfg backendCfg = legacyMockCfg(JEBackendCfg.class);
    when(backendCfg.getDBDirectory()).thenReturn(backendTestName);
    when(backendCfg.getDBDirectoryPermissions()).thenReturn("755");
    when(backendCfg.getDBCacheSize()).thenReturn(0L);
    when(backendCfg.getDBCachePercent()).thenReturn(20);
    when(backendCfg.getDBNumCleanerThreads()).thenReturn(2);
    when(backendCfg.getDBNumLockTables()).thenReturn(63);
    return backendCfg;
  }
}
opendj-server-legacy/src/test/java/org/opends/server/backends/pluggable/PluggableBackendImplTestCase.java
@@ -767,8 +767,7 @@
  public void testSubTreeSearchAgainstAnIndexWithUnrecognizedMatchingRule() throws Exception
  {
    SearchRequest request = newSearchRequest(testBaseDN, SearchScope.WHOLE_SUBTREE, "entryUUID=xxx*");
    List<SearchResultEntry> result = runSearch(request, false);
    assertThat(result).isEmpty();
    assertThat(runSearch(request, false)).isEmpty();
  }
  @Test(dependsOnMethods = "testAdd")
@@ -865,7 +864,7 @@
    // Move the entire subtree to another name and move it back.
    DN prevDN = DN.valueOf("ou=People," + testBaseDN);
    DN newDN = DN.valueOf("ou=users," + testBaseDN);
    Entry renameEntry = backend.getEntry(prevDN);
    Entry renameEntry = backend.getEntry(prevDN).duplicate(false);
    renameEntry.setDN(newDN);
    backend.renameEntry(prevDN, renameEntry, null);
@@ -987,16 +986,12 @@
      public void run(WriteableTransaction txn) throws Exception
      {
        entryContainer.getDN2ID().delete(txn);
        entryContainer.getDN2ID().open(txn, true);
        entryContainer.getDN2URI().delete(txn);
        entryContainer.getDN2URI().open(txn, true);
        entryContainer.getID2ChildrenCount().delete(txn);
        entryContainer.getID2ChildrenCount().open(txn, true);
        for(VLVIndex idx : entryContainer.getVLVIndexes())
        {
          idx.setTrusted(txn, false);
          idx.delete(txn);
          idx.open(txn, true);
        }
        for(AttributeIndex attribute : entryContainer.getAttributeIndexes())
        {
@@ -1004,7 +999,6 @@
          {
            idx.setTrusted(txn, false);
            idx.delete(txn);
            idx.open(txn, true);
          }
        }
      }