From b98d8ff76762d7e110919db8064af3c0d925d8f3 Mon Sep 17 00:00:00 2001
From: Nicolas Capponi <nicolas.capponi@forgerock.com>
Date: Mon, 30 May 2016 10:43:12 +0000
Subject: [PATCH] OPENDJ-2987 Add cleanup to TimeBasedMatchingRuleTest to prevent LDAPSyntaxTest to fail on shared objectclass

---
 opendj-server-legacy/src/test/java/org/opends/server/schema/TimeBasedMatchingRuleTest.java |   40 +++++++++++++++++++++++++++++++++-------
 1 files changed, 33 insertions(+), 7 deletions(-)

diff --git a/opendj-server-legacy/src/test/java/org/opends/server/schema/TimeBasedMatchingRuleTest.java b/opendj-server-legacy/src/test/java/org/opends/server/schema/TimeBasedMatchingRuleTest.java
index 1141dce..3be2d30 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/schema/TimeBasedMatchingRuleTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/schema/TimeBasedMatchingRuleTest.java
@@ -16,6 +16,8 @@
  */
 package org.opends.server.schema;
 
+import static org.assertj.core.api.Assertions.assertThat;
+
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Calendar;
@@ -40,11 +42,11 @@
 import org.opends.server.types.FilterType;
 import org.opends.server.types.SearchFilter;
 import org.opends.server.util.TimeThread;
+import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 
-import static org.assertj.core.api.Assertions.*;
 import static org.opends.server.schema.GeneralizedTimeSyntax.*;
 import static org.opends.server.schema.SchemaConstants.*;
 import static org.testng.Assert.*;
@@ -64,6 +66,15 @@
   private static final String TIME_ATTR = "test-time";
   private static final String DATE_ATTR = "test-date";
 
+  private static final String TEST_TIME_DEF = "( test-time-oid NAME 'test-time' DESC 'Test time attribute'  EQUALITY "
+      + "generalizedTimeMatch ORDERING  generalizedTimeOrderingMatch "
+      + "SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 SINGLE-VALUE )";
+  private static final String TEST_DATE_DEF = "( test-date-oid NAME 'test-date' DESC 'Test date attribute'  EQUALITY "
+      + "generalizedTimeMatch ORDERING  generalizedTimeOrderingMatch "
+      + "SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 SINGLE-VALUE )";
+  private static final String TEST_OC_DEF = "( testoc-oid NAME 'testOC' SUP top AUXILIARY MUST test-time)";
+  private static final String TEST_OC2_DEF = "( testoc2-oid NAME 'testOC2' SUP top AUXILIARY MUST test-date)";
+
 
   /**
    * Ensures that the Directory Server is running before executing the
@@ -90,18 +101,33 @@
     "dn: cn=schema",
     "changetype: modify",
     "add: attributeTypes",
-    "attributeTypes: ( test-time-oid NAME 'test-time' DESC 'Test time attribute'  EQUALITY   " +
-    "generalizedTimeMatch ORDERING  generalizedTimeOrderingMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 SINGLE-VALUE )",
-    "attributeTypes: ( test-date-oid NAME 'test-date' DESC 'Test date attribute'  EQUALITY   " +
-    "generalizedTimeMatch ORDERING  generalizedTimeOrderingMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 SINGLE-VALUE )",
+    "attributeTypes: " + TEST_TIME_DEF,
+    "attributeTypes: " + TEST_DATE_DEF,
     "-",
     "add: objectclasses",
-    "objectclasses: ( testoc-oid NAME 'testOC' SUP top AUXILIARY MUST test-time)",
-    "objectclasses: ( testoc2-oid NAME 'testOC2' SUP top AUXILIARY MUST test-date)"
+    "objectclasses: " + TEST_OC_DEF,
+    "objectclasses: " + TEST_OC2_DEF
     );
     assertEquals(0, resultCode);
   }
 
+  @AfterClass
+  public void cleanup() throws Exception
+  {
+    int resultCode = TestCaseUtils.applyModifications(true,
+        "dn: cn=schema",
+        "changetype: modify",
+        "delete: objectclasses",
+        "objectclasses: " + TEST_OC_DEF,
+        "objectclasses: " + TEST_OC2_DEF,
+        "-",
+        "delete: attributetypes",
+        "attributeTypes: " + TEST_TIME_DEF,
+        "attributeTypes: " + TEST_DATE_DEF
+      );
+      assertThat(resultCode).isEqualTo(0);
+  }
+
   @DataProvider
   public Object[][] relativeTime()
   {

--
Gitblit v1.10.0