From 5d650a123e46c0c86fe3e440fc9dbf04cd831fc9 Mon Sep 17 00:00:00 2001
From: Ludovic Poitou <ludovic.poitou@forgerock.com>
Date: Wed, 15 Jun 2011 15:51:32 +0000
Subject: [PATCH] Tidy up unit-tests so that not all backends are always enabled, and replication related databases are deleted after tests.

---
 opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ReplicationTestCase.java |   38 +++++++++++++++-----------------------
 1 files changed, 15 insertions(+), 23 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 9e46222..5607e71 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
@@ -23,6 +23,7 @@
  *
  *
  *      Copyright 2006-2010 Sun Microsystems, Inc.
+ *      Portions Copyright 2011 ForgeRock AS
  */
 package org.opends.server.replication;
 
@@ -88,6 +89,7 @@
 import org.opends.server.types.SearchFilter;
 import org.opends.server.types.SearchResultEntry;
 import org.opends.server.types.SearchScope;
+import org.opends.server.util.StaticUtils;
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
@@ -483,6 +485,8 @@
     // Clean RS databases
     cleanUpReplicationServersDB();
 
+    removeReplicationServerDB();
+    
     cleanConfigEntries();
     configEntryList = new LinkedList<DN>();
 
@@ -493,29 +497,6 @@
     // (in case our test created some emtries in it)
     TestCaseUtils.initializeTestBackend(true);
 
-    // Clean the default DB dir for replication server
-    String buildRoot = System.getProperty(TestCaseUtils.PROPERTY_BUILD_ROOT);
-    String rsDbDirPath = buildRoot + File.separator + "build" +
-                  File.separator + "unit-tests" + File.separator +
-                  "package-instance"+ File.separator + "changelogDb";
-
-    File rsDbDir = new File(rsDbDirPath);
-    if (rsDbDir != null)
-    {
-      File[] dbFiles = rsDbDir.listFiles();
-      if (dbFiles != null)
-      {
-        for (File dbFile : dbFiles)
-        {
-          if (dbFile != null)
-            TRACER.debugInfo("ReplicationTestCase: classCleanUp: deleting " + dbFile);
-            dbFile.delete();
-        }
-      }
-      TRACER.debugInfo("ReplicationTestCase: classCleanUp: deleting " + rsDbDir);
-      rsDbDir.delete();
-    }
-
     // Check for unexpected replication config/objects left
     if (callParanoiaCheck)
       paranoiaCheck();
@@ -571,6 +552,17 @@
   }
 
   /**
+   * Remove trailing directories and databases of the currently instantiated
+   * replication servers.
+   */
+  protected void removeReplicationServerDB() {
+    for (ReplicationServer rs : ReplicationServer.getAllInstances()) {
+      StaticUtils.recursiveDelete(new File(DirectoryServer.getInstanceRoot(),
+               rs.getDbDirName()));      
+    }
+  }
+  
+  /**
    * Performs a search on the config backend with the specified filter.
    * Fails if a config entry is found.
    * @param filter The filter to apply for the search

--
Gitblit v1.10.0