From 74d6a0e420eaf417329ecbc280d88f4ad0d82a35 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Mon, 17 Aug 2015 11:55:34 +0000
Subject: [PATCH] ChangelogBackendTestCase.java: In assertChangelogAttributesInRootDSE(), removed always true parameter "isECLEnabled".

---
 opendj-server-legacy/src/test/java/org/opends/server/backends/ChangelogBackendTestCase.java |   37 ++++++------------
 opendj-server-legacy/src/test/java/org/opends/server/replication/ReplicationTestCase.java   |   76 ++++++++++---------------------------
 2 files changed, 33 insertions(+), 80 deletions(-)

diff --git a/opendj-server-legacy/src/test/java/org/opends/server/backends/ChangelogBackendTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/backends/ChangelogBackendTestCase.java
index c2fea3b..48af749 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/backends/ChangelogBackendTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/backends/ChangelogBackendTestCase.java
@@ -141,8 +141,8 @@
 
   /** The port of the replicationServer. */
   private int replicationServerPort;
-  private List<LDAPReplicationDomain> domains = new ArrayList<>();
-  private Map<ReplicaId, ReplicationBroker> brokers = new HashMap<>();
+  private final List<LDAPReplicationDomain> domains = new ArrayList<>();
+  private final Map<ReplicaId, ReplicationBroker> brokers = new HashMap<>();
 
   @BeforeClass
   @Override
@@ -276,7 +276,7 @@
         csns[3], cookies[3]);
     assertResultsContainCookieControl(searchOp, cookies);
 
-    assertChangelogAttributesInRootDSE(true, 1, 4);
+    assertChangelogAttributesInRootDSE(1, 4);
 
     debugInfo(test, "Ending search with success");
   }
@@ -573,7 +573,7 @@
     CSN[] csns = generateAndPublishUpdateMsgForEachOperationType(testName, false);
     searchChangesForEachOperationTypeUsingChangeNumberMode(firstChangeNumber, csns, testName);
 
-    assertChangelogAttributesInRootDSE(true, 1, 4);
+    assertChangelogAttributesInRootDSE(1, 4);
 
     debugInfo(testName, "Ending search with success");
   }
@@ -600,8 +600,7 @@
     // search from a provided change number interval: 5-7
     searchChangelogFromToChangeNumber(5,7);
 
-    // check first and last change number
-    assertChangelogAttributesInRootDSE(true, 1, 8);
+    assertChangelogAttributesInRootDSE(1, 8);
 
     // add a new change, then check again first and last change number without previous search
     testName = "Multiple/9";
@@ -609,7 +608,7 @@
     CSN csn = new CSN(lastCsn.getTime() + 1, 9, SERVER_ID_1);
     publishUpdateMessagesInOTest(testName, false, generateDeleteMsg(DN_OTEST, csn, testName, 1));
 
-    assertChangelogAttributesInRootDSE(true, 1, 9);
+    assertChangelogAttributesInRootDSE(1, 9);
   }
 
   /** Verifies that is not possible to read the changelog without the changelog-read privilege. */
@@ -846,7 +845,7 @@
     assertChangeNumberRange(range, -1, -1);
   }
 
-  private List<SearchResultEntry> assertChangelogAttributesInRootDSE(boolean isECLEnabled,
+  private List<SearchResultEntry> assertChangelogAttributesInRootDSE(
       int expectedFirstChangeNumber, int expectedLastChangeNumber) throws Exception
   {
     AssertionError error = null;
@@ -868,25 +867,13 @@
         assertThat(entries).hasSize(1);
 
         final SearchResultEntry entry = entries.get(0);
-        if (isECLEnabled)
+        if (expectedFirstChangeNumber > 0)
         {
-          if (expectedFirstChangeNumber > 0)
-          {
-            assertAttributeValue(entry, "firstchangenumber", expectedFirstChangeNumber);
-          }
-          assertAttributeValue(entry, "lastchangenumber", expectedLastChangeNumber);
-          assertAttributeValue(entry, "changelog", "cn=changelog");
-          assertNotNull(getAttributeValue(entry, "lastExternalChangelogCookie"));
+          assertAttributeValue(entry, "firstchangenumber", expectedFirstChangeNumber);
         }
-        else
-        {
-          if (expectedFirstChangeNumber > 0) {
-            assertNull(getAttributeValue(entry, "firstchangenumber"));
-          }
-          assertNull(getAttributeValue(entry, "lastchangenumber"));
-          assertNull(getAttributeValue(entry, "changelog"));
-          assertNull(getAttributeValue(entry, "lastExternalChangelogCookie"));
-        }
+        assertAttributeValue(entry, "lastchangenumber", expectedLastChangeNumber);
+        assertAttributeValue(entry, "changelog", "cn=changelog");
+        assertNotNull(getAttributeValue(entry, "lastExternalChangelogCookie"));
         return entries;
       }
       catch (AssertionError ae)
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/replication/ReplicationTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/replication/ReplicationTestCase.java
index 7ddabbc..c95e530 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/replication/ReplicationTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/replication/ReplicationTestCase.java
@@ -82,9 +82,7 @@
 import static org.opends.server.util.CollectionUtils.*;
 import static org.testng.Assert.*;
 
-/**
- * An abstract class that all Replication unit test should extend.
- */
+/** An abstract class that all Replication unit test should extend. */
 @SuppressWarnings("javadoc")
 @Test(groups = { "precommit", "replication" }, sequential = true)
 public abstract class ReplicationTestCase extends DirectoryServerTestCase
@@ -101,14 +99,10 @@
    */
   protected static final long TEST_DN_WITH_ROOT_ENTRY_GENID = 5055L;
 
-  /**
-   * Generation id for a fully empty domain.
-   */
+  /** Generation id for a fully empty domain. */
   public static final long EMPTY_DN_GENID = GenerationIdChecksum.EMPTY_BACKEND_GENERATION_ID;
 
-  /**
-   * The internal connection used for operation.
-   */
+  /** The internal connection used for operation. */
   protected InternalClientConnection connection;
 
   /** Created entries that will be deleted on class cleanup. */
@@ -125,9 +119,7 @@
   public static ReplicationDBImplementation replicationDbImplementation = ReplicationDBImplementation.valueOf(
       System.getProperty(REPLICATION_DB_IMPL_PROPERTY, ReplicationDBImplementation.LOG.name()));
 
-  /**
-   * Replication monitor stats.
-   */
+  /** Replication monitor stats. */
   private DN monitorDN;
   private String monitorAttr;
   private long lastCount;
@@ -157,15 +149,11 @@
    */
   protected boolean callParanoiaCheck = true;
 
-  /**
-   * The replication plugin entry.
-   */
+  /** The replication plugin entry. */
   protected static final String SYNCHRO_PLUGIN_DN =
     "cn=Multimaster Synchronization, cn=Synchronization Providers,cn=config";
 
-  /**
-   * Set up the environment for performing the tests in this suite.
-   */
+  /** Set up the environment for performing the tests in this suite. */
   @BeforeClass
   public void setUp() throws Exception
   {
@@ -200,10 +188,11 @@
     }
     catch(Exception e) {
       logger.traceException(e);
+
+      // This is the value of the generationId computed by the server when the
+      // test suffix (o=test) has only the root entry created.
+      return TEST_DN_WITH_ROOT_ENTRY_GENID;
     }
-    // This is the value of the generationId computed by the server when the
-    // test suffix (o=test) has only the root entry created.
-    return TEST_DN_WITH_ROOT_ENTRY_GENID;
   }
 
   /**
@@ -218,10 +207,7 @@
         port, timeout, getGenerationId(baseDN));
   }
 
-  /**
-   * Open a replicationServer session to the local ReplicationServer
-   * providing the generationId.
-   */
+  /** Open a replicationServer session to the local ReplicationServer providing the generationId. */
   protected ReplicationBroker openReplicationSession(final DN baseDN,
       int serverId, int windowSize, int port, int timeout,
       long generationId) throws Exception
@@ -293,7 +279,7 @@
 
   protected void deleteEntry(DN dn) throws Exception
   {
-    if (dn.parent().rdn().toString().equalsIgnoreCase("cn=domains"))
+    if ("cn=domains".equalsIgnoreCase(dn.parent().rdn().toString()))
     {
       deleteEntry(DN.valueOf("cn=external changelog," + dn));
     }
@@ -303,9 +289,7 @@
         "Delete entry " + dn + " failed: " + op.getResultCode());
   }
 
-  /**
-   * Suppress all the config entries created by the tests in this class.
-   */
+  /** Suppress all the config entries created by the tests in this class. */
   protected void cleanConfigEntries() throws Exception
   {
     logger.error(LocalizableMessage.raw("ReplicationTestCase/Cleaning config entries"));
@@ -320,9 +304,7 @@
     replServerEntry = null;
   }
 
-  /**
-   * Suppress all the real entries created by the tests in this class.
-   */
+  /** Suppress all the real entries created by the tests in this class. */
   protected void cleanRealEntries() throws Exception
   {
     logger.error(LocalizableMessage.raw("ReplicationTestCase/Cleaning entries"));
@@ -400,10 +382,7 @@
     }
   }
 
-  /**
-   * Cleanup databases of the currently instantiated replication servers in the
-   * VM.
-   */
+  /** Cleanup databases of the currently instantiated replication servers in the VM. */
   protected void cleanUpReplicationServersDB() throws Exception
   {
     for (ReplicationServer rs : ReplicationServer.getAllInstances())
@@ -412,10 +391,7 @@
     }
   }
 
-  /**
-   * Remove trailing directories and databases of the currently instantiated
-   * replication servers.
-   */
+  /** Remove trailing directories and databases of the currently instantiated replication servers. */
   protected void removeReplicationServerDB() throws Exception
   {
     // avoid ConcurrentModificationException
@@ -476,9 +452,7 @@
     assertEquals(entries.size(), 0, errorMsg + ":\n" + sb);
   }
 
-  /**
-   * Configure the replication for this test.
-   */
+  /** Configure the replication for this test. */
   protected void configureReplication(String replServerEntryLdif,
       String synchroServerEntryLdif) throws Exception
   {
@@ -595,9 +569,7 @@
     return null;
   }
 
-  /**
-   * Update the monitor count for the specified monitor attribute.
-   */
+  /** Update the monitor count for the specified monitor attribute. */
   protected void updateMonitorCount(DN baseDN, String attr) throws Exception
   {
     monitorDN = baseDN;
@@ -634,9 +606,7 @@
     return mods;
   }
 
-  /**
-   * Utility method to create, run a task and check its result.
-   */
+  /** Utility method to create, run a task and check its result. */
   protected void task(String task) throws Exception
   {
     Entry taskEntry = TestCaseUtils.addEntry(task);
@@ -794,9 +764,7 @@
     }
   }
 
-  /**
-   * Add to the current DB the entries necessary to the test.
-   */
+  /** Add to the current DB the entries necessary to the test. */
   protected void addTestEntriesToDB(String... ldifEntries) throws Exception
   {
     for (String ldifEntry : ldifEntries)
@@ -845,9 +813,7 @@
     return found;
   }
 
-  /**
-   * Utility method : removes a domain deleting the passed config entry
-   */
+  /** Utility method : removes a domain deleting the passed config entry */
   protected void removeDomain(Entry... domainCfgEntries) throws Exception
   {
     for (Entry entry : domainCfgEntries)

--
Gitblit v1.10.0