From 1fc3b24ef136c0059ec363e94f0be798cd4dc119 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Fri, 12 Jul 2013 07:54:55 +0000
Subject: [PATCH] Fixing the build.

---
 opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java                        |   21 +++++++++++++++++++++
 opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/authorization/dseecompat/AciBodyTest.java |    7 +++++++
 2 files changed, 28 insertions(+), 0 deletions(-)

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 e0c51d3..6d3561d 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
@@ -221,6 +221,13 @@
   public static boolean SERVER_STARTED = false;
 
   /**
+   * This is used to store the schema as it was before starting the fake server
+   * (for example, it could have been the real schema) so test tearDown can set
+   * it back.
+   */
+  private static Schema schemaBeforeStartingFakeServer;
+
+  /**
    * The LDAP port the server is bound to on start.
    */
   private static int serverLdapPort;
@@ -256,9 +263,13 @@
    * <p>
    * This method is trying hard to provide sensible defaults and core data you
    * would expect from a normal install, including AttributeTypes, etc.
+   *
+   * @see #shutdownFakeServer() Matching method that must be called in the test
+   *      tear down.
    */
   public static void startFakeServer()
   {
+    schemaBeforeStartingFakeServer = DirectoryServer.getSchema();
     DirectoryServer.setSchema(initializeInMemory(new Schema()));
   }
 
@@ -822,6 +833,16 @@
   }
 
   /**
+   * Undo all the setup done by #startFakeServer().
+   *
+   * @see #startFakeServer() Matching method that starts the fake server
+   */
+  public static void shutdownFakeServer()
+  {
+    DirectoryServer.setSchema(schemaBeforeStartingFakeServer);
+  }
+
+  /**
    * Shut down the server, if it has been started.
    * @param reason The reason for the shutdown.
    */
diff --git a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/authorization/dseecompat/AciBodyTest.java b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/authorization/dseecompat/AciBodyTest.java
index 284fcb4..71c9e7a 100644
--- a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/authorization/dseecompat/AciBodyTest.java
+++ b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/authorization/dseecompat/AciBodyTest.java
@@ -30,6 +30,7 @@
 
 import org.opends.server.DirectoryServerTestCase;
 import org.opends.server.TestCaseUtils;
+import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
@@ -44,6 +45,12 @@
     TestCaseUtils.startFakeServer();
   }
 
+  @AfterClass
+  public void tearDown()
+  {
+    TestCaseUtils.shutdownFakeServer();
+  }
+
   @DataProvider(name = "validAcis")
   public Object[][] getValidAcis()
   {

--
Gitblit v1.10.0