From c81b6e844adb1b3fe1337d5670e5280793ce6d69 Mon Sep 17 00:00:00 2001
From: Ludovic Poitou <ludovic.poitou@forgerock.com>
Date: Tue, 08 Jul 2014 16:03:55 +0000
Subject: [PATCH] Improve unit-tests to easy troubleshooting.

---
 opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/monitors/InternalSearchMonitorTestCase.java |   18 +++++++++++-------
 opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/GenerationIdTest.java           |   15 ++++++++-------
 2 files changed, 19 insertions(+), 14 deletions(-)

diff --git a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/monitors/InternalSearchMonitorTestCase.java b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/monitors/InternalSearchMonitorTestCase.java
index 556e4db..0cb90e4 100644
--- a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/monitors/InternalSearchMonitorTestCase.java
+++ b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/monitors/InternalSearchMonitorTestCase.java
@@ -78,7 +78,8 @@
   {
     InternalSearchOperation op = getRootConnection().processSearch(
         "cn=monitor", WHOLE_SUBTREE, "(objectClass=*)");
-    assertEquals(op.getResultCode(), ResultCode.SUCCESS);
+    assertEquals(op.getResultCode(), ResultCode.SUCCESS,
+        "Failed to search cn=monitor subtree. Got error message: " + op.getErrorMessage());
   }
 
 
@@ -116,7 +117,8 @@
     final String monitorDN = "cn="+monitorName+",cn=monitor";
     InternalSearchOperation op = getRootConnection().processSearch(
         monitorDN, BASE_OBJECT, "(objectClass=*)");
-    assertEquals(op.getResultCode(), ResultCode.SUCCESS);
+    assertEquals(op.getResultCode(), ResultCode.SUCCESS,
+        "Failed to read " + monitorDN + " entry. Got error message: " + op.getErrorMessage());
   }
 
   /**
@@ -128,15 +130,17 @@
   public void testWithSubtreeAndBaseMonitorSearch() throws Exception
   {
     final InternalClientConnection conn = getRootConnection();
-    InternalSearchOperation searchOperation = conn.processSearch(
+    InternalSearchOperation op = conn.processSearch(
         "cn=monitor", WHOLE_SUBTREE, "(objectClass=*)");
-    assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS);
+    assertEquals(op.getResultCode(), ResultCode.SUCCESS,
+        "Failed to search cn=monitor subtree. Got error message: " + op.getErrorMessage());
 
-    for (SearchResultEntry sre : searchOperation.getSearchEntries())
+    for (SearchResultEntry sre : op.getSearchEntries())
     {
-      final InternalSearchOperation op = conn.processSearch(
+      final InternalSearchOperation readOp = conn.processSearch(
           sre.getDN(), BASE_OBJECT, createFilterFromString("(objectClass=*)"));
-      assertEquals(op.getResultCode(), ResultCode.SUCCESS);
+      assertEquals(readOp.getResultCode(), ResultCode.SUCCESS,
+          "Failed to read " + sre.getDN() + " entry. Got error message: " + readOp.getErrorMessage());
     }
   }
 
diff --git a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/GenerationIdTest.java b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/GenerationIdTest.java
index 04f6975..38ec231 100644
--- a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/GenerationIdTest.java
+++ b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/GenerationIdTest.java
@@ -81,12 +81,12 @@
   private static final String REPLICATION_GENERATION_ID = "ds-sync-generation-id";
 
   private static final int WINDOW_SIZE = 10;
-  private static final int server1ID = 1;
-  private static final int server2ID = 2;
-  private static final int server3ID = 3;
-  private static final int replServerId1 = 11;
-  private static final int replServerId2 = 12;
-  private static final int replServerId3 = 13;
+  private static final int server1ID = 901;
+  private static final int server2ID = 902;
+  private static final int server3ID = 903;
+  private static final int replServerId1 = 911;
+  private static final int replServerId2 = 912;
+  private static final int replServerId3 = 913;
 
   private DN baseDN;
   private ReplicationBroker broker2;
@@ -450,7 +450,7 @@
 
   private int getRSPort(int replServerId) throws Exception
   {
-    return replServerPort[replServerId - 11];
+    return replServerPort[replServerId - replServerId1];
   }
 
   private long readGenIdFromSuffixRootEntry() throws Exception
@@ -1139,6 +1139,7 @@
     {
       stop(broker);
       postTest();
+      debugInfo("Successfully ending " + testCase);
     }
   }
 

--
Gitblit v1.10.0