From f73b655466092169abac34833fb628fce1fcdebe Mon Sep 17 00:00:00 2001
From: jcduff <jcduff@localhost>
Date: Thu, 23 Oct 2008 14:04:24 +0000
Subject: [PATCH] The commit will bring the following features :     - An updated version of the underlying database. BDB JE 3.3 is now used.     - Attribute API refactoring providing a better abstraction and offering improved performances.     - A new GUI called the Control-Panel to replace the Status-Panel: the specifications for this       GUI are available on OpenDS Wiki and contains a link to a mockup.        See <https://www.opends.org/wiki/page/ControlPanelUISpecification>.     - Some changes in the replication protocol to implement "Assured Replication Mode". The        specifications are on OpenDS Wiki at <https://www.opends.org/wiki/page/AssuredMode> and section 7       described some of the replication changes required to support this. Assured Replication is not finished,       but the main replication protocol changes to support it are done. As explained by Gilles on an email on       the Dev mailing list (http://markmail.org/message/46rgo3meq3vriy4a), with these changes the newer versions       of OpenDS may not be able to replicate with OpenDS 1.0 instances.     - Support for Service Tags on the platforms where the functionality is available and enabled. Specifications       are published at <https://www.opends.org/wiki/page/OpenDSServiceTagEnabled>. For more information on       Service Tags see <http://wikis.sun.com/display/ServiceTag/Sun+Service+Tag+FAQ>.     - The Admin Connector service. In order to provide agentry of the OpenDS server at any time, a new service       has been added, dedicated to the administration, configuration and monitoring of the server.       An overview of the Admin Connector service and it's use is available on the       OpenDS wiki <https://www.opends.org/wiki/page/ManagingAdministrationTrafficToTheServer>     - Updates to the various command line tools to support the Admin Connector service.     - Some internal re-architecting of the server to put the foundation of future developments such as virtual       directory services. The new NetworkGroups and WorkFlow internal services which have been specified in       <https://www.opends.org/wiki/page/BasicOperationRoutingThroughNetworkGroup> are now implemented.     - Many bug fixes...

---
 opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/DbHandlerTest.java |  266 +++++++++++++++++++++++++++++------------------------
 1 files changed, 146 insertions(+), 120 deletions(-)

diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/DbHandlerTest.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/DbHandlerTest.java
index 05ceca0..6861761 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/DbHandlerTest.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/DbHandlerTest.java
@@ -37,6 +37,7 @@
 import org.opends.server.types.DN;
 import org.testng.annotations.Test;
 import static org.testng.Assert.*;
+import static org.opends.server.TestCaseUtils.*;
 
 /**
  * Test the dbHandler class
@@ -46,77 +47,89 @@
   @Test()
   void testDbHandlerTrim() throws Exception
   {
-    TestCaseUtils.startServer();
-
-    //  find  a free port for the replicationServer
-    ServerSocket socket = TestCaseUtils.bindFreePort();
-    int changelogPort = socket.getLocalPort();
-    socket.close();
-
-    // configure a ReplicationServer.
-    ReplServerFakeConfiguration conf =
-      new ReplServerFakeConfiguration(changelogPort, null, 0,
-                                     2, 0, 100, null);
-    ReplicationServer replicationServer = new ReplicationServer(conf);
-
-    // create or clean a directory for the dbHandler
-    String buildRoot = System.getProperty(TestCaseUtils.PROPERTY_BUILD_ROOT);
-    String path = buildRoot + File.separator + "build" + File.separator +
-                  "unit-tests" + File.separator + "dbHandler";
-    File testRoot = new File(path);
-    if (testRoot.exists())
+    File testRoot = null;
+    ReplicationServer replicationServer = null;
+    ReplicationDbEnv dbEnv = null;
+    DbHandler handler = null;
+    try
     {
-      TestCaseUtils.deleteDirectory(testRoot);
-    }
-    testRoot.mkdirs();
+      TestCaseUtils.startServer();
 
-    ReplicationDbEnv dbEnv = new ReplicationDbEnv(path, replicationServer);
+      //  find  a free port for the replicationServer
+      ServerSocket socket = TestCaseUtils.bindFreePort();
+      int changelogPort = socket.getLocalPort();
+      socket.close();
 
-    DbHandler handler =
-      new DbHandler(
-          (short) 1, DN.decode("o=test"), replicationServer, dbEnv, 5000);
+      // configure a ReplicationServer.
+      ReplServerFakeConfiguration conf =
+        new ReplServerFakeConfiguration(changelogPort, null, 0,
+        2, 0, 100, null);
+      replicationServer = new ReplicationServer(conf);
 
-    ChangeNumberGenerator gen = new ChangeNumberGenerator((short)1, 0);
-    ChangeNumber changeNumber1 = gen.newChangeNumber();
-    ChangeNumber changeNumber2 = gen.newChangeNumber();
-    ChangeNumber changeNumber3 = gen.newChangeNumber();
+      // create or clean a directory for the dbHandler
+      String buildRoot = System.getProperty(TestCaseUtils.PROPERTY_BUILD_ROOT);
+      String path = buildRoot + File.separator + "build" + File.separator +
+        "unit-tests" + File.separator + "dbHandler";
+      testRoot = new File(path);
+      if (testRoot.exists())
+      {
+        TestCaseUtils.deleteDirectory(testRoot);
+      }
+      testRoot.mkdirs();
 
-    DeleteMsg update1 = new DeleteMsg("o=test", changeNumber1, "uid");
-    DeleteMsg update2 = new DeleteMsg("o=test", changeNumber2, "uid");
-    DeleteMsg update3 = new DeleteMsg("o=test", changeNumber3, "uid");
+      dbEnv = new ReplicationDbEnv(path, replicationServer);
 
-    handler.add(update1);
-    handler.add(update2);
-    handler.add(update3);
+      handler = new DbHandler((short) 1, DN.decode(TEST_ROOT_DN_STRING),
+        replicationServer, dbEnv, 5000);
 
-    // The ChangeNumber should not get purged
-    assertEquals(changeNumber1, handler.getFirstChange());
-    assertEquals(changeNumber3, handler.getLastChange());
+      ChangeNumberGenerator gen = new ChangeNumberGenerator((short) 1, 0);
+      ChangeNumber changeNumber1 = gen.newChangeNumber();
+      ChangeNumber changeNumber2 = gen.newChangeNumber();
+      ChangeNumber changeNumber3 = gen.newChangeNumber();
 
-    handler.setPurgeDelay(1);
+      DeleteMsg update1 = new DeleteMsg(TEST_ROOT_DN_STRING, changeNumber1,
+        "uid");
+      DeleteMsg update2 = new DeleteMsg(TEST_ROOT_DN_STRING, changeNumber2,
+        "uid");
+      DeleteMsg update3 = new DeleteMsg(TEST_ROOT_DN_STRING, changeNumber3,
+        "uid");
 
-    boolean purged = false;
-    int count = 300;  // wait at most 60 seconds
-    while (!purged && (count>0))
-    {
-      ChangeNumber firstChange = handler.getFirstChange();
-      ChangeNumber lastChange = handler.getLastChange();
-      if ((!firstChange.equals(changeNumber3) ||
+      handler.add(update1);
+      handler.add(update2);
+      handler.add(update3);
+
+      // The ChangeNumber should not get purged
+      assertEquals(changeNumber1, handler.getFirstChange());
+      assertEquals(changeNumber3, handler.getLastChange());
+
+      handler.setPurgeDelay(1);
+
+      boolean purged = false;
+      int count = 300;  // wait at most 60 seconds
+      while (!purged && (count > 0))
+      {
+        ChangeNumber firstChange = handler.getFirstChange();
+        ChangeNumber lastChange = handler.getLastChange();
+        if ((!firstChange.equals(changeNumber3) ||
           (!lastChange.equals(changeNumber3))))
-      {
-        TestCaseUtils.sleep(100);
+        {
+          TestCaseUtils.sleep(100);
+        } else
+        {
+          purged = true;
+        }
       }
-      else
-      {
-        purged = true;
-      }
+    } finally
+    {
+      if (handler != null)
+        handler.shutdown();
+      if (dbEnv != null)
+        dbEnv.shutdown();
+      if (replicationServer != null)
+      replicationServer.remove();
+      if (testRoot != null)
+        TestCaseUtils.deleteDirectory(testRoot);
     }
-
-    handler.shutdown();
-    dbEnv.shutdown();
-    replicationServer.shutdown();
-
-    TestCaseUtils.deleteDirectory(testRoot);
   }
 
   /*
@@ -127,68 +140,81 @@
   @Test()
   void testDbHandlerClear() throws Exception
   {
-    TestCaseUtils.startServer();
-
-    //  find  a free port for the replicationServer
-    ServerSocket socket = TestCaseUtils.bindFreePort();
-    int changelogPort = socket.getLocalPort();
-    socket.close();
-
-    // configure a ReplicationServer.
-    ReplServerFakeConfiguration conf =
-      new ReplServerFakeConfiguration(changelogPort, null, 0,
-                                     2, 0, 100, null);
-    ReplicationServer replicationServer = new ReplicationServer(conf);
-
-    // create or clean a directory for the dbHandler
-    String buildRoot = System.getProperty(TestCaseUtils.PROPERTY_BUILD_ROOT);
-    String path = buildRoot + File.separator + "build" + File.separator +
-                  "unit-tests" + File.separator + "dbHandler";
-    File testRoot = new File(path);
-    if (testRoot.exists())
+    File testRoot = null;
+    ReplicationServer replicationServer = null;
+    ReplicationDbEnv dbEnv = null;
+    DbHandler handler = null;
+    try
     {
-      TestCaseUtils.deleteDirectory(testRoot);
+      TestCaseUtils.startServer();
+
+      //  find  a free port for the replicationServer
+      ServerSocket socket = TestCaseUtils.bindFreePort();
+      int changelogPort = socket.getLocalPort();
+      socket.close();
+
+      // configure a ReplicationServer.
+      ReplServerFakeConfiguration conf =
+        new ReplServerFakeConfiguration(changelogPort, null, 0,
+        2, 0, 100, null);
+      replicationServer = new ReplicationServer(conf);
+
+      // create or clean a directory for the dbHandler
+      String buildRoot = System.getProperty(TestCaseUtils.PROPERTY_BUILD_ROOT);
+      String path = buildRoot + File.separator + "build" + File.separator +
+        "unit-tests" + File.separator + "dbHandler";
+      testRoot = new File(path);
+      if (testRoot.exists())
+      {
+        TestCaseUtils.deleteDirectory(testRoot);
+      }
+      testRoot.mkdirs();
+
+      dbEnv = new ReplicationDbEnv(path, replicationServer);
+
+      handler =
+        new DbHandler((short) 1, DN.decode(TEST_ROOT_DN_STRING),
+        replicationServer, dbEnv, 5000);
+
+      // Creates changes added to the dbHandler
+      ChangeNumberGenerator gen = new ChangeNumberGenerator((short) 1, 0);
+      ChangeNumber changeNumber1 = gen.newChangeNumber();
+      ChangeNumber changeNumber2 = gen.newChangeNumber();
+      ChangeNumber changeNumber3 = gen.newChangeNumber();
+
+      DeleteMsg update1 = new DeleteMsg(TEST_ROOT_DN_STRING, changeNumber1,
+        "uid");
+      DeleteMsg update2 = new DeleteMsg(TEST_ROOT_DN_STRING, changeNumber2,
+        "uid");
+      DeleteMsg update3 = new DeleteMsg(TEST_ROOT_DN_STRING, changeNumber3,
+        "uid");
+
+      // Add the changes
+      handler.add(update1);
+      handler.add(update2);
+      handler.add(update3);
+
+      // Check they are here
+      assertEquals(changeNumber1, handler.getFirstChange());
+      assertEquals(changeNumber3, handler.getLastChange());
+
+      // Clear ...
+      handler.clear();
+
+      // Check the db is cleared.
+      assertEquals(null, handler.getFirstChange());
+      assertEquals(null, handler.getLastChange());
+
+    } finally
+    {
+      if (handler != null)
+        handler.shutdown();
+      if (dbEnv != null)
+        dbEnv.shutdown();
+      if (replicationServer != null)
+        replicationServer.remove();
+      if (testRoot != null)
+        TestCaseUtils.deleteDirectory(testRoot);
     }
-    testRoot.mkdirs();
-
-    ReplicationDbEnv dbEnv = new ReplicationDbEnv(path, replicationServer);
-
-    DbHandler handler =
-      new DbHandler(
-          (short) 1, DN.decode("o=test"), replicationServer, dbEnv, 5000);
-
-    // Creates changes added to the dbHandler
-    ChangeNumberGenerator gen = new ChangeNumberGenerator((short)1, 0);
-    ChangeNumber changeNumber1 = gen.newChangeNumber();
-    ChangeNumber changeNumber2 = gen.newChangeNumber();
-    ChangeNumber changeNumber3 = gen.newChangeNumber();
-
-    DeleteMsg update1 = new DeleteMsg("o=test", changeNumber1, "uid");
-    DeleteMsg update2 = new DeleteMsg("o=test", changeNumber2, "uid");
-    DeleteMsg update3 = new DeleteMsg("o=test", changeNumber3, "uid");
-
-    // Add the changes
-    handler.add(update1);
-    handler.add(update2);
-    handler.add(update3);
-
-    // Check they are here
-    assertEquals(changeNumber1, handler.getFirstChange());
-    assertEquals(changeNumber3, handler.getLastChange());
-
-    // Clear ...
-    handler.clear();
-
-    // Check the db is cleared.
-    assertEquals(null, handler.getFirstChange());
-    assertEquals(null, handler.getLastChange());
-
-    handler.shutdown();
-    dbEnv.shutdown();
-    replicationServer.shutdown();
-
-    TestCaseUtils.deleteDirectory(testRoot);
   }
-
-
 }

--
Gitblit v1.10.0