From feb5d90ec016c99712f19c5485cf7633cd38f111 Mon Sep 17 00:00:00 2001
From: matthew_swift <matthew_swift@localhost>
Date: Fri, 23 Mar 2007 14:26:04 +0000
Subject: [PATCH] Merge admin framework from config-prototype-branch onto trunk.

---
 opends/tests/unit-tests-testng/src/server/org/opends/server/protocols/ldap/LdapTestCase.java |   42 +++++++++++++++++++++++++++++++-----------
 1 files changed, 31 insertions(+), 11 deletions(-)

diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/protocols/ldap/LdapTestCase.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/protocols/ldap/LdapTestCase.java
index 3b4f0d8..56610bc 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/protocols/ldap/LdapTestCase.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/protocols/ldap/LdapTestCase.java
@@ -29,7 +29,10 @@
 import static org.opends.server.config.ConfigConstants.ATTR_LISTEN_PORT;
 import org.opends.server.types.Entry;
 import org.opends.server.DirectoryServerTestCase;
-import org.opends.server.config.ConfigEntry;
+import org.opends.server.admin.server.AdminTestCaseUtils;
+import org.opends.server.admin.std.meta.LDAPConnectionHandlerCfgDefn;
+import org.opends.server.admin.std.server.LDAPConnectionHandlerCfg;
+import org.opends.server.config.ConfigException;
 import org.opends.server.protocols.asn1.ASN1Boolean;
 import org.opends.server.protocols.asn1.ASN1Element;
 import org.opends.server.protocols.asn1.ASN1Long;
@@ -152,7 +155,7 @@
    * entry.
    * 
    * @param handlerEntry The entry to be used to configure the handle.
-   * @return
+   * @return Returns the new LDAP connection handler.
    * @throws Exception if the handler cannot be initialized.
    */
   static LDAPConnectionHandler 
@@ -163,18 +166,35 @@
 	  long serverLdapPort = serverLdapSocket.getLocalPort();
 	  Attribute a=new Attribute(ATTR_LISTEN_PORT, String.valueOf(serverLdapPort));
 	  handlerEntry.addAttribute(a,null);
-	  String LDAPClassName=LDAPConnectionHandler.class.getName();
-	  Class LDAPConnHandlerClass = Class.forName(LDAPClassName);
-	  LDAPConnectionHandler LDAPConnHandler = 
-		  (LDAPConnectionHandler) LDAPConnHandlerClass.newInstance();
-	  LDAPConnHandler.initializeConnectionHandler(new ConfigEntry(handlerEntry, null ));
-	  return LDAPConnHandler;
+    LDAPConnectionHandlerCfg config =
+      getConfiguration(handlerEntry);
+    LDAPConnectionHandler handler = new LDAPConnectionHandler();
+    handler.initializeConnectionHandler(config);
+	  return handler;
+  }
+
+  /**
+   * Decode an LDAP connection handler configuration entry.
+   * 
+   * @param handlerEntry
+   *          The configuration entry.
+   * @return Returns the decoded LDAP connection handler
+   *         configuration.
+   * @throws ConfigException
+   *           If the configuration entry could not be decoded.
+   */
+  static LDAPConnectionHandlerCfg getConfiguration(
+      Entry handlerEntry) throws ConfigException {
+    return AdminTestCaseUtils.getConfiguration(
+        LDAPConnectionHandlerCfgDefn
+            .getInstance(), handlerEntry);
   }
   
   /**
- * @return A free port number.
- * @throws Exception if socket cannot be created or bound to.
- */
+   * @return A free port number.
+   * @throws Exception
+   *           if socket cannot be created or bound to.
+   */
 static long
   getFreePort() throws Exception {
 	  ServerSocket serverLdapSocket = new ServerSocket();

--
Gitblit v1.10.0