From 81418ac3dea77db5b51e6cf65615b532fa069c16 Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Mon, 06 Aug 2007 18:13:25 +0000
Subject: [PATCH] Implement a TestCaseUtils.dsconfig method that provides a more convenient mechanism for making configuration changes within the unit test framework.

---
 opends/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java |   38 +++++++++++++++++++++++++++++++++++++-
 1 files changed, 37 insertions(+), 1 deletions(-)

diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java
index bb659de..f01e8e0 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java
@@ -68,6 +68,7 @@
 import org.opends.server.protocols.ldap.LDAPMessage;
 import org.opends.server.protocols.ldap.BindResponseProtocolOp;
 import org.opends.server.tools.LDAPModify;
+import org.opends.server.tools.dsconfig.DSConfig;
 import org.opends.server.types.DN;
 import org.opends.server.types.DirectoryException;
 import org.opends.server.types.FilePermission;
@@ -353,7 +354,7 @@
     assertTrue(InvocationCounterPlugin.startupCalled());
 
     SERVER_STARTED = true;
-    
+
     initializeTestBackend(true);
   }
 
@@ -1223,4 +1224,39 @@
       }
     }
   }
+
+
+
+  /**
+   * Invokes the dsconfig tool with the provided set of arguments.  Note that
+   * the address, port, bind DN (cn=Directory Manager), and password will always
+   * be provided, so they should not be included in the argument list.  The
+   * given arguments should include only the subcommand and its associated
+   * options, along with any other global options that may not be included by
+   * default.
+   * <BR><BR>
+   * An assertion will be used to ensure that the dsconfig invocation is
+   * successful.  If running dsconfig returns a non-zero result, then an
+   * assertion error will be thrown.
+   *
+   * @param  args  The set of arguments that should be provided when invoking
+   *               the dsconfig tool
+   */
+  public static void dsconfig(String... args)
+  {
+    String[] fullArgs = new String[args.length + 8];
+    fullArgs[0] = "-h";
+    fullArgs[1] = "127.0.0.1";
+    fullArgs[2] = "-p";
+    fullArgs[3] = String.valueOf(serverLdapPort);
+    fullArgs[4] = "-D";
+    fullArgs[5] = "cn=Directory Manager";
+    fullArgs[6] = "-w";
+    fullArgs[7] = "password";
+
+    System.arraycopy(args, 0, fullArgs, 8, args.length);
+
+    assertEquals(DSConfig.main(fullArgs, false, System.out, System.err), 0);
+  }
 }
+

--
Gitblit v1.10.0