641N/A/*
641N/A * CDDL HEADER START
641N/A *
641N/A * The contents of this file are subject to the terms of the
641N/A * Common Development and Distribution License, Version 1.0 only
641N/A * (the "License"). You may not use this file except in compliance
641N/A * with the License.
641N/A *
641N/A * You can obtain a copy of the license at
641N/A * trunk/opends/resource/legal-notices/OpenDS.LICENSE
641N/A * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
641N/A * See the License for the specific language governing permissions
641N/A * and limitations under the License.
641N/A *
641N/A * When distributing Covered Code, include this CDDL HEADER in each
641N/A * file and include the License file at
641N/A * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
641N/A * add the following below this CDDL HEADER, with the fields enclosed
873N/A * by brackets "[]" replaced with your own identifying information:
641N/A * Portions Copyright [yyyy] [name of copyright owner]
641N/A *
641N/A * CDDL HEADER END
641N/A *
641N/A *
5142N/A * Copyright 2006-2010 Sun Microsystems, Inc.
6318N/A * Portions Copyright 2013 ForgeRock AS.
641N/A */
641N/Apackage org.opends.server.backends;
641N/A
641N/A
641N/A
673N/Aimport java.io.File;
673N/Aimport java.util.LinkedHashMap;
641N/A
641N/Aimport org.testng.annotations.BeforeClass;
641N/Aimport org.testng.annotations.Test;
641N/A
641N/Aimport org.opends.server.TestCaseUtils;
673N/Aimport org.opends.server.config.ConfigException;
1689N/Aimport org.opends.server.core.AddOperationBasis;
1689N/Aimport org.opends.server.core.DeleteOperationBasis;
641N/Aimport org.opends.server.core.DirectoryServer;
1858N/Aimport org.opends.server.core.ModifyDNOperationBasis;
673N/Aimport org.opends.server.core.SchemaConfigManager;
641N/Aimport org.opends.server.protocols.internal.InternalClientConnection;
641N/Aimport org.opends.server.protocols.internal.InternalSearchOperation;
641N/Aimport org.opends.server.tools.LDAPModify;
641N/Aimport org.opends.server.types.AttributeType;
641N/Aimport org.opends.server.types.AttributeValue;
641N/Aimport org.opends.server.types.DirectoryException;
673N/Aimport org.opends.server.types.DITContentRule;
641N/Aimport org.opends.server.types.DN;
641N/Aimport org.opends.server.types.Entry;
673N/Aimport org.opends.server.types.ExistingFileBehavior;
673N/Aimport org.opends.server.types.InitializationException;
673N/Aimport org.opends.server.types.LDIFExportConfig;
673N/Aimport org.opends.server.types.LDIFImportConfig;
673N/Aimport org.opends.server.types.MatchingRuleUse;
673N/Aimport org.opends.server.types.ObjectClass;
641N/Aimport org.opends.server.types.ResultCode;
641N/Aimport org.opends.server.types.SearchFilter;
641N/Aimport org.opends.server.types.SearchScope;
641N/A
641N/Aimport static org.testng.Assert.*;
641N/A
641N/Aimport static org.opends.server.util.StaticUtils.*;
641N/A
641N/A
641N/A
641N/A/**
641N/A * A set of test cases for the schema backend.
641N/A */
641N/Apublic class SchemaBackendTestCase
641N/A extends BackendTestCase
641N/A{
641N/A // A reference to the schema backend.
641N/A private SchemaBackend schemaBackend;
641N/A
641N/A
641N/A /**
641N/A * Ensures that the Directory Server is running and gets a reference to the
641N/A * schema backend.
641N/A *
641N/A * @throws Exception If an unexpected problem occurs.
641N/A */
641N/A @BeforeClass()
641N/A public void startServer()
641N/A throws Exception
641N/A {
641N/A TestCaseUtils.startServer();
641N/A
641N/A schemaBackend = (SchemaBackend) DirectoryServer.getBackend("schema");
641N/A assertNotNull(schemaBackend);
641N/A }
641N/A
641N/A
641N/A
641N/A /**
673N/A * Tests the {@code initializeBackend} method by providing a null
673N/A * configuration entry.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test(expectedExceptions = { ConfigException.class,
673N/A InitializationException.class })
673N/A public void testInitializeWithNullEntry()
673N/A throws Exception
673N/A {
673N/A SchemaBackend schemaBackend = new SchemaBackend();
1329N/A schemaBackend.configureBackend(null);
673N/A }
673N/A
673N/A
673N/A
673N/A /**
641N/A * Tests the {@code isLocal} method to ensure that it is considered local.
641N/A */
641N/A @Test()
641N/A public void testIsLocal()
641N/A {
641N/A assertTrue(schemaBackend.isLocal());
641N/A }
641N/A
641N/A
641N/A
641N/A /**
641N/A * Tests the {@code getEntry} method to ensure that it is able to retrieve
641N/A * the schema entry if it is given a valid entry DN.
641N/A *
641N/A * @throws Exception If an unexpected problem occurs.
641N/A */
641N/A @Test()
641N/A public void testGetValidEntry()
641N/A throws Exception
641N/A {
641N/A DN schemaDN = DN.decode("cn=schema");
641N/A Entry schemaEntry = schemaBackend.getEntry(schemaDN);
641N/A assertNotNull(schemaEntry);
641N/A assertEquals(schemaEntry.getDN(), schemaDN);
641N/A
641N/A AttributeType t = DirectoryServer.getAttributeType("attributetypes");
641N/A assertTrue(schemaEntry.hasAttribute(t));
641N/A
641N/A t = DirectoryServer.getAttributeType("objectclasses");
641N/A assertTrue(schemaEntry.hasAttribute(t));
641N/A
641N/A t = DirectoryServer.getAttributeType("ldapsyntaxes");
641N/A assertTrue(schemaEntry.hasAttribute(t));
641N/A
641N/A t = DirectoryServer.getAttributeType("matchingrules");
641N/A assertTrue(schemaEntry.hasAttribute(t));
641N/A }
641N/A
641N/A
641N/A
641N/A /**
641N/A * Tests the {@code getEntry} method to ensure that it is not able to retrieve
641N/A * anything when given an inappropriate DN.
641N/A *
641N/A * @throws Exception If an unexpected problem occurs.
641N/A */
641N/A @Test()
641N/A public void testGetInvalidEntry()
641N/A throws Exception
641N/A {
641N/A DN schemaDN = DN.decode("cn=notschema");
641N/A Entry schemaEntry = schemaBackend.getEntry(schemaDN);
641N/A assertNull(schemaEntry);
641N/A
641N/A schemaDN = DN.decode("cn=child,cn=schema");
641N/A schemaEntry = schemaBackend.getEntry(schemaDN);
641N/A assertNull(schemaEntry);
641N/A }
641N/A
641N/A
641N/A
641N/A /**
641N/A * Tests the {@code getSchemaEntry} method to ensure that it is able to
641N/A * retrieve the appropriate information with different DNs.
641N/A *
641N/A * @throws Exception If an unexpected problem occurs.
641N/A */
641N/A @Test()
641N/A public void testGetSchemaEntry()
641N/A throws Exception
641N/A {
641N/A DN schemaDN = DN.decode("cn=schema");
2817N/A Entry schemaEntry = schemaBackend.getSchemaEntry(schemaDN, false);
641N/A assertNotNull(schemaEntry);
641N/A assertEquals(schemaEntry.getDN(), schemaDN);
641N/A
641N/A AttributeType t = DirectoryServer.getAttributeType("attributetypes");
641N/A assertTrue(schemaEntry.hasAttribute(t));
641N/A
641N/A t = DirectoryServer.getAttributeType("objectclasses");
641N/A assertTrue(schemaEntry.hasAttribute(t));
641N/A
641N/A t = DirectoryServer.getAttributeType("ldapsyntaxes");
641N/A assertTrue(schemaEntry.hasAttribute(t));
641N/A
641N/A t = DirectoryServer.getAttributeType("matchingrules");
641N/A assertTrue(schemaEntry.hasAttribute(t));
641N/A
641N/A
641N/A schemaDN = DN.decode("cn=subschema");
2817N/A schemaEntry = schemaBackend.getSchemaEntry(schemaDN, false);
641N/A assertNotNull(schemaEntry);
641N/A assertEquals(schemaEntry.getDN(), schemaDN);
641N/A
641N/A t = DirectoryServer.getAttributeType("attributetypes");
641N/A assertTrue(schemaEntry.hasAttribute(t));
641N/A
641N/A t = DirectoryServer.getAttributeType("objectclasses");
641N/A assertTrue(schemaEntry.hasAttribute(t));
641N/A
641N/A t = DirectoryServer.getAttributeType("ldapsyntaxes");
641N/A assertTrue(schemaEntry.hasAttribute(t));
641N/A
641N/A t = DirectoryServer.getAttributeType("matchingrules");
641N/A assertTrue(schemaEntry.hasAttribute(t));
641N/A }
641N/A
641N/A
641N/A
641N/A /**
641N/A * Tests the {@code entryExists} method with a valid schema DN.
641N/A *
641N/A * @throws Exception If an unexpected problem occurs.
641N/A */
641N/A @Test()
641N/A public void testEntryExistsValidDN()
641N/A throws Exception
641N/A {
641N/A DN schemaDN = DN.decode("cn=schema");
641N/A assertTrue(schemaBackend.entryExists(schemaDN));
641N/A }
641N/A
641N/A
641N/A
641N/A /**
641N/A * Tests the {@code entryExists} method with an invalid schema DN.
641N/A *
641N/A * @throws Exception If an unexpected problem occurs.
641N/A */
641N/A @Test()
641N/A public void testEntryExistsInvalidDN()
641N/A throws Exception
641N/A {
641N/A DN schemaDN = DN.decode("cn=notschema");
641N/A assertFalse(schemaBackend.entryExists(schemaDN));
641N/A }
641N/A
641N/A
641N/A
641N/A /**
641N/A * Tests to ensure that the {@code addEntry} method always throws an
641N/A * exception.
641N/A */
641N/A @Test(expectedExceptions = { DirectoryException.class })
641N/A public void testAddEntry()
641N/A throws Exception
641N/A {
641N/A Entry entry = createEntry(DN.decode("cn=schema"));
641N/A
641N/A InternalClientConnection conn =
641N/A InternalClientConnection.getRootConnection();
1689N/A AddOperationBasis addOperation =
5902N/A new AddOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(),
641N/A null, entry.getDN(), entry.getObjectClasses(),
641N/A entry.getUserAttributes(),
641N/A entry.getOperationalAttributes());
641N/A
641N/A schemaBackend.addEntry(entry, addOperation);
641N/A }
641N/A
641N/A
641N/A
641N/A /**
641N/A * Tests to ensure that the {@code deleteEntry} method always throws an
641N/A * exception.
641N/A */
641N/A @Test(expectedExceptions = { DirectoryException.class })
641N/A public void testDeleteEntry()
641N/A throws Exception
641N/A {
641N/A DN schemaDN = DN.decode("cn=schema");
641N/A
641N/A InternalClientConnection conn =
641N/A InternalClientConnection.getRootConnection();
1689N/A DeleteOperationBasis deleteOperation =
5902N/A new DeleteOperationBasis(conn, InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(),
641N/A null, schemaDN);
641N/A
641N/A schemaBackend.deleteEntry(schemaDN, deleteOperation);
641N/A }
641N/A
641N/A
641N/A
641N/A /**
641N/A * Tests to ensure that the {@code renameEntry} method always throws an
641N/A * exception.
641N/A */
641N/A @Test(expectedExceptions = { DirectoryException.class })
641N/A public void testRenameEntry()
641N/A throws Exception
641N/A {
641N/A DN currentSchemaDN = DN.decode("cn=schema");
641N/A DN newSchemaDN = DN.decode("cn=newschema");
641N/A
641N/A InternalClientConnection conn =
641N/A InternalClientConnection.getRootConnection();
1858N/A ModifyDNOperationBasis modifyDNOperation =
5902N/A new ModifyDNOperationBasis(conn, InternalClientConnection.nextOperationID(),
5902N/A InternalClientConnection.nextMessageID(), null,
641N/A currentSchemaDN, newSchemaDN.getRDN(),
641N/A true, null);
641N/A
641N/A schemaBackend.renameEntry(currentSchemaDN,
2817N/A schemaBackend.getSchemaEntry(newSchemaDN, false),
641N/A modifyDNOperation);
641N/A }
641N/A
641N/A
641N/A
641N/A /**
641N/A * Performs a simple base-level search to verify that the schema entry is
641N/A * returned.
641N/A *
641N/A * @throws Exception If an unexpected problem occurs.
641N/A */
641N/A @Test()
641N/A public void testSimpleBaseSearch()
641N/A throws Exception
641N/A {
641N/A String filterString = "(|(objectClass=*)(objectClass=ldapSubentry))";
641N/A
641N/A InternalClientConnection conn =
641N/A InternalClientConnection.getRootConnection();
641N/A InternalSearchOperation searchOperation =
641N/A conn.processSearch(DN.decode("cn=schema"), SearchScope.BASE_OBJECT,
641N/A SearchFilter.createFilterFromString(filterString));
641N/A assertNotNull(searchOperation);
641N/A assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS);
641N/A assertFalse(searchOperation.getSearchEntries().isEmpty());
641N/A }
641N/A
641N/A
641N/A
641N/A /**
641N/A * Performs a simple single-level search to verify that nothing is returned.
641N/A *
641N/A * @throws Exception If an unexpected problem occurs.
641N/A */
641N/A @Test()
641N/A public void testSimpleOneLevelSearch()
641N/A throws Exception
641N/A {
641N/A String filterString = "(|(objectClass=*)(objectClass=ldapSubentry))";
641N/A
641N/A InternalClientConnection conn =
641N/A InternalClientConnection.getRootConnection();
641N/A InternalSearchOperation searchOperation =
641N/A conn.processSearch(DN.decode("cn=schema"), SearchScope.SINGLE_LEVEL,
641N/A SearchFilter.createFilterFromString(filterString));
641N/A assertNotNull(searchOperation);
641N/A assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS);
641N/A assertTrue(searchOperation.getSearchEntries().isEmpty());
641N/A }
641N/A
641N/A
641N/A
641N/A /**
641N/A * Performs a simple subtree search to verify that the schema entry is
641N/A * returned.
641N/A *
641N/A * @throws Exception If an unexpected problem occurs.
641N/A */
641N/A @Test()
641N/A public void testSimpleSubtreeSearch()
641N/A throws Exception
641N/A {
641N/A String filterString = "(|(objectClass=*)(objectClass=ldapSubentry))";
641N/A
641N/A InternalClientConnection conn =
641N/A InternalClientConnection.getRootConnection();
641N/A InternalSearchOperation searchOperation =
641N/A conn.processSearch(DN.decode("cn=schema"), SearchScope.WHOLE_SUBTREE,
641N/A SearchFilter.createFilterFromString(filterString));
641N/A assertNotNull(searchOperation);
641N/A assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS);
641N/A assertFalse(searchOperation.getSearchEntries().isEmpty());
641N/A }
641N/A
641N/A
641N/A
641N/A /**
641N/A * Performs a simple subordinate subtree search to verify that nothing is
641N/A * returned.
641N/A *
641N/A * @throws Exception If an unexpected problem occurs.
641N/A */
641N/A @Test()
641N/A public void testSimpleSubordinateSubtreeSearch()
641N/A throws Exception
641N/A {
641N/A String filterString = "(|(objectClass=*)(objectClass=ldapSubentry))";
641N/A
641N/A InternalClientConnection conn =
641N/A InternalClientConnection.getRootConnection();
641N/A InternalSearchOperation searchOperation =
641N/A conn.processSearch(DN.decode("cn=schema"),
641N/A SearchScope.SUBORDINATE_SUBTREE,
641N/A SearchFilter.createFilterFromString(filterString));
641N/A assertNotNull(searchOperation);
641N/A assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS);
641N/A assertTrue(searchOperation.getSearchEntries().isEmpty());
641N/A }
641N/A
641N/A
641N/A
641N/A /**
954N/A * Performs a set of searches in the schema backend to ensure that they
954N/A * correctly set the matched DN in the response.
954N/A *
954N/A * @throws Exception If an unexpected problem occurs.
954N/A */
954N/A @Test()
954N/A public void testSearchMatchedDN()
954N/A throws Exception
954N/A {
954N/A InternalClientConnection conn =
954N/A InternalClientConnection.getRootConnection();
954N/A DN baseDN = DN.decode("o=bogus,cn=schema");
954N/A SearchFilter filter =
954N/A SearchFilter.createFilterFromString("(objectClass=*)");
954N/A
954N/A for (SearchScope scope : SearchScope.values())
954N/A {
954N/A InternalSearchOperation searchOperation =
954N/A conn.processSearch(baseDN, scope, filter);
954N/A assertNotNull(searchOperation.getMatchedDN(),
954N/A "No matched DN for scope " + scope);
954N/A }
954N/A }
954N/A
954N/A
954N/A
954N/A /**
641N/A * Tests the behavior of the schema backend with regard to the
641N/A * ds-cfg-show-all-attributes configuration.
641N/A *
641N/A * @throws Exception If a problem occurs.
641N/A */
641N/A @Test()
641N/A public void testTreatAsUserAttrs()
641N/A throws Exception
641N/A {
641N/A DN schemaDN = DN.decode("cn=schema");
641N/A AttributeType a = DirectoryServer.getAttributeType("attributetypes");
641N/A AttributeType o = DirectoryServer.getAttributeType("objectclasses");
641N/A AttributeType m = DirectoryServer.getAttributeType("matchingrules");
641N/A AttributeType s = DirectoryServer.getAttributeType("ldapsyntaxes");
641N/A
641N/A assertFalse(schemaBackend.showAllAttributes());
2817N/A Entry schemaEntry = schemaBackend.getSchemaEntry(schemaDN, false);
641N/A assertTrue(schemaEntry.hasOperationalAttribute(a));
641N/A assertTrue(schemaEntry.hasOperationalAttribute(o));
641N/A assertTrue(schemaEntry.hasOperationalAttribute(m));
641N/A assertTrue(schemaEntry.hasOperationalAttribute(s));
641N/A
641N/A schemaBackend.setShowAllAttributes(true);
641N/A assertTrue(schemaBackend.showAllAttributes());
2817N/A schemaEntry = schemaBackend.getSchemaEntry(schemaDN, false);
641N/A assertFalse(schemaEntry.hasOperationalAttribute(a));
641N/A assertFalse(schemaEntry.hasOperationalAttribute(o));
641N/A assertFalse(schemaEntry.hasOperationalAttribute(m));
641N/A assertTrue(schemaEntry.hasOperationalAttribute(s));
641N/A
641N/A schemaBackend.setShowAllAttributes(false);
641N/A assertFalse(schemaBackend.showAllAttributes());
2817N/A schemaEntry = schemaBackend.getSchemaEntry(schemaDN, false);
641N/A assertTrue(schemaEntry.hasOperationalAttribute(a));
641N/A assertTrue(schemaEntry.hasOperationalAttribute(o));
641N/A assertTrue(schemaEntry.hasOperationalAttribute(m));
641N/A assertTrue(schemaEntry.hasOperationalAttribute(s));
641N/A }
641N/A
641N/A
641N/A
641N/A /**
641N/A * Tests the behavior of the schema backend when attempting to add a new
673N/A * attribute type that is not allowed to be altered.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testAddUnsupportedAttr()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: objectClass",
673N/A "objectClass: extensibleObject");
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to remove an
673N/A * attribute type that is not allowed to be altered.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testRemoveUnsupportedAttr()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "delete: objectClass",
673N/A "objectClass: subschema",
673N/A "-",
673N/A "add: objectClass",
673N/A "objectClass: extensibleObject");
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to remove all
673N/A * attribute type definitions.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testRemoveAllAttributeTypes()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "delete: attributeTypes");
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to replace all
673N/A * attribute types.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testReplaceAllAttributeTypes()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "replace: attributeTypes");
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to add a new
641N/A * attribute type with a valid syntax and that isn't already defined.
641N/A *
641N/A * @throws Exception If an unexpected problem occurs.
641N/A */
641N/A @Test()
641N/A public void testAddAttributeTypeSuccessful()
641N/A throws Exception
641N/A {
641N/A String path = TestCaseUtils.createTempFile(
641N/A "dn: cn=schema",
641N/A "changetype: modify",
641N/A "add: attributeTypes",
673N/A "attributeTypes: ( 1.3.6.1.4.1.26027.1.999.4 " +
673N/A "NAME 'testAddAttributeTypeSuccessful' " +
673N/A "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " +
673N/A "X-ORGIN 'SchemaBackendTestCase' )");
641N/A
641N/A String attrName = "testaddattributetypesuccessful";
641N/A assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName));
641N/A
641N/A String[] args =
641N/A {
641N/A "-h", "127.0.0.1",
641N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
641N/A "-D", "cn=Directory Manager",
641N/A "-w", "password",
641N/A "-f", path
641N/A };
641N/A
641N/A assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
641N/A assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName));
641N/A }
641N/A
641N/A
641N/A
641N/A /**
641N/A * Tests the behavior of the schema backend when attempting to add a new
641N/A * attribute type with a valid syntax (but using a textual OID rather than
641N/A * numeric) and that isn't already defined.
641N/A *
641N/A * @throws Exception If an unexpected problem occurs.
641N/A */
641N/A @Test()
641N/A public void testAddAttributeTypeSuccessfulNoOID()
641N/A throws Exception
641N/A {
641N/A String path = TestCaseUtils.createTempFile(
641N/A "dn: cn=schema",
641N/A "changetype: modify",
641N/A "add: attributeTypes",
673N/A "attributeTypes: ( testaddattributetypesuccessfulnooid-oid " +
673N/A "NAME 'testAddAttributeTypeSuccessfulNoOID' " +
673N/A "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " +
673N/A "X-ORGIN 'SchemaBackendTestCase' )");
641N/A
641N/A String attrName = "testaddattributetypesuccessfulnooid";
641N/A assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName));
641N/A
641N/A String[] args =
641N/A {
641N/A "-h", "127.0.0.1",
641N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
641N/A "-D", "cn=Directory Manager",
641N/A "-w", "password",
641N/A "-f", path
641N/A };
641N/A
641N/A assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
641N/A assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName));
641N/A }
641N/A
641N/A
641N/A
641N/A /**
641N/A * Tests the behavior of the schema backend when attempting to add a new
4495N/A * attribute type with a valid syntax (but using a textual OID rather than
4495N/A * numeric) and that has no space before last parenthesis.
4495N/A *
4495N/A * @throws Exception If an unexpected problem occurs.
4495N/A */
4495N/A @Test()
4495N/A public void testAddAttributeType()
4495N/A throws Exception
4495N/A {
4495N/A String path = TestCaseUtils.createTempFile(
4495N/A "dn: cn=schema",
4495N/A "changetype: modify",
4495N/A "add: attributeTypes",
4495N/A "attributeTypes: ( testaddattributetypenospacebeforepathenthesis-oid " +
4495N/A "NAME 'testAddAttributeTypeNoSpaceBeforeParenthesis' " +
4495N/A "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " +
4495N/A "SINGLE-VALUE)");
4495N/A
4495N/A String attrName = "testaddattributetypenospacebeforeparenthesis";
4495N/A assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName));
4495N/A
4495N/A String[] args =
4495N/A {
4495N/A "-h", "127.0.0.1",
4495N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
4495N/A "-D", "cn=Directory Manager",
4495N/A "-w", "password",
4495N/A "-f", path
4495N/A };
4495N/A
4495N/A assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
4495N/A assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName));
4495N/A }
4495N/A
4495N/A
4495N/A
4495N/A /**
4495N/A * Tests the behavior of the schema backend when attempting to add a new
673N/A * attribute type to a specific schema file.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
2342N/A @Test
673N/A public void testAddAttributeTypeToAltSchemaFile()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: attributeTypes",
673N/A "attributeTypes: ( testaddattributetypetoaltschemafile-oid " +
673N/A "NAME 'testAddAttributeTypeToAltSchemaFile' " +
673N/A "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' " +
673N/A "X-SCHEMA-FILE '98-schema-test-attrtype.ldif' )");
673N/A
673N/A String attrName = "testaddattributetypetoaltschemafile";
673N/A assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName));
673N/A
6318N/A File schemaFile = new File(SchemaConfigManager.getSchemaDirectoryPath(),
673N/A "98-schema-test-attrtype.ldif");
673N/A assertFalse(schemaFile.exists());
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
673N/A assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName));
673N/A assertTrue(schemaFile.exists());
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to add a new
673N/A * attribute type in a manner that replaces an existing definition.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testAddAttributeTypeSuccessfulReplace()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: attributeTypes",
673N/A "attributeTypes: ( testaddattributetypesuccessfulreplace-oid " +
673N/A "NAME 'testAddAttributeTypeSuccessfulReplace' " +
673N/A "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )",
673N/A "",
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: attributeTypes",
673N/A "attributeTypes: ( testaddattributetypesuccessfulreplace-oid " +
673N/A "NAME 'testAddAttributeTypeSuccessfulReplace' " +
673N/A "SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )");
673N/A
673N/A String attrName = "testaddattributetypesuccessfulreplace";
673N/A assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName));
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
673N/A assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName));
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to replace an
673N/A * attribute type definition in a custom schema file.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
2342N/A @Test
673N/A public void testReplaceAttributeTypeInAltSchemaFile()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: attributeTypes",
673N/A "attributeTypes: ( testreplaceattributetypeinaltschemafile-oid " +
673N/A "NAME 'testReplaceAttributeTypeInAltSchemaFile' " +
673N/A "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' " +
673N/A "X-SCHEMA-FILE '98-schema-test-replaceattrtype.ldif' )",
673N/A "",
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: attributeTypes",
673N/A "attributeTypes: ( testreplaceattributetypeinaltschemafile-oid " +
673N/A "NAME 'testReplaceAttributeTypeInAltSchemaFile' " +
673N/A "SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )");
673N/A
673N/A String attrName = "testreplaceattributetypeinaltschemafile";
673N/A assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName));
673N/A
6318N/A File schemaFile = new File(SchemaConfigManager.getSchemaDirectoryPath(),
673N/A "98-schema-test-replaceattrtype.ldif");
673N/A assertFalse(schemaFile.exists());
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
673N/A assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName));
673N/A assertTrue(schemaFile.exists());
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to add a new
641N/A * attribute type definition that can't be parsed.
641N/A *
641N/A * @throws Exception If an unexpected problem occurs.
641N/A */
641N/A @Test()
641N/A public void testAddAttributeTypeInvalidSyntax()
641N/A throws Exception
641N/A {
641N/A String path = TestCaseUtils.createTempFile(
641N/A "dn: cn=schema",
641N/A "changetype: modify",
641N/A "add: attributeTypes",
641N/A "attributeTypes: invalidsyntax");
641N/A
641N/A String[] args =
641N/A {
641N/A "-h", "127.0.0.1",
641N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
641N/A "-D", "cn=Directory Manager",
641N/A "-w", "password",
641N/A "-f", path
641N/A };
641N/A
641N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
641N/A }
641N/A
641N/A
641N/A
641N/A /**
641N/A * Tests the behavior of the schema backend when attempting to add a new
723N/A * attribute type with an undefined syntax.
723N/A *
723N/A * @throws Exception If an unexpected problem occurs.
723N/A */
723N/A @Test()
723N/A public void testAddAttributeTypeUndefinedSyntax()
723N/A throws Exception
723N/A {
723N/A String path = TestCaseUtils.createTempFile(
723N/A "dn: cn=schema",
723N/A "changetype: modify",
723N/A "add: attributeTypes",
723N/A "attributeTypes: ( testaddatundefinedsyntax-oid " +
723N/A "NAME 'testAddATUndefinedSyntax' " +
723N/A "SYNTAX 1.3.6.1.4.1.1466.115.121.1.99999 SINGLE-VALUE " +
723N/A "X-ORGIN 'SchemaBackendTestCase' )");
723N/A
723N/A String[] args =
723N/A {
723N/A "-h", "127.0.0.1",
723N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
723N/A "-D", "cn=Directory Manager",
723N/A "-w", "password",
723N/A "-f", path
723N/A };
723N/A
723N/A assertFalse(LDAPModify.mainModify(args, false, null, System.err) == 0);
723N/A }
723N/A
723N/A
723N/A
723N/A /**
723N/A * Tests the behavior of the schema backend when attempting to add a new
723N/A * attribute type with an undefined equality matching rule.
723N/A *
723N/A * @throws Exception If an unexpected problem occurs.
723N/A */
723N/A @Test()
723N/A public void testAddAttributeTypeUndefinedEMR()
723N/A throws Exception
723N/A {
723N/A String path = TestCaseUtils.createTempFile(
723N/A "dn: cn=schema",
723N/A "changetype: modify",
723N/A "add: attributeTypes",
723N/A "attributeTypes: ( testaddatundefinedemr-oid " +
723N/A "NAME 'testAddATUndefinedEMR' EQUALITY xxxundefinedxxx " +
723N/A "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " +
723N/A "X-ORGIN 'SchemaBackendTestCase' )");
723N/A
723N/A String[] args =
723N/A {
723N/A "-h", "127.0.0.1",
723N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
723N/A "-D", "cn=Directory Manager",
723N/A "-w", "password",
723N/A "-f", path
723N/A };
723N/A
723N/A assertFalse(LDAPModify.mainModify(args, false, null, System.err) == 0);
723N/A }
723N/A
723N/A
723N/A
723N/A /**
723N/A * Tests the behavior of the schema backend when attempting to add a new
723N/A * attribute type with an undefined ordering matching rule.
723N/A *
723N/A * @throws Exception If an unexpected problem occurs.
723N/A */
723N/A @Test()
723N/A public void testAddAttributeTypeUndefinedOMR()
723N/A throws Exception
723N/A {
723N/A String path = TestCaseUtils.createTempFile(
723N/A "dn: cn=schema",
723N/A "changetype: modify",
723N/A "add: attributeTypes",
723N/A "attributeTypes: ( testaddatundefinedomr-oid " +
723N/A "NAME 'testAddATUndefinedOMR' ORDERING xxxundefinedxxx " +
723N/A "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " +
723N/A "X-ORGIN 'SchemaBackendTestCase' )");
723N/A
723N/A String[] args =
723N/A {
723N/A "-h", "127.0.0.1",
723N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
723N/A "-D", "cn=Directory Manager",
723N/A "-w", "password",
723N/A "-f", path
723N/A };
723N/A
723N/A assertFalse(LDAPModify.mainModify(args, false, null, System.err) == 0);
723N/A }
723N/A
723N/A
723N/A
723N/A /**
723N/A * Tests the behavior of the schema backend when attempting to add a new
723N/A * attribute type with an undefined substring matching rule.
723N/A *
723N/A * @throws Exception If an unexpected problem occurs.
723N/A */
723N/A @Test()
723N/A public void testAddAttributeTypeUndefinedSMR()
723N/A throws Exception
723N/A {
723N/A String path = TestCaseUtils.createTempFile(
723N/A "dn: cn=schema",
723N/A "changetype: modify",
723N/A "add: attributeTypes",
723N/A "attributeTypes: ( testaddatundefinedsmr-oid " +
723N/A "NAME 'testAddATUndefinedSMR' SUBSTR xxxundefinedxxx " +
723N/A "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " +
723N/A "X-ORGIN 'SchemaBackendTestCase' )");
723N/A
723N/A String[] args =
723N/A {
723N/A "-h", "127.0.0.1",
723N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
723N/A "-D", "cn=Directory Manager",
723N/A "-w", "password",
723N/A "-f", path
723N/A };
723N/A
723N/A assertFalse(LDAPModify.mainModify(args, false, null, System.err) == 0);
723N/A }
723N/A
723N/A
723N/A
723N/A /**
723N/A * Tests the behavior of the schema backend when attempting to add a new
723N/A * attribute type with an undefined approximate matching rule.
723N/A *
723N/A * @throws Exception If an unexpected problem occurs.
723N/A */
723N/A @Test()
723N/A public void testAddAttributeTypeUndefinedAMR()
723N/A throws Exception
723N/A {
723N/A String path = TestCaseUtils.createTempFile(
723N/A "dn: cn=schema",
723N/A "changetype: modify",
723N/A "add: attributeTypes",
723N/A "attributeTypes: ( testaddatundefinedamr-oid " +
723N/A "NAME 'testAddATUndefinedAMR' " +
723N/A "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " +
723N/A "X-APPROX 'xxxundefinedxxx' X-ORGIN 'SchemaBackendTestCase' )");
723N/A
723N/A String[] args =
723N/A {
723N/A "-h", "127.0.0.1",
723N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
723N/A "-D", "cn=Directory Manager",
723N/A "-w", "password",
723N/A "-f", path
723N/A };
723N/A
723N/A assertFalse(LDAPModify.mainModify(args, false, null, System.err) == 0);
723N/A }
723N/A
723N/A
723N/A
723N/A /**
723N/A * Tests the behavior of the schema backend when attempting to add a new
723N/A * attribute type with an invalid usage.
723N/A *
723N/A * @throws Exception If an unexpected problem occurs.
723N/A */
723N/A @Test()
723N/A public void testAddAttributeTypeInvalidUsage()
723N/A throws Exception
723N/A {
723N/A String path = TestCaseUtils.createTempFile(
723N/A "dn: cn=schema",
723N/A "changetype: modify",
723N/A "add: attributeTypes",
723N/A "attributeTypes: ( testaddatundefinedsyntax-oid " +
723N/A "NAME 'testAddATUndefinedSyntax' " +
723N/A "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " +
723N/A "USAGE xxxinvalidxxx X-ORGIN 'SchemaBackendTestCase' )");
723N/A
723N/A String[] args =
723N/A {
723N/A "-h", "127.0.0.1",
723N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
723N/A "-D", "cn=Directory Manager",
723N/A "-w", "password",
723N/A "-f", path
723N/A };
723N/A
723N/A assertFalse(LDAPModify.mainModify(args, false, null, System.err) == 0);
723N/A }
723N/A
723N/A
723N/A
723N/A /**
723N/A * Tests the behavior of the schema backend when attempting to add a new
723N/A * attribute type whose superior type is marked OBSOLETE in the server schema.
723N/A *
723N/A * @throws Exception If an unexpected problem occurs.
723N/A */
723N/A @Test()
723N/A public void testAddAttributeTypeObsoleteSuperior()
723N/A throws Exception
723N/A {
723N/A String path = TestCaseUtils.createTempFile(
723N/A "dn: cn=schema",
723N/A "changetype: modify",
723N/A "add: attributeTypes",
723N/A "attributeTypes: ( testaddatobsoletesuperiorsup-oid " +
723N/A "NAME 'testAddATObsoleteSuperiorSup' OBSOLETE " +
723N/A "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " +
723N/A "X-ORGIN 'SchemaBackendTestCase' )",
723N/A "attributeTypes: ( testaddatobsoletesuperior-oid " +
723N/A "NAME 'testAddATObsoleteSuperior' " +
723N/A "SUP testAddATObsoleteSuperiorSup " +
723N/A "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " +
723N/A "X-ORGIN 'SchemaBackendTestCase' )");
723N/A
723N/A String[] args =
723N/A {
723N/A "-h", "127.0.0.1",
723N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
723N/A "-D", "cn=Directory Manager",
723N/A "-w", "password",
723N/A "-f", path
723N/A };
723N/A
723N/A assertFalse(LDAPModify.mainModify(args, false, null, System.err) == 0);
723N/A }
723N/A
723N/A
723N/A
723N/A /**
723N/A * Tests the behavior of the schema backend when attempting to add a new
723N/A * attribute type whose equality matching rule is marked OBSOLETE in the
723N/A * server schema.
723N/A *
723N/A * @throws Exception If an unexpected problem occurs.
723N/A */
723N/A @Test()
723N/A public void testAddAttributeTypeObsoleteEMR()
723N/A throws Exception
723N/A {
723N/A SchemaTestMatchingRule matchingRule =
723N/A new SchemaTestMatchingRule("testAddATObsoleteEMRMatch",
723N/A "1.3.6.1.4.1.26027.1.999.20", true);
723N/A DirectoryServer.registerMatchingRule(matchingRule, false);
723N/A
723N/A
723N/A String path = TestCaseUtils.createTempFile(
723N/A "dn: cn=schema",
723N/A "changetype: modify",
723N/A "add: attributeTypes",
723N/A "attributeTypes: ( testaddatobsoleteemr-oid " +
723N/A "NAME 'testAddATObsoleteEMR' " +
723N/A "EQUALITY testAddATObsoleteEMRMatch " +
723N/A "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " +
723N/A "X-ORGIN 'SchemaBackendTestCase' )");
723N/A
723N/A String[] args =
723N/A {
723N/A "-h", "127.0.0.1",
723N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
723N/A "-D", "cn=Directory Manager",
723N/A "-w", "password",
723N/A "-f", path
723N/A };
723N/A
723N/A assertFalse(LDAPModify.mainModify(args, false, null, System.err) == 0);
723N/A }
723N/A
723N/A
723N/A
723N/A /**
723N/A * Tests the behavior of the schema backend when attempting to add a new
673N/A * attribute type that conflicts with multiple existing types.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testAddAttributeTypeMultipleConflicts()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: attributeTypes",
673N/A "attributeTypes: ( testaddattributetypemultipleconflicts-oid NAME " +
673N/A "( 'testAddAttributeTypeMultipleConflicts' 'cn' 'uid' ) SYNTAX " +
673N/A "1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN " +
673N/A "'SchemaBackendTestCase' )");
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to add a new
673N/A * attribute type that references an undefined superior attribute type.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testAddAttributeTypeUndefinedSuperior()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: attributeTypes",
673N/A "attributeTypes: ( testaddattributetypeundefinedsuperior-oid NAME " +
673N/A "'testAddAttributeTypeUndefinedSuperior' SUP undefined SYNTAX " +
673N/A "1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN " +
673N/A "'SchemaBackendTestCase' )");
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
673N/A }
673N/A
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to remove an
673N/A * attribute type that is defined in the server schema and does not have any
673N/A * dependencies.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testRemoveAttributeTypeSuccessful()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: attributeTypes",
673N/A "attributeTypes: ( 1.3.6.1.4.1.26027.1.999.6 NAME " +
673N/A "'testRemoveAttributeTypeSuccessful' SYNTAX " +
673N/A "1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN " +
673N/A "'SchemaBackendTestCase' )",
673N/A "",
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "delete: attributeTypes",
673N/A "attributeTypes: ( 1.3.6.1.4.1.26027.1.999.6 NAME " +
673N/A "'testRemoveAttributeTypeSuccessful' SYNTAX " +
673N/A "1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN " +
673N/A "'SchemaBackendTestCase' )");
673N/A
673N/A String attrName = "testremoveattributetypesuccessful";
673N/A assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName));
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
673N/A assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName));
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to remove an
673N/A * attribute type and add it back in the same modification.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testRemoveThenAddAttributeTypeSuccessful()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: attributeTypes",
673N/A "attributeTypes: ( testremovethenaddattributetypesuccessful-oid " +
673N/A "NAME 'testRemoveThenAddAttributeTypeSuccessful' " +
673N/A "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )",
673N/A "",
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "delete: attributeTypes",
673N/A "attributeTypes: ( testremovethenaddattributetypesuccessful-oid " +
673N/A "NAME 'testRemoveThenAddAttributeTypeSuccessful' " +
673N/A "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )",
673N/A "-",
673N/A "add: attributeTypes",
673N/A "attributeTypes: ( testremovethenaddattributetypesuccessful-oid " +
673N/A "NAME 'testRemoveThenAddAttributeTypeSuccessful' " +
673N/A "SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )");
673N/A
673N/A String attrName = "testremoveattributetypesuccessful";
673N/A assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName));
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
673N/A assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName));
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to remove an
673N/A * attribute type that is not defined in the server schema.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testRemoveAttributeTypeUndefined()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "delete: attributeTypes",
673N/A "attributeTypes: ( testremoveattributetypeundefined-oid " +
673N/A "NAME 'testRemoveAttributeTypeUndefined' " +
673N/A "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )");
673N/A
673N/A String attrName = "testremoveattributetypeundefined";
673N/A assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName));
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to remove an
673N/A * attribute type that is referenced as the superior type for another
673N/A * attribute type.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testRemoveSuperiorAttributeType()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "delete: attributeTypes",
673N/A "attributeTypes: ( 2.5.4.41 NAME 'name' EQUALITY caseIgnoreMatch " +
673N/A "SUBSTR caseIgnoreSubstringsMatch " +
673N/A "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{32768} " +
673N/A "X-ORIGIN 'RFC 2256' )");
673N/A
673N/A String attrName = "name";
673N/A assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName));
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
673N/A assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName));
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to remove an
673N/A * attribute type that is referenced by an existing objectclass.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testRemoveAttributeTypeReferencedByObjectClass()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "delete: attributeTypes",
673N/A "attributeTypes: ( 0.9.2342.19200300.100.1.1 NAME 'uid' " +
673N/A "EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch " +
673N/A "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{256} " +
673N/A "X-ORIGIN 'RFC 1274' )");
673N/A
673N/A String attrName = "uid";
673N/A assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName));
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
673N/A assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName));
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to remove an
673N/A * attribute type that is referenced by an existing name form.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testRemoveAttributeTypeReferencedByNameForm()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: attributeTypes",
673N/A "attributeTypes: ( testremoveattributetypereferencedbynf-oid " +
673N/A "NAME 'testRemoveAttributeTypeReferencedByNF' " +
673N/A "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )",
673N/A "-",
673N/A "add: objectClasses",
673N/A "objectClasses: ( testremoveattributetypereferencedbynfoc-oid " +
673N/A "NAME 'testRemoveAttributeTypeReferencedByNFOC' SUP top " +
673N/A "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase')",
673N/A "-",
673N/A "add: nameForms",
673N/A "nameForms: ( testremoveattributetypereferencedbynfnf-oid " +
673N/A "NAME 'testRemoveAttributeTypeReferencedByNFNF' " +
673N/A "OC testRemoveAttributeTypeReferencedByNFOC " +
673N/A "MUST testRemoveAttributeTypeReferencedByNF " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )",
673N/A "",
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "delete: attributeTypes",
673N/A "attributeTypes: ( testremoveattributetypereferencedbynf-oid " +
673N/A "NAME 'testRemoveAttributeTypeReferencedByNF' " +
673N/A "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )");
673N/A
673N/A String attrName = "testremoveattributetypereferencedbynf";
673N/A assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName));
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
673N/A assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName));
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to remove an
673N/A * attribute type that is referenced by an existing DIT content rule.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testRemoveAttributeTypeReferencedByDCR()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: attributeTypes",
673N/A "attributeTypes: ( testremoveattributetypereferencedbydcr-oid " +
673N/A "NAME 'testRemoveAttributeTypeReferencedByDCR' " +
673N/A "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )",
673N/A "-",
673N/A "add: objectClasses",
673N/A "objectClasses: ( testremoveattributetypereferencedbydcroc-oid " +
673N/A "NAME 'testRemoveAttributeTypeReferencedByDCROC' SUP top " +
673N/A "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase')",
673N/A "-",
673N/A "add: ditContentRules",
673N/A "ditContentRules: ( testremoveattributetypereferencedbydcroc-oid " +
673N/A "NAME 'testRemoveAttributeTypeReferencedByDCRDCR' " +
673N/A "MAY testRemoveAttributeTypeReferencedByDCR " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )",
673N/A "",
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "delete: attributeTypes",
673N/A "attributeTypes: ( testremoveattributetypereferencedbydcr-oid " +
673N/A "NAME 'testRemoveAttributeTypeReferencedByDCR' " +
673N/A "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )");
673N/A
673N/A String attrName = "testremoveattributetypereferencedbydcr";
673N/A assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName));
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
673N/A assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName));
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to remove an
673N/A * attribute type that is referenced by an existing matching rule use.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testRemoveAttributeTypeReferencedByMRU()
673N/A throws Exception
673N/A {
673N/A SchemaTestMatchingRule matchingRule =
673N/A new SchemaTestMatchingRule("testRemoveATRefByMRUMatch",
673N/A "1.3.6.1.4.1.26027.1.999.17");
673N/A DirectoryServer.registerMatchingRule(matchingRule, false);
673N/A
673N/A
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: attributeTypes",
673N/A "attributeTypes: ( testremoveatrefbymruat-oid " +
673N/A "NAME 'testRemoveATRefByMRUAT' " +
673N/A "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )",
673N/A "-",
673N/A "add: matchingRuleUse",
673N/A "matchingRuleUse: ( 1.3.6.1.4.1.26027.1.999.17 " +
673N/A "NAME 'testRemoveATRefByMRUMRU' APPLIES testRemoveATRefByMRUAT " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )",
673N/A "",
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "delete: attributeTypes",
673N/A "attributeTypes: ( testremoveatrefbymruat-oid " +
673N/A "NAME 'testRemoveATRefByMRUAT' " +
673N/A "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )");
673N/A
673N/A String attrName = "testremoveatrefbymruat";
673N/A assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName));
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
673N/A
673N/A MatchingRuleUse mru =
673N/A DirectoryServer.getSchema().getMatchingRuleUse(matchingRule);
673N/A assertNotNull(mru);
673N/A assertTrue(mru.hasName("testremoveatrefbymrumru"));
673N/A
673N/A assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName));
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to add a new
641N/A * objectclass that doesn't already exist, that has a valid superior class,
641N/A * and for which all attributes contained in it are already defined.
641N/A *
641N/A * @throws Exception If an unexpected problem occurs.
641N/A */
641N/A @Test()
641N/A public void testAddObjectClassSuccessful()
641N/A throws Exception
641N/A {
641N/A String path = TestCaseUtils.createTempFile(
641N/A "dn: cn=schema",
641N/A "changetype: modify",
641N/A "add: objectClasses",
641N/A "objectClasses: ( 1.3.6.1.4.1.26027.1.999.5 NAME " +
641N/A "'testAddObjectClassSuccessful' SUP top STRUCTURAL MUST cn " +
641N/A "X-ORIGIN 'SchemaBackendTestCase' )");
641N/A
641N/A String ocName = "testaddobjectclasssuccessful";
641N/A assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName));
641N/A
641N/A String[] args =
641N/A {
641N/A "-h", "127.0.0.1",
641N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
641N/A "-D", "cn=Directory Manager",
641N/A "-w", "password",
641N/A "-f", path
641N/A };
641N/A
641N/A assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
641N/A assertTrue(DirectoryServer.getSchema().hasObjectClass(ocName));
641N/A }
641N/A
641N/A
641N/A
641N/A /**
641N/A * Tests the behavior of the schema backend when attempting to add a new
641N/A * objectclass that doesn't already exist, that has a textual OID rather than
641N/A * numeric, has a valid superior class, and for which all attributes contained
641N/A * in it are already defined.
641N/A *
641N/A * @throws Exception If an unexpected problem occurs.
641N/A */
641N/A @Test()
641N/A public void testAddObjectClassSuccessfulNoOID()
641N/A throws Exception
641N/A {
641N/A String path = TestCaseUtils.createTempFile(
641N/A "dn: cn=schema",
641N/A "changetype: modify",
641N/A "add: objectClasses",
641N/A "objectClasses: ( testaddobjectclasssuccessfulnooid-oid NAME " +
641N/A "'testAddObjectClassSuccessfulNoOID' SUP top STRUCTURAL " +
641N/A "MUST cn X-ORIGIN 'SchemaBackendTestCase' )");
641N/A
641N/A String ocName = "testaddobjectclasssuccessfulnooid";
641N/A assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName));
641N/A
641N/A String[] args =
641N/A {
641N/A "-h", "127.0.0.1",
641N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
641N/A "-D", "cn=Directory Manager",
641N/A "-w", "password",
641N/A "-f", path
641N/A };
641N/A
641N/A assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
641N/A assertTrue(DirectoryServer.getSchema().hasObjectClass(ocName));
641N/A }
641N/A
641N/A
641N/A
641N/A /**
641N/A * Tests the behavior of the schema backend when attempting to add a new
673N/A * objectclass to a specific schema file.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testAddObjectClassToAltSchemaFile()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: objectClasses",
673N/A "objectClasses: ( testaddobjectclasstoaltschemafile-oid NAME " +
673N/A "'testAddObjectClassToAltSchemaFile' SUP top STRUCTURAL " +
673N/A "MUST cn X-ORIGIN 'SchemaBackendTestCase' " +
673N/A "X-SCHEMA-FILE '98-schema-test-oc.ldif' )");
673N/A
673N/A String ocName = "testaddobjectclasstoaltschemafile";
673N/A assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName));
673N/A
6318N/A File schemaFile = new File(SchemaConfigManager.getSchemaDirectoryPath(),
673N/A "98-schema-test-oc.ldif");
673N/A assertFalse(schemaFile.exists());
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
673N/A assertTrue(DirectoryServer.getSchema().hasObjectClass(ocName));
673N/A assertTrue(schemaFile.exists());
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to add a new
673N/A * objectclass that already exists (i.e., a replace)
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testAddObjectClassSuccessfulReplace()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: objectClasses",
673N/A "objectClasses: ( testaddobjectclasssuccessfulreplace-oid " +
673N/A "NAME 'testAddObjectClassSuccessfulReplace' SUP top STRUCTURAL " +
673N/A "MUST cn X-ORIGIN 'SchemaBackendTestCase' )",
673N/A "",
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: objectClasses",
673N/A "objectClasses: ( testaddobjectclasssuccessfulreplace-oid " +
673N/A "NAME 'testAddObjectClassSuccessfulReplace' SUP top STRUCTURAL " +
673N/A "MUST cn MAY description X-ORIGIN 'SchemaBackendTestCase' )");
673N/A
673N/A String ocName = "testaddobjectclasssuccessfulreplace";
673N/A assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName));
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
673N/A assertTrue(DirectoryServer.getSchema().hasObjectClass(ocName));
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to add a new
673N/A * objectclass that conflicts with multiple existing objectclasses.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testAddObjectClassMultipleConflicts()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: objectClasses",
673N/A "objectClasses: ( testaddobjectclassmultipleconflicts-oid " +
673N/A "NAME ( 'testAddObjectClassMultipleConflicts' 'person' " +
673N/A "'device' ) SUP top STRUCTURAL MUST cn " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )");
673N/A
673N/A String ocName = "testaddobjectclassmultipleconflicts";
673N/A assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName));
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
673N/A assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName));
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to remove an
673N/A * existing objectclass definition and then add it back in the same operation
673N/A * with a different definition.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testRemoveThenAddAddObjectClassSuccessful()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: objectClasses",
673N/A "objectClasses: ( testremovethenaddobjectclasssuccessful-oid " +
673N/A "NAME 'testRemoveThenAddObjectClassSuccessful' SUP top " +
673N/A "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase' )",
673N/A "",
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "delete: objectClasses",
673N/A "objectClasses: ( testremovethenaddobjectclasssuccessful-oid " +
673N/A "NAME 'testRemoveThenAddObjectClassSuccessful' SUP top " +
673N/A "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase' )",
673N/A "-",
673N/A "add: objectClasses",
673N/A "objectClasses: ( testremovethenaddobjectclasssuccessful-oid " +
673N/A "NAME 'testRemoveThenAddObjectClassSuccessful' SUP top " +
673N/A "STRUCTURAL MUST cn MAY description " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )");
673N/A
673N/A String ocName = "testremovethenaddobjectclasssuccessful";
673N/A assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName));
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
673N/A assertTrue(DirectoryServer.getSchema().hasObjectClass(ocName));
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to add a new
641N/A * objectclass definition that can't be parsed.
641N/A *
641N/A * @throws Exception If an unexpected problem occurs.
641N/A */
641N/A @Test()
641N/A public void testAddObjectClassInvalidSyntax()
641N/A throws Exception
641N/A {
641N/A String path = TestCaseUtils.createTempFile(
641N/A "dn: cn=schema",
641N/A "changetype: modify",
641N/A "add: objectClasses",
641N/A "objectClasses: invalidsyntax");
641N/A
641N/A String[] args =
641N/A {
641N/A "-h", "127.0.0.1",
641N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
641N/A "-D", "cn=Directory Manager",
641N/A "-w", "password",
641N/A "-f", path
641N/A };
641N/A
641N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
641N/A }
641N/A
641N/A
641N/A
641N/A /**
641N/A * Tests the behavior of the schema backend when attempting to add a new
641N/A * objectclass that references an undefined superior class.
641N/A *
641N/A * @throws Exception If an unexpected problem occurs.
641N/A */
641N/A @Test()
641N/A public void testAddObjectClassUndefinedSuperiorClass()
641N/A throws Exception
641N/A {
641N/A String path = TestCaseUtils.createTempFile(
641N/A "dn: cn=schema",
641N/A "changetype: modify",
641N/A "add: objectClasses",
641N/A "objectClasses: ( testaddocundefinedsuperior-oid NAME " +
641N/A "'testAddOCUndefinedSuperior' SUP undefined STRUCTURAL " +
641N/A "MUST cn X-ORIGIN 'SchemaBackendTestCase' )");
641N/A
641N/A String[] args =
641N/A {
641N/A "-h", "127.0.0.1",
641N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
641N/A "-D", "cn=Directory Manager",
641N/A "-w", "password",
641N/A "-f", path
641N/A };
641N/A
641N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
641N/A }
641N/A
641N/A
641N/A
641N/A /**
641N/A * Tests the behavior of the schema backend when attempting to add a new
723N/A * objectclass that references an obsolete superior class.
723N/A *
723N/A * @throws Exception If an unexpected problem occurs.
723N/A */
723N/A @Test()
723N/A public void testAddObjectClassObsoleteSuperiorClass()
723N/A throws Exception
723N/A {
723N/A String path = TestCaseUtils.createTempFile(
723N/A "dn: cn=schema",
723N/A "changetype: modify",
723N/A "add: objectClasses",
723N/A "objectClasses: ( testaddocobsoletesuperiorsup-oid " +
723N/A "NAME 'testAddOCObsoleteSuperiorSup' OBSOLETE STRUCTURAL " +
723N/A "MUST cn X-ORIGIN 'SchemaBackendTestCase' )",
723N/A "objectClasses: ( testaddocobsoletesuperior-oid " +
723N/A "NAME 'testAddOCObsoleteSuperior' OBSOLETE " +
723N/A "SUP testAddOCObsoleteSuperiorSup STRUCTURAL MUST cn " +
723N/A "X-ORIGIN 'SchemaBackendTestCase' )");
723N/A
723N/A String[] args =
723N/A {
723N/A "-h", "127.0.0.1",
723N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
723N/A "-D", "cn=Directory Manager",
723N/A "-w", "password",
723N/A "-f", path
723N/A };
723N/A
723N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
723N/A }
723N/A
723N/A
723N/A
723N/A /**
723N/A * Tests the behavior of the schema backend when attempting to add a new
723N/A * objectclass that references an obsolete required attribute type.
723N/A *
723N/A * @throws Exception If an unexpected problem occurs.
723N/A */
723N/A @Test()
723N/A public void testAddObjectClassObsoleteRequiredAttribute()
723N/A throws Exception
723N/A {
723N/A String path = TestCaseUtils.createTempFile(
723N/A "dn: cn=schema",
723N/A "changetype: modify",
723N/A "add: attributeTypes",
723N/A "attributeTypes: ( testaddocobsoleterequiredattrat-oid " +
723N/A "NAME 'testAddOCObsoleteRequiredAttrAT' OBSOLETE " +
723N/A "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " +
723N/A "X-ORIGIN 'SchemaBackendTestCase' )",
723N/A "-",
723N/A "add: objectClasses",
723N/A "objectClasses: ( testaddocobsoleterequiredattroc-oid " +
723N/A "NAME 'testAddOCObsoleteRequiredAttrOC' " +
723N/A "STRUCTURAL MUST testAddOCObsoleteRequiredAttrAT " +
723N/A "X-ORIGIN 'SchemaBackendTestCase' )");
723N/A
723N/A String[] args =
723N/A {
723N/A "-h", "127.0.0.1",
723N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
723N/A "-D", "cn=Directory Manager",
723N/A "-w", "password",
723N/A "-f", path
723N/A };
723N/A
723N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
723N/A }
723N/A
723N/A
723N/A
723N/A /**
723N/A * Tests the behavior of the schema backend when attempting to add a new
723N/A * objectclass that references an obsolete optional attribute type.
723N/A *
723N/A * @throws Exception If an unexpected problem occurs.
723N/A */
723N/A @Test()
723N/A public void testAddObjectClassObsoleteOptionalAttribute()
723N/A throws Exception
723N/A {
723N/A String path = TestCaseUtils.createTempFile(
723N/A "dn: cn=schema",
723N/A "changetype: modify",
723N/A "add: attributeTypes",
723N/A "attributeTypes: ( testaddocobsoleteoptionalattrat-oid " +
723N/A "NAME 'testAddOCObsoleteOptionalAttrAT' OBSOLETE " +
723N/A "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " +
723N/A "X-ORIGIN 'SchemaBackendTestCase' )",
723N/A "-",
723N/A "add: objectClasses",
723N/A "objectClasses: ( testaddocobsoleteoptionalattroc-oid " +
723N/A "NAME 'testAddOCObsoleteOptionalAttrOC' " +
723N/A "STRUCTURAL MAY testAddOCObsoleteOptionalAttrAT " +
723N/A "X-ORIGIN 'SchemaBackendTestCase' )");
723N/A
723N/A String[] args =
723N/A {
723N/A "-h", "127.0.0.1",
723N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
723N/A "-D", "cn=Directory Manager",
723N/A "-w", "password",
723N/A "-f", path
723N/A };
723N/A
723N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
723N/A }
723N/A
723N/A
723N/A
723N/A /**
723N/A * Tests the behavior of the schema backend when attempting to add a new
641N/A * objectclass that references an undefined required attribute.
641N/A *
641N/A * @throws Exception If an unexpected problem occurs.
641N/A */
641N/A @Test()
641N/A public void testAddObjectClassUndefinedRequiredAttribute()
641N/A throws Exception
641N/A {
641N/A String path = TestCaseUtils.createTempFile(
641N/A "dn: cn=schema",
641N/A "changetype: modify",
641N/A "add: objectClasses",
641N/A "objectClasses: ( testaddocundefinedrequired-oid NAME " +
641N/A "'testAddOCUndefinedRequired' SUP top STRUCTURAL " +
641N/A "MUST undefined X-ORIGIN 'SchemaBackendTestCase' )");
641N/A
641N/A String[] args =
641N/A {
641N/A "-h", "127.0.0.1",
641N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
641N/A "-D", "cn=Directory Manager",
641N/A "-w", "password",
641N/A "-f", path
641N/A };
641N/A
641N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
641N/A }
641N/A
641N/A
641N/A
641N/A /**
641N/A * Tests the behavior of the schema backend when attempting to add a new
723N/A * objectclass that references an undefined required attribute when multiple
723N/A * required attributes were provided.
723N/A *
723N/A * @throws Exception If an unexpected problem occurs.
723N/A */
723N/A @Test()
723N/A public void testAddObjectClassMultipleUndefinedRequiredAttribute()
723N/A throws Exception
723N/A {
723N/A String path = TestCaseUtils.createTempFile(
723N/A "dn: cn=schema",
723N/A "changetype: modify",
723N/A "add: objectClasses",
723N/A "objectClasses: ( testaddocmultipleundefinedrequired-oid NAME " +
723N/A "'testAddOCMultipleUndefinedRequired' SUP top STRUCTURAL " +
723N/A "MUST ( cn $ xxxundefinedxxx ) " +
723N/A "X-ORIGIN 'SchemaBackendTestCase' )");
723N/A
723N/A String[] args =
723N/A {
723N/A "-h", "127.0.0.1",
723N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
723N/A "-D", "cn=Directory Manager",
723N/A "-w", "password",
723N/A "-f", path
723N/A };
723N/A
723N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
723N/A }
723N/A
723N/A
723N/A
723N/A /**
723N/A * Tests the behavior of the schema backend when attempting to add a new
641N/A * objectclass that references an undefined optional attribute.
641N/A *
641N/A * @throws Exception If an unexpected problem occurs.
641N/A */
641N/A @Test()
641N/A public void testAddObjectClassUndefinedOptionalAttribute()
641N/A throws Exception
641N/A {
641N/A String path = TestCaseUtils.createTempFile(
641N/A "dn: cn=schema",
641N/A "changetype: modify",
641N/A "add: objectClasses",
641N/A "objectClasses: ( testaddocundefinedoptional-oid NAME " +
641N/A "'testAddOCUndefinedOptional' SUP top STRUCTURAL " +
641N/A "MAY undefined X-ORIGIN 'SchemaBackendTestCase' )");
641N/A
641N/A String[] args =
641N/A {
641N/A "-h", "127.0.0.1",
641N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
641N/A "-D", "cn=Directory Manager",
641N/A "-w", "password",
641N/A "-f", path
641N/A };
641N/A
641N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
641N/A }
673N/A
673N/A
673N/A
673N/A /**
723N/A * Tests the behavior of the schema backend when attempting to add a new
723N/A * objectclass that references an undefined optional attribute when multiple
723N/A * optional attributes were provided.
723N/A *
723N/A * @throws Exception If an unexpected problem occurs.
723N/A */
723N/A @Test()
723N/A public void testAddObjectClassMultipleUndefinedOptionalAttribute()
723N/A throws Exception
723N/A {
723N/A String path = TestCaseUtils.createTempFile(
723N/A "dn: cn=schema",
723N/A "changetype: modify",
723N/A "add: objectClasses",
723N/A "objectClasses: ( testaddocmultipleundefinedoptional-oid NAME " +
723N/A "'testAddOCMultipleUndefinedOptional' SUP top STRUCTURAL " +
723N/A "MAY ( cn $ xxxundefinedxxx ) " +
723N/A "X-ORIGIN 'SchemaBackendTestCase' )");
723N/A
723N/A String[] args =
723N/A {
723N/A "-h", "127.0.0.1",
723N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
723N/A "-D", "cn=Directory Manager",
723N/A "-w", "password",
723N/A "-f", path
723N/A };
723N/A
723N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
723N/A }
723N/A
723N/A
723N/A
723N/A /**
723N/A * Tests the behavior of the schema backend when attempting to add a new
723N/A * abstract objectclass whose superior class is not abstract.
723N/A *
723N/A * @throws Exception If an unexpected problem occurs.
723N/A */
723N/A @Test()
723N/A public void testAddAbstractObjectClassWithNonAbstractSuperior()
723N/A throws Exception
723N/A {
723N/A String path = TestCaseUtils.createTempFile(
723N/A "dn: cn=schema",
723N/A "changetype: modify",
723N/A "add: objectClasses",
723N/A "objectClasses: ( testaddabstractocwithnonabstractsuperior-oid NAME " +
723N/A "'testAddAbstractOCWithNonAbstractSuperior' SUP person " +
723N/A "ABSTRACT MAY description X-ORIGIN 'SchemaBackendTestCase' )");
723N/A
723N/A String[] args =
723N/A {
723N/A "-h", "127.0.0.1",
723N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
723N/A "-D", "cn=Directory Manager",
723N/A "-w", "password",
723N/A "-f", path
723N/A };
723N/A
723N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
723N/A }
723N/A
723N/A
723N/A
723N/A /**
723N/A * Tests the behavior of the schema backend when attempting to add a new
723N/A * auxiliary objectclass whose superior class is structural.
723N/A *
723N/A * @throws Exception If an unexpected problem occurs.
723N/A */
723N/A @Test()
723N/A public void testAddAuxiliaryObjectClassWithStructuralSuperior()
723N/A throws Exception
723N/A {
723N/A String path = TestCaseUtils.createTempFile(
723N/A "dn: cn=schema",
723N/A "changetype: modify",
723N/A "add: objectClasses",
723N/A "objectClasses: ( testaddauxiliaryocwithstructuralsuperior-oid NAME " +
723N/A "'testAddAuxiliaryOCWithStructuralSuperior' SUP person " +
723N/A "AUXILIARY MAY description X-ORIGIN 'SchemaBackendTestCase' )");
723N/A
723N/A String[] args =
723N/A {
723N/A "-h", "127.0.0.1",
723N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
723N/A "-D", "cn=Directory Manager",
723N/A "-w", "password",
723N/A "-f", path
723N/A };
723N/A
723N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
723N/A }
723N/A
723N/A
723N/A
723N/A /**
723N/A * Tests the behavior of the schema backend when attempting to add a new
723N/A * structural objectclass whose superior class is auxiliary.
723N/A *
723N/A * @throws Exception If an unexpected problem occurs.
723N/A */
723N/A @Test()
723N/A public void testAddStructuralObjectClassWithAuxiliarySuperior()
723N/A throws Exception
723N/A {
723N/A String path = TestCaseUtils.createTempFile(
723N/A "dn: cn=schema",
723N/A "changetype: modify",
723N/A "add: objectClasses",
723N/A "objectClasses: ( testaddstructuralocwithauxiliarysuperior-oid NAME " +
723N/A "'testAddStructuralOCWithAuxiliarySuperior' SUP posixAccount " +
723N/A "STRUCTURAL MAY description X-ORIGIN 'SchemaBackendTestCase' )");
723N/A
723N/A String[] args =
723N/A {
723N/A "-h", "127.0.0.1",
723N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
723N/A "-D", "cn=Directory Manager",
723N/A "-w", "password",
723N/A "-f", path
723N/A };
723N/A
723N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
723N/A }
723N/A
723N/A
723N/A
723N/A /**
673N/A * Tests the behavior of the schema backend when attempting to remove an
673N/A * objectclass that exists and for which there are no dependencies.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testRemoveObjectClassSuccessful()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: objectClasses",
673N/A "objectClasses: ( 1.3.6.1.4.1.26027.1.999.7 NAME " +
673N/A "'testRemoveObjectClassSuccessful' SUP top STRUCTURAL MUST cn " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )",
673N/A "",
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "delete: objectClasses",
673N/A "objectClasses: ( 1.3.6.1.4.1.26027.1.999.7 NAME " +
673N/A "'testRemoveObjectClassSuccessful' SUP top STRUCTURAL MUST cn " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )");
673N/A
673N/A String ocName = "testremoveobjectclasssuccessful";
673N/A assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName));
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
673N/A assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName));
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to remove an
673N/A * objectclass that is the superior class for another objectclass.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testRemoveSuperiorObjectClass()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "delete: objectClasses",
673N/A "objectClasses: ( 2.5.6.6 NAME 'person' SUP top STRUCTURAL " +
673N/A "MUST ( sn $ cn ) MAY ( userPassword $ telephoneNumber $ " +
673N/A "seeAlso $ description ) X-ORIGIN 'RFC 2256' )");
673N/A
673N/A String ocName = "person";
673N/A assertTrue(DirectoryServer.getSchema().hasObjectClass(ocName));
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
673N/A assertTrue(DirectoryServer.getSchema().hasObjectClass(ocName));
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to remove an
673N/A * objectclass that is referenced by an existing name form.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testRemoveObjectClassReferencedByNameForm()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: objectClasses",
673N/A "objectClasses: ( testremoveobjectclassreferencedbynf-oid " +
673N/A "NAME 'testRemoveObjectClassReferencedByNF' SUP top " +
673N/A "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase')",
673N/A "-",
673N/A "add: nameForms",
673N/A "nameForms: ( testremoveattributetypereferencedbynfnf-oid " +
673N/A "NAME 'testRemoveObjectClassReferencedByNFNF' " +
673N/A "OC testRemoveObjectClassReferencedByNF MUST cn " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )",
673N/A "",
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "delete: objectClasses",
673N/A "objectClasses: ( testremoveobjectclassreferencedbynf-oid " +
673N/A "NAME 'testRemoveObjectClassReferencedByNF' SUP top " +
673N/A "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase')");
673N/A
673N/A String ocName = "testremoveobjectclassreferencedbynf";
673N/A assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName));
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
673N/A assertTrue(DirectoryServer.getSchema().hasObjectClass(ocName));
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to remove an
673N/A * objectclass that is referenced by an existing DIT content rule.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testRemoveObjectClassReferencedByDCR()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: objectClasses",
673N/A "objectClasses: ( testremoveobjectclassreferencedbydcr-oid " +
673N/A "NAME 'testRemoveObjectClassReferencedByDCR' SUP top " +
673N/A "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase')",
673N/A "-",
673N/A "add: ditContentRules",
673N/A "ditContentRules: ( testremoveobjectclassreferencedbydcr-oid " +
673N/A "NAME 'testRemoveObjectClassReferencedByDCRDCR' " +
673N/A "MAY description X-ORIGIN 'SchemaBackendTestCase' )",
673N/A "",
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "delete: objectClasses",
673N/A "objectClasses: ( testremoveobjectclassreferencedbydcr-oid " +
673N/A "NAME 'testRemoveObjectClassReferencedByDCR' SUP top " +
673N/A "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase')");
673N/A
673N/A String ocName = "testremoveobjectclassreferencedbydcr";
673N/A assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName));
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
673N/A assertTrue(DirectoryServer.getSchema().hasObjectClass(ocName));
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to add a new name
673N/A * form that doesn't already exist.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testAddNameFormSuccessful()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: objectClasses",
673N/A "objectClasses: ( testaddnameformsuccessfuloc-oid " +
673N/A "NAME 'testAddNameFormSuccessfulOC' SUP top STRUCTURAL MUST cn " +
673N/A "X-ORIGIN 'SchemaBackendTestCase')",
673N/A "-",
673N/A "add: nameForms",
673N/A "nameForms: ( 1.3.6.1.4.1.26027.1.999.8 " +
673N/A "NAME 'testAddNameFormSuccessful' " +
673N/A "OC testAddNameFormSuccessfulOC MUST cn " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )");
673N/A
673N/A String nameFormName = "testaddnameformsuccessful";
673N/A assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
673N/A assertTrue(DirectoryServer.getSchema().hasNameForm(nameFormName));
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to add a new name
673N/A * form that doesn't already exist to an alternate schema file.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testAddNameFormToAltSchemaFile()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: objectClasses",
673N/A "objectClasses: ( testaddnameformtoaltschemafileoc-oid " +
673N/A "NAME 'testAddNameFormToAltSchemaFileOC' SUP top STRUCTURAL " +
673N/A "MUST cn X-ORIGIN 'SchemaBackendTestCase')",
673N/A "-",
673N/A "add: nameForms",
673N/A "nameForms: ( testaddnameformtoaltschemafile-oid " +
673N/A "NAME 'testAddNameFormToAltSchemaFile' " +
673N/A "OC testAddNameFormToAltSchemaFileOC MUST cn " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' " +
673N/A "X-SCHEMA-FILE '98-schema-test-nameform.ldif' )");
673N/A
673N/A String nameFormName = "testaddnameformtoaltschemafile";
673N/A assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
673N/A
6318N/A File schemaFile = new File(SchemaConfigManager.getSchemaDirectoryPath(),
673N/A "98-schema-test-nameform.ldif");
673N/A assertFalse(schemaFile.exists());
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
673N/A assertTrue(DirectoryServer.getSchema().hasNameForm(nameFormName));
673N/A assertTrue(schemaFile.exists());
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to add a new name
673N/A * form that references a required attribute type not defined in the server
673N/A * schema.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testAddNameFormWithUndefinedReqAT()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: objectClasses",
673N/A "objectClasses: ( testaddnameformwithundefinedreqatoc-oid " +
673N/A "NAME 'testAddNameFormWithUndefinedReqATOC' SUP top STRUCTURAL " +
673N/A "MUST cn X-ORIGIN 'SchemaBackendTestCase')",
673N/A "-",
673N/A "add: nameForms",
723N/A "nameForms: ( testaddnameformwithundefinedreqat-oid " +
673N/A "NAME 'testAddNameFormWithUndefinedReqAT' " +
673N/A "OC testAddNameFormWithUndefinedReqATOC MUST xxxundefinedxxx " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )");
673N/A
673N/A String nameFormName = "testaddnameformwithundefinedreqat";
673N/A assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
673N/A assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to add a new name
723N/A * form that references a required attribute type not defined in the server
723N/A * schema when multiple required attributes were given.
723N/A *
723N/A * @throws Exception If an unexpected problem occurs.
723N/A */
723N/A @Test()
723N/A public void testAddNameFormWithMultipleUndefinedReqAT()
723N/A throws Exception
723N/A {
723N/A String path = TestCaseUtils.createTempFile(
723N/A "dn: cn=schema",
723N/A "changetype: modify",
723N/A "add: objectClasses",
723N/A "objectClasses: ( testaddnameformwithmultipleundefinedreqatoc-oid " +
723N/A "NAME 'testAddNameFormWithMultipleUndefinedReqATOC' SUP top " +
723N/A "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase')",
723N/A "-",
723N/A "add: nameForms",
723N/A "nameForms: ( testaddnameformwithmultipleundefinedreqat-oid " +
723N/A "NAME 'testAddNameFormWithMultipleUndefinedReqAT' " +
723N/A "OC testAddNameFormWithMultipleUndefinedReqATOC " +
723N/A "MUST ( cn $ xxxundefinedxxx ) " +
723N/A "X-ORIGIN 'SchemaBackendTestCase' )");
723N/A
723N/A String nameFormName = "testaddnameformwithmultipleundefinedreqat";
723N/A assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
723N/A
723N/A String[] args =
723N/A {
723N/A "-h", "127.0.0.1",
723N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
723N/A "-D", "cn=Directory Manager",
723N/A "-w", "password",
723N/A "-f", path
723N/A };
723N/A
723N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
723N/A assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
723N/A }
723N/A
723N/A
723N/A
723N/A /**
723N/A * Tests the behavior of the schema backend when attempting to add a new name
673N/A * form that references an optional attribute type not defined in the server
673N/A * schema.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testAddNameFormWithUndefinedOptAT()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: objectClasses",
673N/A "objectClasses: ( testaddnameformwithundefinedoptatoc-oid " +
673N/A "NAME 'testAddNameFormWithUndefinedOptATOC' SUP top STRUCTURAL " +
673N/A "MUST cn X-ORIGIN 'SchemaBackendTestCase')",
673N/A "-",
673N/A "add: nameForms",
723N/A "nameForms: ( testaddnameformwithundefinedoptat-oid " +
673N/A "NAME 'testAddNameFormWithUndefinedOptAT' " +
673N/A "OC testAddNameFormWithUndefinedOptATOC MUST cn " +
673N/A "MAY xxxundefinedxxx X-ORIGIN 'SchemaBackendTestCase' )");
673N/A
673N/A String nameFormName = "testaddnameformwithundefinedoptat";
673N/A assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
673N/A assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to add a new name
723N/A * form that references an optional attribute type not defined in the server
723N/A * schema when multiple optional attribute types were provided.
723N/A *
723N/A * @throws Exception If an unexpected problem occurs.
723N/A */
723N/A @Test()
723N/A public void testAddNameFormWithMultipleUndefinedOptAT()
723N/A throws Exception
723N/A {
723N/A String path = TestCaseUtils.createTempFile(
723N/A "dn: cn=schema",
723N/A "changetype: modify",
723N/A "add: objectClasses",
723N/A "objectClasses: ( testaddnameformwithmultipleundefinedoptatoc-oid " +
723N/A "NAME 'testAddNameFormWithMultipleUndefinedOptATOC' SUP top " +
723N/A "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase')",
723N/A "-",
723N/A "add: nameForms",
723N/A "nameForms: ( testaddnameformwithmultipleundefinedoptat-oid " +
723N/A "NAME 'testAddNameFormWithMultipleUndefinedOptAT' " +
723N/A "OC testAddNameFormWithMultipleUndefinedOptATOC MUST cn " +
723N/A "MAY ( description $ xxxundefinedxxx ) " +
723N/A "X-ORIGIN 'SchemaBackendTestCase' )");
723N/A
723N/A String nameFormName = "testaddnameformwithmultipleundefinedoptat";
723N/A assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
723N/A
723N/A String[] args =
723N/A {
723N/A "-h", "127.0.0.1",
723N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
723N/A "-D", "cn=Directory Manager",
723N/A "-w", "password",
723N/A "-f", path
723N/A };
723N/A
723N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
723N/A assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
723N/A }
723N/A
723N/A
723N/A
723N/A /**
723N/A * Tests the behavior of the schema backend when attempting to add a new name
673N/A * form whose structural objectclass is not defined in the server schema.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testAddNameFormWithUndefinedOC()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: nameForms",
673N/A "nameForms: ( testaddnameformwithundefinedoc-oid " +
673N/A "NAME 'testAddNameFormWithUndefinedOC' " +
673N/A "OC xxxundefinedxxx MUST cn X-ORIGIN 'SchemaBackendTestCase' )");
673N/A
673N/A String nameFormName = "testaddnameformwithundefinedoc";
673N/A assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
673N/A assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to add a new name
673N/A * form whose objectclass auxiliary rather than structural.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testAddNameFormWithAuxiliaryOC()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: objectClasses",
673N/A "objectClasses: ( testaddnameformwithauxiliaryococ-oid " +
673N/A "NAME 'testAddNameFormWithAuxiliaryOCOC' SUP top AUXILIARY " +
673N/A "MUST cn X-ORIGIN 'SchemaBackendTestCase')",
673N/A "-",
673N/A "add: nameForms",
673N/A "nameForms: ( testaddnameformwithauxiliaryoc-oid " +
673N/A "NAME 'testAddNameFormWithAuxiliaryOC' " +
673N/A "OC testAddNameFormWithAuxiliaryOCOC MUST cn " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )");
673N/A
673N/A String nameFormName = "testaddnameformwithauxiliaryoc";
673N/A assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
673N/A assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to add a new name
723N/A * form whose structural objectclass is OBSOLETE rather than structural.
723N/A *
723N/A * @throws Exception If an unexpected problem occurs.
723N/A */
723N/A @Test()
723N/A public void testAddNameFormWithObsoleteOC()
723N/A throws Exception
723N/A {
723N/A String path = TestCaseUtils.createTempFile(
723N/A "dn: cn=schema",
723N/A "changetype: modify",
723N/A "add: objectClasses",
723N/A "objectClasses: ( testaddnameformwithobsoleteococ-oid " +
723N/A "NAME 'testAddNameFormWithObsoleteOCOC' OBSOLETE SUP top " +
723N/A "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase')",
723N/A "-",
723N/A "add: nameForms",
723N/A "nameForms: ( testaddnameformwithobsoleteoc-oid " +
723N/A "NAME 'testAddNameFormWithObsoleteOC' " +
723N/A "OC testAddNameFormWithObsoleteOCOC MUST cn " +
723N/A "X-ORIGIN 'SchemaBackendTestCase' )");
723N/A
723N/A String nameFormName = "testaddnameformwithobsoleteoc";
723N/A assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
723N/A
723N/A String[] args =
723N/A {
723N/A "-h", "127.0.0.1",
723N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
723N/A "-D", "cn=Directory Manager",
723N/A "-w", "password",
723N/A "-f", path
723N/A };
723N/A
723N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
723N/A assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
723N/A }
723N/A
723N/A
723N/A
723N/A /**
723N/A * Tests the behavior of the schema backend when attempting to add a new name
723N/A * form with a required attribute type that is declared OBSOLETE.
723N/A *
723N/A * @throws Exception If an unexpected problem occurs.
723N/A */
723N/A @Test()
723N/A public void testAddNameFormWithObsoleteReqAT()
723N/A throws Exception
723N/A {
723N/A String path = TestCaseUtils.createTempFile(
723N/A "dn: cn=schema",
723N/A "changetype: modify",
723N/A "add: attributeTypes",
723N/A "attributeTypes: ( testaddnfwithobsoletereqatat-oid " +
723N/A "NAME 'testAddNFWithObsoleteReqATAT' OBSOLETE " +
723N/A "X-ORIGIN 'SchemaBackendTestCase' )",
723N/A "-",
723N/A "add: objectClasses",
723N/A "objectClasses: ( testaddnfwithobsoletereqatoc-oid " +
723N/A "NAME 'testAddNFWithObsoleteReqATOC' SUP top STRUCTURAL " +
723N/A "MUST cn X-ORIGIN 'SchemaBackendTestCase' )",
723N/A "-",
723N/A "add: nameForms",
723N/A "nameForms: ( testaddnfwithobsoletereqatnf-oid " +
723N/A "NAME 'testAddNFWithObsoleteReqATNF' " +
723N/A "OC testAddNFWithObsoleteReqATOC " +
723N/A "MUST testAddNFWithObsoleteReqATAT " +
723N/A "X-ORIGIN 'SchemaBackendTestCase' )");
723N/A
723N/A String[] args =
723N/A {
723N/A "-h", "127.0.0.1",
723N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
723N/A "-D", "cn=Directory Manager",
723N/A "-w", "password",
723N/A "-f", path
723N/A };
723N/A
723N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
723N/A }
723N/A
723N/A
723N/A
723N/A /**
723N/A * Tests the behavior of the schema backend when attempting to add a new name
723N/A * form with an optional attribute type that is declared OBSOLETE.
723N/A *
723N/A * @throws Exception If an unexpected problem occurs.
723N/A */
723N/A @Test()
723N/A public void testAddNameFormWithObsoleteOptAT()
723N/A throws Exception
723N/A {
723N/A String path = TestCaseUtils.createTempFile(
723N/A "dn: cn=schema",
723N/A "changetype: modify",
723N/A "add: attributeTypes",
723N/A "attributeTypes: ( testaddnfwithobsoleteoptatat-oid " +
723N/A "NAME 'testAddNFWithObsoleteOptATAT' OBSOLETE " +
723N/A "X-ORIGIN 'SchemaBackendTestCase' )",
723N/A "-",
723N/A "add: objectClasses",
723N/A "objectClasses: ( testaddnfwithobsoleteoptatoc-oid " +
723N/A "NAME 'testAddNFWithObsoleteOptATOC' SUP top STRUCTURAL " +
723N/A "MUST cn X-ORIGIN 'SchemaBackendTestCase' )",
723N/A "-",
723N/A "add: nameForms",
723N/A "nameForms: ( testaddnfwithobsoleteoptatnf-oid " +
723N/A "NAME 'testAddNFWithObsoleteOptATNF' " +
723N/A "OC testAddNFWithObsoleteOptATOC " +
723N/A "MUST cn MAY testAddNFWithObsoleteOptATAT " +
723N/A "X-ORIGIN 'SchemaBackendTestCase' )");
723N/A
723N/A String[] args =
723N/A {
723N/A "-h", "127.0.0.1",
723N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
723N/A "-D", "cn=Directory Manager",
723N/A "-w", "password",
723N/A "-f", path
723N/A };
723N/A
723N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
723N/A }
723N/A
723N/A
723N/A
723N/A /**
723N/A * Tests the behavior of the schema backend when attempting to add a new name
673N/A * form that references a structural objectclass already referenced by another
673N/A * name form.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testAddNameFormOCConflict()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: objectClasses",
673N/A "objectClasses: ( testaddnameformocconflictoc-oid " +
673N/A "NAME 'testAddNameFormOCConflictOC' SUP top STRUCTURAL MUST cn " +
673N/A "X-ORIGIN 'SchemaBackendTestCase')",
673N/A "-",
673N/A "add: nameForms",
673N/A "nameForms: ( testaddnameformocconflict-oid " +
673N/A "NAME 'testAddNameFormOCConflict' " +
673N/A "OC testAddNameFormOCConflictOC MUST cn " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )",
673N/A "",
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: nameForms",
673N/A "nameForms: ( testaddnameformocconflict2-oid " +
673N/A "NAME 'testAddNameFormOCConflict2' " +
673N/A "OC testAddNameFormOCConflictOC MUST cn " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )");
673N/A
673N/A String nameFormName = "testaddnameformocconflict2";
673N/A assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
4443N/A assertTrue(LDAPModify.mainModify(args, false, null, null) == 0);
4443N/A assertTrue(DirectoryServer.getSchema().hasNameForm(nameFormName));
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to remove an
673N/A * existing name form.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testRemoveNameFormSuccessful()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: objectClasses",
673N/A "objectClasses: ( testremovenameformsuccessfuloc-oid " +
673N/A "NAME 'testRemoveNameFormSuccessfulOC' SUP top STRUCTURAL " +
673N/A "MUST cn X-ORIGIN 'SchemaBackendTestCase')",
673N/A "-",
673N/A "add: nameForms",
673N/A "nameForms: ( 1.3.6.1.4.1.26027.1.999.9 " +
673N/A "NAME 'testRemoveNameFormSuccessful' " +
673N/A "OC testRemoveNameFormSuccessfulOC MUST cn " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )",
673N/A "",
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "delete: nameForms",
673N/A "nameForms: ( 1.3.6.1.4.1.26027.1.999.9 " +
673N/A "NAME 'testRemoveNameFormSuccessful' " +
673N/A "OC testRemoveNameFormSuccessfulOC MUST cn " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )");
673N/A
673N/A String nameFormName = "testremovenameformsuccessful";
673N/A assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
673N/A assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to remove an
673N/A * existing name form and then add it back in the same operation.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testRemoveThenAddNameFormSuccessful()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: objectClasses",
673N/A "objectClasses: ( testremovethenaddnameformsuccessfuloc-oid " +
673N/A "NAME 'testRemoveThenAddNameFormSuccessfulOC' SUP top " +
673N/A "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase' )",
673N/A "-",
673N/A "add: nameForms",
673N/A "nameForms: ( testremovethenaddnameformsuccessful-oid " +
673N/A "NAME 'testRemoveThenAddNameFormSuccessful' " +
673N/A "OC testRemoveThenAddNameFormSuccessfulOC MUST cn " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )",
673N/A "",
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "delete: nameForms",
673N/A "nameForms: ( testremovethenaddnameformsuccessful-oid " +
673N/A "NAME 'testRemoveThenAddNameFormSuccessful' " +
673N/A "OC testRemoveThenAddNameFormSuccessfulOC MUST cn " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )",
673N/A "-",
673N/A "add: nameForms",
673N/A "nameForms: ( testremovethenaddnameformsuccessful-oid " +
673N/A "NAME 'testRemoveThenAddNameFormSuccessful' " +
673N/A "OC testRemoveThenAddNameFormSuccessfulOC MUST cn MAY sn " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )");
673N/A
673N/A String nameFormName = "testremovethenaddnameformsuccessful";
673N/A assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
673N/A assertTrue(DirectoryServer.getSchema().hasNameForm(nameFormName));
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to remove a name
673N/A * form that is referenced by a DIT structure rule.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testRemoveNameFormReferencedByDSR()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: objectClasses",
673N/A "objectClasses: ( testremovenameformreferencedbydsroc-oid " +
673N/A "NAME 'testRemoveNameFormReferencedByDSROC' SUP top " +
673N/A "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase')",
673N/A "-",
673N/A "add: nameForms",
673N/A "nameForms: ( testremovenameformreferencedbydsrnf-oid " +
673N/A "NAME 'testRemoveNameFormReferencedByDSRNF' " +
673N/A "OC testRemoveNameFormReferencedByDSROC MUST cn " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )",
673N/A "-",
673N/A "add: ditStructureRules",
673N/A "ditStructureRules: ( 999009 " +
673N/A "NAME 'testRemoveNameFormReferencedByDSRDSR' " +
673N/A "FORM testRemoveNameFormReferencedByDSRNF " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )",
673N/A "",
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "delete: nameForms",
673N/A "nameForms: ( testremovenameformreferencedbydsrnf-oid " +
673N/A "NAME 'testRemoveNameFormReferencedByDSRNF' " +
673N/A "OC testRemoveNameFormReferencedByDSROC MUST cn " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )");
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A String nameFormName = "testremovenameformreferencedbydsrnf";
673N/A assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName));
673N/A
673N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
673N/A assertTrue(DirectoryServer.getSchema().hasNameForm(nameFormName));
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to add a new DIT
673N/A * content rule that doesn't already exist.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testAddDITContentRuleSuccessful()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: objectClasses",
673N/A "objectClasses: ( testaddditcontentrulesuccessfuloc-oid " +
673N/A "NAME 'testAddDITContentRuleSuccessfulOC' SUP top STRUCTURAL " +
673N/A "MUST cn X-ORIGIN 'SchemaBackendTestCase')",
673N/A "-",
673N/A "add: ditContentRules",
673N/A "ditContentRules: ( testaddditcontentrulesuccessfuloc-oid " +
673N/A "NAME 'testAddDITContentRuleSuccessful' NOT description " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )");
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A String ocName = "testaddditcontentrulesuccessfuloc";
673N/A assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName));
673N/A
673N/A assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
673N/A
673N/A ObjectClass oc = DirectoryServer.getSchema().getObjectClass(ocName);
673N/A assertNotNull(oc);
673N/A
673N/A DITContentRule dcr = DirectoryServer.getSchema().getDITContentRule(oc);
673N/A assertNotNull(dcr);
673N/A assertTrue(dcr.hasName("testaddditcontentrulesuccessful"));
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to replace an
673N/A * existing DIT content rule.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testReplaceDITContentRuleSuccessful()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: objectClasses",
673N/A "objectClasses: ( testreplaceditcontentrulesuccessfuloc-oid " +
673N/A "NAME 'testReplaceDITContentRuleSuccessfulOC' SUP top " +
673N/A "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase')",
673N/A "-",
673N/A "add: ditContentRules",
673N/A "ditContentRules: ( testreplaceditcontentrulesuccessfuloc-oid " +
673N/A "NAME 'testReplaceDITContentRuleSuccessful' NOT description " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )",
673N/A "",
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: ditContentRules",
673N/A "ditContentRules: ( testreplaceditcontentrulesuccessfuloc-oid " +
673N/A "NAME 'testReplaceDITContentRuleSuccessful' MAY sn " +
673N/A "NOT description X-ORIGIN 'SchemaBackendTestCase' )");
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A String ocName = "testreplaceditcontentrulesuccessfuloc";
673N/A assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName));
673N/A
673N/A assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
673N/A
673N/A ObjectClass oc = DirectoryServer.getSchema().getObjectClass(ocName);
673N/A assertNotNull(oc);
673N/A
673N/A DITContentRule dcr = DirectoryServer.getSchema().getDITContentRule(oc);
673N/A assertNotNull(dcr);
673N/A assertTrue(dcr.hasName("testreplaceditcontentrulesuccessful"));
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to add a new DIT
673N/A * content rule to an alternate schema file.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testAddDITContentRuleToAltSchemaFile()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: objectClasses",
673N/A "objectClasses: ( testadddcrtoaltschemafileoc-oid " +
673N/A "NAME 'testAddDCRToAltSchemaFileOC' SUP top STRUCTURAL " +
673N/A "MUST cn X-SCHEMA-FILE '98-schema-test-dcr.ldif' " +
673N/A "X-ORIGIN 'SchemaBackendTestCase')",
673N/A "-",
673N/A "add: ditContentRules",
673N/A "ditContentRules: ( testadddcrtoaltschemafileoc-oid " +
673N/A "NAME 'testAddDCRToAltSchemaFile' NOT description " +
673N/A "X-SCHEMA-FILE '98-schema-test-dcr.ldif' " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )");
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A String ocName = "testadddcrtoaltschemafileoc";
673N/A assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName));
673N/A
6318N/A File schemaFile = new File(SchemaConfigManager.getSchemaDirectoryPath(),
673N/A "98-schema-test-dcr.ldif");
673N/A assertFalse(schemaFile.exists());
673N/A
673N/A assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
673N/A
673N/A ObjectClass oc = DirectoryServer.getSchema().getObjectClass(ocName);
673N/A assertNotNull(oc);
673N/A
673N/A DITContentRule dcr = DirectoryServer.getSchema().getDITContentRule(oc);
673N/A assertNotNull(dcr);
673N/A assertTrue(dcr.hasName("testadddcrtoaltschemafile"));
673N/A
673N/A assertTrue(schemaFile.exists());
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to remove an
673N/A * existing DIT content rule and add it back in the same operation.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testRemoveThenAddDITContentRule()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: objectClasses",
673N/A "objectClasses: ( testremovethenaddditcontentruleoc-oid " +
673N/A "NAME 'testRemoveThenAddDITContentRuleOC' SUP top " +
673N/A "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase')",
673N/A "-",
673N/A "add: ditContentRules",
673N/A "ditContentRules: ( testremovethenaddditcontentruleoc-oid " +
673N/A "NAME 'testRemoveThenAddDITContentRule' NOT description " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )",
673N/A "",
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "delete: ditContentRules",
673N/A "ditContentRules: ( testremovethenaddditcontentruleoc-oid " +
673N/A "NAME 'testRemoveThenAddDITContentRule' NOT description " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )",
673N/A "-",
673N/A "add: ditContentRules",
673N/A "ditContentRules: ( testremovethenaddditcontentruleoc-oid " +
673N/A "NAME 'testRemoveThenAddDITContentRule' MAY sn " +
673N/A "NOT description X-ORIGIN 'SchemaBackendTestCase' )");
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A String ocName = "testremovethenaddditcontentruleoc";
673N/A assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName));
673N/A
673N/A assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
673N/A
673N/A ObjectClass oc = DirectoryServer.getSchema().getObjectClass(ocName);
673N/A assertNotNull(oc);
673N/A
673N/A DITContentRule dcr = DirectoryServer.getSchema().getDITContentRule(oc);
673N/A assertNotNull(dcr);
673N/A assertTrue(dcr.hasName("testremovethenaddditcontentrule"));
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to add a new DIT
673N/A * content rule whose structural objectclass is not defined in the schema.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testAddDITContentRuleUndefinedOC()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: ditContentRules",
673N/A "ditContentRules: ( xxxundefinedxxx-oid " +
673N/A "NAME 'testAddDITContentRuleUndefinedOC' NOT description " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )");
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to add a new DIT
673N/A * content rule whose structural objectclass is not actually structural.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testAddDITContentRuleAuxiliaryOC()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: objectClasses",
673N/A "objectClasses: ( testaddditcontentruleauxiliaryococ-oid " +
673N/A "NAME 'testAddDITContentRuleAuxiliaryOCOC' SUP top AUXILIARY " +
673N/A "MUST cn X-ORIGIN 'SchemaBackendTestCase')",
673N/A "-",
673N/A "add: ditContentRules",
673N/A "ditContentRules: ( testaddditcontentruleauxiliaryococ-oid " +
673N/A "NAME 'testAddDITContentRuleAuxiliaryOC' NOT description " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )");
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to add a new DIT
723N/A * content rule whose structural objectclass is OBSOLETE.
723N/A *
723N/A * @throws Exception If an unexpected problem occurs.
723N/A */
723N/A @Test()
723N/A public void testAddDITContentRuleObsoleteOC()
723N/A throws Exception
723N/A {
723N/A String path = TestCaseUtils.createTempFile(
723N/A "dn: cn=schema",
723N/A "changetype: modify",
723N/A "add: objectClasses",
723N/A "objectClasses: ( testaddditcontentruleobsoleteococ-oid " +
723N/A "NAME 'testAddDITContentRuleObsoleteOCOC' OBSOLETE SUP top " +
723N/A "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase')",
723N/A "-",
723N/A "add: ditContentRules",
723N/A "ditContentRules: ( testaddditcontentruleobsoleteococ-oid " +
723N/A "NAME 'testAddDITContentRuleObsoleteOC' NOT description " +
723N/A "X-ORIGIN 'SchemaBackendTestCase' )");
723N/A
723N/A String[] args =
723N/A {
723N/A "-h", "127.0.0.1",
723N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
723N/A "-D", "cn=Directory Manager",
723N/A "-w", "password",
723N/A "-f", path
723N/A };
723N/A
723N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
723N/A }
723N/A
723N/A
723N/A
723N/A /**
723N/A * Tests the behavior of the schema backend when attempting to add a new DIT
673N/A * content rule whose structural objectclass is already referenced by an
673N/A * existing DIT content rule.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testAddDITContentRuleConflictingOC()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: objectClasses",
673N/A "objectClasses: ( testaddditcontentruleconflictingococ-oid " +
673N/A "NAME 'testAddDITContentRuleConflictingOCOC' SUP top " +
673N/A "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase')",
673N/A "-",
673N/A "add: ditContentRules",
673N/A "ditContentRules: ( testaddditcontentruleconflictingococ-oid " +
673N/A "NAME 'testAddDITContentRuleConflictingOC' NOT description " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )",
673N/A "",
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: ditContentRules",
673N/A "ditContentRules: ( testaddditcontentruleconflictingococ-oid " +
673N/A "NAME 'testAddDITContentRuleConflictingOC2' NOT description " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )");
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to add a new DIT
673N/A * content rule with an undefined auxiliary objectclass.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testAddDITContentRuleUndefinedAuxOC()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: objectClasses",
673N/A "objectClasses: ( testaddditcontentruleundefinedauxococ-oid " +
673N/A "NAME 'testAddDITContentRuleUndefinedAuxOCOC' SUP top " +
673N/A "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase')",
673N/A "-",
673N/A "add: ditContentRules",
673N/A "ditContentRules: ( testaddditcontentruleundefinedauxococ-oid " +
673N/A "NAME 'testAddDITContentRuleUndefinedAuxOC' " +
673N/A "AUX xxxundefinedxxx X-ORIGIN 'SchemaBackendTestCase' )");
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to add a new DIT
723N/A * content rule with an undefined auxiliary objectclass when multiple
723N/A * auxiliary classes were provided.
723N/A *
723N/A * @throws Exception If an unexpected problem occurs.
723N/A */
723N/A @Test()
723N/A public void testAddDITContentRuleMultipleUndefinedAuxOC()
723N/A throws Exception
723N/A {
723N/A String path = TestCaseUtils.createTempFile(
723N/A "dn: cn=schema",
723N/A "changetype: modify",
723N/A "add: objectClasses",
723N/A "objectClasses: ( testaddditcontentrulemultundefinedauxococ-oid " +
723N/A "NAME 'testAddDITContentRuleMultUndefinedAuxOCOC' SUP top " +
723N/A "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase')",
723N/A "-",
723N/A "add: ditContentRules",
723N/A "ditContentRules: ( testaddditcontentrulemultundefinedauxococ-oid " +
723N/A "NAME 'testAddDITContentRuleMultUndefinedAuxOC' " +
723N/A "AUX ( posixAccount $ xxxundefinedxxx ) " +
723N/A "X-ORIGIN 'SchemaBackendTestCase' )");
723N/A
723N/A String[] args =
723N/A {
723N/A "-h", "127.0.0.1",
723N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
723N/A "-D", "cn=Directory Manager",
723N/A "-w", "password",
723N/A "-f", path
723N/A };
723N/A
723N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
723N/A }
723N/A
723N/A
723N/A
723N/A /**
723N/A * Tests the behavior of the schema backend when attempting to add a new DIT
723N/A * content rule with an auxiliary objectclass that is not auxiliary.
723N/A *
723N/A * @throws Exception If an unexpected problem occurs.
723N/A */
723N/A @Test()
723N/A public void testAddDITContentRuleAuxOCNotAux()
723N/A throws Exception
723N/A {
723N/A String path = TestCaseUtils.createTempFile(
723N/A "dn: cn=schema",
723N/A "changetype: modify",
723N/A "add: objectClasses",
723N/A "objectClasses: ( testaddditcontentruleauxocnotauxoc-oid " +
723N/A "NAME 'testAddDITContentRuleAuxOCNotAuxOC' SUP top " +
723N/A "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase')",
723N/A "-",
723N/A "add: ditContentRules",
723N/A "ditContentRules: ( testaddditcontentruleauxocnotaux-oid " +
723N/A "NAME 'testAddDITContentRuleAuxOCNotAuxOC' " +
723N/A "AUX person X-ORIGIN 'SchemaBackendTestCase' )");
723N/A
723N/A String[] args =
723N/A {
723N/A "-h", "127.0.0.1",
723N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
723N/A "-D", "cn=Directory Manager",
723N/A "-w", "password",
723N/A "-f", path
723N/A };
723N/A
723N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
723N/A }
723N/A
723N/A
723N/A
723N/A /**
723N/A * Tests the behavior of the schema backend when attempting to add a new DIT
723N/A * content rule with an auxiliary objectclass that is not auxiliary when
723N/A * multiple auxiliary classes were provided.
723N/A *
723N/A * @throws Exception If an unexpected problem occurs.
723N/A */
723N/A @Test()
723N/A public void testAddDITContentRuleMultipleAuxOCNotAux()
723N/A throws Exception
723N/A {
723N/A String path = TestCaseUtils.createTempFile(
723N/A "dn: cn=schema",
723N/A "changetype: modify",
723N/A "add: objectClasses",
723N/A "objectClasses: ( testaddditcontentrulemultipleauxocnotauxoc-oid " +
723N/A "NAME 'testAddDITContentRuleMultipleAuxOCNotAuxOC' SUP top " +
723N/A "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase')",
723N/A "-",
723N/A "add: ditContentRules",
723N/A "ditContentRules: ( testaddditcontentrulemultipleauxocnotaux-oid " +
723N/A "NAME 'testAddDITContentRuleMultipleAuxOCNotAuxOC' " +
723N/A "AUX ( posixAccount $ person ) " +
723N/A "X-ORIGIN 'SchemaBackendTestCase' )");
723N/A
723N/A String[] args =
723N/A {
723N/A "-h", "127.0.0.1",
723N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
723N/A "-D", "cn=Directory Manager",
723N/A "-w", "password",
723N/A "-f", path
723N/A };
723N/A
723N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
723N/A }
723N/A
723N/A
723N/A
723N/A /**
723N/A * Tests the behavior of the schema backend when attempting to add a new DIT
723N/A * content rule with an auxiliary objectclass that is OBSOLETE.
723N/A *
723N/A * @throws Exception If an unexpected problem occurs.
723N/A */
723N/A @Test()
723N/A public void testAddDITContentRuleObsoleteAuxOC()
723N/A throws Exception
723N/A {
723N/A String path = TestCaseUtils.createTempFile(
723N/A "dn: cn=schema",
723N/A "changetype: modify",
723N/A "add: objectClasses",
723N/A "objectClasses: ( testaddditcontentruleobsoleteauxstructural-oid " +
723N/A "NAME 'testAddDITContentRuleObsoleteAuxOCStructural' SUP top " +
723N/A "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase' )",
723N/A "objectClasses: ( testaddditcontentruleobsoleteauxauxiliary-oid " +
723N/A "NAME 'testAddDITContentRuleObsoleteAuxOCAuxiliary' OBSOLETE " +
723N/A "SUP top AUXILIARY MUST cn X-ORIGIN 'SchemaBackendTestCase' )",
723N/A "-",
723N/A "add: ditContentRules",
723N/A "ditContentRules: ( testaddditcontentruleobsoleteauxstructural-oid " +
723N/A "NAME 'testAddDITContentRuleObsoleteAuxOC' " +
723N/A "AUX testAddDITContentRuleObsoleteAuxOCAuxiliary " +
723N/A "X-ORIGIN 'SchemaBackendTestCase' )");
723N/A
723N/A String[] args =
723N/A {
723N/A "-h", "127.0.0.1",
723N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
723N/A "-D", "cn=Directory Manager",
723N/A "-w", "password",
723N/A "-f", path
723N/A };
723N/A
723N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
723N/A }
723N/A
723N/A
723N/A
723N/A /**
723N/A * Tests the behavior of the schema backend when attempting to add a new DIT
673N/A * content rule that references an undefined required attribute type.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testAddDITContentRuleUndefinedReqAT()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: objectClasses",
673N/A "objectClasses: ( testaddditcontentruleundefinedreqatoc-oid " +
723N/A "NAME 'testAddDITContentRuleUndefinedReqATOC' SUP top " +
723N/A "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase')",
673N/A "-",
673N/A "add: ditContentRules",
673N/A "ditContentRules: ( testaddditcontentruleundefinedreqatoc-oid " +
673N/A "NAME 'testAddDITContentRuleUndefinedReqAT' " +
673N/A "MUST xxxundefinedxxx X-ORIGIN 'SchemaBackendTestCase' )");
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to add a new DIT
723N/A * content rule that references an undefined required attribute type when
723N/A * multiple required attributes were provided.
723N/A *
723N/A * @throws Exception If an unexpected problem occurs.
723N/A */
723N/A @Test()
723N/A public void testAddDITContentRuleMultipleUndefinedReqAT()
723N/A throws Exception
723N/A {
723N/A String path = TestCaseUtils.createTempFile(
723N/A "dn: cn=schema",
723N/A "changetype: modify",
723N/A "add: objectClasses",
723N/A "objectClasses: ( testaddditcontentrulemultundefinedreqatoc-oid " +
723N/A "NAME 'testAddDITContentRuleMultUndefinedReqATOC' SUP top " +
723N/A "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase')",
723N/A "-",
723N/A "add: ditContentRules",
723N/A "ditContentRules: ( testaddditcontentrulemultundefinedreqatoc-oid " +
723N/A "NAME 'testAddDITContentMultRuleUndefinedReqAT' " +
723N/A "MUST ( cn $ xxxundefinedxxx ) " +
723N/A "X-ORIGIN 'SchemaBackendTestCase' )");
723N/A
723N/A String[] args =
723N/A {
723N/A "-h", "127.0.0.1",
723N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
723N/A "-D", "cn=Directory Manager",
723N/A "-w", "password",
723N/A "-f", path
723N/A };
723N/A
723N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
723N/A }
723N/A
723N/A
723N/A
723N/A /**
723N/A * Tests the behavior of the schema backend when attempting to add a new DIT
673N/A * content rule that references an undefined optional attribute type.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testAddDITContentRuleUndefinedOptAT()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: objectClasses",
673N/A "objectClasses: ( testaddditcontentruleundefinedoptatoc-oid " +
723N/A "NAME 'testAddDITContentRuleUndefinedOptATOC' SUP top " +
723N/A "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase')",
673N/A "-",
673N/A "add: ditContentRules",
673N/A "ditContentRules: ( testaddditcontentruleundefinedoptatoc-oid " +
673N/A "NAME 'testAddDITContentRuleUndefinedOptAT' " +
673N/A "MAY xxxundefinedxxx X-ORIGIN 'SchemaBackendTestCase' )");
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to add a new DIT
723N/A * content rule that references an undefined optional attribute type when
723N/A * multiple optional attributes were provided.
723N/A *
723N/A * @throws Exception If an unexpected problem occurs.
723N/A */
723N/A @Test()
723N/A public void testAddDITContentRuleMultipleUndefinedOptAT()
723N/A throws Exception
723N/A {
723N/A String path = TestCaseUtils.createTempFile(
723N/A "dn: cn=schema",
723N/A "changetype: modify",
723N/A "add: objectClasses",
723N/A "objectClasses: ( testaddditcontentrulemultundefinedoptatoc-oid " +
723N/A "NAME 'testAddDITContentRuleMultUndefinedOptATOC' SUP top " +
723N/A "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase')",
723N/A "-",
723N/A "add: ditContentRules",
723N/A "ditContentRules: ( testaddditcontentrulemultundefinedoptatoc-oid " +
723N/A "NAME 'testAddDITContentRuleMultUndefinedOptAT' " +
723N/A "MAY ( cn $ xxxundefinedxxx ) " +
723N/A "X-ORIGIN 'SchemaBackendTestCase' )");
723N/A
723N/A String[] args =
723N/A {
723N/A "-h", "127.0.0.1",
723N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
723N/A "-D", "cn=Directory Manager",
723N/A "-w", "password",
723N/A "-f", path
723N/A };
723N/A
723N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
723N/A }
723N/A
723N/A
723N/A
723N/A /**
723N/A * Tests the behavior of the schema backend when attempting to add a new DIT
673N/A * content rule that references an undefined prohibited attribute type.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testAddDITContentRuleUndefinedNotAT()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: objectClasses",
673N/A "objectClasses: ( testaddditcontentruleundefinednotatoc-oid " +
723N/A "NAME 'testAddDITContentRuleUndefinedNotATOC' SUP top " +
723N/A "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase')",
673N/A "-",
673N/A "add: ditContentRules",
673N/A "ditContentRules: ( testaddditcontentruleundefinednotatoc-oid " +
673N/A "NAME 'testAddDITContentRuleUndefinedNotAT' " +
673N/A "NOT xxxundefinedxxx X-ORIGIN 'SchemaBackendTestCase' )");
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
673N/A }
673N/A
673N/A
673N/A
673N/A /**
723N/A * Tests the behavior of the schema backend when attempting to add a new DIT
723N/A * content rule that references an undefined prohibited attribute type when
723N/A * multiple prohibited attributes were provided.
723N/A *
723N/A * @throws Exception If an unexpected problem occurs.
723N/A */
723N/A @Test()
723N/A public void testAddDITContentRuleMultipleUndefinedNotAT()
723N/A throws Exception
723N/A {
723N/A String path = TestCaseUtils.createTempFile(
723N/A "dn: cn=schema",
723N/A "changetype: modify",
723N/A "add: objectClasses",
723N/A "objectClasses: ( testaddditcontentrulemultundefinednotatoc-oid " +
723N/A "NAME 'testAddDITContentRuleMultUndefinedNotATOC' SUP top " +
723N/A "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase')",
723N/A "-",
723N/A "add: ditContentRules",
723N/A "ditContentRules: ( testaddditcontentrulemultundefinednotatoc-oid " +
723N/A "NAME 'testAddDITContentRuleMultUndefinedNotAT' " +
723N/A "NOT ( description $ xxxundefinedxxx ) " +
723N/A "X-ORIGIN 'SchemaBackendTestCase' )");
723N/A
723N/A String[] args =
723N/A {
723N/A "-h", "127.0.0.1",
723N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
723N/A "-D", "cn=Directory Manager",
723N/A "-w", "password",
723N/A "-f", path
723N/A };
723N/A
723N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
723N/A }
723N/A
723N/A
723N/A
723N/A /**
723N/A * Tests the behavior of the schema backend when attempting to add a new DIT
723N/A * content rule that prohibits an attribute type that is required by the
723N/A * structural object class.
723N/A *
723N/A * @throws Exception If an unexpected problem occurs.
723N/A */
723N/A @Test()
723N/A public void testAddDITContentRuleProhibitRequiredStructuralAttribute()
723N/A throws Exception
723N/A {
723N/A String path = TestCaseUtils.createTempFile(
723N/A "dn: cn=schema",
723N/A "changetype: modify",
723N/A "add: objectClasses",
723N/A "objectClasses: ( testadddcrprohibitreqstructuralatoc-oid " +
723N/A "NAME 'testAddDCRProhibitReqStructuralATOC' SUP top " +
723N/A "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase')",
723N/A "-",
723N/A "add: ditContentRules",
723N/A "ditContentRules: ( testadddcrprohibitreqstructuralatoc-oid " +
723N/A "NAME 'testAddDCRProhibitReqStructuralAT' " +
723N/A "NOT cn X-ORIGIN 'SchemaBackendTestCase' )");
723N/A
723N/A String[] args =
723N/A {
723N/A "-h", "127.0.0.1",
723N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
723N/A "-D", "cn=Directory Manager",
723N/A "-w", "password",
723N/A "-f", path
723N/A };
723N/A
723N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
723N/A }
723N/A
723N/A
723N/A
723N/A /**
723N/A * Tests the behavior of the schema backend when attempting to add a new DIT
723N/A * content rule that prohibits an attribute type that is required by an
723N/A * associated auxiliary object class.
723N/A *
723N/A * @throws Exception If an unexpected problem occurs.
723N/A */
723N/A @Test()
723N/A public void testAddDITContentRuleProhibitRequiredAuxiliaryAttribute()
723N/A throws Exception
723N/A {
723N/A String path = TestCaseUtils.createTempFile(
723N/A "dn: cn=schema",
723N/A "changetype: modify",
723N/A "add: objectClasses",
723N/A "objectClasses: ( testadddcrprohibitreqauxiliaryatoc-oid " +
723N/A "NAME 'testAddDCRProhibitReqAuxiliaryATOC' SUP top " +
723N/A "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase')",
723N/A "-",
723N/A "add: ditContentRules",
723N/A "ditContentRules: ( testadddcrprohibitreqauxiliaryatoc-oid " +
723N/A "NAME 'testAddDCRProhibitReqAuxiliaryAT' AUX posixAccount " +
723N/A "NOT uid X-ORIGIN 'SchemaBackendTestCase' )");
723N/A
723N/A String[] args =
723N/A {
723N/A "-h", "127.0.0.1",
723N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
723N/A "-D", "cn=Directory Manager",
723N/A "-w", "password",
723N/A "-f", path
723N/A };
723N/A
723N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
723N/A }
723N/A
723N/A
723N/A
723N/A /**
723N/A * Tests the behavior of the schema backend when attempting to add a new DIT
723N/A * content rule with an OBSOLETE required attribute type.
723N/A *
723N/A * @throws Exception If an unexpected problem occurs.
723N/A */
723N/A @Test()
723N/A public void testAddDITContentRuleObsoleteRequiredAttributeType()
723N/A throws Exception
723N/A {
723N/A String path = TestCaseUtils.createTempFile(
723N/A "dn: cn=schema",
723N/A "changetype: modify",
723N/A "add: attributeTypes",
723N/A "attributeTypes: ( testadddcrobsoletereqatat-oid " +
723N/A "NAME 'testAddDCRObsoleteReqATAT' OBSOLETE " +
723N/A "X-ORIGIN 'SchemaBackendTestCase' )",
723N/A "-",
723N/A "add: objectClasses",
723N/A "objectClasses: ( testadddcrobsoletereqatoc-oid " +
723N/A "NAME 'testAddDCRObsoleteReqATOC' SUP top " +
723N/A "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase')",
723N/A "-",
723N/A "add: ditContentRules",
723N/A "ditContentRules: ( testadddcrobsoletereqatoc-oid " +
723N/A "NAME 'testAddDCRObsoleteReqATDCR' " +
723N/A "MUST testAddDCRObsoleteReqATAT " +
723N/A "X-ORIGIN 'SchemaBackendTestCase' )");
723N/A
723N/A String[] args =
723N/A {
723N/A "-h", "127.0.0.1",
723N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
723N/A "-D", "cn=Directory Manager",
723N/A "-w", "password",
723N/A "-f", path
723N/A };
723N/A
723N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
723N/A }
723N/A
723N/A
723N/A
723N/A /**
723N/A * Tests the behavior of the schema backend when attempting to add a new DIT
723N/A * content rule with an OBSOLETE optional attribute type.
723N/A *
723N/A * @throws Exception If an unexpected problem occurs.
723N/A */
723N/A @Test()
723N/A public void testAddDITContentRuleObsoleteOptionalAttributeType()
723N/A throws Exception
723N/A {
723N/A String path = TestCaseUtils.createTempFile(
723N/A "dn: cn=schema",
723N/A "changetype: modify",
723N/A "add: attributeTypes",
723N/A "attributeTypes: ( testadddcrobsoleteoptatat-oid " +
723N/A "NAME 'testAddDCRObsoleteOptATAT' OBSOLETE " +
723N/A "X-ORIGIN 'SchemaBackendTestCase' )",
723N/A "-",
723N/A "add: objectClasses",
723N/A "objectClasses: ( testadddcrobsoleteoptatoc-oid " +
723N/A "NAME 'testAddDCRObsoleteOptATOC' SUP top " +
723N/A "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase')",
723N/A "-",
723N/A "add: ditContentRules",
723N/A "ditContentRules: ( testadddcrobsoleteoptatoc-oid " +
723N/A "NAME 'testAddDCRObsoleteOptATDCR' " +
723N/A "MAY testAddDCRObsoleteOptATAT " +
723N/A "X-ORIGIN 'SchemaBackendTestCase' )");
723N/A
723N/A String[] args =
723N/A {
723N/A "-h", "127.0.0.1",
723N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
723N/A "-D", "cn=Directory Manager",
723N/A "-w", "password",
723N/A "-f", path
723N/A };
723N/A
723N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
723N/A }
723N/A
723N/A
723N/A
723N/A /**
723N/A * Tests the behavior of the schema backend when attempting to add a new DIT
723N/A * content rule with an OBSOLETE prohibited attribute type.
723N/A *
723N/A * @throws Exception If an unexpected problem occurs.
723N/A */
723N/A @Test()
723N/A public void testAddDITContentRuleObsoleteProhibitedAttributeType()
723N/A throws Exception
723N/A {
723N/A String path = TestCaseUtils.createTempFile(
723N/A "dn: cn=schema",
723N/A "changetype: modify",
723N/A "add: attributeTypes",
723N/A "attributeTypes: ( testadddcrobsoletenotatat-oid " +
723N/A "NAME 'testAddDCRObsoleteNotATAT' OBSOLETE " +
723N/A "X-ORIGIN 'SchemaBackendTestCase' )",
723N/A "-",
723N/A "add: objectClasses",
723N/A "objectClasses: ( testadddcrobsoletenotatoc-oid " +
723N/A "NAME 'testAddDCRObsoleteNotATOC' SUP top " +
723N/A "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase')",
723N/A "-",
723N/A "add: ditContentRules",
723N/A "ditContentRules: ( testadddcrobsoletenotatoc-oid " +
723N/A "NAME 'testAddDCRObsoleteNotATDCR' " +
723N/A "NOT testAddDCRObsoleteNotATAT " +
723N/A "X-ORIGIN 'SchemaBackendTestCase' )");
723N/A
723N/A String[] args =
723N/A {
723N/A "-h", "127.0.0.1",
723N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
723N/A "-D", "cn=Directory Manager",
723N/A "-w", "password",
723N/A "-f", path
723N/A };
723N/A
723N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
723N/A }
723N/A
723N/A
723N/A
723N/A /**
673N/A * Tests the behavior of the schema backend when attempting to remove an
673N/A * existing DIT content rule.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testRemoveDITContentRuleSuccessful()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: objectClasses",
673N/A "objectClasses: ( testremoveditcontentrulesuccessfuloc-oid " +
673N/A "NAME 'testRemoveDITContentRuleSuccessfulOC' SUP top " +
673N/A "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase')",
673N/A "-",
673N/A "add: ditContentRules",
673N/A "ditContentRules: ( testremoveditcontentrulesuccessfuloc-oid " +
673N/A "NAME 'testRemoveDITContentRuleSuccessful' NOT description " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )",
673N/A "",
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "delete: ditContentRules",
673N/A "ditContentRules: ( testremoveditcontentrulesuccessfuloc-oid " +
673N/A "NAME 'testRemoveDITContentRuleSuccessful' NOT description " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )");
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A String ocName = "testremoveditcontentrulesuccessfuloc";
673N/A assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName));
673N/A
673N/A assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
673N/A
673N/A ObjectClass oc = DirectoryServer.getSchema().getObjectClass(ocName);
673N/A assertNotNull(oc);
673N/A
673N/A DITContentRule dcr = DirectoryServer.getSchema().getDITContentRule(oc);
673N/A assertNull(dcr);
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to add a new
673N/A * DIT structure rule.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testAddDITStructureRuleSuccessful()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: objectClasses",
673N/A "objectClasses: ( testaddditstructurerulesuccessfuloc-oid " +
673N/A "NAME 'testAddDITStructureRuleSuccessfulOC' SUP top " +
673N/A "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase')",
673N/A "-",
673N/A "add: nameForms",
673N/A "nameForms: ( testaddditstructurerulesuccessfulnf-oid " +
673N/A "NAME 'testAddDITStructureRuleSuccessfulNF' " +
673N/A "OC testAddDITStructureRuleSuccessfulOC MUST cn " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )",
673N/A "-",
673N/A "add: ditStructureRules",
673N/A "ditStructureRules: ( 999001 " +
673N/A "NAME 'testAddDITStructureRuleSuccessful' " +
673N/A "FORM testAddDITStructureRuleSuccessfulNF " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )");
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A int ruleID = 999001;
673N/A assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
673N/A
673N/A assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
673N/A assertTrue(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to replace an
673N/A * existing DIT structure rule definition.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testReplaceDITStructureRuleSuccessful()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: objectClasses",
673N/A "objectClasses: ( testreplaceditstructurerulesuccessfuloc-oid " +
673N/A "NAME 'testReplaceDITStructureRuleSuccessfulOC' SUP top " +
673N/A "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase')",
673N/A "-",
673N/A "add: nameForms",
673N/A "nameForms: ( testreplaceditstructurerulesuccessfulnf-oid " +
673N/A "NAME 'testReplaceDITStructureRuleSuccessfulNF' " +
673N/A "OC testReplaceDITStructureRuleSuccessfulOC MUST cn " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )",
673N/A "-",
673N/A "add: ditStructureRules",
673N/A "ditStructureRules: ( 999002 " +
673N/A "NAME 'testReplaceDITStructureRuleSuccessful' " +
673N/A "FORM testReplaceDITStructureRuleSuccessfulNF " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )",
673N/A "",
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: ditStructureRules",
673N/A "ditStructureRules: ( 999002 " +
673N/A "NAME 'testReplaceDITStructureRuleSuccessful' " +
673N/A "DESC 'Testing the replacement of an existing DSR' " +
673N/A "FORM testReplaceDITStructureRuleSuccessfulNF " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )");
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A int ruleID = 999002;
673N/A assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
673N/A
673N/A assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
673N/A assertTrue(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to add a new
673N/A * DIT structure rule to an alternate schema file.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testAddDITStructureRuleToAltSchemaFile()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: objectClasses",
673N/A "objectClasses: ( testaddditstructureruletoaltschemafileoc-oid " +
673N/A "NAME 'testAddDITStructureRuleToAltSchemaFileOC' SUP top " +
673N/A "STRUCTURAL MUST cn X-SCHEMA-FILE '98-schema-test-dsr.ldif' " +
673N/A "X-ORIGIN 'SchemaBackendTestCase')",
673N/A "-",
673N/A "add: nameForms",
673N/A "nameForms: ( testaddditstructureruletoaltschemafilenf-oid " +
673N/A "NAME 'testAddDITStructureRuleToAltSchemaFileNF' " +
673N/A "OC testAddDITStructureRuleToAltSchemaFileOC MUST cn " +
673N/A "X-SCHEMA-FILE '98-schema-test-dsr.ldif' " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )",
673N/A "-",
673N/A "add: ditStructureRules",
673N/A "ditStructureRules: ( 999010 " +
673N/A "NAME 'testAddDITStructureRuleToAltSchemaFile' " +
673N/A "FORM testAddDITStructureRuleToAltSchemaFileNF " +
673N/A "X-SCHEMA-FILE '98-schema-test-dsr.ldif' " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )");
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A int ruleID = 999010;
673N/A assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
673N/A
6318N/A File schemaFile = new File(SchemaConfigManager.getSchemaDirectoryPath(),
673N/A "98-schema-test-dsr.ldif");
673N/A assertFalse(schemaFile.exists());
673N/A
673N/A assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
673N/A assertTrue(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
673N/A
673N/A assertTrue(schemaFile.exists());
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to remove an
673N/A * existing DIT structure rule definition and add it back in the same
673N/A * operation.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testRemoveAndAddDITStructureRuleSuccessful()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: objectClasses",
673N/A "objectClasses: ( testremoveandaddditstructurerulesuccessfuloc-oid " +
673N/A "NAME 'testRemoveAndAddDITStructureRuleSuccessfulOC' SUP top " +
673N/A "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase')",
673N/A "-",
673N/A "add: nameForms",
673N/A "nameForms: ( testremoveandaddditstructurerulesuccessfulnf-oid " +
673N/A "NAME 'testRemoveAndAddDITStructureRuleSuccessfulNF' " +
673N/A "OC testRemoveAndAddDITStructureRuleSuccessfulOC MUST cn " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )",
673N/A "-",
673N/A "add: ditStructureRules",
673N/A "ditStructureRules: ( 999003 " +
673N/A "NAME 'testRemoveAndAddDITStructureRuleSuccessful' " +
673N/A "FORM testRemoveAndAddDITStructureRuleSuccessfulNF " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )",
673N/A "",
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "delete: ditStructureRules",
673N/A "ditStructureRules: ( 999003 " +
673N/A "NAME 'testRemoveAndAddDITStructureRuleSuccessful' " +
673N/A "FORM testRemoveAndAddDITStructureRuleSuccessfulNF " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )",
673N/A "-",
673N/A "add: ditStructureRules",
673N/A "ditStructureRules: ( 999003 " +
673N/A "NAME 'testRemoveAndAddDITStructureRuleSuccessful' " +
673N/A "DESC 'Testing removing and re-adding an existing DSR' " +
673N/A "FORM testRemoveAndAddDITStructureRuleSuccessfulNF " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )");
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A int ruleID = 999003;
673N/A assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
673N/A
673N/A assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
673N/A assertTrue(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to add a new
673N/A * DIT structure rule with an undefined name form.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testAddDITStructureRuleUndefinedNameForm()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: ditStructureRules",
673N/A "ditStructureRules: ( 999004 " +
673N/A "NAME 'testAddDITStructureRuleUndefinedNameForm' " +
673N/A "FORM xxxundefinedxxx " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )");
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A int ruleID = 999004;
673N/A assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
673N/A
673N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
673N/A assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to add a new
673N/A * DIT structure rule that references an undefined superior rule.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testAddDITStructureRuleUndefinedSuperior()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: objectClasses",
673N/A "objectClasses: ( testadddsrundefinedsuperioroc-oid " +
673N/A "NAME 'testAddDSRUndefinedSuperiorOC' SUP top " +
673N/A "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase')",
673N/A "-",
673N/A "add: nameForms",
673N/A "nameForms: ( testadddsrundefinedsuperiornf-oid " +
673N/A "NAME 'testAddDSRUndefinedSuperiorNF' " +
673N/A "OC testAddDSRUndefinedSuperiorOC MUST cn " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )",
673N/A "-",
673N/A "add: ditStructureRules",
673N/A "ditStructureRules: ( 999005 " +
673N/A "NAME 'testAddDSRUndefinedSuperior' " +
673N/A "FORM testAddDSRUndefinedSuperiorNF SUP 999000 " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )");
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A int ruleID = 999005;
673N/A assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
673N/A
673N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
673N/A assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
673N/A }
673N/A
673N/A
673N/A
673N/A /**
723N/A * Tests the behavior of the schema backend when attempting to add a new
723N/A * DIT structure rule that references a name form which is OBSOLETE.
723N/A *
723N/A * @throws Exception If an unexpected problem occurs.
723N/A */
723N/A @Test()
723N/A public void testAddDITStructureRuleObsoleteNameForm()
723N/A throws Exception
723N/A {
723N/A String path = TestCaseUtils.createTempFile(
723N/A "dn: cn=schema",
723N/A "changetype: modify",
723N/A "add: objectClasses",
723N/A "objectClasses: ( testaddditstructureruleobsoletenameformoc-oid " +
723N/A "NAME 'testAddDITStructureRuleObsoleteNameFormOC' SUP top " +
723N/A "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase')",
723N/A "-",
723N/A "add: nameForms",
723N/A "nameForms: ( testaddditstructureruleobsoletenameformnf-oid " +
723N/A "NAME 'testAddDITStructureRuleObsoleteNameFormNF' OBSOLETE " +
723N/A "OC testAddDITStructureRuleObsoleteNameFormOC MUST cn " +
723N/A "X-ORIGIN 'SchemaBackendTestCase' )",
723N/A "-",
723N/A "add: ditStructureRules",
723N/A "ditStructureRules: ( 999011 " +
723N/A "NAME 'testAddDITStructureRuleObsoleteNameForm' " +
723N/A "FORM testAddDITStructureRuleObsoleteNameFormNF " +
723N/A "X-ORIGIN 'SchemaBackendTestCase' )");
723N/A
723N/A String[] args =
723N/A {
723N/A "-h", "127.0.0.1",
723N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
723N/A "-D", "cn=Directory Manager",
723N/A "-w", "password",
723N/A "-f", path
723N/A };
723N/A
723N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
723N/A }
723N/A
723N/A
723N/A
723N/A /**
723N/A * Tests the behavior of the schema backend when attempting to add a new
723N/A * DIT structure rule that references a superior rule which is OBSOLETE.
723N/A *
723N/A * @throws Exception If an unexpected problem occurs.
723N/A */
723N/A @Test()
723N/A public void testAddDITStructureRuleObsoleteSuperiorRule()
723N/A throws Exception
723N/A {
723N/A String path = TestCaseUtils.createTempFile(
723N/A "dn: cn=schema",
723N/A "changetype: modify",
723N/A "add: objectClasses",
723N/A "objectClasses: ( testaddditstructureruleobsoletesuperioroc1-oid " +
723N/A "NAME 'testAddDITStructureRuleObsoleteSuperiorOC1' SUP top " +
723N/A "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase')",
723N/A "objectClasses: ( testaddditstructureruleobsoletesuperioroc2-oid " +
723N/A "NAME 'testAddDITStructureRuleObsoleteSuperiorOC2' SUP top " +
723N/A "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase')",
723N/A "-",
723N/A "add: nameForms",
723N/A "nameForms: ( testaddditstructureruleobsoletesuperiornf1-oid " +
723N/A "NAME 'testAddDITStructureRuleObsoleteSuperiorNF1' " +
723N/A "OC testAddDITStructureRuleObsoleteSuperiorOC1 MUST cn " +
723N/A "X-ORIGIN 'SchemaBackendTestCase' )",
723N/A "nameForms: ( testaddditstructureruleobsoletesuperiornf2-oid " +
723N/A "NAME 'testAddDITStructureRuleObsoleteSuperiorNF2' " +
723N/A "OC testAddDITStructureRuleObsoleteSuperiorOC2 MUST cn " +
723N/A "X-ORIGIN 'SchemaBackendTestCase' )",
723N/A "-",
723N/A "add: ditStructureRules",
723N/A "ditStructureRules: ( 999012 " +
723N/A "NAME 'testAddDITStructureRuleObsoleteSuperiorSup' OBSOLETE " +
723N/A "FORM testAddDITStructureRuleObsoleteSuperiorNF1 " +
723N/A "X-ORIGIN 'SchemaBackendTestCase' )",
723N/A "ditStructureRules: ( 999013 " +
723N/A "NAME 'testAddDITStructureRuleObsoleteSuperiorSub' " +
723N/A "FORM testAddDITStructureRuleObsoleteSuperiorNF2 SUP 999012 " +
723N/A "X-ORIGIN 'SchemaBackendTestCase' )");
723N/A
723N/A String[] args =
723N/A {
723N/A "-h", "127.0.0.1",
723N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
723N/A "-D", "cn=Directory Manager",
723N/A "-w", "password",
723N/A "-f", path
723N/A };
723N/A
723N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
723N/A }
723N/A
723N/A
723N/A
723N/A /**
673N/A * Tests the behavior of the schema backend when attempting to remove an
673N/A * existing DIT structure rule definition.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testRemoveDITStructureRuleSuccessful()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: objectClasses",
673N/A "objectClasses: ( testremoveditstructurerulesuccessfuloc-oid " +
673N/A "NAME 'testRemoveDITStructureRuleSuccessfulOC' SUP top " +
673N/A "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase')",
673N/A "-",
673N/A "add: nameForms",
673N/A "nameForms: ( testremoveditstructurerulesuccessfulnf-oid " +
673N/A "NAME 'testRemoveDITStructureRuleSuccessfulNF' " +
673N/A "OC testRemoveDITStructureRuleSuccessfulOC MUST cn " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )",
673N/A "-",
673N/A "add: ditStructureRules",
673N/A "ditStructureRules: ( 999006 " +
673N/A "NAME 'testRemoveDITStructureRuleSuccessful' " +
673N/A "FORM testRemoveDITStructureRuleSuccessfulNF " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )",
673N/A "",
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "delete: ditStructureRules",
673N/A "ditStructureRules: ( 999006 " +
673N/A "NAME 'testRemoveDITStructureRuleSuccessful' " +
673N/A "FORM testRemoveDITStructureRuleSuccessfulNF " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )");
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A int ruleID = 999006;
673N/A assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
673N/A
673N/A assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
673N/A assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to remove an
673N/A * existing DIT structure rule definition which is the superior rule for
673N/A * another DIT structure rule.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testRemoveSuperiorDITStructureRule()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: objectClasses",
673N/A "objectClasses: ( testremovesuperiorditstructureruleoc-oid " +
673N/A "NAME 'testRemoveSuperiorDITStructureRuleOC' SUP top " +
673N/A "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase')",
673N/A "objectClasses: ( testremovesuperiorditstructureruleoc2-oid " +
673N/A "NAME 'testRemoveSuperiorDITStructureRuleOC2' SUP top " +
673N/A "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase')",
673N/A "-",
673N/A "add: nameForms",
673N/A "nameForms: ( testremovesuperiorditstructurerulenf-oid " +
673N/A "NAME 'testRemoveSuperiorDITStructureRuleNF' " +
673N/A "OC testRemoveSuperiorDITStructureRuleOC MUST cn " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )",
673N/A "nameForms: ( testremovesuperiorditstructurerulenf2-oid " +
673N/A "NAME 'testRemoveSuperiorDITStructureRuleNF2' " +
673N/A "OC testRemoveSuperiorDITStructureRuleOC2 MUST cn " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )",
673N/A "-",
673N/A "add: ditStructureRules",
673N/A "ditStructureRules: ( 999007 " +
673N/A "NAME 'testRemoveSuperiorDITStructureRule' " +
673N/A "FORM testRemoveSuperiorDITStructureRuleNF " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )",
673N/A "ditStructureRules: ( 999008 " +
673N/A "NAME 'testRemoveSuperiorDITStructureRule2' " +
673N/A "FORM testRemoveSuperiorDITStructureRuleNF2 SUP 999007 " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )",
673N/A "",
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "delete: ditStructureRules",
673N/A "ditStructureRules: ( 999007 " +
673N/A "NAME 'testRemoveSuperiorDITStructureRule' " +
673N/A "FORM testRemoveSuperiorDITStructureRuleNF " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )");
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A int ruleID = 999007;
673N/A assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
673N/A
673N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
673N/A assertTrue(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
673N/A
673N/A
673N/A path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "delete: ditStructureRules",
673N/A "ditStructureRules: ( 999008 " +
673N/A "NAME 'testRemoveSuperiorDITStructureRule2' " +
673N/A "FORM testRemoveSuperiorDITStructureRuleNF2 SUP 999007 " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )",
673N/A "ditStructureRules: ( 999007 " +
673N/A "NAME 'testRemoveSuperiorDITStructureRule' " +
673N/A "FORM testRemoveSuperiorDITStructureRuleNF " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )");
673N/A
673N/A args = new String[]
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
673N/A assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID));
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to add a new
673N/A * matching rule use that doesn't already exist.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testAddMatchingRuleUseSuccessful()
673N/A throws Exception
673N/A {
673N/A SchemaTestMatchingRule matchingRule =
673N/A new SchemaTestMatchingRule("testAddMRUSuccessfulMatch",
673N/A "1.3.6.1.4.1.26027.1.999.10");
673N/A DirectoryServer.registerMatchingRule(matchingRule, false);
673N/A
673N/A
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: matchingRuleUse",
673N/A "matchingRuleUse: ( 1.3.6.1.4.1.26027.1.999.10 " +
673N/A "NAME 'testAddMRUSuccessful' APPLIES cn " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )");
673N/A
673N/A assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule));
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
673N/A
673N/A MatchingRuleUse mru =
673N/A DirectoryServer.getSchema().getMatchingRuleUse(matchingRule);
673N/A assertNotNull(mru);
673N/A assertTrue(mru.hasName("testaddmrusuccessful"));
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to add a new
673N/A * matching rule to an alternate schema file.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testAddMatchingRuleUseToAltSchemaFile()
673N/A throws Exception
673N/A {
673N/A SchemaTestMatchingRule matchingRule =
673N/A new SchemaTestMatchingRule("testAddMRUToAltSchemaFileMatch",
673N/A "1.3.6.1.4.1.26027.1.999.18");
673N/A DirectoryServer.registerMatchingRule(matchingRule, false);
673N/A
673N/A
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: matchingRuleUse",
673N/A "matchingRuleUse: ( 1.3.6.1.4.1.26027.1.999.18 " +
673N/A "NAME 'testAddMRUToAltSchemaFile' APPLIES cn " +
673N/A "X-SCHEMA-FILE '98-schema-test-mru.ldif' " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )");
673N/A
673N/A assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule));
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
6318N/A File schemaFile = new File(SchemaConfigManager.getSchemaDirectoryPath(),
673N/A "98-schema-test-mru.ldif");
673N/A assertFalse(schemaFile.exists());
673N/A
673N/A assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
673N/A
673N/A MatchingRuleUse mru =
673N/A DirectoryServer.getSchema().getMatchingRuleUse(matchingRule);
673N/A assertNotNull(mru);
673N/A assertTrue(mru.hasName("testaddmrutoaltschemafile"));
673N/A
673N/A assertTrue(schemaFile.exists());
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to replace an
673N/A * existing matching rule use.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testReplaceMatchingRuleUseSuccessful()
673N/A throws Exception
673N/A {
673N/A SchemaTestMatchingRule matchingRule =
673N/A new SchemaTestMatchingRule("testReplaceMRUSuccessfulMatch",
673N/A "1.3.6.1.4.1.26027.1.999.11");
673N/A DirectoryServer.registerMatchingRule(matchingRule, false);
673N/A
673N/A
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: matchingRuleUse",
673N/A "matchingRuleUse: ( 1.3.6.1.4.1.26027.1.999.11 " +
673N/A "NAME 'testReplaceMRUSuccessful' APPLIES cn " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )",
673N/A "",
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: matchingRuleUse",
673N/A "matchingRuleUse: ( 1.3.6.1.4.1.26027.1.999.11 " +
673N/A "NAME 'testReplaceMRUSuccessful' APPLIES ( cn $ sn ) " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )");
673N/A
673N/A assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule));
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
673N/A
673N/A MatchingRuleUse mru =
673N/A DirectoryServer.getSchema().getMatchingRuleUse(matchingRule);
673N/A assertNotNull(mru);
673N/A assertTrue(mru.hasName("testreplacemrusuccessful"));
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to remove and
673N/A * re-add an existing matching rule use in the same operation.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testRemoveAndAddMatchingRuleUse()
673N/A throws Exception
673N/A {
673N/A SchemaTestMatchingRule matchingRule =
673N/A new SchemaTestMatchingRule("testRemoveAndAddMRUMatch",
673N/A "1.3.6.1.4.1.26027.1.999.12");
673N/A DirectoryServer.registerMatchingRule(matchingRule, false);
673N/A
673N/A
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: matchingRuleUse",
673N/A "matchingRuleUse: ( 1.3.6.1.4.1.26027.1.999.12 " +
673N/A "NAME 'testRemoveAndAddMRU' APPLIES cn " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )",
673N/A "",
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "delete: matchingRuleUse",
673N/A "matchingRuleUse: ( 1.3.6.1.4.1.26027.1.999.12 " +
673N/A "NAME 'testRemoveAndAddMRU' APPLIES cn " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )",
673N/A "-",
673N/A "add: matchingRuleUse",
673N/A "matchingRuleUse: ( 1.3.6.1.4.1.26027.1.999.12 " +
673N/A "NAME 'testRemoveAndAddMRU' APPLIES ( cn $ sn ) " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )");
673N/A
673N/A assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule));
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
673N/A
673N/A MatchingRuleUse mru =
673N/A DirectoryServer.getSchema().getMatchingRuleUse(matchingRule);
673N/A assertNotNull(mru);
673N/A assertTrue(mru.hasName("testremoveandaddmru"));
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to add a matching
673N/A * rule use that references the same matching rule as another matching rule
673N/A * use.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testAddMatchingRuleUseMRConflict()
673N/A throws Exception
673N/A {
673N/A SchemaTestMatchingRule matchingRule =
673N/A new SchemaTestMatchingRule("testAddMRUMRConflictMatch",
673N/A "1.3.6.1.4.1.26027.1.999.14");
673N/A DirectoryServer.registerMatchingRule(matchingRule, false);
673N/A
673N/A
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: matchingRuleUse",
673N/A "matchingRuleUse: ( 1.3.6.1.4.1.26027.1.999.14 " +
673N/A "NAME 'testAddMRUMRConflict' APPLIES cn " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )",
673N/A "",
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: matchingRuleUse",
673N/A "matchingRuleUse: ( 1.3.6.1.4.1.26027.1.999.14 " +
673N/A "NAME 'testAddMRUMRConflict2' APPLIES sn " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )");
673N/A
673N/A assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule));
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
673N/A
673N/A MatchingRuleUse mru =
673N/A DirectoryServer.getSchema().getMatchingRuleUse(matchingRule);
673N/A assertNotNull(mru);
673N/A assertTrue(mru.hasName("testaddmrumrconflict"));
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to add a new
673N/A * matching rule use that references an undefined matching rule.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testAddMatchingRuleUseMRUndefined()
673N/A throws Exception
673N/A {
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: matchingRuleUse",
673N/A "matchingRuleUse: ( 1.3.6.1.4.1.26027.1.999.15 " +
673N/A "NAME 'testAddMRUMRUndefined' APPLIES cn " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )");
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the behavior of the schema backend when attempting to add a new
673N/A * matching rule use that references an undefined attribute type.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testAddMatchingRuleUseAttributeTypeUndefined()
673N/A throws Exception
673N/A {
673N/A SchemaTestMatchingRule matchingRule =
673N/A new SchemaTestMatchingRule("testAddMRUATUndefinedMatch",
673N/A "1.3.6.1.4.1.26027.1.999.16");
673N/A DirectoryServer.registerMatchingRule(matchingRule, false);
673N/A
673N/A
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: matchingRuleUse",
673N/A "matchingRuleUse: ( 1.3.6.1.4.1.26027.1.999.16 " +
673N/A "NAME 'testAddMatchingRuleUseATUndefined' " +
673N/A "APPLIES xxxundefinedxxx " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )");
673N/A
673N/A assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule));
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
673N/A }
673N/A
673N/A
673N/A
673N/A /**
723N/A * Tests the behavior of the schema backend when attempting to add a new
723N/A * matching rule use that references an undefined attribute type.
723N/A *
723N/A * @throws Exception If an unexpected problem occurs.
723N/A */
723N/A @Test()
723N/A public void testAddMatchingRuleUseAttributeTypeMultipleUndefined()
723N/A throws Exception
723N/A {
723N/A SchemaTestMatchingRule matchingRule =
723N/A new SchemaTestMatchingRule("testAddMRUATMultipleUndefinedMatch",
723N/A "1.3.6.1.4.1.26027.1.999.19");
723N/A DirectoryServer.registerMatchingRule(matchingRule, false);
723N/A
723N/A
723N/A String path = TestCaseUtils.createTempFile(
723N/A "dn: cn=schema",
723N/A "changetype: modify",
723N/A "add: matchingRuleUse",
723N/A "matchingRuleUse: ( 1.3.6.1.4.1.26027.1.999.19 " +
723N/A "NAME 'testAddMatchingRuleUseATMultipleUndefined' " +
723N/A "APPLIES ( cn $ xxxundefinedxxx ) " +
723N/A "X-ORIGIN 'SchemaBackendTestCase' )");
723N/A
723N/A assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule));
723N/A
723N/A String[] args =
723N/A {
723N/A "-h", "127.0.0.1",
723N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
723N/A "-D", "cn=Directory Manager",
723N/A "-w", "password",
723N/A "-f", path
723N/A };
723N/A
723N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
723N/A }
723N/A
723N/A
723N/A
723N/A /**
723N/A * Tests the behavior of the schema backend when attempting to add a new
723N/A * matching rule whose matching rule is OBSOLETE.
723N/A *
723N/A * @throws Exception If an unexpected problem occurs.
723N/A */
723N/A @Test()
723N/A public void testAddMatchingRuleUseObsoleteMatchingRule()
723N/A throws Exception
723N/A {
723N/A SchemaTestMatchingRule matchingRule =
723N/A new SchemaTestMatchingRule("testAddMRUObsoleteMRMatch",
723N/A "1.3.6.1.4.1.26027.1.999.21", true);
723N/A DirectoryServer.registerMatchingRule(matchingRule, false);
723N/A
723N/A
723N/A String path = TestCaseUtils.createTempFile(
723N/A "dn: cn=schema",
723N/A "changetype: modify",
723N/A "add: matchingRuleUse",
723N/A "matchingRuleUse: ( 1.3.6.1.4.1.26027.1.999.21 " +
723N/A "NAME 'testAddMatchingRuleUseObsoleteMatchingRule' " +
723N/A "APPLIES cn X-ORIGIN 'SchemaBackendTestCase' )");
723N/A
723N/A assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule));
723N/A
723N/A String[] args =
723N/A {
723N/A "-h", "127.0.0.1",
723N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
723N/A "-D", "cn=Directory Manager",
723N/A "-w", "password",
723N/A "-f", path
723N/A };
723N/A
723N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
723N/A }
723N/A
723N/A
723N/A
723N/A /**
723N/A * Tests the behavior of the schema backend when attempting to add a new
723N/A * matching rule with an associated attribute type that is marked OBSOLETE.
723N/A *
723N/A * @throws Exception If an unexpected problem occurs.
723N/A */
723N/A @Test()
723N/A public void testAddMatchingRuleUseObsoleteAttributeType()
723N/A throws Exception
723N/A {
723N/A SchemaTestMatchingRule matchingRule =
723N/A new SchemaTestMatchingRule("testAddMRUObsoleteATMatch",
723N/A "1.3.6.1.4.1.26027.1.999.22");
723N/A DirectoryServer.registerMatchingRule(matchingRule, false);
723N/A
723N/A
723N/A String path = TestCaseUtils.createTempFile(
723N/A "dn: cn=schema",
723N/A "changetype: modify",
723N/A "add: attributeTypes",
723N/A "attributeTypes: ( testaddmruobsoleteat-oid " +
723N/A "NAME 'testAddMRUObsoleteAT' OBSOLETE )",
723N/A "-",
723N/A "add: matchingRuleUse",
723N/A "matchingRuleUse: ( 1.3.6.1.4.1.26027.1.999.22 " +
723N/A "NAME 'testAddMatchingRuleUseObsoleteAttributeType' " +
723N/A "APPLIES testAddMRUObsoleteAT " +
723N/A "X-ORIGIN 'SchemaBackendTestCase' )");
723N/A
723N/A assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule));
723N/A
723N/A String[] args =
723N/A {
723N/A "-h", "127.0.0.1",
723N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
723N/A "-D", "cn=Directory Manager",
723N/A "-w", "password",
723N/A "-f", path
723N/A };
723N/A
723N/A assertFalse(LDAPModify.mainModify(args, false, null, null) == 0);
723N/A }
723N/A
723N/A
723N/A
723N/A /**
673N/A * Tests the behavior of the schema backend when attempting to remove an
673N/A * existing matching rule use.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testRemoveMatchingRuleUseSuccessful()
673N/A throws Exception
673N/A {
673N/A SchemaTestMatchingRule matchingRule =
673N/A new SchemaTestMatchingRule("testRemoveMRUSuccessfulMatch",
673N/A "1.3.6.1.4.1.26027.1.999.13");
673N/A DirectoryServer.registerMatchingRule(matchingRule, false);
673N/A
673N/A
673N/A String path = TestCaseUtils.createTempFile(
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "add: matchingRuleUse",
673N/A "matchingRuleUse: ( 1.3.6.1.4.1.26027.1.999.13 " +
673N/A "NAME 'testRemoveMRUSuccessful' APPLIES cn " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )",
673N/A "",
673N/A "dn: cn=schema",
673N/A "changetype: modify",
673N/A "delete: matchingRuleUse",
673N/A "matchingRuleUse: ( 1.3.6.1.4.1.26027.1.999.13 " +
673N/A "NAME 'testRemoveMRUSuccessful' APPLIES cn " +
673N/A "X-ORIGIN 'SchemaBackendTestCase' )");
673N/A
673N/A assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule));
673N/A
673N/A String[] args =
673N/A {
673N/A "-h", "127.0.0.1",
673N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
673N/A "-D", "cn=Directory Manager",
673N/A "-w", "password",
673N/A "-f", path
673N/A };
673N/A
673N/A assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
673N/A
673N/A MatchingRuleUse mru =
673N/A DirectoryServer.getSchema().getMatchingRuleUse(matchingRule);
673N/A assertNull(mru);
673N/A }
673N/A
673N/A
673N/A
673N/A /**
910N/A * This test case covers the problem identified in issue #1318. In that
910N/A * issue, a problem arose if the following elements occurred in the following
910N/A * order in a single modify request:
910N/A *
910N/A * <OL>
910N/A * <LI>Delete an existing object class</LI>
910N/A * <LI>Add a new attribute type</LI>
910N/A * <LI>Add a new object class (different from the one that was removed) that
910N/A * depends on the new attribute type</LI>
910N/A * </OL>
910N/A *
910N/A * The problem was that in the process of removing the object class in step 1,
910N/A * the server checks to see if the same object class is going to be re-added
910N/A * again later. It does that by looking through the remaining modifications
910N/A * in the operation and for each modification that would add a new object
910N/A * class we decode it to see if it has the same OID. The process of decoding
910N/A * that object class would fail because it depended on a new attribute type
910N/A * that wasn't yet defined in the schema, and the server wasn't told to ignore
910N/A * missing schema elements.
910N/A *
910N/A * @throws Exception If an unexpected problem occurs.
910N/A */
910N/A @Test()
910N/A public void testRemoveAndAddObjectClassIssue1318()
910N/A throws Exception
910N/A {
910N/A String path = TestCaseUtils.createTempFile(
910N/A "dn: cn=schema",
910N/A "changetype: modify",
910N/A "add: objectClasses",
910N/A "objectClasses: ( testissue1318oc1-oid NAME 'testIssue1381OC1' )",
910N/A "",
910N/A "dn: cn=schema",
910N/A "changetype: modify",
910N/A "delete: objectClasses",
910N/A "objectClasses: ( testissue1318oc1-oid NAME 'testIssue1381OC1' )",
910N/A "-",
910N/A "add: attributeTypes",
910N/A "attributeTypes: ( testissue1318at-oid NAME 'testIssue1381AT' )",
910N/A "-",
910N/A "add: objectClasses",
910N/A "objectClasses: ( testissue1318oc2-oid NAME 'testIssue1381OC2' " +
910N/A "MUST testIssue1381AT )");
910N/A
910N/A String[] args =
910N/A {
910N/A "-h", "127.0.0.1",
910N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
910N/A "-D", "cn=Directory Manager",
910N/A "-w", "password",
910N/A "-f", path
910N/A };
910N/A
910N/A assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
910N/A }
910N/A
910N/A
910N/A
910N/A /**
4495N/A * Tests the behavior of schema backend when attribute type definitions
4495N/A * are added without a space before closing parenthesis.
4495N/A */
4495N/A @Test()
4495N/A public void testAddAttributeTypeNoSpaceBeforeParenthesis() throws Exception
4495N/A {
4495N/A
4495N/A String path = TestCaseUtils.createTempFile(
4495N/A "dn: cn=schema",
4495N/A "changetype: modify",
4495N/A "add: attributeTypes",
4495N/A "attributeTypes: ( test-oid1)",
4495N/A "attributeTypes: ( test-oid2 NAME 'test2')",
4495N/A "attributeTypes: ( test-oid3 NAME ('test3' 'test4'))",
4495N/A "attributeTypes: ( test-oid4 DESC 'test')",
4495N/A "attributeTypes: ( test-oid5 OBSOLETE)",
4495N/A "attributeTypes: ( test-oid6 SUP test-oid4)",
4495N/A "attributeTypes: ( test-oid7 EQUALITY caseIgnoreMatch)",
4495N/A "attributeTypes: ( test-oid8 SINGLE-VALUE)",
4495N/A "attributeTypes: ( test-oid9 COLLECTIVE)",
4495N/A "attributeTypes: ( test-oid10 NO-USER-MODIFICATION USAGE directoryOperation)",
4495N/A "attributeTypes: ( test-oid11 USAGE userApplications)",
4495N/A "attributeTypes: (test-oid12 EQUALITY caseIgnoreMatch" +
4495N/A " SUBSTR caseIgnoreSubstringsMatch)",
4495N/A "attributeTypes: (test-oid13 EQUALITY caseIgnoreMatch ORDERING " +
4495N/A " caseIgnoreOrderingMatch SUBSTR caseIgnoreSubstringsMatch " +
4495N/A "SYNTAX 1.3.6.1.4.1.1466.115.121.1.44 X-ORIGIN 'RFC 4519')");
4495N/A
4495N/A
4495N/A String[] args =
4495N/A {
4495N/A "-h", "127.0.0.1",
4495N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
4495N/A "-D", "cn=Directory Manager",
4495N/A "-w", "password",
4495N/A "-f", path
4495N/A };
4495N/A
4495N/A assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
4495N/A
4495N/A }
4495N/A
4495N/A
4495N/A
4495N/A
4495N/A
4495N/A
4495N/A
4495N/A
4495N/A /**
710N/A * Tests to ensure that the schema subentry includes the lastmod attributes
710N/A * and that the modifiersName and modifyTimestamp attributes get updated when
710N/A * the schema is modified.
710N/A *
710N/A * @throws Exception If an unexpected problem occurs.
710N/A */
5142N/A @Test
710N/A public void testLastModAttributes()
710N/A throws Exception
710N/A {
710N/A Entry schemaEntry = DirectoryServer.getEntry(DN.decode("cn=schema"));
710N/A assertNotNull(schemaEntry);
710N/A
710N/A AttributeType cnType =
710N/A DirectoryServer.getAttributeType("creatorsname", true);
710N/A AttributeType ctType =
710N/A DirectoryServer.getAttributeType("createtimestamp", true);
710N/A AttributeType mnType =
710N/A DirectoryServer.getAttributeType("modifiersname", true);
710N/A AttributeType mtType =
710N/A DirectoryServer.getAttributeType("modifytimestamp", true);
710N/A
710N/A assertTrue(schemaEntry.hasAttribute(cnType));
710N/A assertTrue(schemaEntry.hasAttribute(ctType));
710N/A assertTrue(schemaEntry.hasAttribute(mnType));
710N/A assertTrue(schemaEntry.hasAttribute(mtType));
710N/A
710N/A AttributeValue oldMTValue =
3853N/A schemaEntry.getAttribute(mtType).get(0).iterator().next();
710N/A
710N/A String path = TestCaseUtils.createTempFile(
710N/A "dn: cn=schema",
710N/A "changetype: modify",
710N/A "add: attributeTypes",
710N/A "attributeTypes: ( testlastmodattributes-oid " +
710N/A "NAME 'testLastModAttributes' " +
710N/A "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " +
710N/A "X-ORGIN 'SchemaBackendTestCase' )");
710N/A
710N/A String[] args =
710N/A {
710N/A "-h", "127.0.0.1",
710N/A "-p", String.valueOf(TestCaseUtils.getServerLdapPort()),
710N/A "-D", "cn=Directory Manager",
710N/A "-w", "password",
710N/A "-f", path
710N/A };
710N/A
5142N/A // Sleep longer than the TimeThread delay to ensure the modifytimestamp
5142N/A // will be different.
5148N/A Thread.sleep(6000);
710N/A assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
710N/A
710N/A schemaEntry = DirectoryServer.getEntry(DN.decode("cn=schema"));
710N/A assertNotNull(schemaEntry);
710N/A assertTrue(schemaEntry.hasAttribute(cnType));
710N/A assertTrue(schemaEntry.hasAttribute(ctType));
710N/A assertTrue(schemaEntry.hasAttribute(mnType));
710N/A assertTrue(schemaEntry.hasAttribute(mtType));
710N/A
710N/A AttributeValue newMTValue =
3853N/A schemaEntry.getAttribute(mtType).get(0).iterator().next();
710N/A assertFalse(oldMTValue.equals(newMTValue));
710N/A }
710N/A
710N/A
710N/A
710N/A /**
2580N/A * Tests the ability to properly handle adding and removing a schema
2580N/A * definition in which the definition has extra spaces. This was added as a
2580N/A * test case for issue #2171.
2580N/A *
2580N/A * @throws Exception If an unexpected problem occurs.
2580N/A */
2580N/A @Test()
2580N/A public void testAddAndDeleteDefinitionWithExtraSpaces()
2580N/A throws Exception
2580N/A {
3853N/A int resultCode = TestCaseUtils.applyModifications(false,
2580N/A "dn: cn=schema",
2580N/A "changetype: modify",
2580N/A "add: objectClasses",
2580N/A "objectClasses: ( testaddanddeletedefinitionwithextraspaces-oid",
2580N/A " NAME 'testAddAndDeleteDefinitionWithExtraSpaces' SUP person",
2580N/A " MAY ( street $ c) X-ORIGIN 'user defined' )");
2580N/A assertEquals(resultCode, 0);
2580N/A
2580N/A assertNotNull(DirectoryServer.getObjectClass(
2580N/A "testaddanddeletedefinitionwithextraspaces"));
2580N/A assertNotNull(DirectoryServer.getObjectClass(
2580N/A "testaddanddeletedefinitionwithextraspaces-oid"));
2580N/A
3853N/A resultCode = TestCaseUtils.applyModifications(false,
2580N/A "dn: cn=schema",
2580N/A "changetype: modify",
2580N/A "delete: objectClasses",
2580N/A "objectClasses: ( testaddanddeletedefinitionwithextraspaces-oid",
2580N/A " NAME 'testAddAndDeleteDefinitionWithExtraSpaces' SUP person",
2580N/A " MAY ( street $ c) X-ORIGIN 'user defined' )");
2580N/A assertEquals(resultCode, 0);
2580N/A
2580N/A assertNull(DirectoryServer.getObjectClass(
2580N/A "testaddanddeletedefinitionwithextraspaces"));
2580N/A assertNull(DirectoryServer.getObjectClass(
2580N/A "testaddanddeletedefinitionwithextraspaces-oid"));
2580N/A }
2580N/A
2580N/A
2580N/A
2580N/A /**
673N/A * Tests the {@code exportLDIF} method with a valid configuration.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testExportLDIF()
673N/A throws Exception
673N/A {
673N/A File tempFile = File.createTempFile("schema", "testExportLDIF");
673N/A tempFile.deleteOnExit();
673N/A LDIFExportConfig exportConfig =
673N/A new LDIFExportConfig(tempFile.getAbsolutePath(),
673N/A ExistingFileBehavior.OVERWRITE);
673N/A
1329N/A schemaBackend.exportLDIF(exportConfig);
673N/A
673N/A assertTrue(tempFile.exists());
673N/A assertTrue(tempFile.length() > 0);
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the {@code importLDIF} method to ensure that it throws an exception.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
2817N/A @Test()
673N/A public void testImportLDIF()
673N/A throws Exception
673N/A {
673N/A File tempFile = File.createTempFile("schema", "testImportLDIF");
673N/A tempFile.deleteOnExit();
4443N/A
2817N/A LDIFExportConfig exportConfig =
2817N/A new LDIFExportConfig(tempFile.getAbsolutePath(),
2817N/A ExistingFileBehavior.OVERWRITE);
2817N/A
2817N/A schemaBackend.exportLDIF(exportConfig);
673N/A
673N/A LDIFImportConfig importConfig =
673N/A new LDIFImportConfig(tempFile.getAbsolutePath());
4443N/A
1329N/A schemaBackend.importLDIF(importConfig);
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the {@code getComponentEntryDN} method.
673N/A *
673N/A * @throws Exception If an unexpected problem occurs.
673N/A */
673N/A @Test()
673N/A public void testGetComponentEntryDN()
673N/A throws Exception
673N/A {
673N/A DN configEntryDN =
673N/A DN.decode("ds-cfg-backend-id=schema,cn=Backends,cn=config");
673N/A assertEquals(schemaBackend.getComponentEntryDN(), configEntryDN);
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the {@code getClassName} method.
673N/A */
673N/A @Test()
673N/A public void testGetClassName()
673N/A {
673N/A assertEquals(schemaBackend.getClassName(), SchemaBackend.class.getName());
673N/A }
673N/A
673N/A
673N/A
673N/A /**
673N/A * Tests the {@code getAlerts} method.
673N/A */
673N/A @Test()
673N/A public void testGetAlerts()
673N/A {
673N/A LinkedHashMap<String,String> alerts = schemaBackend.getAlerts();
673N/A assertNotNull(alerts);
673N/A assertFalse(alerts.isEmpty());
673N/A }
641N/A}
641N/A