From 714b57c8ad2c6eab6e518f3f4888c9d83996e41c Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Mon, 18 Apr 2016 13:49:37 +0000
Subject: [PATCH] Code cleanup

---
 opendj-server-legacy/src/main/java/org/opends/server/tools/dsreplication/ReplicationCliMain.java                 |  128 ++++-----
 opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/TopologyViewTest.java                    |    5 
 opendj-server-legacy/src/main/java/org/opends/admin/ads/util/ServerLoader.java                                   |   51 +--
 opendj-server-legacy/src/main/java/org/opends/admin/ads/util/ConnectionUtils.java                                |   37 --
 opendj-server-legacy/src/test/java/org/opends/server/extensions/LDAPPassThroughAuthenticationPolicyTestCase.java |  516 +++------------------------------------
 5 files changed, 115 insertions(+), 622 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/admin/ads/util/ConnectionUtils.java b/opendj-server-legacy/src/main/java/org/opends/admin/ads/util/ConnectionUtils.java
index f305c4a..8a3a55f 100644
--- a/opendj-server-legacy/src/main/java/org/opends/admin/ads/util/ConnectionUtils.java
+++ b/opendj-server-legacy/src/main/java/org/opends/admin/ads/util/ConnectionUtils.java
@@ -480,44 +480,7 @@
     return "true".equalsIgnoreCase(getEnvProperty(ctx, STARTTLS_PROPERTY));
   }
 
-  /**
-   * Method used to know if we can connect as administrator in a server with a
-   * given password and dn.
-   * @param ldapUrl the LDAP URL of the server.
-   * @param dn the dn to be used.
-   * @param pwd the password to be used.
-   * @param timeout the timeout to establish the connection in milliseconds.
-   * Use {@code 0} to express no timeout.
-   * @return <CODE>true</CODE> if we can connect and read the configuration and
-   * <CODE>false</CODE> otherwise.
-   */
-  public static boolean canConnectAsAdministrativeUser(String ldapUrl,
-      String dn, String pwd, int timeout)
-  {
-    try
-    {
-      InitialLdapContext ctx;
-      if (ldapUrl.toLowerCase().startsWith("ldap:"))
-      {
-        ctx = createLdapContext(ldapUrl, dn, pwd, timeout,
-            null);
-      }
-      else
-      {
-        ctx = createLdapsContext(ldapUrl, dn, pwd, timeout,
-            null, null, null);
-      }
 
-      return connectedAsAdministrativeUser(ctx);
-    } catch (NamingException ne)
-    {
-      // Nothing to do.
-      return false;
-    } catch (Throwable t)
-    {
-      throw new IllegalStateException("Unexpected throwable.", t);
-    }
-  }
 
   /**
    * Method used to know if we are connected as administrator in a server with a
diff --git a/opendj-server-legacy/src/main/java/org/opends/admin/ads/util/ServerLoader.java b/opendj-server-legacy/src/main/java/org/opends/admin/ads/util/ServerLoader.java
index 30b5800..15e6673 100644
--- a/opendj-server-legacy/src/main/java/org/opends/admin/ads/util/ServerLoader.java
+++ b/opendj-server-legacy/src/main/java/org/opends/admin/ads/util/ServerLoader.java
@@ -45,18 +45,18 @@
  */
 public class ServerLoader extends Thread
 {
-  private Map<ServerProperty,Object> serverProperties;
+  private final Map<ServerProperty, Object> serverProperties;
   private boolean isOver;
   private boolean isInterrupted;
   private String lastLdapUrl;
   private TopologyCacheException lastException;
   private ServerDescriptor serverDescriptor;
-  private ApplicationTrustManager trustManager;
-  private int timeout;
-  private String dn;
-  private String pwd;
+  private final ApplicationTrustManager trustManager;
+  private final int timeout;
+  private final String dn;
+  private final String pwd;
   private final LinkedHashSet<PreferredConnection> preferredLDAPURLs;
-  private TopologyCacheFilter filter;
+  private final TopologyCacheFilter filter;
 
   private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
 
@@ -116,14 +116,13 @@
     return lastException;
   }
 
-  /** {@inheritDoc} */
   @Override
   public void interrupt()
   {
     if (!isOver)
     {
       isInterrupted = true;
-      String ldapUrl = getLastLdapUrl();
+      String ldapUrl = lastLdapUrl;
       if (ldapUrl == null)
       {
         LinkedHashSet<PreferredConnection> urls = getLDAPURLsByPreference();
@@ -141,9 +140,7 @@
     super.interrupt();
   }
 
-  /**
-   * The method where we try to generate the ServerDescriptor object.
-   */
+  /** The method where we try to generate the ServerDescriptor object. */
   @Override
   public void run()
   {
@@ -158,40 +155,35 @@
     }
     catch (NoPermissionException e)
     {
-      logger.warn(LocalizableMessage.raw(
-          "Permissions error reading server: " + getLastLdapUrl(), e));
+      logger.warn(LocalizableMessage.raw("Permissions error reading server: " + lastLdapUrl, e));
       Type type = isAdministratorDn()
           ? TopologyCacheException.Type.NO_PERMISSIONS
           : TopologyCacheException.Type.NOT_GLOBAL_ADMINISTRATOR;
-      lastException = new TopologyCacheException(type, e, trustManager, getLastLdapUrl());
+      lastException = new TopologyCacheException(type, e, trustManager, lastLdapUrl);
     }
     catch (AuthenticationException e)
     {
-      logger.warn(LocalizableMessage.raw(
-          "Authentication exception: " + getLastLdapUrl(), e));
+      logger.warn(LocalizableMessage.raw("Authentication exception: " + lastLdapUrl, e));
       Type type = isAdministratorDn()
           ? TopologyCacheException.Type.GENERIC_READING_SERVER
           : TopologyCacheException.Type.NOT_GLOBAL_ADMINISTRATOR;
-      lastException = new TopologyCacheException(type, e, trustManager, getLastLdapUrl());
+      lastException = new TopologyCacheException(type, e, trustManager, lastLdapUrl);
     }
     catch (NamingException e)
     {
-      logger.warn(LocalizableMessage.raw(
-          "NamingException error reading server: " + getLastLdapUrl(), e));
+      logger.warn(LocalizableMessage.raw("NamingException error reading server: " + lastLdapUrl, e));
       Type type = connCreated
           ? TopologyCacheException.Type.GENERIC_READING_SERVER
           : TopologyCacheException.Type.GENERIC_CREATING_CONNECTION;
-      lastException = new TopologyCacheException(type, e, trustManager, getLastLdapUrl());
+      lastException = new TopologyCacheException(type, e, trustManager, lastLdapUrl);
     }
     catch (Throwable t)
     {
       if (!isInterrupted)
       {
-        logger.warn(LocalizableMessage.raw(
-            "Generic error reading server: "+getLastLdapUrl(), t));
-        logger.warn(LocalizableMessage.raw("server Properties: "+serverProperties));
-        lastException =
-            new TopologyCacheException(TopologyCacheException.Type.BUG, t);
+        logger.warn(LocalizableMessage.raw("Generic error reading server: " + lastLdapUrl, t));
+        logger.warn(LocalizableMessage.raw("server Properties: " + serverProperties));
+        lastException = new TopologyCacheException(TopologyCacheException.Type.BUG, t);
       }
     }
     finally
@@ -233,15 +225,6 @@
   }
 
   /**
-   * Returns the last LDAP URL to which we tried to connect.
-   * @return the last LDAP URL to which we tried to connect.
-   */
-  private String getLastLdapUrl()
-  {
-    return lastLdapUrl;
-  }
-
-  /**
    * Returns the non-secure LDAP URL for the given server properties.  It
    * returns NULL if according to the server properties no non-secure LDAP URL
    * can be generated (LDAP disabled or port not defined).
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/dsreplication/ReplicationCliMain.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/dsreplication/ReplicationCliMain.java
index faa8e2a..c12f4dc 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/dsreplication/ReplicationCliMain.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/dsreplication/ReplicationCliMain.java
@@ -83,10 +83,13 @@
 import org.forgerock.i18n.LocalizedIllegalArgumentException;
 import org.forgerock.i18n.slf4j.LocalizedLogger;
 import org.forgerock.opendj.config.ConfigurationFramework;
+import org.forgerock.opendj.config.DecodingException;
 import org.forgerock.opendj.config.ManagedObjectNotFoundException;
+import org.forgerock.opendj.config.OperationsException;
 import org.forgerock.opendj.config.PropertyException;
 import org.forgerock.opendj.config.server.ConfigException;
 import org.forgerock.opendj.ldap.DN;
+import org.forgerock.opendj.ldap.LdapException;
 import org.forgerock.opendj.server.config.client.CryptoManagerCfgClient;
 import org.forgerock.opendj.server.config.client.ReplicationDomainCfgClient;
 import org.forgerock.opendj.server.config.client.ReplicationServerCfgClient;
@@ -178,9 +181,9 @@
   /** The fully-qualified name of this class. */
   private static final String CLASS_NAME = ReplicationCliMain.class.getName();
   /** Prefix for log files. */
-  public static final String LOG_FILE_PREFIX = "opendj-replication-";
+  private static final String LOG_FILE_PREFIX = "opendj-replication-";
   /** Suffix for log files. */
-  public static final String LOG_FILE_SUFFIX = ".log";
+  private static final String LOG_FILE_SUFFIX = ".log";
 
   /**
    * Property used to call the dsreplication script and ReplicationCliMain to
@@ -295,7 +298,7 @@
   private LDAPConnectionConsoleInteraction sourceServerCI;
   private CommandBuilder firstServerCommandBuilder;
   /** The message formatter. */
-  private PlainTextProgressMessageFormatter formatter = new PlainTextProgressMessageFormatter();
+  private final PlainTextProgressMessageFormatter formatter = new PlainTextProgressMessageFormatter();
 
   /**
    * Constructor for the ReplicationCliMain object.
@@ -382,7 +385,7 @@
    *
    * @return The error code.
    */
-  public ReplicationCliReturnCode execute(String[] args, boolean initializeServer)
+  private ReplicationCliReturnCode execute(String[] args, boolean initializeServer)
   {
     // Create the command-line argument parser for use with this program.
     try
@@ -651,7 +654,7 @@
    * @throws ClientException
    *           If the value could not be retrieved for some reason.
    */
-  public final int readInteger(
+  private final int readInteger(
       LocalizableMessage prompt, final int defaultValue) throws ClientException
   {
     ValidationCallback<Integer> callback = new ValidationCallback<Integer>()
@@ -1878,11 +1881,11 @@
    */
   private boolean promptIfRequired(PurgeHistoricalUserData uData)
   {
-    ConnectionWrapper connWrapper = null;
+    ConnectionWrapper conn = null;
     try
     {
-      connWrapper = getConnection(uData);
-      if (connWrapper == null)
+      conn = getConnection(uData);
+      if (conn == null)
       {
         return false;
       }
@@ -1900,7 +1903,7 @@
       List<String> suffixes = argParser.getBaseDNs();
       if (uData.isOnline())
       {
-        checkSuffixesForPurgeHistorical(suffixes, connWrapper, true);
+        checkSuffixesForPurgeHistorical(suffixes, conn, true);
       }
       else
       {
@@ -1914,7 +1917,7 @@
 
       if (uData.isOnline())
       {
-        List<? extends TaskEntry> taskEntries = getAvailableTaskEntries(connWrapper);
+        List<? extends TaskEntry> taskEntries = getAvailableTaskEntries(conn);
 
         TaskScheduleInteraction interaction =
             new TaskScheduleInteraction(uData.getTaskSchedule(), argParser.taskArgs, this,
@@ -1935,7 +1938,7 @@
     }
     finally
     {
-      close(connWrapper);
+      close(conn);
     }
   }
 
@@ -3365,26 +3368,18 @@
   }
 
   /**
-   * Returns the replication port of server to which the LdapContext is
-   * connected and -1 if the replication port could not be found.
-   * @param connWrapper the InitialLdapContext to be used.
-   * @return the replication port of server to which the LdapContext is
-   * connected and -1 if the replication port could not be found.
+   * Returns the replication port of server for which the connection is provided.
+   * @param conn the connection to be used.
+   * @return the server's replication port or -1 if the replication port could not be found
    */
-  private int getReplicationPort(ConnectionWrapper connWrapper)
+  private int getReplicationPort(ConnectionWrapper conn)
   {
     try
     {
-      RootCfgClient root = connWrapper.getRootConfiguration();
-
-      ReplicationSynchronizationProviderCfgClient sync =
-          (ReplicationSynchronizationProviderCfgClient)
-          root.getSynchronizationProvider("Multimaster Synchronization");
+      ReplicationSynchronizationProviderCfgClient sync = getMultimasterSynchronization(conn);
       if (sync.hasReplicationServer())
       {
-        ReplicationServerCfgClient replicationServer =
-          sync.getReplicationServer();
-        return replicationServer.getReplicationPort();
+        return sync.getReplicationServer().getReplicationPort();
       }
     }
     catch (Throwable t)
@@ -3403,7 +3398,7 @@
    * accordingly.
    *
    * @param ci the LDAP connection to the server
-   * @param connWrapper the connection to be used in an array: note the connection
+   * @param conn the connection to be used in an array: note the connection
    * may be modified with the new credentials provided by the user.
    * @param uData the ReplicationUserData to be updated.
    * @param isFirstOrSourceServer whether this is the first server in the
@@ -3416,12 +3411,12 @@
    * messages.
    */
   private boolean loadADSAndAcceptCertificates(LDAPConnectionConsoleInteraction ci,
-      AtomicReference<ConnectionWrapper> connWrapper, ReplicationUserData uData, boolean isFirstOrSourceServer)
+      AtomicReference<ConnectionWrapper> conn, ReplicationUserData uData, boolean isFirstOrSourceServer)
   throws ReplicationCliException
   {
     boolean cancelled = false;
     boolean triedWithUserProvidedAdmin = false;
-    final ConnectionWrapper conn1 = connWrapper.get();
+    final ConnectionWrapper conn1 = conn.get();
     HostPort hostPort = conn1.getHostPort();
     Type connectionType = getConnectionType(conn1);
     if (getTrustManager(ci) == null)
@@ -3512,15 +3507,15 @@
                 close(conn1);
                   try
                   {
-                    final ConnectionWrapper connWrapper2 = new ConnectionWrapper(
+                    final ConnectionWrapper conn2 = new ConnectionWrapper(
                           hostPort, connectionType, getAdministratorDN(adminUid), adminPwd,
                           getConnectTimeout(), getTrustManager(ci));
-                    connWrapper.set(connWrapper2);
-                    adsContext = new ADSContext(connWrapper2);
+                    conn.set(conn2);
+                    adsContext = new ADSContext(conn2);
                     cache = new TopologyCache(adsContext, getTrustManager(ci), getConnectTimeout());
                     cache.getFilter().setSearchMonitoringInformation(false);
                     cache.getFilter().setSearchBaseDNInformation(false);
-                    cache.setPreferredConnections(getPreferredConnections(connWrapper2));
+                    cache.setPreferredConnections(getPreferredConnections(conn2));
                     connected = true;
                   }
                   catch (Throwable t)
@@ -3913,27 +3908,26 @@
     }
   }
 
-  private void checkReplicationServerAlreadyConfigured(
-      ConnectionWrapper connWrapper, EnableReplicationServerData server)
+  private void checkReplicationServerAlreadyConfigured(ConnectionWrapper conn, EnableReplicationServerData server)
   {
-    int repPort = getReplicationPort(connWrapper);
+    int repPort = getReplicationPort(conn);
     if (!server.configureReplicationServer() && repPort > 0)
     {
-      println(INFO_REPLICATION_SERVER_CONFIGURED_WARNING.get(connWrapper.getHostPort(), repPort));
+      println(INFO_REPLICATION_SERVER_CONFIGURED_WARNING.get(conn.getHostPort(), repPort));
       println();
     }
   }
 
   private void checksForNonInteractiveMode(EnableReplicationUserData uData,
-      ConnectionWrapper connWrapper1, ConnectionWrapper connWrapper2, List<LocalizableMessage> errorMessages)
+      ConnectionWrapper conn1, ConnectionWrapper conn2, List<LocalizableMessage> errorMessages)
   {
     EnableReplicationServerData server1 = uData.getServer1();
     EnableReplicationServerData server2 = uData.getServer2();
     String host1 = server1.getHostName();
     String host2 = server2.getHostName();
 
-    int replPort1 = checkReplicationPort(connWrapper1, server1, errorMessages);
-    int replPort2 = checkReplicationPort(connWrapper2, server2, errorMessages);
+    int replPort1 = checkReplicationPort(conn1, server1, errorMessages);
+    int replPort2 = checkReplicationPort(conn2, server2, errorMessages);
     if (replPort1 > 0 && replPort1 == replPort2 && host1.equalsIgnoreCase(host2))
     {
       errorMessages.add(ERR_REPLICATION_SAME_REPLICATION_PORT.get(replPort1, host1));
@@ -3949,9 +3943,9 @@
   }
 
   private int checkReplicationPort(
-      ConnectionWrapper connWrapper, EnableReplicationServerData server, List<LocalizableMessage> errorMessages)
+      ConnectionWrapper conn, EnableReplicationServerData server, List<LocalizableMessage> errorMessages)
   {
-    int replPort = getReplicationPort(connWrapper);
+    int replPort = getReplicationPort(conn);
     boolean hasReplicationPort = replPort > 0;
     if (replPort < 0 && server.configureReplicationServer())
     {
@@ -5343,8 +5337,7 @@
     else if (connSource != null && connDestination != null)
     {
       print(formatter.getFormattedWithPoints(
-INFO_ENABLE_REPLICATION_INITIALIZING_ADS.get(
-          connDestination.getHostPort(), connSource.getHostPort())));
+          INFO_ENABLE_REPLICATION_INITIALIZING_ADS.get(connDestination.getHostPort(), connSource.getHostPort())));
 
       initializeSuffix(ADSContext.getAdministrationSuffixDN(), connSource, connDestination, false);
       print(formatter.getFormattedDone());
@@ -5368,7 +5361,7 @@
       {
         PointAdder pointAdder = new PointAdder(this);
         println(INFO_ENABLE_REPLICATION_INITIALIZING_SCHEMA.get(
-connDestination.getHostPort(), connSource.getHostPort()));
+            connDestination.getHostPort(), connSource.getHostPort()));
         pointAdder.start();
         try
         {
@@ -5383,8 +5376,7 @@
       else
       {
         print(formatter.getFormattedWithPoints(INFO_ENABLE_REPLICATION_INITIALIZING_SCHEMA.get(
-connDestination
-            .getHostPort(), connSource.getHostPort())));
+            connDestination.getHostPort(), connSource.getHostPort())));
         initializeSuffix(Constants.SCHEMA_DN, connSource, connDestination, false);
       }
       print(formatter.getFormattedDone());
@@ -6625,20 +6617,19 @@
     print(formatter.getFormattedWithPoints(
         INFO_REPLICATION_ENABLE_CONFIGURING_REPLICATION_SERVER.get(conn.getHostPort())));
 
-    RootCfgClient root = conn.getRootConfiguration();
 
     /* Configure Synchronization plugin. */
     ReplicationSynchronizationProviderCfgClient sync = null;
     try
     {
-      sync = (ReplicationSynchronizationProviderCfgClient)
-      root.getSynchronizationProvider("Multimaster Synchronization");
+      sync = getMultimasterSynchronization(conn);
     }
     catch (ManagedObjectNotFoundException monfe)
     {
       logger.info(LocalizableMessage.raw(
           "Synchronization server does not exist in " + conn.getHostPort()));
     }
+    RootCfgClient root = conn.getRootConfiguration();
     if (sync == null)
     {
       ReplicationSynchronizationProviderCfgDefn provider =
@@ -6724,11 +6715,7 @@
     print(formatter.getFormattedWithPoints(
         INFO_REPLICATION_ENABLE_UPDATING_REPLICATION_SERVER.get(conn.getHostPort())));
 
-    RootCfgClient root = conn.getRootConfiguration();
-
-    ReplicationSynchronizationProviderCfgClient sync =
-      (ReplicationSynchronizationProviderCfgClient)
-    root.getSynchronizationProvider("Multimaster Synchronization");
+    ReplicationSynchronizationProviderCfgClient sync = getMultimasterSynchronization(conn);
     boolean mustCommit = false;
     ReplicationServerCfgClient replicationServer = sync.getReplicationServer();
     Set<String> servers = replicationServer.getReplicationServer();
@@ -6812,10 +6799,7 @@
           INFO_REPLICATION_ENABLE_CONFIGURING_BASEDN.get(baseDN, conn.getHostPort())));
     }
 
-    RootCfgClient root = conn.getRootConfiguration();
-    ReplicationSynchronizationProviderCfgClient sync =
-      (ReplicationSynchronizationProviderCfgClient)
-      root.getSynchronizationProvider("Multimaster Synchronization");
+    ReplicationSynchronizationProviderCfgClient sync = getMultimasterSynchronization(conn);
 
     String[] domainNames = sync.listReplicationDomains();
     if (domainNames == null)
@@ -7257,7 +7241,7 @@
    * @throws PeerNotFoundException if the replication mechanism cannot find
    * a peer.
    */
-  public void initializeAllSuffixTry(String baseDN, ConnectionWrapper conn, boolean displayProgress)
+  private void initializeAllSuffixTry(String baseDN, ConnectionWrapper conn, boolean displayProgress)
       throws ClientException, PeerNotFoundException
   {
     boolean isOver = false;
@@ -7559,12 +7543,10 @@
     try (ConnectionWrapper conn = loader.createConnectionWrapper())
     {
       hostPort = conn.getHostPort();
-      RootCfgClient root = conn.getRootConfiguration();
       ReplicationSynchronizationProviderCfgClient sync = null;
       try
       {
-        sync = (ReplicationSynchronizationProviderCfgClient)
-        root.getSynchronizationProvider("Multimaster Synchronization");
+        sync = getMultimasterSynchronization(conn);
       }
       catch (ManagedObjectNotFoundException monfe)
       {
@@ -7675,12 +7657,10 @@
     HostPort hostPort = conn.getHostPort();
     try
     {
-      RootCfgClient root = conn.getRootConfiguration();
       ReplicationSynchronizationProviderCfgClient sync = null;
       try
       {
-        sync = (ReplicationSynchronizationProviderCfgClient)
-        root.getSynchronizationProvider("Multimaster Synchronization");
+        sync = getMultimasterSynchronization(conn);
       }
       catch (ManagedObjectNotFoundException monfe)
       {
@@ -7718,25 +7698,29 @@
     }
   }
 
+  private ReplicationSynchronizationProviderCfgClient getMultimasterSynchronization(ConnectionWrapper conn)
+      throws DecodingException, OperationsException, LdapException
+  {
+    RootCfgClient root = conn.getRootConfiguration();
+    return (ReplicationSynchronizationProviderCfgClient) root.getSynchronizationProvider("Multimaster Synchronization");
+  }
+
   /**
    * Disables the replication server for a given server.
-   * @param connWrapper the connection to the server.
+   * @param conn the connection to the server.
    * @throws ReplicationCliException if there is an error updating the
    * configuration of the server.
    */
-  private void disableReplicationServer(ConnectionWrapper connWrapper)
-  throws ReplicationCliException
+  private void disableReplicationServer(ConnectionWrapper conn) throws ReplicationCliException
   {
-    HostPort hostPort = connWrapper.getHostPort();
+    HostPort hostPort = conn.getHostPort();
     try
     {
-      RootCfgClient root = connWrapper.getRootConfiguration();
       ReplicationSynchronizationProviderCfgClient sync = null;
       ReplicationServerCfgClient replicationServer = null;
       try
       {
-        sync = (ReplicationSynchronizationProviderCfgClient)
-        root.getSynchronizationProvider("Multimaster Synchronization");
+        sync = getMultimasterSynchronization(conn);
         if (sync.hasReplicationServer())
         {
           replicationServer = sync.getReplicationServer();
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/extensions/LDAPPassThroughAuthenticationPolicyTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/extensions/LDAPPassThroughAuthenticationPolicyTestCase.java
index 8acfc35..676d6b7 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/extensions/LDAPPassThroughAuthenticationPolicyTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/extensions/LDAPPassThroughAuthenticationPolicyTestCase.java
@@ -36,6 +36,7 @@
 import java.util.concurrent.TimeoutException;
 
 import org.forgerock.i18n.LocalizableMessage;
+import org.forgerock.opendj.config.server.ConfigurationChangeListener;
 import org.forgerock.opendj.io.ASN1;
 import org.forgerock.opendj.io.ASN1Writer;
 import org.forgerock.opendj.ldap.ByteString;
@@ -45,11 +46,10 @@
 import org.forgerock.opendj.ldap.ResultCode;
 import org.forgerock.opendj.ldap.SearchScope;
 import org.forgerock.opendj.ldap.schema.AttributeType;
-import org.opends.server.TestCaseUtils;
-import org.forgerock.opendj.config.server.ConfigurationChangeListener;
 import org.forgerock.opendj.server.config.meta.LDAPPassThroughAuthenticationPolicyCfgDefn.MappingPolicy;
 import org.forgerock.opendj.server.config.server.AuthenticationPolicyCfg;
 import org.forgerock.opendj.server.config.server.LDAPPassThroughAuthenticationPolicyCfg;
+import org.opends.server.TestCaseUtils;
 import org.opends.server.api.AuthenticationPolicy;
 import org.opends.server.api.AuthenticationPolicyState;
 import org.opends.server.core.DirectoryServer;
@@ -85,13 +85,10 @@
 import static org.opends.server.protocols.ldap.LDAPConstants.*;
 import static org.testng.Assert.*;
 
-/**
- * Test LDAP authentication mappingPolicy implementation.
- */
+/** Test LDAP authentication mappingPolicy implementation. */
 public class LDAPPassThroughAuthenticationPolicyTestCase extends
     ExtensionsTestCase
 {
-
   static class CloseEvent extends Event<Void>
   {
     private final GetConnectionEvent getConnectionEvent;
@@ -101,7 +98,6 @@
       this.getConnectionEvent = getConnectionEvent;
     }
 
-    /** {@inheritDoc} */
     @Override
     boolean matchesEvent(final Event<?> event)
     {
@@ -113,9 +109,6 @@
       return false;
     }
 
-
-
-    /** {@inheritDoc} */
     @Override
     StringBuilder toString(final StringBuilder builder)
     {
@@ -124,14 +117,10 @@
       builder.append(')');
       return builder;
     }
-
   }
 
-
-
   static abstract class Event<T>
   {
-
     @Override
     public final boolean equals(final Object obj)
     {
@@ -142,8 +131,6 @@
       return false;
     }
 
-
-
     @Override
     public final String toString()
     {
@@ -151,8 +138,6 @@
       return toString(builder).toString();
     }
 
-
-
     T getResult()
     {
       return null;
@@ -163,8 +148,6 @@
     abstract StringBuilder toString(StringBuilder builder);
   }
 
-
-
   static class GetConnectionEvent extends Event<DirectoryException>
   {
     private final GetLDAPConnectionFactoryEvent fevent;
@@ -182,7 +165,6 @@
       this.resultCode = resultCode;
     }
 
-    /** {@inheritDoc} */
     @Override
     DirectoryException getResult()
     {
@@ -193,9 +175,6 @@
       return null;
     }
 
-
-
-    /** {@inheritDoc} */
     @Override
     boolean matchesEvent(final Event<?> event)
     {
@@ -207,9 +186,6 @@
       return false;
     }
 
-
-
-    /** {@inheritDoc} */
     @Override
     StringBuilder toString(final StringBuilder builder)
     {
@@ -218,18 +194,13 @@
       builder.append(')');
       return builder;
     }
-
   }
 
-
-
   static class GetLDAPConnectionFactoryEvent extends Event<Void>
   {
     private final String hostPort;
     private final LDAPPassThroughAuthenticationPolicyCfg options;
 
-
-
     GetLDAPConnectionFactoryEvent(final String hostPort,
         final LDAPPassThroughAuthenticationPolicyCfg options)
     {
@@ -237,9 +208,6 @@
       this.options = options;
     }
 
-
-
-    /** {@inheritDoc} */
     @Override
     boolean matchesEvent(final Event<?> event)
     {
@@ -253,9 +221,6 @@
       return false;
     }
 
-
-
-    /** {@inheritDoc} */
     @Override
     StringBuilder toString(final StringBuilder builder)
     {
@@ -264,20 +229,14 @@
       builder.append(')');
       return builder;
     }
-
   }
 
-
-
   static final class MockConnection implements
       LDAPPassThroughAuthenticationPolicyFactory.Connection
   {
-
     private final GetConnectionEvent getConnectionEvent;
     private final MockProvider mockProvider;
 
-
-
     MockConnection(final MockProvider mockProvider,
         final GetConnectionEvent getConnectionEvent)
     {
@@ -285,9 +244,6 @@
       this.getConnectionEvent = getConnectionEvent;
     }
 
-
-
-    /** {@inheritDoc} */
     @Override
     public void close()
     {
@@ -295,9 +251,6 @@
       mockProvider.assertExpectedEventWasReceived(event);
     }
 
-
-
-    /** {@inheritDoc} */
     @Override
     public ByteString search(final DN baseDN, final SearchScope scope,
         final SearchFilter filter) throws DirectoryException
@@ -315,9 +268,6 @@
       }
     }
 
-
-
-    /** {@inheritDoc} */
     @Override
     public void simpleBind(final ByteString username, final ByteString password)
         throws DirectoryException
@@ -334,16 +284,12 @@
 
   }
 
-
-
   static final class MockFactory implements
       LDAPPassThroughAuthenticationPolicyFactory.ConnectionFactory
   {
     private final GetLDAPConnectionFactoryEvent getLDAPConnectionFactoryEvent;
     private final MockProvider mockProvider;
 
-
-
     MockFactory(final MockProvider mockProvider,
         final GetLDAPConnectionFactoryEvent providerEvent)
     {
@@ -351,18 +297,12 @@
       this.getLDAPConnectionFactoryEvent = providerEvent;
     }
 
-
-
-    /** {@inheritDoc} */
     @Override
     public void close()
     {
       // Nothing to do.
     }
 
-
-
-    /** {@inheritDoc} */
     @Override
     public Connection getConnection() throws DirectoryException
     {
@@ -375,16 +315,10 @@
       {
         throw e;
       }
-      else
-      {
-        return new MockConnection(mockProvider, event);
-      }
+      return new MockConnection(mockProvider, event);
     }
-
   }
 
-
-
   final class MockPolicyCfg implements LDAPPassThroughAuthenticationPolicyCfg
   {
     private final SortedSet<DN> baseDNs = new TreeSet<>();
@@ -401,9 +335,6 @@
     private String mappedSearchBindPasswordProperty;
     private boolean usePasswordCaching;
 
-
-
-
     @Override
     public void addChangeListener(
         final ConfigurationChangeListener<AuthenticationPolicyCfg> listener)
@@ -411,8 +342,6 @@
       // Do nothing.
     }
 
-
-
     @Override
     public void addLDAPPassThroughChangeListener(
         final ConfigurationChangeListener<LDAPPassThroughAuthenticationPolicyCfg> listener)
@@ -420,157 +349,117 @@
       // Do nothing.
     }
 
-
-
     @Override
     public Class<? extends LDAPPassThroughAuthenticationPolicyCfg> configurationClass()
     {
       return LDAPPassThroughAuthenticationPolicyCfg.class;
     }
 
-
-
     @Override
     public DN dn()
     {
       return policyDN;
     }
 
-
-
     @Override
     public long getConnectionTimeout()
     {
       return timeoutMS;
     }
 
-
-
     @Override
     public InetAddress getSourceAddress() { return null; }
 
-
-
     @Override
     public String getJavaClass()
     {
       return LDAPPassThroughAuthenticationPolicyFactory.class.getName();
     }
 
-
-
     @Override
     public SortedSet<AttributeType> getMappedAttribute()
     {
       return mappedAttributes;
     }
 
-
-
     @Override
     public SortedSet<DN> getMappedSearchBaseDN()
     {
       return baseDNs;
     }
 
-
-
     @Override
     public DN getMappedSearchBindDN()
     {
       return mappedSearchBindDN;
     }
 
-
-
     @Override
     public String getMappedSearchBindPassword()
     {
       return mappedSearchBindPassword;
     }
 
-
-
     @Override
     public MappingPolicy getMappingPolicy()
     {
       return mappingPolicy;
     }
 
-
-
     @Override
     public SortedSet<String> getPrimaryRemoteLDAPServer()
     {
       return primaryServers;
     }
 
-
-
     @Override
     public SortedSet<String> getSecondaryRemoteLDAPServer()
     {
       return secondaryServers;
     }
 
-
-
     @Override
     public SortedSet<String> getSSLCipherSuite()
     {
       return new TreeSet<>();
     }
 
-
-
     @Override
     public SortedSet<String> getSSLProtocol()
     {
       return new TreeSet<>();
     }
 
-
-
     @Override
     public String getTrustManagerProvider()
     {
       return "ignored";
     }
 
-
-
     @Override
     public DN getTrustManagerProviderDN()
     {
       return trustManagerDN;
     }
 
-
-
     @Override
     public boolean isUseSSL()
     {
       return false;
     }
 
-
-
     @Override
     public boolean isUseTCPKeepAlive()
     {
       return false;
     }
 
-
-
     @Override
     public boolean isUseTCPNoDelay()
     {
       return false;
     }
 
-
-
     @Override
     public void removeChangeListener(
         final ConfigurationChangeListener<AuthenticationPolicyCfg> listener)
@@ -578,8 +467,6 @@
       // Do nothing.
     }
 
-
-
     @Override
     public void removeLDAPPassThroughChangeListener(
         final ConfigurationChangeListener<LDAPPassThroughAuthenticationPolicyCfg> listener)
@@ -587,141 +474,102 @@
       // Do nothing.
     }
 
-
-
     MockPolicyCfg withBaseDN(final String baseDN)
     {
       baseDNs.add(DN.valueOf(baseDN));
       return this;
     }
 
-
-
     MockPolicyCfg withConnectionTimeout(final int timeoutMS)
     {
       this.timeoutMS = timeoutMS;
       return this;
     }
 
-
-
     MockPolicyCfg withMappedAttribute(final String attrName)
     {
       mappedAttributes.add(DirectoryServer.getAttributeType(attrName));
       return this;
     }
 
-
-
     MockPolicyCfg withMappingPolicy(final MappingPolicy policy)
     {
       this.mappingPolicy = policy;
       return this;
     }
 
-
-
     MockPolicyCfg withPrimaryServer(final String hostPort)
     {
       primaryServers.add(hostPort);
       return this;
     }
 
-
-
     MockPolicyCfg withSecondaryServer(final String hostPort)
     {
       secondaryServers.add(hostPort);
       return this;
     }
 
-
-
     MockPolicyCfg withMappedSearchBindDN(final DN value)
     {
       this.mappedSearchBindDN = value;
       return this;
     }
 
-
-
     MockPolicyCfg withMappedSearchBindPassword(final String value)
     {
       this.mappedSearchBindPassword = value;
       return this;
     }
 
-
-
     MockPolicyCfg withMappedSearchBindPasswordEnvironmentVariable(final String value)
     {
       this.mappedSearchBindPasswordEnvVar = value;
       return this;
     }
 
-
-
     MockPolicyCfg withMappedSearchBindPasswordFile(final String value)
     {
       this.mappedSearchBindPasswordFile = value;
       return this;
     }
 
-
-
     MockPolicyCfg withMappedSearchBindPasswordProperty(final String value)
     {
       this.mappedSearchBindPasswordProperty = value;
       return this;
     }
 
-
-
     MockPolicyCfg withUsePasswordCaching(final boolean usePasswordCaching)
     {
       this.usePasswordCaching = usePasswordCaching;
       return this;
     }
 
-
-
-    /** {@inheritDoc} */
     @Override
     public String getMappedSearchBindPasswordEnvironmentVariable()
     {
       return mappedSearchBindPasswordEnvVar;
     }
 
-
-
-    /** {@inheritDoc} */
     @Override
     public String getMappedSearchBindPasswordFile()
     {
       return mappedSearchBindPasswordFile;
     }
 
-
-
-    /** {@inheritDoc} */
     @Override
     public String getMappedSearchBindPasswordProperty()
     {
       return mappedSearchBindPasswordProperty;
     }
 
-
-
-    /** {@inheritDoc} */
     @Override
     public long getCachedPasswordTTL()
     {
       return 86400;
     }
 
-
-
-    /** {@inheritDoc} */
     @Override
     public String getCachedPasswordStorageScheme()
     {
@@ -734,9 +582,6 @@
       return DN.valueOf("cn=Salted SHA-1,cn=Password Storage Schemes,cn=config");
     }
 
-
-
-    /** {@inheritDoc} */
     @Override
     public boolean isUsePasswordCaching()
     {
@@ -744,25 +589,18 @@
     }
   }
 
-
-
   static final class MockProvider implements
       LDAPPassThroughAuthenticationPolicyFactory.Provider
   {
-
     private final class MockScheduledFuture implements ScheduledFuture<Void>
     {
       private final Runnable runnable;
 
-
-
       MockScheduledFuture(final Runnable runnable)
       {
         this.runnable = runnable;
       }
 
-
-
       @Override
       public boolean cancel(final boolean mayInterruptIfRunning)
       {
@@ -770,24 +608,18 @@
         return true;
       }
 
-
-
       @Override
       public int compareTo(final Delayed o)
       {
         return 0;
       }
 
-
-
       @Override
       public Void get() throws InterruptedException, ExecutionException
       {
         return null;
       }
 
-
-
       @Override
       public Void get(final long timeout, final TimeUnit unit)
           throws InterruptedException, ExecutionException, TimeoutException
@@ -795,40 +627,30 @@
         return null;
       }
 
-
-
       @Override
       public long getDelay(final TimeUnit unit)
       {
         return 0;
       }
 
-
-
       @Override
       public boolean isCancelled()
       {
         return false;
       }
 
-
-
       @Override
       public boolean isDone()
       {
         return false;
       }
 
-
-
       Runnable getRunnable()
       {
         return runnable;
       }
     }
 
-
-
     private final Queue<Event<?>> expectedEvents = new LinkedList<>();
     private final List<MockScheduledFuture> monitorRunnables = new LinkedList<>();
     private String currentTime = TimeThread.getGMTTime();
@@ -844,16 +666,12 @@
         throw new UnsupportedOperationException();
       }
 
-
-
       @Override
       public void execute(final Runnable command)
       {
         throw new UnsupportedOperationException();
       }
 
-
-
       @Override
       public <T> List<Future<T>> invokeAll(
           final Collection<? extends Callable<T>> tasks)
@@ -862,8 +680,6 @@
         throw new UnsupportedOperationException();
       }
 
-
-
       @Override
       public <T> List<Future<T>> invokeAll(
           final Collection<? extends Callable<T>> tasks, final long timeout,
@@ -872,8 +688,6 @@
         throw new UnsupportedOperationException();
       }
 
-
-
       @Override
       public <T> T invokeAny(final Collection<? extends Callable<T>> tasks)
           throws InterruptedException, ExecutionException
@@ -881,8 +695,6 @@
         throw new UnsupportedOperationException();
       }
 
-
-
       @Override
       public <T> T invokeAny(final Collection<? extends Callable<T>> tasks,
           final long timeout, final TimeUnit unit) throws InterruptedException,
@@ -891,24 +703,18 @@
         throw new UnsupportedOperationException();
       }
 
-
-
       @Override
       public boolean isShutdown()
       {
         return false;
       }
 
-
-
       @Override
       public boolean isTerminated()
       {
         return false;
       }
 
-
-
       @Override
       public <V> ScheduledFuture<V> schedule(final Callable<V> callable,
           final long delay, final TimeUnit unit)
@@ -916,8 +722,6 @@
         throw new UnsupportedOperationException();
       }
 
-
-
       @Override
       public ScheduledFuture<?> schedule(final Runnable command,
           final long delay, final TimeUnit unit)
@@ -925,8 +729,6 @@
         throw new UnsupportedOperationException();
       }
 
-
-
       @Override
       public ScheduledFuture<?> scheduleAtFixedRate(final Runnable command,
           final long initialDelay, final long period, final TimeUnit unit)
@@ -934,8 +736,6 @@
         throw new UnsupportedOperationException();
       }
 
-
-
       @Override
       public ScheduledFuture<?> scheduleWithFixedDelay(final Runnable command,
           final long initialDelay, final long delay, final TimeUnit unit)
@@ -945,40 +745,30 @@
         return future;
       }
 
-
-
       @Override
       public void shutdown()
       {
         throw new UnsupportedOperationException();
       }
 
-
-
       @Override
       public List<Runnable> shutdownNow()
       {
         throw new UnsupportedOperationException();
       }
 
-
-
       @Override
       public <T> Future<T> submit(final Callable<T> task)
       {
         throw new UnsupportedOperationException();
       }
 
-
-
       @Override
       public Future<?> submit(final Runnable task)
       {
         throw new UnsupportedOperationException();
       }
 
-
-
       @Override
       public <T> Future<T> submit(final Runnable task, final T result)
       {
@@ -986,9 +776,6 @@
       }
     };
 
-
-
-    /** {@inheritDoc} */
     @Override
     public ConnectionFactory getLDAPConnectionFactory(final String host,
         final int port, final LDAPPassThroughAuthenticationPolicyCfg options)
@@ -999,27 +786,18 @@
       return new MockFactory(this, event);
     }
 
-
-
-    /** {@inheritDoc} */
     @Override
     public ScheduledExecutorService getScheduledExecutorService()
     {
       return mockScheduler;
     }
 
-
-
-    /** {@inheritDoc} */
     @Override
     public String getCurrentTime()
     {
       return currentTime;
     }
 
-
-
-    /** {@inheritDoc} */
     @Override
     public long getCurrentTimeMS()
     {
@@ -1034,48 +812,32 @@
       }
     }
 
-
-
     void assertAllExpectedEventsReceived()
     {
       assertTrue(expectedEvents.isEmpty());
     }
 
-
-
     @SuppressWarnings("unchecked")
     <T> T assertExpectedEventWasReceived(final Event<T> actualEvent)
     {
       final Event<?> expectedEvent = expectedEvents.poll();
-      if (expectedEvent == null)
-      {
-        fail("Unexpected event: " + actualEvent);
-      }
-      else
-      {
-        assertEquals(actualEvent, expectedEvent);
-      }
+      assertNotNull(expectedEvent, "Unexpected event: " + actualEvent);
+      assertEquals(actualEvent, expectedEvent);
       return ((Event<T>) expectedEvent).getResult();
     }
 
-
-
     MockProvider expectEvent(final Event<?> expectedEvent)
     {
       expectedEvents.add(expectedEvent);
       return this;
     }
 
-
-
     MockProvider withCurrentTime(final String currentTime)
     {
       this.currentTime = currentTime;
       return this;
     }
 
-
-
     void runMonitorTasks()
     {
       for (final MockScheduledFuture task : monitorRunnables)
@@ -1086,8 +848,6 @@
 
   }
 
-
-
   final class MockServer
   {
     /** Waits for an incoming client connection. */
@@ -1100,29 +860,21 @@
       }
     }
 
-
-
     abstract class Action
     {
       abstract void run() throws Exception;
     }
 
-
-
     /** Blocks the server until it is released. */
     class BlockAction extends Action
     {
       private final CountDownLatch latch = new CountDownLatch(1);
 
-
-
       void release()
       {
         latch.countDown();
       }
 
-
-
       @Override
       void run() throws Exception
       {
@@ -1130,8 +882,6 @@
       }
     }
 
-
-
     /** Close the client socket. */
     class CloseAction extends Action
     {
@@ -1142,24 +892,18 @@
       }
     }
 
-
-
     /** Read the next message and check it matches the expected message. */
     class ReceiveAction extends Action
     {
       private final int messageID;
       private final ProtocolOp expectedOp;
 
-
-
       ReceiveAction(final int messageID, final ProtocolOp expectedOp)
       {
         this.messageID = messageID;
         this.expectedOp = expectedOp;
       }
 
-
-
       @Override
       void run() throws Exception
       {
@@ -1182,24 +926,18 @@
       }
     }
 
-
-
     /** Sends a message. */
     class SendAction extends Action
     {
       private final int messageID;
       private final ProtocolOp op;
 
-
-
       SendAction(final int messageID, final ProtocolOp op)
       {
         this.messageID = messageID;
         this.op = op;
       }
 
-
-
       @Override
       void run() throws Exception
       {
@@ -1209,8 +947,6 @@
       }
     }
 
-
-
     private final ServerSocket serverSocket;
     private final List<Action> actions = new LinkedList<>();
     private Socket socket;
@@ -1219,15 +955,11 @@
     private final CountDownLatch stopLatch = new CountDownLatch(1);
     private final Queue<BlockAction> blockers = new LinkedList<>();
 
-
-
     MockServer(final ServerSocket serverSocket)
     {
       this.serverSocket = serverSocket;
     }
 
-
-
     void assertNoExceptions() throws Exception
     {
       if (e != null)
@@ -1236,20 +968,15 @@
       }
     }
 
-
-
     int getPort()
     {
       return serverSocket.getLocalPort();
     }
 
-
-
     MockServer start()
     {
       serverThread = new Thread(new Runnable()
       {
-        /** {@inheritDoc} */
         @Override
         public void run()
         {
@@ -1277,8 +1004,6 @@
       return this;
     }
 
-
-
     void stop() throws Exception
     {
       stopLatch.await(10, TimeUnit.SECONDS);
@@ -1290,16 +1015,12 @@
       assertNoExceptions();
     }
 
-
-
     MockServer thenAccept()
     {
       actions.add(new AcceptAction());
       return this;
     }
 
-
-
     MockServer thenBlock()
     {
       final BlockAction action = new BlockAction();
@@ -1308,32 +1029,24 @@
       return this;
     }
 
-
-
     MockServer thenClose()
     {
       actions.add(new CloseAction());
       return this;
     }
 
-
-
     MockServer thenReceive(final int messageID, final ProtocolOp op)
     {
       actions.add(new ReceiveAction(messageID, op));
       return this;
     }
 
-
-
     MockServer thenSend(final int messageID, final ProtocolOp op)
     {
       actions.add(new SendAction(messageID, op));
       return this;
     }
 
-
-
     void unblock() throws Exception
     {
       final BlockAction action = blockers.poll();
@@ -1341,25 +1054,18 @@
       action.release();
     }
 
-
-
     private Socket accept() throws IOException
     {
       socket = serverSocket.accept();
       return socket;
     }
 
-
-
     private Socket getSocket()
     {
       return socket;
     }
-
   }
 
-
-
   static class SearchEvent extends Event<Object>
   {
     private final String baseDN;
@@ -1369,16 +1075,12 @@
     private final SearchScope scope;
     private final String username;
 
-
-
     SearchEvent(final GetConnectionEvent cevent, final String baseDN,
         final SearchScope scope, final String filter)
     {
       this(cevent, baseDN, scope, filter, null, ResultCode.SUCCESS);
     }
 
-
-
     SearchEvent(final GetConnectionEvent cevent, final String baseDN,
         final SearchScope scope, final String filter,
         final ResultCode resultCode)
@@ -1386,16 +1088,12 @@
       this(cevent, baseDN, scope, filter, null, resultCode);
     }
 
-
-
     SearchEvent(final GetConnectionEvent cevent, final String baseDN,
         final SearchScope scope, final String filter, final String username)
     {
       this(cevent, baseDN, scope, filter, username, ResultCode.SUCCESS);
     }
 
-
-
     private SearchEvent(final GetConnectionEvent cevent, final String baseDN,
         final SearchScope scope, final String filter, final String username,
         final ResultCode resultCode)
@@ -1408,9 +1106,6 @@
       this.resultCode = resultCode;
     }
 
-
-
-    /** {@inheritDoc} */
     @Override
     Object getResult()
     {
@@ -1418,9 +1113,6 @@
           : new DirectoryException(resultCode, resultCode.getName());
     }
 
-
-
-    /** {@inheritDoc} */
     @Override
     boolean matchesEvent(final Event<?> event)
     {
@@ -1435,9 +1127,6 @@
       return false;
     }
 
-
-
-    /** {@inheritDoc} */
     @Override
     StringBuilder toString(final StringBuilder builder)
     {
@@ -1452,11 +1141,8 @@
       builder.append(')');
       return builder;
     }
-
   }
 
-
-
   static class SimpleBindEvent extends Event<DirectoryException>
   {
     private final GetConnectionEvent cevent;
@@ -1464,16 +1150,12 @@
     private final ResultCode resultCode;
     private final String username;
 
-
-
     SimpleBindEvent(final GetConnectionEvent cevent, final String username,
         final String password)
     {
       this(cevent, username, password, ResultCode.SUCCESS);
     }
 
-
-
     SimpleBindEvent(final GetConnectionEvent cevent, final String username,
         final String password, final ResultCode resultCode)
     {
@@ -1483,9 +1165,6 @@
       this.resultCode = resultCode;
     }
 
-
-
-    /** {@inheritDoc} */
     @Override
     DirectoryException getResult()
     {
@@ -1497,9 +1176,6 @@
       return null;
     }
 
-
-
-    /** {@inheritDoc} */
     @Override
     boolean matchesEvent(final Event<?> event)
     {
@@ -1513,9 +1189,6 @@
       return false;
     }
 
-
-
-    /** {@inheritDoc} */
     @Override
     StringBuilder toString(final StringBuilder builder)
     {
@@ -1528,11 +1201,8 @@
       builder.append(')');
       return builder;
     }
-
   }
 
-
-
   private final String phost1 = "phost1:11";
   private final String phost2 = "phost2:22";
   private final String phost3 = "phost3:33";
@@ -1548,8 +1218,6 @@
   private Entry userEntry;
   private final String userPassword = "password";
 
-
-
   /**
    * Ensures that the Directory Server is running and creates a test backend
    * containing a single test user.
@@ -1578,8 +1246,6 @@
     );
   }
 
-
-
   /**
    * Tests that failures during the search are handled properly.
    * <p>
@@ -1591,7 +1257,7 @@
    * @throws Exception
    *           If an unexpected exception occurred.
    */
-  @Test(enabled = true, dataProvider = "testConnectionFailureDuringSearchData")
+  @Test(dataProvider = "testConnectionFailureDuringSearchData")
   public void testConnectionFailureDuringSearch(
       final ResultCode searchResultCode) throws Exception
   {
@@ -1661,8 +1327,6 @@
     provider.assertAllExpectedEventsReceived();
   }
 
-
-
   /**
    * Tests that failures to authenticate a search connection are handled
    * properly.
@@ -1676,7 +1340,7 @@
    * @throws Exception
    *           If an unexpected exception occurred.
    */
-  @Test(enabled = true, dataProvider = "testConnectionFailureDuringSearchBindData")
+  @Test(dataProvider = "testConnectionFailureDuringSearchBindData")
   public void testConnectionFailureDuringSearchBind(
       final ResultCode bindResultCode) throws Exception
   {
@@ -1727,8 +1391,6 @@
     policy.finalizeAuthenticationPolicy();
   }
 
-
-
   /**
    * Returns test data for {@link #testConnectionFailureDuringSearchBind}.
    *
@@ -1746,8 +1408,6 @@
     // @formatter:on
   }
 
-
-
   /**
    * Returns test data for {@link #testConnectionFailureDuringSearch}.
    *
@@ -1766,8 +1426,6 @@
     // @formatter:on
   }
 
-
-
   /**
    * Tests that failures to obtain a search connection are handled properly.
    *
@@ -1776,7 +1434,7 @@
    * @throws Exception
    *           If an unexpected exception occurred.
    */
-  @Test(enabled = true, dataProvider = "testConnectionFailureDuringSearchGetConnectionData")
+  @Test(dataProvider = "testConnectionFailureDuringSearchGetConnectionData")
   public void testConnectionFailureDuringSearchGetConnection(
       final ResultCode connectResultCode) throws Exception
   {
@@ -1824,8 +1482,6 @@
     policy.finalizeAuthenticationPolicy();
   }
 
-
-
   /**
    * Returns test data for
    * {@link #testConnectionFailureDuringSearchGetConnection}.
@@ -1843,8 +1499,6 @@
     // @formatter:on
   }
 
-
-
   /**
    * Tests fail-over between 2 primary servers then to the secondary data
    * center.
@@ -1852,7 +1506,7 @@
    * @throws Exception
    *           If an unexpected exception occurred.
    */
-  @Test(enabled = true)
+  @Test
   public void testFailOverOnConnect() throws Exception
   {
     // Mock configuration.
@@ -1971,8 +1625,6 @@
     provider.assertAllExpectedEventsReceived();
   }
 
-
-
   /**
    * Tests that searches which fail in one LB pool are automatically retried in
    * the secondary LB pool.
@@ -1980,7 +1632,7 @@
    * @throws Exception
    *           If an unexpected exception occurred.
    */
-  @Test(enabled = true)
+  @Test
   public void testFBRetrySearchOnFailure() throws Exception
   {
     // Mock configuration.
@@ -2113,8 +1765,6 @@
     provider.assertAllExpectedEventsReceived();
   }
 
-
-
   /**
    * Tests configuration validation.
    *
@@ -2125,7 +1775,7 @@
    * @throws Exception
    *           If an unexpected exception occurred.
    */
-  @Test(enabled = true, dataProvider = "testIsConfigurationAcceptableData")
+  @Test(dataProvider = "testIsConfigurationAcceptableData")
   public void testIsConfigurationAcceptable(
       final LDAPPassThroughAuthenticationPolicyCfg cfg, final boolean isValid)
       throws Exception
@@ -2136,8 +1786,6 @@
         isValid);
   }
 
-
-
   /**
    * Returns test data for {@link #testIsConfigurationAcceptable}.
    *
@@ -2176,8 +1824,6 @@
     // @formatter:on
   }
 
-
-
   /**
    * Tests that searches which fail on one server are automatically retried on
    * another within the same LB.
@@ -2185,7 +1831,7 @@
    * @throws Exception
    *           If an unexpected exception occurred.
    */
-  @Test(enabled = true)
+  @Test
   public void testLBRetrySearchOnFailure() throws Exception
   {
     // Mock configuration.
@@ -2323,8 +1969,6 @@
     provider.assertAllExpectedEventsReceived();
   }
 
-
-
   /**
    * Tests valid bind which times out at the client. These should trigger a
    * CLIENT_SIDE_TIMEOUT result code.
@@ -2332,7 +1976,7 @@
    * @throws Exception
    *           If an unexpected exception occurred.
    */
-  @Test(enabled = true)
+  @Test
   public void testLDAPConnectionFactoryBindClientTimeout() throws Exception
   {
     // Mock configuration.
@@ -2366,8 +2010,6 @@
     }
   }
 
-
-
   /**
    * Tests valid bind which never receives a response because the server
    * abruptly closes the connection.
@@ -2375,7 +2017,7 @@
    * @throws Exception
    *           If an unexpected exception occurred.
    */
-  @Test(enabled = true)
+  @Test
   public void testLDAPConnectionFactoryBindConnectionClosed() throws Exception
   {
     // Mock configuration.
@@ -2409,8 +2051,6 @@
     }
   }
 
-
-
   /**
    * Tests bind which receives a disconnect notification. The error result code
    * should be passed back to the called.
@@ -2418,7 +2058,7 @@
    * @throws Exception
    *           If an unexpected exception occurred.
    */
-  @Test(enabled = true)
+  @Test
   public void testLDAPConnectionFactoryBindDisconnectNotification()
       throws Exception
   {
@@ -2455,8 +2095,6 @@
     }
   }
 
-
-
   /**
    * Tests bind with invalid credentials which should return a
    * INVALID_CREDENTIALS result code.
@@ -2464,7 +2102,7 @@
    * @throws Exception
    *           If an unexpected exception occurred.
    */
-  @Test(enabled = true)
+  @Test
   public void testLDAPConnectionFactoryBindInvalidCredentials()
       throws Exception
   {
@@ -2499,8 +2137,6 @@
     }
   }
 
-
-
   /**
    * Tests bind which returns an error result. The error result code should be
    * passed back to the caller.
@@ -2508,7 +2144,7 @@
    * @throws Exception
    *           If an unexpected exception occurred.
    */
-  @Test(enabled = true)
+  @Test
   public void testLDAPConnectionFactoryBindOtherError() throws Exception
   {
     // Mock configuration.
@@ -2541,15 +2177,13 @@
     }
   }
 
-
-
   /**
    * Tests valid bind returning success.
    *
    * @throws Exception
    *           If an unexpected exception occurred.
    */
-  @Test(enabled = true)
+  @Test
   public void testLDAPConnectionFactoryBindSuccess() throws Exception
   {
     // Mock configuration.
@@ -2577,15 +2211,13 @@
     }
   }
 
-
-
   /**
    * Tests successful connect/unbind.
    *
    * @throws Exception
    *           If an unexpected exception occurred.
    */
-  @Test(enabled = true)
+  @Test
   public void testLDAPConnectionFactoryConnectAndUnbind() throws Exception
   {
     // Mock configuration.
@@ -2609,8 +2241,6 @@
     }
   }
 
-
-
   /**
    * Tests that invalid ports are handled properly. These should trigger a
    * CLIENT_SIDE_CONNECT_ERROR result code.
@@ -2618,7 +2248,7 @@
    * @throws Exception
    *           If an unexpected exception occurred.
    */
-  @Test(enabled = true)
+  @Test
   public void testLDAPConnectionFactoryConnectPortNotInUse() throws Exception
   {
     final int port = TestCaseUtils.findFreePort();
@@ -2646,8 +2276,6 @@
     }
   }
 
-
-
   /**
    * Tests that unknown hosts are handled properly. These should trigger a
    * CLIENT_SIDE_CONNECT_ERROR result code.
@@ -2655,7 +2283,7 @@
    * @throws Exception
    *           If an unexpected exception occurred.
    */
-  @Test(enabled = true)
+  @Test
   public void testLDAPConnectionFactoryConnectUnknownHost() throws Exception
   {
     // Mock configuration.
@@ -2681,8 +2309,6 @@
     }
   }
 
-
-
   /**
    * Tests valid search which times out at the client. These should trigger a
    * CLIENT_SIDE_TIMEOUT result code.
@@ -2690,7 +2316,7 @@
    * @throws Exception
    *           If an unexpected exception occurred.
    */
-  @Test(enabled = true)
+  @Test
   public void testLDAPConnectionFactorySearchClientTimeout() throws Exception
   {
     // Mock configuration.
@@ -2723,8 +2349,6 @@
     }
   }
 
-
-
   /**
    * Tests valid search which never receives a response because the server
    * abruptly closes the connection.
@@ -2732,7 +2356,7 @@
    * @throws Exception
    *           If an unexpected exception occurred.
    */
-  @Test(enabled = true)
+  @Test
   public void testLDAPConnectionFactorySearchConnectionClosed()
       throws Exception
   {
@@ -2769,8 +2393,6 @@
     }
   }
 
-
-
   /**
    * Tests valid search which receives a disconnect notification. The error
    * result code should be passed back to the called.
@@ -2778,7 +2400,7 @@
    * @throws Exception
    *           If an unexpected exception occurred.
    */
-  @Test(enabled = true)
+  @Test
   public void testLDAPConnectionFactorySearchDisconnectNotification()
       throws Exception
   {
@@ -2816,8 +2438,6 @@
     }
   }
 
-
-
   /**
    * Tests valid search returning no results are handled properly. These should
    * trigger a CLIENT_SIDE_NO_RESULTS_RETURNED result code.
@@ -2825,7 +2445,7 @@
    * @throws Exception
    *           If an unexpected exception occurred.
    */
-  @Test(enabled = true)
+  @Test
   public void testLDAPConnectionFactorySearchNoResults() throws Exception
   {
     // Mock configuration.
@@ -2861,8 +2481,6 @@
     }
   }
 
-
-
   /**
    * Tests search returning no entries and an error result. The error result
    * code should be passed back to the caller.
@@ -2870,7 +2488,7 @@
    * @throws Exception
    *           If an unexpected exception occurred.
    */
-  @Test(enabled = true)
+  @Test
   public void testLDAPConnectionFactorySearchOtherError() throws Exception
   {
     // Mock configuration.
@@ -2906,8 +2524,6 @@
     }
   }
 
-
-
   /**
    * Tests valid search returning a single entry followed by a size limit
    * exceeded error are handled properly. These should trigger a
@@ -2916,7 +2532,7 @@
    * @throws Exception
    *           If an unexpected exception occurred.
    */
-  @Test(enabled = true)
+  @Test
   public void testLDAPConnectionFactorySearchSizeLimit() throws Exception
   {
     // Mock configuration.
@@ -2953,15 +2569,13 @@
     }
   }
 
-
-
   /**
    * Tests valid search returning a single entry works properly.
    *
    * @throws Exception
    *           If an unexpected exception occurred.
    */
-  @Test(enabled = true)
+  @Test
   public void testLDAPConnectionFactorySearchSuccess() throws Exception
   {
     // Mock configuration.
@@ -2994,8 +2608,6 @@
     }
   }
 
-
-
   /**
    * Tests valid search returning a single entry followed by a time limit
    * exceeded error are handled properly. These should trigger a
@@ -3004,7 +2616,7 @@
    * @throws Exception
    *           If an unexpected exception occurred.
    */
-  @Test(enabled = true)
+  @Test
   public void testLDAPConnectionFactorySearchTimeLimit() throws Exception
   {
     // Mock configuration.
@@ -3041,8 +2653,6 @@
     }
   }
 
-
-
   /**
    * Tests valid search returning many results are handled properly. These
    * should trigger a CLIENT_SIDE_MORE_RESULTS_TO_RETURN result code.
@@ -3050,7 +2660,7 @@
    * @throws Exception
    *           If an unexpected exception occurred.
    */
-  @Test(enabled = true)
+  @Test
   public void testLDAPConnectionFactorySearchTooManyResults() throws Exception
   {
     // Mock configuration.
@@ -3088,15 +2698,13 @@
     }
   }
 
-
-
   /**
    * Tests load balancing across 3 servers.
    *
    * @throws Exception
    *           If an unexpected exception occurred.
    */
-  @Test(enabled = true)
+  @Test
   public void testLoadBalancing() throws Exception
   {
     // Mock configuration.
@@ -3221,8 +2829,6 @@
     provider.assertAllExpectedEventsReceived();
   }
 
-
-
   /**
    * Tests the different mapping policies: connection attempts will succeed, as
    * will any searches, but the final user bind may or may not succeed depending
@@ -3238,7 +2844,7 @@
    * @throws Exception
    *           If an unexpected exception occurred.
    */
-  @Test(enabled = true, dataProvider = "testMappingPolicyAuthenticationData")
+  @Test(dataProvider = "testMappingPolicyAuthenticationData")
   public void testMappingPolicyAuthentication(
       final MappingPolicy mappingPolicy, final ResultCode bindResultCode)
       throws Exception
@@ -3342,8 +2948,6 @@
     provider.assertAllExpectedEventsReceived();
   }
 
-
-
   /**
    * Returns test data for {@link #testMappingPolicyAuthentication}.
    *
@@ -3370,15 +2974,13 @@
     // @formatter:on
   }
 
-
-
   /**
    * Tests that mapped PTA fails when no match attribute values are found.
    *
    * @throws Exception
    *           If an unexpected exception occurred.
    */
-  @Test(enabled = true)
+  @Test
   public void testMissingMappingAttributes() throws Exception
   {
     // Mock configuration.
@@ -3435,8 +3037,6 @@
     provider.assertAllExpectedEventsReceived();
   }
 
-
-
   /**
    * Tests that mapped PTA uses an appropriate filter when multiple match
    * attributes are defined.
@@ -3444,7 +3044,7 @@
    * @throws Exception
    *           If an unexpected exception occurred.
    */
-  @Test(enabled = true)
+  @Test
   public void testMultipleMappingAttributes() throws Exception
   {
     // Mock configuration.
@@ -3518,8 +3118,6 @@
     provider.assertAllExpectedEventsReceived();
   }
 
-
-
   /**
    * Tests that mapped PTA uses an appropriate filter when multiple match
    * attribute values are found.
@@ -3527,7 +3125,7 @@
    * @throws Exception
    *           If an unexpected exception occurred.
    */
-  @Test(enabled = true)
+  @Test
   public void testMultipleMappingAttributeValues() throws Exception
   {
     // Mock configuration.
@@ -3600,8 +3198,6 @@
     provider.assertAllExpectedEventsReceived();
   }
 
-
-
   /**
    * Tests that mapped PTA performs searches across multiple base DNs if
    * configured.
@@ -3609,7 +3205,7 @@
    * @throws Exception
    *           If an unexpected exception occurred.
    */
-  @Test(enabled = true)
+  @Test
   public void testMultipleSearchBaseDNs() throws Exception
   {
     // Mock configuration.
@@ -3675,8 +3271,6 @@
     provider.assertAllExpectedEventsReceived();
   }
 
-
-
   /**
    * Test for issue OPENDJ-292
    * (https://bugster.forgerock.org/jira/browse/OPENDJ-292). This test checks
@@ -3686,7 +3280,7 @@
    * @throws Exception
    *           If an unexpected exception occurred.
    */
-  @Test(enabled = true)
+  @Test
   public void testIssueOPENDJ292_1() throws Exception
   {
     // Mock configuration.
@@ -3754,8 +3348,6 @@
     provider.assertAllExpectedEventsReceived();
   }
 
-
-
   /**
    * Test for issue OPENDJ-292
    * (https://bugster.forgerock.org/jira/browse/OPENDJ-292). This test checks
@@ -3765,7 +3357,7 @@
    * @throws Exception
    *           If an unexpected exception occurred.
    */
-  @Test(enabled = true)
+  @Test
   public void testIssueOPENDJ292_2() throws Exception
   {
     // Mock configuration.
@@ -3873,8 +3465,6 @@
     provider.assertAllExpectedEventsReceived();
   }
 
-
-
   /**
    * Test for issue OPENDJ-294
    * (https://bugster.forgerock.org/jira/browse/OPENDJ-294). Password
@@ -3884,7 +3474,7 @@
    *           If an unexpected exception occurred.
    */
   @SuppressWarnings("unchecked")
-  @Test(enabled = true)
+  @Test
   public void testIssueOPENDJ294() throws Exception
   {
     // Mock configurations.
@@ -4007,8 +3597,6 @@
     provider.assertAllExpectedEventsReceived();
   }
 
-
-
   /**
    * Test for issue OPENDJ-290
    * (https://bugster.forgerock.org/jira/browse/OPENDJ-290).
@@ -4016,7 +3604,7 @@
    * @throws Exception
    *           If an unexpected exception occurred.
    */
-  @Test(enabled = true)
+  @Test
   public void testIssueOPENDJ290() throws Exception
   {
     // Mock configuration.
@@ -4095,8 +3683,6 @@
     provider.assertAllExpectedEventsReceived();
   }
 
-
-
   /**
    * Returns test data for {@link #testPasswordCaching}.
    *
@@ -4124,8 +3710,6 @@
     // @formatter:on
   }
 
-
-
   /**
    * Tests password caching functionality.
    *
@@ -4141,7 +3725,7 @@
    * @throws Exception
    *           If an unexpected exception occurred.
    */
-  @Test(enabled = true, dataProvider = "testPasswordCachingData")
+  @Test(dataProvider = "testPasswordCachingData")
   public void testPasswordCaching(String cacheState, boolean matchesCache,
       boolean matchesReal) throws Exception
   {
@@ -4310,23 +3894,17 @@
     provider.assertAllExpectedEventsReceived();
   }
 
-
-
   MockPolicyCfg mockCfg()
   {
     return new MockPolicyCfg();
   }
 
-
-
   MockServer mockServer() throws IOException
   {
     final ServerSocket serverSocket = TestCaseUtils.bindFreePort();
     return new MockServer(serverSocket);
   }
 
-
-
   BindRequestProtocolOp newBindRequest(final String dn, final String password)
       throws LDAPException
   {
@@ -4334,15 +3912,11 @@
         ByteString.valueOfUtf8(password));
   }
 
-
-
   BindResponseProtocolOp newBindResult(final ResultCode resultCode)
   {
     return new BindResponseProtocolOp(resultCode.intValue());
   }
 
-
-
   ExtendedResponseProtocolOp newDisconnectNotification(
       final ResultCode resultCode)
   {
@@ -4350,16 +3924,12 @@
         null, OID_NOTICE_OF_DISCONNECTION, null);
   }
 
-
-
   SearchResultEntryProtocolOp newSearchEntry(final String dn)
       throws DirectoryException
   {
     return new SearchResultEntryProtocolOp(DN.valueOf(dn));
   }
 
-
-
   SearchRequestProtocolOp newSearchRequest(final String dn,
       final String filter, final LDAPPassThroughAuthenticationPolicyCfg cfg)
       throws LDAPException
@@ -4371,8 +3941,6 @@
         LDAPPassThroughAuthenticationPolicyFactory.NO_ATTRIBUTES);
   }
 
-
-
   SearchResultDoneProtocolOp newSearchResult(final ResultCode resultCode)
   {
     return new SearchResultDoneProtocolOp(resultCode.intValue());
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/TopologyViewTest.java b/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/TopologyViewTest.java
index 1272b7a..baab6a7 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/TopologyViewTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/TopologyViewTest.java
@@ -1057,11 +1057,6 @@
       }
       return sb.toString();
     }
-
-    private TopologyViewTest getOuterType()
-    {
-      return TopologyViewTest.this;
-    }
   }
 
   private String getHostPort(int port)

--
Gitblit v1.10.0