From 9d1bd29ee527b598f0e91a9d02920eaacb3f767d Mon Sep 17 00:00:00 2001
From: Nicolas Capponi <nicolas.capponi@forgerock.com>
Date: Wed, 07 May 2014 09:27:48 +0000
Subject: [PATCH] OPENDJ-1388 – Implement simple changelog db based on single log file

---
 opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ReplicationTestCase.java |   28 ++++++++++++++++++++++++----
 1 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ReplicationTestCase.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ReplicationTestCase.java
index 2be604a..64dedee 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ReplicationTestCase.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ReplicationTestCase.java
@@ -35,6 +35,7 @@
 import org.opends.messages.Severity;
 import org.opends.server.DirectoryServerTestCase;
 import org.opends.server.TestCaseUtils;
+import org.opends.server.admin.std.meta.ReplicationServerCfgDefn.ReplicationDBImplementation;
 import org.opends.server.admin.std.server.ReplicationDomainCfg;
 import org.opends.server.backends.task.TaskState;
 import org.opends.server.config.ConfigException;
@@ -50,6 +51,7 @@
 import org.opends.server.replication.protocol.ReplicationMsg;
 import org.opends.server.replication.protocol.Session;
 import org.opends.server.replication.server.ReplicationServer;
+import org.opends.server.replication.server.changelog.file.FileChangelogDB;
 import org.opends.server.replication.server.changelog.je.JEChangelogDB;
 import org.opends.server.replication.service.ReplicationBroker;
 import org.opends.server.schema.IntegerSyntax;
@@ -105,6 +107,11 @@
   protected Entry synchroServerEntry;
   protected Entry replServerEntry;
 
+  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.LOG.name()));
+
   /**
    * Replication monitor stats
    */
@@ -181,7 +188,9 @@
       LDAPReplicationDomain replDomain = LDAPReplicationDomain.retrievesReplicationDomain(baseDN);
       genId = replDomain.getGenerationID();
     }
-    catch(Exception e) {}
+    catch(Exception e) {
+      TRACER.debugCaught(DebugLogLevel.ERROR, e);
+    }
     return genId;
   }
 
@@ -317,8 +326,7 @@
   @AfterClass
   public void classCleanUp() throws Exception
   {
-    logError(Message.raw(Category.SYNC, Severity.NOTICE,
-      " ##### Calling ReplicationTestCase.classCleanUp ##### "));
+    logError(Message.raw(Category.SYNC, Severity.NOTICE, " ##### Calling ReplicationTestCase.classCleanUp ##### "));
 
     removeReplicationServerDB();
 
@@ -365,7 +373,14 @@
 
   protected void clearChangelogDB(ReplicationServer rs) throws Exception
   {
-    ((JEChangelogDB) rs.getChangelogDB()).clearDB();
+    if (replicationDbImplementation == ReplicationDBImplementation.JE)
+    {
+      ((JEChangelogDB) rs.getChangelogDB()).clearDB();
+    }
+    else
+    {
+      ((FileChangelogDB) rs.getChangelogDB()).clearDB();
+    }
   }
 
   /**
@@ -926,4 +941,9 @@
         + " Also received the following messages during wait time: " + msgs);
     return null;
   }
+
+  protected static void setReplicationDBImplementation(ReplicationDBImplementation impl)
+  {
+    replicationDbImplementation = impl;
+  }
 }

--
Gitblit v1.10.0