From e39349187e6d55c90fec6a7e9b14e2d30aba49fa Mon Sep 17 00:00:00 2001
From: ludovicp <ludovicp@localhost>
Date: Wed, 26 May 2010 21:09:55 +0000
Subject: [PATCH] Add support of build.dir redefinition for unit tests By default, most of the files generated at build time are located in <ws>/build. If -Dbuild.dir is used, it is possible to specify another directory. This change allows to run unit-tests in this kind of build environment.

---
 opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/messages/MessagesTestCase.java                      |   14 +
 opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/DbHandlerTest.java        |   15 +
 opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/ConfigFileHandlerTestCase.java    |    6 
 opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java                           |    7 
 opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/SchemaReplicationTest.java       |    6 
 opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/DraftCNDbHandlerTest.java |   12 
 opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/core/SubentryPasswordPolicyTestCase.java     |  403 ++++++++++++++++++++++++++++++++++++++++++++
 opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/util/CertificateManagerTestCase.java         |   19 +
 8 files changed, 456 insertions(+), 26 deletions(-)

diff --git a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/messages/MessagesTestCase.java b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/messages/MessagesTestCase.java
index 90e0952..bc38bf9 100644
--- a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/messages/MessagesTestCase.java
+++ b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/messages/MessagesTestCase.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2006-2008 Sun Microsystems, Inc.
+ *      Copyright 2006-2010 Sun Microsystems, Inc.
  */
 package org.opends.messages;
 
@@ -65,9 +65,15 @@
       corePseudoI18nMsgs.put(keyEnum.nextElement(), TEST_MSG);
     }
     File buildRoot = new File(System.getProperty(TestCaseUtils.PROPERTY_BUILD_ROOT));
-    File corePseudoI18nMsgsFile = new File(buildRoot,
-            "build" + File.separator + "unit-tests" +
-                    File.separator + "classes" +
+    String buildDirStr = System.getProperty(TestCaseUtils.PROPERTY_BUILD_DIR);
+    File buildDir;
+    if (buildDirStr != null) {
+      buildDir = new File(buildDirStr);
+    } else  {
+      buildDir = new File(buildRoot, "build");
+    }
+    File corePseudoI18nMsgsFile = new File(buildDir,
+            "unit-tests" + File.separator + "classes" +
                     File.separator + "messages" +
                     File.separator + "core_" + TEST_LOCALE.getLanguage() +
                     ".properties");
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 ef4d8f1..b09417f 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
@@ -115,6 +115,9 @@
   public static final String PROPERTY_BUILD_ROOT =
        "org.opends.server.BuildRoot";
 
+  public static final String PROPERTY_BUILD_DIR  =
+       "org.opends.server.BuildDir";
+
    /**
    * The name of the system property that specifies an existing OpenDS
    * installation root (inside or outside of the source tree).
@@ -271,7 +274,9 @@
 
       // Get the build root and use it to create a test package directory.
       String buildRoot = System.getProperty(PROPERTY_BUILD_ROOT);
-      File   buildDir  = new File(buildRoot, "build");
+      String buildDirStr = System.getProperty(PROPERTY_BUILD_DIR,
+              buildRoot + File.separator + "build");
+      File   buildDir = new File(buildDirStr);
       File   unitRoot  = new File(buildDir, "unit-tests");
       File   testInstallRoot  = null;
       File   testInstanceRoot  = null;
diff --git a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/core/SubentryPasswordPolicyTestCase.java b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/core/SubentryPasswordPolicyTestCase.java
new file mode 100644
index 0000000..cc0050d
--- /dev/null
+++ b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/core/SubentryPasswordPolicyTestCase.java
@@ -0,0 +1,403 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License").  You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at
+ * trunk/opends/resource/legal-notices/OpenDS.LICENSE
+ * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at
+ * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
+ * add the following below this CDDL HEADER, with the fields enclosed
+ * by brackets "[]" replaced with your own identifying information:
+ *      Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ *
+ *
+ *      Copyright 2010 Sun Microsystems, Inc.
+ */
+package org.opends.server.core;
+
+
+
+import java.util.List;
+
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import org.opends.server.TestCaseUtils;
+import org.opends.server.protocols.internal.InternalClientConnection;
+import org.opends.server.types.AttributeType;
+import org.opends.server.types.AttributeValues;
+import org.opends.server.types.DN;
+import org.opends.server.types.Entry;
+import org.opends.server.types.ResultCode;
+import org.opends.server.util.StaticUtils;
+import org.testng.annotations.AfterClass;
+
+import static org.testng.Assert.*;
+
+
+/**
+ * A set of test cases for the Directory Server subentry password policy.
+ */
+public class SubentryPasswordPolicyTestCase
+       extends CoreTestCase
+{
+  private static final String SUFFIX = "dc=example,dc=com";
+  private static final String BASE = "ou=People," + SUFFIX;
+
+  @BeforeClass()
+  public void setUp() throws Exception
+  {
+    TestCaseUtils.startServer();
+    TestCaseUtils.clearJEBackend(false, "userRoot", SUFFIX);
+
+    InternalClientConnection connection =
+         InternalClientConnection.getRootConnection();
+
+    // Add suffix entry.
+    DN suffixDN = DN.decode(SUFFIX);
+    if (DirectoryServer.getEntry(suffixDN) == null)
+    {
+      Entry suffixEntry = StaticUtils.createEntry(suffixDN);
+      AddOperation addOperation =
+           connection.processAdd(suffixEntry.getDN(),
+                                 suffixEntry.getObjectClasses(),
+                                 suffixEntry.getUserAttributes(),
+                                 suffixEntry.getOperationalAttributes());
+      assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
+      assertNotNull(DirectoryServer.getEntry(suffixEntry.getDN()));
+    }
+
+    // Add base entry.
+    DN baseDN = DN.decode(BASE);
+    if (DirectoryServer.getEntry(baseDN) == null)
+    {
+      Entry baseEntry = StaticUtils.createEntry(baseDN);
+      AddOperation addOperation =
+           connection.processAdd(baseEntry.getDN(),
+                                 baseEntry.getObjectClasses(),
+                                 baseEntry.getUserAttributes(),
+                                 baseEntry.getOperationalAttributes());
+      assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
+      assertNotNull(DirectoryServer.getEntry(baseEntry.getDN()));
+    }
+
+    // Add test entry.
+    Entry testEntry = TestCaseUtils.makeEntry(
+         "dn: uid=rogasawara," + BASE,
+         "objectclass: top",
+         "objectclass: person",
+         "objectclass: organizationalPerson",
+         "objectclass: inetOrgPerson",
+         "uid: rogasawara",
+         "userpassword: password",
+         "mail: rogasawara@example.com",
+         "givenname: Rodney",
+         "sn: Ogasawara",
+         "cn: Rodney Ogasawara",
+         "title: Sales, Director"
+    );
+    AddOperation addOperation =
+         connection.processAdd(testEntry.getDN(),
+                               testEntry.getObjectClasses(),
+                               testEntry.getUserAttributes(),
+                               testEntry.getOperationalAttributes());
+    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
+    assertNotNull(DirectoryServer.getEntry(testEntry.getDN()));
+  }
+
+  @AfterClass
+  public void cleanUp() throws Exception
+  {
+    TestCaseUtils.clearJEBackend(false, "userRoot", SUFFIX);
+  }
+
+  /**
+   * Retrieves a set of invalid configurations that cannot be used to
+   * initialize a password policy.
+   *
+   * @return  A set of invalid configurations that cannot be used to
+   *          initialize a password policy.
+   *
+   * @throws  Exception  If an unexpected problem occurs.
+   */
+  @DataProvider(name = "invalidConfigs")
+  public Object[][] getInvalidConfigurations()
+         throws Exception
+  {
+    List<Entry> entries = TestCaseUtils.makeEntries(
+         "dn: cn=Temp Policy 1," + SUFFIX,
+         "objectClass: top",
+         "objectClass: pwdPolicy",
+         "objectClass: subentry",
+         "cn: Temp Policy 1",
+         "subtreeSpecification: { base \"ou=people\" }",
+         "pwdLockoutDuration: 300",
+         "pwdMaxFailure: 3",
+         "pwdMustChange: 1",
+         "pwdAttribute: userPassword",
+         "",
+         "dn: cn=Temp Policy 2," + SUFFIX,
+         "objectClass: top",
+         "objectClass: pwdPolicy",
+         "objectClass: subentry",
+         "cn: Temp Policy 2",
+         "subtreeSpecification: { base \"ou=people\" }",
+         "pwdLockoutDuration: 300 seconds",
+         "pwdMaxFailure: 3",
+         "pwdMustChange: TRUE",
+         "pwdAttribute: userPassword",
+         "",
+         "dn: cn=Temp Policy 3," + SUFFIX,
+         "objectClass: top",
+         "objectClass: pwdPolicy",
+         "objectClass: subentry",
+         "cn: Temp Policy 3",
+         "subtreeSpecification: { base \"ou=people\" }",
+         "pwdLockoutDuration: 300",
+         "pwdMaxFailure: 3",
+         "pwdMustChange: TRUE",
+         "pwdAttribute: noSuchAttribute",
+         "",
+         "dn: cn=Temp Policy 4," + SUFFIX,
+         "objectClass: top",
+         "objectClass: pwdPolicy",
+         "objectClass: subentry",
+         "cn: Temp Policy 4",
+         "subtreeSpecification: { base \"ou=people\" }",
+         "pwdLockoutDuration: 300",
+         "pwdMaxFailure: -3",
+         "pwdMustChange: TRUE",
+         "pwdAttribute: userPassword",
+         "",
+         "dn: cn=Temp Policy 5," + SUFFIX,
+         "objectClass: top",
+         "objectClass: pwdPolicy",
+         "objectClass: subentry",
+         "cn: Temp Policy 5",
+         "subtreeSpecification: { base \"ou=people\" }",
+         "pwdLockoutDuration: 2147483648",
+         "pwdMaxFailure: 3",
+         "pwdMustChange: TRUE",
+         "pwdAttribute: userPassword"
+         );
+
+    Object[][] configEntries = new Object[entries.size()][1];
+    for (int i=0; i < configEntries.length; i++)
+    {
+      configEntries[i] = new Object[] { entries.get(i) };
+    }
+
+    return configEntries;
+  }
+
+  /**
+   * Ensures that password policy creation will fail when given
+   * an invalid configuration.
+   *
+   * @param  e  The entry containing an invalid password policy
+   *            configuration.
+   *
+   * @throws  Exception  If an unexpected problem occurs.
+   */
+  @Test(dataProvider = "invalidConfigs")
+  public void testInvalidConfigurations(Entry e)
+         throws Exception
+  {
+    InternalClientConnection connection =
+         InternalClientConnection.getRootConnection();
+
+    AddOperation addOperation =
+         connection.processAdd(e.getDN(),
+                               e.getObjectClasses(),
+                               e.getUserAttributes(),
+                               e.getOperationalAttributes());
+    assertTrue(addOperation.getResultCode() != ResultCode.SUCCESS);
+    assertNull(DirectoryServer.getEntry(e.getDN()));
+  }
+
+  /**
+   * Ensures that password policy constructed from subentry
+   * is active and has a valid configuration.
+   *
+   * @throws  Exception  If an unexpected problem occurs.
+   */
+  @Test()
+  public void testValidConfiguration()
+         throws Exception
+  {
+    PasswordPolicy defaultPolicy =
+            DirectoryServer.getDefaultPasswordPolicy();
+    assertNotNull(defaultPolicy);
+
+    // The values are selected on a basis that they
+    // should differ from default password policy.
+    Entry policyEntry = TestCaseUtils.makeEntry(
+         "dn: cn=Temp Policy," + SUFFIX,
+         "objectClass: top",
+         "objectClass: pwdPolicy",
+         "objectClass: subentry",
+         "cn: Temp Policy",
+         "subtreeSpecification: { base \"ou=people\" }",
+         "pwdLockoutDuration: 300",
+         "pwdMaxFailure: 3",
+         "pwdMustChange: TRUE",
+         "pwdAttribute: authPassword",
+         "pwdMinAge: 600",
+         "pwdMaxAge: 2147483647",
+         "pwdInHistory: 5",
+         "pwdExpireWarning: 864000",
+         "pwdGraceAuthNLimit: 3",
+         "pwdFailureCountInterval: 3600",
+         "pwdAllowUserChange: FALSE",
+         "pwdSafeModify: TRUE"
+    );
+
+    InternalClientConnection connection =
+         InternalClientConnection.getRootConnection();
+
+    AddOperation addOperation =
+         connection.processAdd(policyEntry.getDN(),
+                               policyEntry.getObjectClasses(),
+                               policyEntry.getUserAttributes(),
+                               policyEntry.getOperationalAttributes());
+    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
+    assertNotNull(DirectoryServer.getEntry(policyEntry.getDN()));
+
+    PasswordPolicy policy = DirectoryServer.getPasswordPolicy(
+            DN.decode("cn=Temp Policy," + SUFFIX));
+    assertNotNull(policy);
+
+    // Check all pwp attributes for correct values.
+    assertEquals(policy.getLockoutDuration(), 300);
+    assertEquals(policy.getLockoutFailureCount(), 3);
+    assertEquals(policy.forceChangeOnReset(), true);
+    assertTrue(policy.getPasswordAttribute(
+            ).getPrimaryName().equalsIgnoreCase(
+            "authPassword"));
+    assertEquals(policy.getMinimumPasswordAge(), 600);
+    assertEquals(policy.getMaximumPasswordAge(), 2147483647);
+    assertEquals(policy.getPasswordHistoryCount(), 5);
+    assertEquals(policy.getWarningInterval(), 864000);
+    assertEquals(policy.getGraceLoginCount(), 3);
+    assertEquals(policy.getLockoutFailureExpirationInterval(),
+            3600);
+    assertEquals(policy.allowUserPasswordChanges(), false);
+    assertEquals(policy.requireCurrentPassword(), true);
+
+    // Make sure this policy applies to the test entry
+    // its supposed to target and that its the same
+    // policy object as previously tested.
+    Entry testEntry = DirectoryServer.getEntry(DN.decode(
+            "uid=rogasawara," + BASE));
+    assertNotNull(testEntry);
+
+    PasswordPolicyState state =
+            new PasswordPolicyState(testEntry, false);
+    assertNotNull(state);
+    PasswordPolicy statePolicy = state.getPolicy();
+    assertNotNull(statePolicy);
+    assertEquals(policy, statePolicy);
+
+    // Make sure this policy is gone and default
+    // policy is in effect instead.
+    TestCaseUtils.deleteEntry(policyEntry.getDN());
+    state = new PasswordPolicyState(testEntry, false);
+    assertNotNull(state);
+    statePolicy = state.getPolicy();
+    assertNotNull(statePolicy);
+    assertEquals(defaultPolicy, statePolicy);
+  }
+
+  /**
+   * Ensures that password policy pwdPolicySubentry
+   * operational attribute reflects active password
+   * policy for a given user entry.
+   *
+   * @throws  Exception  If an unexpected problem occurs.
+   */
+  @Test()
+  public void testPasswordPolicySubentryAttribute()
+         throws Exception
+  {
+    PasswordPolicy defaultPolicy =
+            DirectoryServer.getDefaultPasswordPolicy();
+    assertNotNull(defaultPolicy);
+
+    Entry testEntry = DirectoryServer.getEntry(DN.decode(
+            "uid=rogasawara," + BASE));
+    assertNotNull(testEntry);
+
+    AttributeType attrType = DirectoryServer.getAttributeType(
+            "pwdpolicysubentry");
+
+    // Make sure that default policy is in effect
+    // for the user entry.
+    assertTrue(testEntry.hasAttribute(attrType));
+    assertTrue(testEntry.hasValue(attrType, null,
+            AttributeValues.create(attrType,
+            defaultPolicy.getConfigEntryDN(
+            ).toString())));
+
+    // Add new subentry policy with the
+    // scope to apply to the user entry.
+    Entry policyEntry = TestCaseUtils.makeEntry(
+         "dn: cn=Temp Policy," + SUFFIX,
+         "objectClass: top",
+         "objectClass: pwdPolicy",
+         "objectClass: subentry",
+         "cn: Temp Policy",
+         "subtreeSpecification: { base \"ou=people\" }",
+         "pwdLockoutDuration: 300",
+         "pwdMaxFailure: 3",
+         "pwdMustChange: true",
+         "pwdAttribute: userPassword"
+        );
+
+    InternalClientConnection connection =
+         InternalClientConnection.getRootConnection();
+
+    AddOperation addOperation =
+         connection.processAdd(policyEntry.getDN(),
+                               policyEntry.getObjectClasses(),
+                               policyEntry.getUserAttributes(),
+                               policyEntry.getOperationalAttributes());
+    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
+    assertNotNull(DirectoryServer.getEntry(policyEntry.getDN()));
+
+    // Make sure just added policy is in effect.
+    testEntry = DirectoryServer.getEntry(DN.decode(
+            "uid=rogasawara," + BASE));
+    assertNotNull(testEntry);
+
+    assertTrue(testEntry.hasAttribute(attrType));
+    assertTrue(testEntry.hasValue(attrType, null,
+            AttributeValues.create(attrType,
+            "cn=Temp Policy," + SUFFIX)));
+
+    // Remove subentry policy and make sure
+    // default policy is in effect again.
+    TestCaseUtils.deleteEntry(policyEntry.getDN());
+
+    testEntry = DirectoryServer.getEntry(DN.decode(
+            "uid=rogasawara," + BASE));
+    assertNotNull(testEntry);
+
+    assertTrue(testEntry.hasAttribute(attrType));
+    assertTrue(testEntry.hasValue(attrType, null,
+            AttributeValues.create(attrType,
+            defaultPolicy.getConfigEntryDN(
+            ).toString())));
+  }
+}
diff --git a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/ConfigFileHandlerTestCase.java b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/ConfigFileHandlerTestCase.java
index 81c38fb..6c54fc4 100644
--- a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/ConfigFileHandlerTestCase.java
+++ b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/extensions/ConfigFileHandlerTestCase.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2008 Sun Microsystems, Inc.
+ *      Copyright 2008-2010 Sun Microsystems, Inc.
  */
 package org.opends.server.extensions;
 
@@ -63,7 +63,9 @@
     TestCaseUtils.startServer();
 
     String buildRoot = System.getProperty(TestCaseUtils.PROPERTY_BUILD_ROOT);
-    String startOKFile = buildRoot + File.separator + "build" + File.separator +
+    String buildDir = System.getProperty(TestCaseUtils.PROPERTY_BUILD_DIR,
+            buildRoot + File.separator + "build");
+    String startOKFile = buildDir + File.separator +
                          "unit-tests" + File.separator + "package-instance" +
                          File.separator + "config" + File.separator +
                          "config.ldif.startok";
diff --git a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/SchemaReplicationTest.java b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/SchemaReplicationTest.java
index 51ce7ad..99145e1 100644
--- a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/SchemaReplicationTest.java
+++ b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/SchemaReplicationTest.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2008-2009 Sun Microsystems, Inc.
+ *      Copyright 2008-2010 Sun Microsystems, Inc.
  */
 package org.opends.server.replication;
 
@@ -315,7 +315,9 @@
 
       // open the schema file
       String buildRoot = System.getProperty(TestCaseUtils.PROPERTY_BUILD_ROOT);
-      String path = buildRoot + File.separator + "build" + File.separator +
+      String buildDir = System.getProperty(TestCaseUtils.PROPERTY_BUILD_DIR,
+              buildRoot + File.separator + "build");
+      String path = buildDir + File.separator +
         "unit-tests" + File.separator + "package-instance" + File.separator +
         "config" + File.separator + "schema" + File.separator +
         "99-user.ldif";
diff --git a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/DbHandlerTest.java b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/DbHandlerTest.java
index 36912e1..41e93e4 100644
--- a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/DbHandlerTest.java
+++ b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/DbHandlerTest.java
@@ -85,8 +85,9 @@
 
       // create or clean a directory for the dbHandler
       String buildRoot = System.getProperty(TestCaseUtils.PROPERTY_BUILD_ROOT);
-      String path = buildRoot + File.separator + "build" + File.separator +
-        "unit-tests" + File.separator + "dbHandler";
+      String path = System.getProperty(TestCaseUtils.PROPERTY_BUILD_DIR,
+              buildRoot + File.separator + "build");
+      path = path + File.separator + "unit-tests" + File.separator + "dbHandler";
       testRoot = new File(path);
       if (testRoot.exists())
       {
@@ -306,8 +307,9 @@
 
       // create or clean a directory for the dbHandler
       String buildRoot = System.getProperty(TestCaseUtils.PROPERTY_BUILD_ROOT);
-      String path = buildRoot + File.separator + "build" + File.separator +
-        "unit-tests" + File.separator + "dbHandler";
+      String path = System.getProperty(TestCaseUtils.PROPERTY_BUILD_DIR,
+              buildRoot + File.separator + "build");
+      path = path + File.separator + "unit-tests" + File.separator + "dbHandler";
       testRoot = new File(path);
       if (testRoot.exists())
       {
@@ -415,8 +417,9 @@
 
       // create or clean a directory for the dbHandler
       String buildRoot = System.getProperty(TestCaseUtils.PROPERTY_BUILD_ROOT);
-      String path = buildRoot + File.separator + "build" + File.separator +
-      "unit-tests" + File.separator + "dbHandlercp";
+      String path = System.getProperty(TestCaseUtils.PROPERTY_BUILD_DIR,
+              buildRoot + File.separator + "build");
+      path = path + File.separator + "unit-tests" + File.separator + "dbHandler";
       testRoot = new File(path);
       if (testRoot.exists())
       {
diff --git a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/DraftCNDbHandlerTest.java b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/DraftCNDbHandlerTest.java
index 731111b..794942b 100644
--- a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/DraftCNDbHandlerTest.java
+++ b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/DraftCNDbHandlerTest.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2009 Sun Microsystems, Inc.
+ *      Copyright 2009-2010 Sun Microsystems, Inc.
  */
 package org.opends.server.replication.server;
 
@@ -82,8 +82,9 @@
 
       // create or clean a directory for the DraftCNDbHandler
       String buildRoot = System.getProperty(TestCaseUtils.PROPERTY_BUILD_ROOT);
-      String path = buildRoot + File.separator + "build" + File.separator +
-        "unit-tests" + File.separator + "DraftCNDbHandler";
+      String path = System.getProperty(TestCaseUtils.PROPERTY_BUILD_DIR,
+              buildRoot + File.separator + "build");
+      path = path + File.separator + "unit-tests" + File.separator + "DraftCNDbHandler";
       testRoot = new File(path);
       if (testRoot.exists())
       {
@@ -204,8 +205,9 @@
 
       // create or clean a directory for the DraftCNDbHandler
       String buildRoot = System.getProperty(TestCaseUtils.PROPERTY_BUILD_ROOT);
-      String path = buildRoot + File.separator + "build" + File.separator +
-        "unit-tests" + File.separator + "DraftCNDbHandler";
+      String path = System.getProperty(TestCaseUtils.PROPERTY_BUILD_DIR,
+              buildRoot + File.separator + "build");
+      path = path + File.separator + "unit-tests" + File.separator + "DraftCNDbHandler";
       testRoot = new File(path);
       if (testRoot.exists())
       {
diff --git a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/util/CertificateManagerTestCase.java b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/util/CertificateManagerTestCase.java
index 11e8bb5..90ef7cf 100644
--- a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/util/CertificateManagerTestCase.java
+++ b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/util/CertificateManagerTestCase.java
@@ -57,13 +57,18 @@
        CertificateManager.mayUseCertificateManager();
 
 
+  // Get the build root and use it to create a test package directory.
+  public static final String BUILD_ROOT = 
+          System.getProperty(TestCaseUtils.PROPERTY_BUILD_ROOT);
 
+      
   /**
    * The path to a JKS key store file.
    */
   public static final String JKS_KEY_STORE_PATH =
-       System.getProperty(TestCaseUtils.PROPERTY_BUILD_ROOT) + File.separator +
-       "build" + File.separator + "unit-tests" + File.separator +
+       System.getProperty(TestCaseUtils.PROPERTY_BUILD_DIR,
+       BUILD_ROOT + File.separator + "build") +
+       File.separator + "unit-tests" + File.separator +
        "package-instance" +
        File.separator + "config" + File.separator + "server.keystore";
 
@@ -73,8 +78,9 @@
    * The path to a PKCS#12 key store file.
    */
   public static final String PKCS12_KEY_STORE_PATH =
-       System.getProperty(TestCaseUtils.PROPERTY_BUILD_ROOT) + File.separator +
-       "build" + File.separator + "unit-tests" + File.separator +
+       System.getProperty(TestCaseUtils.PROPERTY_BUILD_DIR,
+       BUILD_ROOT + File.separator + "build") +
+       File.separator + "unit-tests" + File.separator +
        "package-instance" +
        File.separator + "config" + File.separator + "server-cert.p12";
 
@@ -84,8 +90,9 @@
    * The path to the unit test working directory.
    */
   public static final String TEST_DIR =
-       System.getProperty(TestCaseUtils.PROPERTY_BUILD_ROOT) + File.separator +
-       "build" + File.separator + "unit-tests" + File.separator +
+       System.getProperty(TestCaseUtils.PROPERTY_BUILD_DIR,
+       BUILD_ROOT + File.separator + "build") +
+       File.separator + "unit-tests" + File.separator +
        "package-instance";
 
 

--
Gitblit v1.10.0