From b9fd53230703d3d4f135f27e4fd1597a220c906e Mon Sep 17 00:00:00 2001
From: Nicolas Capponi <nicolas.capponi@forgerock.com>
Date: Tue, 23 Sep 2014 14:23:42 +0000
Subject: [PATCH] Launch tests with file-based changelog by default

---
 opendj3-server-dev/build.xml                                                                                 |    4 ++--
 opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/ReplicationTestCase.java |   36 +++++++++++++++++++++++++++++++++++-
 2 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/opendj3-server-dev/build.xml b/opendj3-server-dev/build.xml
index b72a5ff..6e308a1 100644
--- a/opendj3-server-dev/build.xml
+++ b/opendj3-server-dev/build.xml
@@ -2209,7 +2209,7 @@
     <echo message="      Value must be one of: JE, LOG." />
     <echo message="      JE: use berkeley DB JE as implementation." />
     <echo message="      LOG: use log file as implementation." />
-    <echo message="      Default value is JE" />
+    <echo message="      Default value is LOG" />
     <echo message=""/>
     <echo message="  -Dtest.diff.srcpath=src/server/org/opends/server/core"/>
     <echo message="      for example includes only the classes in"/>
@@ -2290,7 +2290,7 @@
 
     <!-- This sets org.opends.test.replicationDbImpl if and only if it's not
          already set. -->
-    <condition property="org.opends.test.replicationDbImpl" value="JE">
+    <condition property="org.opends.test.replicationDbImpl" value="LOG">
       <not>
         <isset property="org.opends.test.replicationDbImpl" />
       </not>
diff --git a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/ReplicationTestCase.java b/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/ReplicationTestCase.java
index ca91217..6bd4d99 100644
--- a/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/ReplicationTestCase.java
+++ b/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/replication/ReplicationTestCase.java
@@ -34,6 +34,7 @@
 import org.forgerock.i18n.slf4j.LocalizedLogger;
 import org.forgerock.opendj.config.server.ConfigException;
 import org.forgerock.opendj.ldap.ByteString;
+import org.forgerock.opendj.ldap.DereferenceAliasesPolicy;
 import org.forgerock.opendj.ldap.ModificationType;
 import org.forgerock.opendj.ldap.ResultCode;
 import org.forgerock.opendj.ldap.SearchScope;
@@ -46,6 +47,7 @@
 import org.opends.server.core.DeleteOperation;
 import org.opends.server.core.DirectoryServer;
 import org.opends.server.protocols.internal.InternalClientConnection;
+import org.opends.server.protocols.internal.InternalSearchListener;
 import org.opends.server.protocols.internal.InternalSearchOperation;
 import org.opends.server.replication.common.ServerState;
 import org.opends.server.replication.plugin.*;
@@ -78,6 +80,9 @@
   /** The tracer object for the debug logger */
   private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
 
+  private static final Set<String> ALL_ATTRIBUTES = newSet("*", "+");
+  private static final List<Control> NO_CONTROL = null;
+
   /**
    * This is the generation id matching the memory test backend with its initial
    * root entry o=test created. This matches the backend obtained calling:
@@ -108,7 +113,7 @@
   private static final String REPLICATION_DB_IMPL_PROPERTY = "org.opends.test.replicationDbImpl";
 
   public static ReplicationDBImplementation replicationDbImplementation = ReplicationDBImplementation.valueOf(
-      System.getProperty(REPLICATION_DB_IMPL_PROPERTY, ReplicationDBImplementation.JE.name()));
+      System.getProperty(REPLICATION_DB_IMPL_PROPERTY, ReplicationDBImplementation.LOG.name()));
 
   /**
    * Replication monitor stats
@@ -931,6 +936,35 @@
     return null;
   }
 
+  /**
+   * Performs an internal search, waiting for at most 3 seconds for expected result code and expected
+   * number of entries. 
+   */
+  protected InternalSearchOperation waitForSearchResult(String dn, SearchScope scope, String filter,
+      ResultCode expectedResultCode, int expectedNbEntries) throws Exception
+  {
+    InternalSearchOperation searchOp = null;
+    int sizeLimitZero = 0;
+    int timeLimitZero = 0;
+    boolean typesOnlyFalse = false;
+    InternalSearchListener noSearchListener = null;
+    int count = 0;
+    do
+    {
+      Thread.sleep(10);
+      searchOp = connection.processSearch(dn, scope, DereferenceAliasesPolicy.NEVER, sizeLimitZero,
+          timeLimitZero, typesOnlyFalse, filter, ALL_ATTRIBUTES, NO_CONTROL, noSearchListener);
+      count++;
+      System.out.println(searchOp.getResultCode() + " " + searchOp.getSearchEntries().size());
+    }
+    while (count < 300 && searchOp.getResultCode() != expectedResultCode &&
+        searchOp.getSearchEntries().size() != expectedNbEntries);
+
+    final List<SearchResultEntry> entries = searchOp.getSearchEntries();
+    Assertions.assertThat(entries).hasSize(expectedNbEntries);
+    return searchOp;
+  }
+
   protected static void setReplicationDBImplementation(ReplicationDBImplementation impl)
   {
     replicationDbImplementation = impl;

--
Gitblit v1.10.0