From dd0aa3d6f2295686b10d2e11c972687a225c103f Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Fri, 19 Jan 2007 22:57:49 +0000
Subject: [PATCH] Update the schema backend so that the creatorsName, createTimestamp, modifiersName, and modifyTimestamp attributes are included in the subschema subentry as recommended in RFC 4512 section 4.2.  The create timestamp will be set to the oldest modification time of all the schema configuration files.  The modify timestamp will be initially set to the youngest modification time of all the schema configuration files, but if the schema is updated with the server online then the modifiersName and modifyTimestamp will be updated accordingly.

---
 opends/tests/unit-tests-testng/src/server/org/opends/server/backends/SchemaBackendTestCase.java |   65 ++++++++++++++++++++++++++++++++
 1 files changed, 65 insertions(+), 0 deletions(-)

diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/backends/SchemaBackendTestCase.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/backends/SchemaBackendTestCase.java
index 1996d52..ae85150 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/backends/SchemaBackendTestCase.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/backends/SchemaBackendTestCase.java
@@ -3674,6 +3674,71 @@
 
 
   /**
+   * Tests to ensure that the schema subentry includes the lastmod attributes
+   * and that the modifiersName and modifyTimestamp attributes get updated when
+   * the schema is modified.
+   *
+   * @throws  Exception  If an unexpected problem occurs.
+   */
+  @Test()
+  public void testLastModAttributes()
+         throws Exception
+  {
+    Entry schemaEntry = DirectoryServer.getEntry(DN.decode("cn=schema"));
+    assertNotNull(schemaEntry);
+
+    AttributeType cnType =
+         DirectoryServer.getAttributeType("creatorsname", true);
+    AttributeType ctType =
+         DirectoryServer.getAttributeType("createtimestamp", true);
+    AttributeType mnType =
+         DirectoryServer.getAttributeType("modifiersname", true);
+    AttributeType mtType =
+         DirectoryServer.getAttributeType("modifytimestamp", true);
+
+    assertTrue(schemaEntry.hasAttribute(cnType));
+    assertTrue(schemaEntry.hasAttribute(ctType));
+    assertTrue(schemaEntry.hasAttribute(mnType));
+    assertTrue(schemaEntry.hasAttribute(mtType));
+
+    AttributeValue oldMTValue =
+         schemaEntry.getAttribute(mtType).get(0).getValues().iterator().next();
+
+    String path = TestCaseUtils.createTempFile(
+         "dn: cn=schema",
+         "changetype: modify",
+         "add: attributeTypes",
+         "attributeTypes: ( testlastmodattributes-oid " +
+              "NAME 'testLastModAttributes' " +
+              "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " +
+              "X-ORGIN 'SchemaBackendTestCase' )");
+
+    String[] args =
+    {
+      "-h", "127.0.0.1",
+      "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
+      "-D", "cn=Directory Manager",
+      "-w", "password",
+      "-f", path
+    };
+
+    assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
+
+    schemaEntry = DirectoryServer.getEntry(DN.decode("cn=schema"));
+    assertNotNull(schemaEntry);
+    assertTrue(schemaEntry.hasAttribute(cnType));
+    assertTrue(schemaEntry.hasAttribute(ctType));
+    assertTrue(schemaEntry.hasAttribute(mnType));
+    assertTrue(schemaEntry.hasAttribute(mtType));
+
+    AttributeValue newMTValue =
+         schemaEntry.getAttribute(mtType).get(0).getValues().iterator().next();
+    assertFalse(oldMTValue.equals(newMTValue));
+  }
+
+
+
+  /**
    * Tests the {@code exportLDIF} method with a valid configuration.
    *
    * @throws  Exception  If an unexpected problem occurs.

--
Gitblit v1.10.0