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

Jean-Noël Rouvignac
20.49.2016 6d2dab657d824fb82d6c58a17517cd8f1c47c70f
opendj-server-legacy/src/test/java/org/opends/server/extensions/DefaultEntryCacheTestCase.java
@@ -16,27 +16,28 @@
 */
package org.opends.server.extensions;
import static org.testng.Assert.*;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.SortedMap;
import java.util.TreeMap;
import org.opends.server.TestCaseUtils;
import org.testng.annotations.BeforeClass;
import org.forgerock.opendj.server.config.meta.*;
import org.forgerock.opendj.ldap.DN;
import org.forgerock.opendj.server.config.meta.FIFOEntryCacheCfgDefn;
import org.forgerock.opendj.server.config.meta.SoftReferenceEntryCacheCfgDefn;
import org.forgerock.opendj.server.config.server.EntryCacheCfg;
import org.opends.server.TestCaseUtils;
import org.opends.server.api.EntryCache;
import org.opends.server.core.DirectoryServer;
import org.forgerock.opendj.ldap.DN;
import org.opends.server.types.Entry;
import org.opends.server.util.ServerConstants;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterGroups;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeGroups;
import org.testng.annotations.Test;
import static org.testng.Assert.*;
/**
 * A set of test cases for default entry cache implementation.
 */
@@ -73,7 +74,7 @@
    TestCaseUtils.startServer();
    // Get default cache.
    super.cache = DirectoryServer.getEntryCache();
    super.cache = (EntryCache<EntryCacheCfg>) DirectoryServer.getEntryCache();
    // Configure and initialize all entry cache implementations.
    softRefCache = new SoftReferenceEntryCache();
@@ -114,11 +115,12 @@
    // Plug all cache implementations into default entry cache.
    final Method[] defaultCacheMethods =
        super.cache.getClass().getDeclaredMethods();
    for (int i = 0; i < defaultCacheMethods.length; ++i) {
      if (defaultCacheMethods[i].getName().equals("setCacheOrder")) {
        defaultCacheMethods[i].setAccessible(true);
    for (Method defaultCacheMethod : defaultCacheMethods)
    {
      if (defaultCacheMethod.getName().equals("setCacheOrder")) {
        defaultCacheMethod.setAccessible(true);
        Object arglist[] = new Object[] { cacheOrderMap };
        defaultCacheMethods[i].invoke(cache, arglist);
        defaultCacheMethod.invoke(cache, arglist);
      }
    }
@@ -194,11 +196,12 @@
    SortedMap<Integer, EntryCache<? extends EntryCacheCfg>> emptyCacheOrderMap = new TreeMap<>();
    final Method[] defaultCacheMethods =
        super.cache.getClass().getDeclaredMethods();
    for (int i = 0; i < defaultCacheMethods.length; ++i) {
      if (defaultCacheMethods[i].getName().equals("setCacheOrder")) {
        defaultCacheMethods[i].setAccessible(true);
    for (Method defaultCacheMethod : defaultCacheMethods)
    {
      if (defaultCacheMethod.getName().equals("setCacheOrder")) {
        defaultCacheMethod.setAccessible(true);
        Object arglist[] = new Object[] { emptyCacheOrderMap };
        defaultCacheMethods[i].invoke(cache, arglist);
        defaultCacheMethod.invoke(cache, arglist);
      }
    }
@@ -405,8 +408,7 @@
  @BeforeGroups(groups = "testDefaultCacheConcurrency")
  public void cacheConcurrencySetup()
         throws Exception
  public void cacheConcurrencySetup() throws Exception
  {
    assertNull(cache.toVerboseString(),
      "Expected empty cache.  " + "Cache contents:" + ServerConstants.EOL +
@@ -416,8 +418,7 @@
  @AfterGroups(groups = "testDefaultCacheConcurrency")
  public void cacheConcurrencyCleanup()
         throws Exception
  public void cacheConcurrencyCleanup() throws Exception
  {
    // Clear the cache so that other tests can start from scratch.
    super.cache.clear();