From 078d47f0fec499677322bffac89e318dc66e6f20 Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Mon, 04 Sep 2006 05:59:21 +0000
Subject: [PATCH] Update the Directory Server build process so that the test target will create a minimized installation that will allow the server to be started for those tests that need access to the configuration, schema, or any other aspect of the running server. Also, update the test cases to make use of this capability when necessary.
---
opends/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 56 insertions(+), 0 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 a1b2dca..104a0ab 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
@@ -33,11 +33,67 @@
import java.io.InputStream;
import java.io.OutputStream;
+import org.opends.server.config.ConfigException;
+import org.opends.server.core.DirectoryServer;
+import org.opends.server.core.InitializationException;
+import org.opends.server.loggers.Error;
+import org.opends.server.loggers.Debug;
+
/**
* This class defines some utility functions which can be used by test
* cases.
*/
public final class TestCaseUtils {
+ /**
+ * The name of the system property that can be used to set the fully-qualified
+ * name of the Java class to use as the config handler.
+ */
+ public static final String PROPERTY_CONFIG_CLASS =
+ "org.opends.server.ConfigClass";
+
+ /**
+ * The name of the system property that can be used to set the path to the
+ * Directory Server configuration file.
+ */
+ public static final String PROPERTY_CONFIG_FILE =
+ "org.opends.server.ConfigFile";
+
+ /**
+ * Indicates whether the server has already been started.
+ */
+ private static boolean serverStarted = false;
+
+ /**
+ * Starts the Directory Server so that it will be available for use while
+ * running the unit tests. This will only actually start the server once, so
+ * subsequent attempts to start it will be ignored because it will already be
+ * available.
+ *
+ * @throws InitializationException If a problem occurs while starting the
+ * server.
+ *
+ * @throws ConfigException If there is a problem with the server
+ * configuration.
+ */
+ public static void startServer()
+ throws InitializationException, ConfigException
+ {
+ if (serverStarted)
+ {
+ return;
+ }
+
+ String configClass = System.getProperty(PROPERTY_CONFIG_CLASS);
+ String configFile = System.getProperty(PROPERTY_CONFIG_FILE);
+
+ DirectoryServer directoryServer = DirectoryServer.getInstance();
+ directoryServer.bootstrapServer();
+ directoryServer.initializeConfiguration(configClass, configFile);
+ Error.removeAllErrorLoggers(false);
+ Debug.removeAllDebugLoggers(false);
+ directoryServer.startServer();
+ serverStarted = true;
+ }
/**
* Create a temporary directory with the specified prefix.
--
Gitblit v1.10.0