From a918f017f7c2aa5117370838055ae88f70ad3106 Mon Sep 17 00:00:00 2001
From: dugan <dugan@localhost>
Date: Tue, 10 Feb 2009 22:31:40 +0000
Subject: [PATCH] Fix chronic failure in unit tests related to dependancies between previous unit test methods.

---
 opends/tests/unit-tests-testng/src/server/org/opends/server/authorization/dseecompat/ReferencesTestCase.java |   27 ++++++++++++++++++++-------
 1 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/authorization/dseecompat/ReferencesTestCase.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/authorization/dseecompat/ReferencesTestCase.java
index 96230fe..239fcf9 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/authorization/dseecompat/ReferencesTestCase.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/authorization/dseecompat/ReferencesTestCase.java
@@ -96,11 +96,6 @@
     TestCaseUtils.clearJEBackend(false,"userRoot", suffix);
   }
 
-  @BeforeMethod
-  public void clearBackend() throws Exception {
-    deleteAttrFromEntry(adminBase, "aci");
-    deleteAttrFromAdminEntry(ACCESS_HANDLER_DN, ATTR_AUTHZ_GLOBAL_ACI);
-  }
 
   /**
    * Test using ACI added to admin base containing "ref" attribute type name
@@ -110,6 +105,7 @@
    */
   @Test()
   public void testRef() throws Exception {
+    try {
     String pwdLdifs =
             makeAddLDIF("aci", adminBase, ALLOW_OC);
 
@@ -118,8 +114,12 @@
             LDAPSearchParams(level5User, PWD, null,null, null,
                     adminBase, filter, null);
     Assert.assertTrue(isRefMap(userResults));
+    } finally {
+      deleteAttrFromEntry(adminBase, "aci");
+    }
   }
 
+
   /**
    * Test using ACI added to actual referral entry (added using ldifmodify
    * passing manageDsaIT control).
@@ -128,6 +128,7 @@
    */
   @Test()
   public void testRefAci() throws Exception {
+    try {
     String pwdLdifs =
             makeAddLDIF("aci", smartReferralAdmin, ALLOW_OC);
     //Add the ACI passing the manageDsaIT control.
@@ -136,10 +137,15 @@
             LDAPSearchParams(level5User, PWD, null,null, null,
                     adminBase, filter, null);
     Assert.assertTrue(isRefMap(userResults));
+    } finally {
+      String delPwdLdifs =
+        makeDelLDIF("aci", smartReferralAdmin, ALLOW_OC);
+      //Delete the ACI passing the manageDsaIT control.
+      LDIFModify(delPwdLdifs, DIR_MGR_DN, PWD, ctrlString);
+    }
   }
 
 
-
   /**
    * Test global ACI allowing the "ref" attribute type to be returned only if
    * if the search is under the people base. A search under the admin base
@@ -149,6 +155,7 @@
    */
   @Test()
   public void testGlobalTargetAci() throws Exception {
+    try {
     String pwdLdifs =
             makeAddLDIF(ATTR_AUTHZ_GLOBAL_ACI, ACCESS_HANDLER_DN, ALLOW_PEOPLE);
     LDIFAdminModify(pwdLdifs, DIR_MGR_DN, PWD);
@@ -162,10 +169,12 @@
             LDAPSearchParams(level5User, PWD, null,null, null,
                     peopleBase, filter, null);
     Assert.assertTrue(isRefMap(userResults1));
+    } finally {
+      deleteAttrFromAdminEntry(ACCESS_HANDLER_DN, ATTR_AUTHZ_GLOBAL_ACI);
+    }
   }
 
 
-
   /**
    * Test global ACI allowing the "ref" attribute type specifed by the
    * plus operator.
@@ -174,6 +183,7 @@
    */
   @Test()
   public void testGlobalAci() throws Exception {
+    try {
     String pwdLdifs =
            makeAddLDIF(ATTR_AUTHZ_GLOBAL_ACI, ACCESS_HANDLER_DN, ALLOW_OC_PLUS);
     LDIFAdminModify(pwdLdifs, DIR_MGR_DN, PWD);
@@ -181,6 +191,9 @@
             LDAPSearchParams(level5User, PWD, null,null, null,
                     adminBase, filter, null);
     Assert.assertTrue(isRefMap(userResults));
+    } finally {
+      deleteAttrFromAdminEntry(ACCESS_HANDLER_DN, ATTR_AUTHZ_GLOBAL_ACI);
+    }
   }
 
 

--
Gitblit v1.10.0