From c9cb0e89dadb2872d6d76e657ea8a76ce105bc14 Mon Sep 17 00:00:00 2001
From: coulbeck <coulbeck@localhost>
Date: Fri, 15 Sep 2006 16:53:05 +0000
Subject: [PATCH] Add a @AfterSuite annotated method to the DirectoryServerTestCase to shut down the server after tests have been run. This eleiminates a problem running tests from within IDEA where the test process had to be stopped manually after the tests had completed.
---
opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java | 14 +++++++++++++-
opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/DirectoryServerTestCase.java | 7 ++++++-
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/DirectoryServerTestCase.java b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/DirectoryServerTestCase.java
index dd8a53d..3fc04d8 100644
--- a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/DirectoryServerTestCase.java
+++ b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/DirectoryServerTestCase.java
@@ -26,7 +26,7 @@
*/
package org.opends.server;
-import org.testng.annotations.Test;
+import org.testng.annotations.AfterSuite;
import java.io.PrintStream;
@@ -41,6 +41,11 @@
// The print stream to use for printing error messages.
private PrintStream errorStream;
+ @AfterSuite
+ public final void shutdownServer() {
+ TestCaseUtils.shutdownServer("The current test suite has finished.");
+ }
+
/**
* Creates a new instance of this test case with the provided name.
*/
diff --git a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java
index 4a5695f..45733f5 100644
--- a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java
+++ b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java
@@ -48,7 +48,6 @@
import org.opends.server.loggers.Error;
import org.opends.server.loggers.Debug;
import org.opends.server.types.DN;
-import org.opends.server.types.Entry;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
@@ -162,6 +161,19 @@
}
/**
+ * Shut down the server, if it has been started.
+ * @param reason The reason for the shutdown.
+ */
+ public static void shutdownServer(String reason)
+ {
+ if (SERVER_STARTED)
+ {
+ DirectoryServer.shutDown("org.opends.server.TestCaseUtils", reason);
+ SERVER_STARTED = false;
+ }
+ }
+
+ /**
* Initializes a memory-based backend that may be used to perform operations
* while testing the server. This will ensure that the memory backend is
* created in the server if it does not yet exist, and that it is empty. Note
--
Gitblit v1.10.0