| | |
| | | import static org.opends.server.util.StaticUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.io.ByteArrayInputStream; |
| | | import java.io.File; |
| | | import java.io.InputStream; |
| | | import java.io.PrintStream; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | |
| | | import org.forgerock.opendj.ldap.schema.MatchingRule; |
| | | import org.forgerock.opendj.ldap.schema.Schema; |
| | | import org.forgerock.opendj.ldap.schema.SchemaBuilder; |
| | | import org.forgerock.util.Utils; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.*; |
| | | import org.opends.server.core.AddOperation; |
| | | import org.opends.server.core.DeleteOperationBasis; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.ModifyDNOperationBasis; |
| | | import org.opends.server.core.SchemaConfigManager; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.schema.SchemaConstants; |
| | | import org.opends.server.tools.LDAPModify; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.util.CollectionUtils; |
| | | import org.opends.server.util.ServerConstants; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | * A set of test cases for the schema backend. |
| | | */ |
| | | /** A set of test cases for the schema backend. */ |
| | | @SuppressWarnings("javadoc") |
| | | public class SchemaBackendTestCase extends BackendTestCase |
| | | { |
| | | /** A reference to the schema backend. */ |
| | | private SchemaBackend schemaBackend; |
| | | |
| | | |
| | | /** |
| | | * Ensures that the Directory Server is running and gets a reference to the |
| | | * schema backend. |
| | | */ |
| | | /** Ensures that the Directory Server is running and gets a reference to the schema backend. */ |
| | | @BeforeClass |
| | | public void startServer() throws Exception |
| | | { |
| | |
| | | assertNotNull(schemaBackend); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the {@code initializeBackend} method by providing a null |
| | | * configuration entry. |
| | |
| | | schemaBackend.configureBackend(null, null); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the {@code getEntry} method to ensure that it is able to retrieve |
| | | * the schema entry if it is given a valid entry DN. |
| | |
| | | assertTrue(schemaEntry.hasAttribute(t)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the {@code getEntry} method to ensure that it is not able to retrieve |
| | | * anything when given an inappropriate DN. |
| | |
| | | assertNull(schemaEntry); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the {@code getSchemaEntry} method to ensure that it is able to |
| | | * retrieve the appropriate information with different DNs. |
| | |
| | | t = DirectoryServer.getAttributeTypeOrNull("matchingrules"); |
| | | assertTrue(schemaEntry.hasAttribute(t)); |
| | | |
| | | |
| | | schemaDN = DN.valueOf("cn=subschema"); |
| | | schemaEntry = schemaBackend.getSchemaEntry(schemaDN, false); |
| | | assertNotNull(schemaEntry); |
| | |
| | | assertTrue(schemaEntry.hasAttribute(t)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the {@code entryExists} method with a valid schema DN. |
| | | * |
| | |
| | | assertTrue(schemaBackend.entryExists(schemaDN)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the {@code entryExists} method with an invalid schema DN. |
| | | * |
| | |
| | | assertFalse(schemaBackend.entryExists(schemaDN)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests to ensure that the {@code addEntry} method always throws an |
| | | * exception. |
| | | */ |
| | | @Test(expectedExceptions = { DirectoryException.class }) |
| | | /** Tests to ensure that the {@code addEntry} method always throws an exception. */ |
| | | @Test(expectedExceptions = DirectoryException.class) |
| | | public void testAddEntry() throws Exception |
| | | { |
| | | Entry entry = createEntry(DN.valueOf("cn=schema")); |
| | |
| | | schemaBackend.addEntry(entry, addOperation); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests to ensure that the {@code deleteEntry} method always throws an |
| | | * exception. |
| | | */ |
| | | @Test(expectedExceptions = { DirectoryException.class }) |
| | | /** Tests to ensure that the {@code deleteEntry} method always throws an exception. */ |
| | | @Test(expectedExceptions = DirectoryException.class) |
| | | public void testDeleteEntry() |
| | | throws Exception |
| | | { |
| | |
| | | schemaBackend.deleteEntry(schemaDN, deleteOperation); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests to ensure that the {@code renameEntry} method always throws an |
| | | * exception. |
| | | */ |
| | | @Test(expectedExceptions = { DirectoryException.class }) |
| | | /** Tests to ensure that the {@code renameEntry} method always throws an exception. */ |
| | | @Test(expectedExceptions = DirectoryException.class) |
| | | public void testRenameEntry() |
| | | throws Exception |
| | | { |
| | |
| | | modifyDNOperation); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Performs a simple base-level search to verify that the schema entry is |
| | | * returned. |
| | |
| | | assertFalse(searchOperation.getSearchEntries().isEmpty()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Performs a simple single-level search to verify that nothing is returned. |
| | | * |
| | |
| | | assertTrue(searchOperation.getSearchEntries().isEmpty()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Performs a simple subtree search to verify that the schema entry is |
| | | * returned. |
| | |
| | | assertFalse(searchOperation.getSearchEntries().isEmpty()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Performs a simple subordinate subtree search to verify that nothing is |
| | | * returned. |
| | |
| | | assertTrue(searchOperation.getSearchEntries().isEmpty()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Performs a set of searches in the schema backend to ensure that they |
| | | * correctly set the matched DN in the response. |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend with regard to the |
| | | * ds-cfg-show-all-attributes configuration. |
| | |
| | | assertTrue(schemaEntry.hasOperationalAttribute(s)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new |
| | | * attribute type that is not allowed to be altered. |
| | |
| | | public void testAddUnsupportedAttr() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClass", |
| | | "objectClass: extensibleObject"); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to remove an |
| | | * attribute type that is not allowed to be altered. |
| | |
| | | public void testRemoveUnsupportedAttr() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "delete: objectClass", |
| | |
| | | "add: objectClass", |
| | | "objectClass: extensibleObject"); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to remove all |
| | | * attribute type definitions. |
| | |
| | | public void testRemoveAllAttributeTypes() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "delete: attributeTypes"); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to replace all |
| | | * attribute types. |
| | |
| | | public void testReplaceAllAttributeTypes() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "replace: attributeTypes"); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new |
| | | * attribute type with a valid syntax and that isn't already defined. |
| | |
| | | public void testAddAttributeTypeSuccessful() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: attributeTypes", |
| | |
| | | String attrName = "testaddattributetypesuccessful"; |
| | | assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new |
| | | * attribute type with a valid syntax (but using a textual OID rather than |
| | |
| | | public void testAddAttributeTypeSuccessfulNoOID() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: attributeTypes", |
| | |
| | | String attrName = "testaddattributetypesuccessfulnooid"; |
| | | assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new |
| | | * attribute type with a valid syntax (but using a textual OID rather than |
| | |
| | | public void testAddAttributeType() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: attributeTypes", |
| | |
| | | String attrName = "testaddattributetypenospacebeforeparenthesis"; |
| | | assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new |
| | | * attribute type to a specific schema file. |
| | |
| | | public void testAddAttributeTypeToAltSchemaFile() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: attributeTypes", |
| | |
| | | "98-schema-test-attrtype.ldif"); |
| | | assertFalse(schemaFile.exists()); |
| | | |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | assertTrue(schemaFile.exists()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new |
| | | * attribute type in a manner that replaces an existing definition. |
| | |
| | | public void testAddAttributeTypeSuccessfulReplace() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: attributeTypes", |
| | |
| | | String attrName = "testaddattributetypesuccessfulreplace"; |
| | | assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-J", "1.2.840.113556.1.4.1413", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(runModifyWithSystemErr(args), 0); |
| | | assertEquals(runModify(argsPermissive(), ldif, System.err), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to replace an |
| | | * attribute type definition in a custom schema file. |
| | |
| | | public void testReplaceAttributeTypeInAltSchemaFile() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: attributeTypes", |
| | |
| | | "98-schema-test-replaceattrtype.ldif"); |
| | | assertFalse(schemaFile.exists()); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-J", "1.2.840.113556.1.4.1413", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(runModifyWithSystemErr(args), 0); |
| | | assertEquals(runModify(argsPermissive(), ldif, System.err), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | assertTrue(schemaFile.exists()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new |
| | | * attribute type definition that can't be parsed. |
| | |
| | | public void testAddAttributeTypeInvalidSyntax() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: attributeTypes", |
| | | "attributeTypes: invalidsyntax"); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new |
| | | * attribute type with an undefined syntax. |
| | |
| | | public void testAddAttributeTypeUndefinedSyntax() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: attributeTypes", |
| | |
| | | "SYNTAX 1.3.6.1.4.1.1466.115.121.1.99999 SINGLE-VALUE " + |
| | | "X-ORGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertNotEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif, System.err), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new |
| | | * attribute type with an undefined equality matching rule. |
| | |
| | | public void testAddAttributeTypeUndefinedEMR() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: attributeTypes", |
| | |
| | | "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " + |
| | | "X-ORGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertNotEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif, System.err), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new |
| | | * attribute type with an undefined ordering matching rule. |
| | |
| | | public void testAddAttributeTypeUndefinedOMR() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: attributeTypes", |
| | |
| | | "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " + |
| | | "X-ORGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertNotEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif, System.err), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new |
| | | * attribute type with an undefined substring matching rule. |
| | |
| | | public void testAddAttributeTypeUndefinedSMR() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: attributeTypes", |
| | |
| | | "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " + |
| | | "X-ORGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertNotEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif, System.err), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new |
| | | * attribute type with an undefined approximate matching rule. |
| | |
| | | public void testAddAttributeTypeUndefinedAMR() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: attributeTypes", |
| | |
| | | "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " + |
| | | "X-APPROX 'xxxundefinedxxx' X-ORGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertNotEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif, System.err), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new |
| | | * attribute type with an invalid usage. |
| | |
| | | public void testAddAttributeTypeInvalidUsage() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: attributeTypes", |
| | |
| | | "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " + |
| | | "USAGE xxxinvalidxxx X-ORGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertNotEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif, System.err), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new |
| | | * attribute type whose superior type is marked OBSOLETE in the server schema. |
| | |
| | | public void testAddAttributeTypeObsoleteSuperior() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: attributeTypes", |
| | |
| | | "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " + |
| | | "X-ORGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertNotEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif, System.err), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new |
| | | * attribute type whose equality matching rule is marked OBSOLETE in the |
| | |
| | | MatchingRule matchingRule = getMatchingRule("testAddATObsoleteEMRMatch", "1.3.6.1.4.1.26027.1.999.20", true); |
| | | DirectoryServer.registerMatchingRule(matchingRule, false); |
| | | |
| | | |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: attributeTypes", |
| | |
| | | "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " + |
| | | "X-ORGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertNotEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif, System.err), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new |
| | | * attribute type that conflicts with multiple existing types. |
| | |
| | | public void testAddAttributeTypeMultipleConflicts() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: attributeTypes", |
| | |
| | | "1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN " + |
| | | "'SchemaBackendTestCase' )"); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new |
| | | * attribute type that references an undefined superior attribute type. |
| | |
| | | public void testAddAttributeTypeUndefinedSuperior() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: attributeTypes", |
| | |
| | | "1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN " + |
| | | "'SchemaBackendTestCase' )"); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to remove an |
| | | * attribute type that is defined in the server schema and does not have any |
| | |
| | | public void testRemoveAttributeTypeSuccessful() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: attributeTypes", |
| | |
| | | String attrName = "testremoveattributetypesuccessful"; |
| | | assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0); |
| | | assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to remove an |
| | | * attribute type and add it back in the same modification. |
| | |
| | | public void testRemoveThenAddAttributeTypeSuccessful() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: attributeTypes", |
| | |
| | | String attrName = "testremoveattributetypesuccessful"; |
| | | assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0); |
| | | assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to remove an |
| | | * attribute type that is not defined in the server schema. |
| | |
| | | public void testRemoveAttributeTypeUndefined() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "delete: attributeTypes", |
| | |
| | | String attrName = "testremoveattributetypeundefined"; |
| | | assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to remove an |
| | | * attribute type that is referenced as the superior type for another |
| | |
| | | public void testRemoveSuperiorAttributeType() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "delete: attributeTypes", |
| | |
| | | String attrName = "name"; |
| | | assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to remove an |
| | | * attribute type that is referenced by an existing objectclass. |
| | |
| | | public void testRemoveAttributeTypeReferencedByObjectClass() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "delete: attributeTypes", |
| | |
| | | String attrName = "uid"; |
| | | assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to remove an |
| | | * attribute type that is referenced by an existing name form. |
| | |
| | | public void testRemoveAttributeTypeReferencedByNameForm() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String attrName = "testremoveattributetypereferencedbynf"; |
| | | String modifyAttributeTypes = "attributeTypes: ( " + attrName + "-oid " + |
| | | "NAME '" + attrName + "' " + |
| | | "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"; |
| | | String modifyObjectClasses = "objectClasses: ( " + attrName + "oc-oid " + |
| | | "NAME '" + attrName + "OC' SUP top " + |
| | | "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase')"; |
| | | String modifyNameForms = "nameForms: ( " + attrName + "nf-oid " + |
| | | "NAME '" + attrName + "NF' " + |
| | | "OC " + attrName + "OC " + |
| | | "MUST " + attrName + " " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"; |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: attributeTypes", |
| | | "attributeTypes: ( testremoveattributetypereferencedbynf-oid " + |
| | | "NAME 'testRemoveAttributeTypeReferencedByNF' " + |
| | | "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )", |
| | | modifyAttributeTypes, |
| | | "-", |
| | | "add: objectClasses", |
| | | "objectClasses: ( testremoveattributetypereferencedbynfoc-oid " + |
| | | "NAME 'testRemoveAttributeTypeReferencedByNFOC' SUP top " + |
| | | "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase')", |
| | | modifyObjectClasses, |
| | | "-", |
| | | "add: nameForms", |
| | | "nameForms: ( testremoveattributetypereferencedbynfnf-oid " + |
| | | "NAME 'testRemoveAttributeTypeReferencedByNFNF' " + |
| | | "OC testRemoveAttributeTypeReferencedByNFOC " + |
| | | "MUST testRemoveAttributeTypeReferencedByNF " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )", |
| | | "", |
| | | modifyNameForms); |
| | | |
| | | String ldif1 = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "delete: attributeTypes", |
| | | "attributeTypes: ( testremoveattributetypereferencedbynf-oid " + |
| | | "NAME 'testRemoveAttributeTypeReferencedByNF' " + |
| | | "SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | modifyAttributeTypes); |
| | | |
| | | String attrName = "testremoveattributetypereferencedbynf"; |
| | | assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | String ldif2 = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "delete: nameForms", |
| | | modifyNameForms, |
| | | "-", |
| | | "delete: objectClasses", |
| | | modifyObjectClasses, |
| | | "-", |
| | | "delete: attributeTypes", |
| | | modifyAttributeTypes); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | try |
| | | { |
| | | assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | assertEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif1), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | } |
| | | finally |
| | | { |
| | | assertEquals(runModify(argsNotPermissive(), ldif2), 0); |
| | | assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to remove an |
| | | * attribute type that is referenced by an existing DIT content rule. |
| | |
| | | public void testRemoveAttributeTypeReferencedByDCR() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: attributeTypes", |
| | |
| | | String attrName = "testremoveattributetypereferencedbydcr"; |
| | | assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to remove an |
| | | * attribute type that is referenced by an existing matching rule use. |
| | |
| | | MatchingRule matchingRule = getMatchingRule("testRemoveATRefByMRUMatch", "1.3.6.1.4.1.26027.1.999.17", false); |
| | | DirectoryServer.registerMatchingRule(matchingRule, false); |
| | | |
| | | |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: attributeTypes", |
| | |
| | | String attrName = "testremoveatrefbymruat"; |
| | | assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | |
| | | MatchingRuleUse mru = |
| | | DirectoryServer.getSchema().getMatchingRuleUse(matchingRule); |
| | |
| | | assertTrue(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new |
| | | * objectclass that doesn't already exist, that has a valid superior class, |
| | |
| | | public void testAddObjectClassSuccessful() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | String ocName = "testaddobjectclasssuccessful"; |
| | | assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName)); |
| | | |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasObjectClass(ocName)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new |
| | | * objectclass that doesn't already exist, that has a textual OID rather than |
| | |
| | | public void testAddObjectClassSuccessfulNoOID() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | String ocName = "testaddobjectclasssuccessfulnooid"; |
| | | assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName)); |
| | | |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasObjectClass(ocName)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new |
| | | * objectclass to a specific schema file. |
| | |
| | | public void testAddObjectClassToAltSchemaFile() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | "98-schema-test-oc.ldif"); |
| | | assertFalse(schemaFile.exists()); |
| | | |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasObjectClass(ocName)); |
| | | assertTrue(schemaFile.exists()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new |
| | | * objectclass that already exists (i.e., a replace) |
| | |
| | | public void testAddObjectClassSuccessfulReplace() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | String ocName = "testaddobjectclasssuccessfulreplace"; |
| | | assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName)); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-J", "1.2.840.113556.1.4.1413", |
| | | "-f", path |
| | | }; |
| | | |
| | | assertEquals(runModifyWithSystemErr(args), 0); |
| | | assertEquals(runModify(argsPermissive(), ldif, System.err), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasObjectClass(ocName)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new |
| | | * objectclass that conflicts with multiple existing objectclasses. |
| | |
| | | public void testAddObjectClassMultipleConflicts() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | String ocName = "testaddobjectclassmultipleconflicts"; |
| | | assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName)); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to remove an |
| | | * existing objectclass definition and then add it back in the same operation |
| | |
| | | public void testRemoveThenAddAddObjectClassSuccessful() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | String ocName = "testremovethenaddobjectclasssuccessful"; |
| | | assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName)); |
| | | |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasObjectClass(ocName)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new |
| | | * objectclass definition that can't be parsed. |
| | |
| | | public void testAddObjectClassInvalidSyntax() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | | "objectClasses: invalidsyntax"); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new |
| | | * objectclass that references an undefined superior class. |
| | |
| | | public void testAddObjectClassUndefinedSuperiorClass() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | "'testAddOCUndefinedSuperior' SUP undefined STRUCTURAL " + |
| | | "MUST cn X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new |
| | | * objectclass that references an obsolete superior class. |
| | |
| | | public void testAddObjectClassObsoleteSuperiorClass() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | "SUP testAddOCObsoleteSuperiorSup STRUCTURAL MUST cn " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new |
| | | * objectclass that references an obsolete required attribute type. |
| | |
| | | public void testAddObjectClassObsoleteRequiredAttribute() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: attributeTypes", |
| | |
| | | "STRUCTURAL MUST testAddOCObsoleteRequiredAttrAT " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new |
| | | * objectclass that references an obsolete optional attribute type. |
| | |
| | | public void testAddObjectClassObsoleteOptionalAttribute() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: attributeTypes", |
| | |
| | | "STRUCTURAL MAY testAddOCObsoleteOptionalAttrAT " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new |
| | | * objectclass that references an undefined required attribute. |
| | |
| | | public void testAddObjectClassUndefinedRequiredAttribute() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | "'testAddOCUndefinedRequired' SUP top STRUCTURAL " + |
| | | "MUST undefined X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new |
| | | * objectclass that references an undefined required attribute when multiple |
| | |
| | | public void testAddObjectClassMultipleUndefinedRequiredAttribute() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | "MUST ( cn $ xxxundefinedxxx ) " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new |
| | | * objectclass that references an undefined optional attribute. |
| | |
| | | public void testAddObjectClassUndefinedOptionalAttribute() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | "'testAddOCUndefinedOptional' SUP top STRUCTURAL " + |
| | | "MAY undefined X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new |
| | | * objectclass that references an undefined optional attribute when multiple |
| | |
| | | public void testAddObjectClassMultipleUndefinedOptionalAttribute() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | "MAY ( cn $ xxxundefinedxxx ) " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new |
| | | * abstract objectclass whose superior class is not abstract. |
| | |
| | | public void testAddAbstractObjectClassWithNonAbstractSuperior() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | "'testAddAbstractOCWithNonAbstractSuperior' SUP person " + |
| | | "ABSTRACT MAY description X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new |
| | | * auxiliary objectclass whose superior class is structural. |
| | |
| | | public void testAddAuxiliaryObjectClassWithStructuralSuperior() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | "'testAddAuxiliaryOCWithStructuralSuperior' SUP person " + |
| | | "AUXILIARY MAY description X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new |
| | | * structural objectclass whose superior class is auxiliary. |
| | |
| | | public void testAddStructuralObjectClassWithAuxiliarySuperior() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | "'testAddStructuralOCWithAuxiliarySuperior' SUP posixAccount " + |
| | | "STRUCTURAL MAY description X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to remove an |
| | | * objectclass that exists and for which there are no dependencies. |
| | |
| | | public void testRemoveObjectClassSuccessful() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | String ocName = "testremoveobjectclasssuccessful"; |
| | | assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName)); |
| | | |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0); |
| | | assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to remove an |
| | | * objectclass that is the superior class for another objectclass. |
| | |
| | | public void testRemoveSuperiorObjectClass() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "delete: objectClasses", |
| | |
| | | String ocName = "person"; |
| | | assertTrue(DirectoryServer.getSchema().hasObjectClass(ocName)); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasObjectClass(ocName)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to remove an |
| | | * objectclass that is referenced by an existing name form. |
| | |
| | | * @throws Exception If an unexpected problem occurs. |
| | | */ |
| | | @Test |
| | | public void testRemoveObjectClassReferencedByNameForm() |
| | | throws Exception |
| | | public void testRemoveObjectClassReferencedByNameForm() throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | | "objectClasses: ( testremoveobjectclassreferencedbynf-oid " + |
| | | "NAME 'testRemoveObjectClassReferencedByNF' SUP top " + |
| | | "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase')", |
| | | "-", |
| | | "add: nameForms", |
| | | "nameForms: ( testremoveattributetypereferencedbynfnf-oid " + |
| | | "NAME 'testRemoveObjectClassReferencedByNFNF' " + |
| | | "OC testRemoveObjectClassReferencedByNF MUST cn " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )", |
| | | "", |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "delete: objectClasses", |
| | | "objectClasses: ( testremoveobjectclassreferencedbynf-oid " + |
| | | "NAME 'testRemoveObjectClassReferencedByNF' SUP top " + |
| | | "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase')"); |
| | | |
| | | String ocName = "testremoveobjectclassreferencedbynf"; |
| | | assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName)); |
| | | String modifyObjectClasses = "objectClasses: ( " + ocName + "-oid " + |
| | | "NAME '" + ocName + "' SUP top " + |
| | | "STRUCTURAL MUST cn X-ORIGIN 'SchemaBackendTestCase')"; |
| | | String modifyNameForms = "nameForms: ( testremoveattributetypereferencedbynfnf-oid " + |
| | | "NAME '" + ocName + "NF' " + |
| | | "OC " + ocName + " MUST cn " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"; |
| | | |
| | | String[] args = |
| | | String addOCThenNF = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | | modifyObjectClasses, |
| | | "-", |
| | | "add: nameForms", |
| | | modifyNameForms); |
| | | String deleteOC = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "delete: objectClasses", |
| | | modifyObjectClasses); |
| | | String deleteNFThenOC = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "delete: nameForms", |
| | | modifyNameForms, |
| | | "-", |
| | | "delete: objectClasses", |
| | | modifyObjectClasses); |
| | | |
| | | try |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-J", "1.2.840.113556.1.4.1413", |
| | | "-f", path |
| | | }; |
| | | assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName)); |
| | | assertEquals(runModify(argsPermissive(), addOCThenNF), 0); |
| | | |
| | | assertNotEquals(runModify(args), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasObjectClass(ocName)); |
| | | assertNotEquals(runModify(argsPermissive(), deleteOC), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasObjectClass(ocName)); |
| | | } |
| | | finally |
| | | { |
| | | assertEquals(runModify(argsPermissive(), deleteNFThenOC), 0); |
| | | assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName)); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to remove an |
| | | * objectclass that is referenced by an existing DIT content rule. |
| | |
| | | public void testRemoveObjectClassReferencedByDCR() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | String ocName = "testremoveobjectclassreferencedbydcr"; |
| | | assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName)); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasObjectClass(ocName)); |
| | | } |
| | | |
| | | private String[] standardArgs(String path) |
| | | private String[] argsNotPermissive() |
| | | { |
| | | return new String[] { |
| | | return args(false); |
| | | } |
| | | |
| | | private String[] argsPermissive() |
| | | { |
| | | return args(true); |
| | | } |
| | | |
| | | private String[] args(boolean usePermissiveModifyControl) |
| | | { |
| | | final List<String> args = CollectionUtils.newArrayList( |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-f", path |
| | | }; |
| | | "-w", "password" |
| | | ); |
| | | if (usePermissiveModifyControl) |
| | | { |
| | | args.add("-J"); |
| | | args.add(ServerConstants.OID_PERMISSIVE_MODIFY_CONTROL); |
| | | } |
| | | return args.toArray(new String[0]); |
| | | } |
| | | |
| | | /** |
| | |
| | | public void testAddNameFormSuccessful() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | String nameFormName = "testaddnameformsuccessful"; |
| | | assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName)); |
| | | |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasNameForm(nameFormName)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new name |
| | | * form that doesn't already exist to an alternate schema file. |
| | |
| | | public void testAddNameFormToAltSchemaFile() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | "98-schema-test-nameform.ldif"); |
| | | assertFalse(schemaFile.exists()); |
| | | |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasNameForm(nameFormName)); |
| | | assertTrue(schemaFile.exists()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new name |
| | | * form that references a required attribute type not defined in the server |
| | |
| | | public void testAddNameFormWithUndefinedReqAT() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | String nameFormName = "testaddnameformwithundefinedreqat"; |
| | | assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName)); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new name |
| | | * form that references a required attribute type not defined in the server |
| | |
| | | public void testAddNameFormWithMultipleUndefinedReqAT() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | String nameFormName = "testaddnameformwithmultipleundefinedreqat"; |
| | | assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName)); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new name |
| | | * form that references an optional attribute type not defined in the server |
| | |
| | | public void testAddNameFormWithUndefinedOptAT() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | String nameFormName = "testaddnameformwithundefinedoptat"; |
| | | assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName)); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new name |
| | | * form that references an optional attribute type not defined in the server |
| | |
| | | public void testAddNameFormWithMultipleUndefinedOptAT() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | String nameFormName = "testaddnameformwithmultipleundefinedoptat"; |
| | | assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName)); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new name |
| | | * form whose structural objectclass is not defined in the server schema. |
| | |
| | | public void testAddNameFormWithUndefinedOC() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: nameForms", |
| | |
| | | String nameFormName = "testaddnameformwithundefinedoc"; |
| | | assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName)); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new name |
| | | * form whose objectclass auxiliary rather than structural. |
| | |
| | | public void testAddNameFormWithAuxiliaryOC() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | String nameFormName = "testaddnameformwithauxiliaryoc"; |
| | | assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName)); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new name |
| | | * form whose structural objectclass is OBSOLETE rather than structural. |
| | |
| | | public void testAddNameFormWithObsoleteOC() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | String nameFormName = "testaddnameformwithobsoleteoc"; |
| | | assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName)); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new name |
| | | * form with a required attribute type that is declared OBSOLETE. |
| | |
| | | public void testAddNameFormWithObsoleteReqAT() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: attributeTypes", |
| | |
| | | "MUST testAddNFWithObsoleteReqATAT " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new name |
| | | * form with an optional attribute type that is declared OBSOLETE. |
| | |
| | | public void testAddNameFormWithObsoleteOptAT() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: attributeTypes", |
| | |
| | | "MUST cn MAY testAddNFWithObsoleteOptATAT " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new name |
| | | * form that references a structural objectclass already referenced by another |
| | |
| | | public void testAddNameFormOCConflict() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | String nameFormName = "testaddnameformocconflict2"; |
| | | assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName)); |
| | | |
| | | assertEquals(runModify(standardArgs(path)), 0); |
| | | assertEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasNameForm(nameFormName)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to remove an |
| | | * existing name form. |
| | |
| | | public void testRemoveNameFormSuccessful() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | String nameFormName = "testremovenameformsuccessful"; |
| | | assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName)); |
| | | |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0); |
| | | assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to remove an |
| | | * existing name form and then add it back in the same operation. |
| | |
| | | public void testRemoveThenAddNameFormSuccessful() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | String nameFormName = "testremovethenaddnameformsuccessful"; |
| | | assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName)); |
| | | |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasNameForm(nameFormName)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to remove a name |
| | | * form that is referenced by a DIT structure rule. |
| | |
| | | public void testRemoveNameFormReferencedByDSR() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | String nameFormName = "testremovenameformreferencedbydsrnf"; |
| | | assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName)); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasNameForm(nameFormName)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new DIT |
| | | * content rule that doesn't already exist. |
| | |
| | | public void testAddDITContentRuleSuccessful() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | String ocName = "testaddditcontentrulesuccessfuloc"; |
| | | assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName)); |
| | | |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0); |
| | | |
| | | ObjectClass oc = DirectoryServer.getSchema().getObjectClass(ocName); |
| | | assertNotNull(oc); |
| | |
| | | assertTrue(dcr.hasName("testaddditcontentrulesuccessful")); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to replace an |
| | | * existing DIT content rule. |
| | |
| | | public void testReplaceDITContentRuleSuccessful() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | "NAME 'testReplaceDITContentRuleSuccessful' MAY sn " + |
| | | "NOT description X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-J", "1.2.840.113556.1.4.1413", |
| | | "-f", path |
| | | }; |
| | | |
| | | String ocName = "testreplaceditcontentrulesuccessfuloc"; |
| | | assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName)); |
| | | |
| | | assertEquals(runModifyWithSystemErr(args), 0); |
| | | assertEquals(runModify(argsPermissive(), ldif, System.err), 0); |
| | | |
| | | ObjectClass oc = DirectoryServer.getSchema().getObjectClass(ocName); |
| | | assertNotNull(oc); |
| | |
| | | assertTrue(dcr.hasName("testreplaceditcontentrulesuccessful")); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new DIT |
| | | * content rule to an alternate schema file. |
| | |
| | | public void testAddDITContentRuleToAltSchemaFile() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | "98-schema-test-dcr.ldif"); |
| | | assertFalse(schemaFile.exists()); |
| | | |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0); |
| | | |
| | | ObjectClass oc = DirectoryServer.getSchema().getObjectClass(ocName); |
| | | assertNotNull(oc); |
| | |
| | | assertTrue(schemaFile.exists()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to remove an |
| | | * existing DIT content rule and add it back in the same operation. |
| | |
| | | public void testRemoveThenAddDITContentRule() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | String ocName = "testremovethenaddditcontentruleoc"; |
| | | assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName)); |
| | | |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0); |
| | | |
| | | ObjectClass oc = DirectoryServer.getSchema().getObjectClass(ocName); |
| | | assertNotNull(oc); |
| | |
| | | assertTrue(dcr.hasName("testremovethenaddditcontentrule")); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new DIT |
| | | * content rule whose structural objectclass is not defined in the schema. |
| | |
| | | public void testAddDITContentRuleUndefinedOC() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: ditContentRules", |
| | |
| | | "NAME 'testAddDITContentRuleUndefinedOC' NOT description " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new DIT |
| | | * content rule whose structural objectclass is not actually structural. |
| | |
| | | public void testAddDITContentRuleAuxiliaryOC() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | "NAME 'testAddDITContentRuleAuxiliaryOC' NOT description " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new DIT |
| | | * content rule whose structural objectclass is OBSOLETE. |
| | |
| | | public void testAddDITContentRuleObsoleteOC() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | "NAME 'testAddDITContentRuleObsoleteOC' NOT description " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new DIT |
| | | * content rule whose structural objectclass is already referenced by an |
| | |
| | | public void testAddDITContentRuleConflictingOC() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | "NAME 'testAddDITContentRuleConflictingOC2' NOT description " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new DIT |
| | | * content rule with an undefined auxiliary objectclass. |
| | |
| | | public void testAddDITContentRuleUndefinedAuxOC() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | "NAME 'testAddDITContentRuleUndefinedAuxOC' " + |
| | | "AUX xxxundefinedxxx X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new DIT |
| | | * content rule with an undefined auxiliary objectclass when multiple |
| | |
| | | public void testAddDITContentRuleMultipleUndefinedAuxOC() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | "AUX ( posixAccount $ xxxundefinedxxx ) " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new DIT |
| | | * content rule with an auxiliary objectclass that is not auxiliary. |
| | |
| | | public void testAddDITContentRuleAuxOCNotAux() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | "NAME 'testAddDITContentRuleAuxOCNotAuxOC' " + |
| | | "AUX person X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new DIT |
| | | * content rule with an auxiliary objectclass that is not auxiliary when |
| | |
| | | public void testAddDITContentRuleMultipleAuxOCNotAux() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | "AUX ( posixAccount $ person ) " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new DIT |
| | | * content rule with an auxiliary objectclass that is OBSOLETE. |
| | |
| | | public void testAddDITContentRuleObsoleteAuxOC() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | "AUX testAddDITContentRuleObsoleteAuxOCAuxiliary " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new DIT |
| | | * content rule that references an undefined required attribute type. |
| | |
| | | public void testAddDITContentRuleUndefinedReqAT() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | "NAME 'testAddDITContentRuleUndefinedReqAT' " + |
| | | "MUST xxxundefinedxxx X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new DIT |
| | | * content rule that references an undefined required attribute type when |
| | |
| | | public void testAddDITContentRuleMultipleUndefinedReqAT() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | "MUST ( cn $ xxxundefinedxxx ) " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new DIT |
| | | * content rule that references an undefined optional attribute type. |
| | |
| | | public void testAddDITContentRuleUndefinedOptAT() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | "NAME 'testAddDITContentRuleUndefinedOptAT' " + |
| | | "MAY xxxundefinedxxx X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new DIT |
| | | * content rule that references an undefined optional attribute type when |
| | |
| | | public void testAddDITContentRuleMultipleUndefinedOptAT() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | "MAY ( cn $ xxxundefinedxxx ) " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new DIT |
| | | * content rule that references an undefined prohibited attribute type. |
| | |
| | | public void testAddDITContentRuleUndefinedNotAT() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | "NAME 'testAddDITContentRuleUndefinedNotAT' " + |
| | | "NOT xxxundefinedxxx X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new DIT |
| | | * content rule that references an undefined prohibited attribute type when |
| | |
| | | public void testAddDITContentRuleMultipleUndefinedNotAT() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | "NOT ( description $ xxxundefinedxxx ) " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new DIT |
| | | * content rule that prohibits an attribute type that is required by the |
| | |
| | | public void testAddDITContentRuleProhibitRequiredStructuralAttribute() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | "NAME 'testAddDCRProhibitReqStructuralAT' " + |
| | | "NOT cn X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new DIT |
| | | * content rule that prohibits an attribute type that is required by an |
| | |
| | | public void testAddDITContentRuleProhibitRequiredAuxiliaryAttribute() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | "NAME 'testAddDCRProhibitReqAuxiliaryAT' AUX posixAccount " + |
| | | "NOT uid X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new DIT |
| | | * content rule with an OBSOLETE required attribute type. |
| | |
| | | public void testAddDITContentRuleObsoleteRequiredAttributeType() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: attributeTypes", |
| | |
| | | "MUST testAddDCRObsoleteReqATAT " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new DIT |
| | | * content rule with an OBSOLETE optional attribute type. |
| | |
| | | public void testAddDITContentRuleObsoleteOptionalAttributeType() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: attributeTypes", |
| | |
| | | "MAY testAddDCRObsoleteOptATAT " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new DIT |
| | | * content rule with an OBSOLETE prohibited attribute type. |
| | |
| | | public void testAddDITContentRuleObsoleteProhibitedAttributeType() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: attributeTypes", |
| | |
| | | "NOT testAddDCRObsoleteNotATAT " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to remove an |
| | | * existing DIT content rule. |
| | |
| | | public void testRemoveDITContentRuleSuccessful() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | String ocName = "testremoveditcontentrulesuccessfuloc"; |
| | | assertFalse(DirectoryServer.getSchema().hasObjectClass(ocName)); |
| | | |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0); |
| | | |
| | | ObjectClass oc = DirectoryServer.getSchema().getObjectClass(ocName); |
| | | assertNotNull(oc); |
| | |
| | | assertNull(dcr); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new |
| | | * DIT structure rule. |
| | |
| | | public void testAddDITStructureRuleSuccessful() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | int ruleID = 999001; |
| | | assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID)); |
| | | |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasDITStructureRule(ruleID)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to replace an |
| | | * existing DIT structure rule definition. |
| | |
| | | public void testReplaceDITStructureRuleSuccessful() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | "FORM testReplaceDITStructureRuleSuccessfulNF " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-J", "1.2.840.113556.1.4.1413", |
| | | "-f", path |
| | | }; |
| | | |
| | | int ruleID = 999002; |
| | | assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID)); |
| | | |
| | | assertEquals(runModifyWithSystemErr(args), 0); |
| | | assertEquals(runModify(argsPermissive(), ldif, System.err), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasDITStructureRule(ruleID)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new |
| | | * DIT structure rule to an alternate schema file. |
| | |
| | | public void testAddDITStructureRuleToAltSchemaFile() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | "98-schema-test-dsr.ldif"); |
| | | assertFalse(schemaFile.exists()); |
| | | |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasDITStructureRule(ruleID)); |
| | | |
| | | assertTrue(schemaFile.exists()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to remove an |
| | | * existing DIT structure rule definition and add it back in the same |
| | |
| | | public void testRemoveAndAddDITStructureRuleSuccessful() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | int ruleID = 999003; |
| | | assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID)); |
| | | |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasDITStructureRule(ruleID)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new |
| | | * DIT structure rule with an undefined name form. |
| | |
| | | public void testAddDITStructureRuleUndefinedNameForm() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: ditStructureRules", |
| | |
| | | int ruleID = 999004; |
| | | assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID)); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new |
| | | * DIT structure rule that references an undefined superior rule. |
| | |
| | | public void testAddDITStructureRuleUndefinedSuperior() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | int ruleID = 999005; |
| | | assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID)); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new |
| | | * DIT structure rule that references a name form which is OBSOLETE. |
| | |
| | | public void testAddDITStructureRuleObsoleteNameForm() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | "FORM testAddDITStructureRuleObsoleteNameFormNF " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new |
| | | * DIT structure rule that references a superior rule which is OBSOLETE. |
| | |
| | | public void testAddDITStructureRuleObsoleteSuperiorRule() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | "FORM testAddDITStructureRuleObsoleteSuperiorNF2 SUP 999012 " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to remove an |
| | | * existing DIT structure rule definition. |
| | |
| | | public void testRemoveDITStructureRuleSuccessful() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | int ruleID = 999006; |
| | | assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID)); |
| | | |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0); |
| | | assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to remove an |
| | | * existing DIT structure rule definition which is the superior rule for |
| | |
| | | public void testRemoveSuperiorDITStructureRule() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | int ruleID = 999007; |
| | | assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID)); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | assertTrue(DirectoryServer.getSchema().hasDITStructureRule(ruleID)); |
| | | |
| | | |
| | | path = TestCaseUtils.createTempFile( |
| | | ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "delete: ditStructureRules", |
| | |
| | | "FORM testRemoveSuperiorDITStructureRuleNF " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0); |
| | | assertFalse(DirectoryServer.getSchema().hasDITStructureRule(ruleID)); |
| | | } |
| | | |
| | |
| | | MatchingRule matchingRule = getMatchingRule("testAddMRUSuccessfulMatch", "1.3.6.1.4.1.26027.1.999.10", false); |
| | | DirectoryServer.registerMatchingRule(matchingRule, false); |
| | | |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: matchingRuleUse", |
| | |
| | | |
| | | assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule)); |
| | | |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0); |
| | | |
| | | MatchingRuleUse mru = |
| | | DirectoryServer.getSchema().getMatchingRuleUse(matchingRule); |
| | |
| | | assertTrue(mru.hasName("testaddmrusuccessful")); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new |
| | | * matching rule to an alternate schema file. |
| | |
| | | MatchingRule matchingRule = getMatchingRule("testAddMRUToAltSchemaFileMatch", "1.3.6.1.4.1.26027.1.999.18", false); |
| | | DirectoryServer.registerMatchingRule(matchingRule, false); |
| | | |
| | | |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: matchingRuleUse", |
| | |
| | | "98-schema-test-mru.ldif"); |
| | | assertFalse(schemaFile.exists()); |
| | | |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0); |
| | | |
| | | MatchingRuleUse mru = |
| | | DirectoryServer.getSchema().getMatchingRuleUse(matchingRule); |
| | |
| | | assertTrue(schemaFile.exists()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to replace an |
| | | * existing matching rule use. |
| | |
| | | MatchingRule matchingRule = getMatchingRule("testReplaceMRUSuccessfulMatch", "1.3.6.1.4.1.26027.1.999.11", false); |
| | | DirectoryServer.registerMatchingRule(matchingRule, false); |
| | | |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: matchingRuleUse", |
| | |
| | | |
| | | assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule)); |
| | | |
| | | String[] args = |
| | | { |
| | | "-h", "127.0.0.1", |
| | | "-p", String.valueOf(TestCaseUtils.getServerLdapPort()), |
| | | "-D", "cn=Directory Manager", |
| | | "-w", "password", |
| | | "-J", "1.2.840.113556.1.4.1413", |
| | | "-f", path |
| | | }; |
| | | assertEquals(runModify(argsPermissive(), ldif, System.err), 0); |
| | | |
| | | assertEquals(runModifyWithSystemErr(args), 0); |
| | | |
| | | MatchingRuleUse mru = |
| | | DirectoryServer.getSchema().getMatchingRuleUse(matchingRule); |
| | | MatchingRuleUse mru = DirectoryServer.getSchema().getMatchingRuleUse(matchingRule); |
| | | assertNotNull(mru); |
| | | assertTrue(mru.hasName("testreplacemrusuccessful")); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to remove and |
| | | * re-add an existing matching rule use in the same operation. |
| | |
| | | MatchingRule matchingRule = getMatchingRule("testRemoveAndAddMRUMatch", "1.3.6.1.4.1.26027.1.999.12", false); |
| | | DirectoryServer.registerMatchingRule(matchingRule, false); |
| | | |
| | | |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: matchingRuleUse", |
| | |
| | | |
| | | assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule)); |
| | | |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0); |
| | | |
| | | MatchingRuleUse mru = |
| | | DirectoryServer.getSchema().getMatchingRuleUse(matchingRule); |
| | |
| | | MatchingRule matchingRule = getMatchingRule("testAddMRUMRConflictMatch", "1.3.6.1.4.1.26027.1.999.14", false); |
| | | DirectoryServer.registerMatchingRule(matchingRule, false); |
| | | |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: matchingRuleUse", |
| | |
| | | |
| | | assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule)); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | |
| | | MatchingRuleUse mru = |
| | | DirectoryServer.getSchema().getMatchingRuleUse(matchingRule); |
| | |
| | | assertTrue(mru.hasName("testaddmrumrconflict")); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new |
| | | * matching rule use that references an undefined matching rule. |
| | |
| | | public void testAddMatchingRuleUseMRUndefined() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: matchingRuleUse", |
| | |
| | | "NAME 'testAddMRUMRUndefined' APPLIES cn " + |
| | | "X-ORIGIN 'SchemaBackendTestCase' )"); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | } |
| | | |
| | | /** |
| | |
| | | MatchingRule matchingRule = getMatchingRule("testAddMRUATUndefinedMatch", "1.3.6.1.4.1.26027.1.999.16", false); |
| | | DirectoryServer.registerMatchingRule(matchingRule, false); |
| | | |
| | | |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: matchingRuleUse", |
| | |
| | | |
| | | assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule)); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new |
| | | * matching rule use that references an undefined attribute type. |
| | |
| | | getMatchingRule("testAddMRUATMultipleUndefinedMatch", "1.3.6.1.4.1.26027.1.999.19", false); |
| | | DirectoryServer.registerMatchingRule(matchingRule, false); |
| | | |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: matchingRuleUse", |
| | |
| | | |
| | | assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule)); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | } |
| | | |
| | | /** |
| | |
| | | MatchingRule matchingRule = getMatchingRule("testAddMRUObsoleteMRMatch", "1.3.6.1.4.1.26027.1.999.21", true); |
| | | DirectoryServer.registerMatchingRule(matchingRule, false); |
| | | |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: matchingRuleUse", |
| | |
| | | |
| | | assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule)); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add a new |
| | | * matching rule with an associated attribute type that is marked OBSOLETE. |
| | |
| | | MatchingRule matchingRule = getMatchingRule("testAddMRUObsoleteATMatch", "1.3.6.1.4.1.26027.1.999.22", false); |
| | | DirectoryServer.registerMatchingRule(matchingRule, false); |
| | | |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: attributeTypes", |
| | |
| | | |
| | | assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule)); |
| | | |
| | | assertNotEquals(runModify(standardArgs(path)), 0); |
| | | assertNotEquals(runModify(argsNotPermissive(), ldif), 0); |
| | | } |
| | | |
| | | private int runModify(String[] args) |
| | | private int runModify(String[] args, String ldifContent) |
| | | { |
| | | return LDAPModify.mainModify(args, false, null, null); |
| | | return runModify(args, ldifContent, null); |
| | | } |
| | | |
| | | private int runModify(String[] args, String ldifContent, PrintStream stderr) |
| | | { |
| | | final InputStream stdin = System.in; |
| | | try |
| | | { |
| | | System.setIn(new ByteArrayInputStream(ldifContent.getBytes())); |
| | | return LDAPModify.mainModify(args, false, null, stderr); |
| | | } |
| | | finally |
| | | { |
| | | System.setIn(stdin); |
| | | } |
| | | } |
| | | |
| | | private String toLdif(Object... ldifLines) |
| | | { |
| | | return Utils.joinAsString("\n", ldifLines); |
| | | } |
| | | |
| | | /** |
| | |
| | | MatchingRule matchingRule = getMatchingRule("testRemoveMRUSuccessfulMatch", "1.3.6.1.4.1.26027.1.999.13", false); |
| | | DirectoryServer.registerMatchingRule(matchingRule, false); |
| | | |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: matchingRuleUse", |
| | |
| | | |
| | | assertFalse(DirectoryServer.getSchema().hasMatchingRuleUse(matchingRule)); |
| | | |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0); |
| | | |
| | | MatchingRuleUse mru = |
| | | DirectoryServer.getSchema().getMatchingRuleUse(matchingRule); |
| | | assertNull(mru); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add another |
| | | * value to attributeTypes that matches an existing one using the correct |
| | |
| | | public void testAttributeTypesMatchingRule() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: attributeTypes", |
| | |
| | | String attrName = "testattributetypesmatchingrule"; |
| | | assertFalse(DirectoryServer.getSchema().hasAttributeType(attrName)); |
| | | |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 20); |
| | | assertEquals(runModify(argsNotPermissive(), ldif, System.err), 20); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add another |
| | | * value to objectClasses that matches an existing one using the correct |
| | |
| | | public void testObjectClassesMatchingRule() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | String objectClassName = "testobjectclassesmatchingrule"; |
| | | assertFalse(DirectoryServer.getSchema().hasObjectClass(objectClassName)); |
| | | |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 20); |
| | | assertEquals(runModify(argsNotPermissive(), ldif, System.err), 20); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add another |
| | | * value to nameForms that matches an existing one using the correct |
| | |
| | | public void testNameFormsMatchingRule() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | String nameFormName = "testnameformsmatchingrule"; |
| | | assertFalse(DirectoryServer.getSchema().hasNameForm(nameFormName)); |
| | | |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 20); |
| | | assertEquals(runModify(argsNotPermissive(), ldif, System.err), 20); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add another |
| | | * value to dITContentRules that matches an existing one using the correct |
| | |
| | | public void testDitContentRulesMatchingRule() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | String objectClassName = "testditcontentrulesmatchingruleoc"; |
| | | assertNull(DirectoryServer.getSchema().getObjectClass(objectClassName)); |
| | | |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 20); |
| | | assertEquals(runModify(argsNotPermissive(), ldif, System.err), 20); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add another |
| | | * value to dITStructureRules that matches an existing one using the correct |
| | |
| | | public void testDitStructureRulesMatchingRule() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | String objectClassName = "testditcontentrulesmatchingruleoc1"; |
| | | assertNull(DirectoryServer.getSchema().getObjectClass(objectClassName)); |
| | | |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 20); |
| | | assertEquals(runModify(argsNotPermissive(), ldif, System.err), 20); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the behavior of the schema backend when attempting to add another |
| | | * value to matchingRuleUse that matches an existing one using the correct |
| | |
| | | public void testMatchingRuleUseMatchingRule() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: attributeTypes", |
| | |
| | | String attrName = "testmatchingruleusematchingruleat1"; |
| | | assertNull(DirectoryServer.getSchema().getAttributeType(attrName)); |
| | | |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 20); |
| | | assertEquals(runModify(argsNotPermissive(), ldif, System.err), 20); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * This test case covers the problem identified in issue #1318. In that |
| | | * issue, a problem arose if the following elements occurred in the following |
| | |
| | | public void testRemoveAndAddObjectClassIssue1318() |
| | | throws Exception |
| | | { |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: objectClasses", |
| | |
| | | "objectClasses: ( testissue1318oc2-oid NAME 'testIssue1381OC2' " + |
| | | "MUST testIssue1381AT )"); |
| | | |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0); |
| | | } |
| | | |
| | | /** |
| | |
| | | ByteString oldMTValue = |
| | | schemaEntry.getAttribute(mtType).get(0).iterator().next(); |
| | | |
| | | String path = TestCaseUtils.createTempFile( |
| | | String ldif = toLdif( |
| | | "dn: cn=schema", |
| | | "changetype: modify", |
| | | "add: attributeTypes", |
| | |
| | | // Sleep longer than the TimeThread delay to ensure the modifytimestamp |
| | | // will be different. |
| | | Thread.sleep(6000); |
| | | assertEquals(runModifyWithSystemErr(standardArgs(path)), 0); |
| | | assertEquals(runModify(argsNotPermissive(), ldif, System.err), 0); |
| | | |
| | | schemaEntry = DirectoryServer.getEntry(DN.valueOf("cn=schema")); |
| | | assertNotNull(schemaEntry); |
| | |
| | | assertNotEquals(oldMTValue, newMTValue); |
| | | } |
| | | |
| | | private int runModifyWithSystemErr(String[] args) |
| | | { |
| | | return LDAPModify.mainModify(args, false, null, System.err); |
| | | } |
| | | |
| | | /** |
| | | * Tests the ability to properly handle adding and removing a schema |
| | | * definition in which the definition has extra spaces. This was added as a |
| | |
| | | "testaddanddeletedefinitionwithextraspaces-oid")); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the {@code exportLDIF} method with a valid configuration. |
| | | * |
| | |
| | | assertTrue(tempFile.length() > 0); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the {@code importLDIF} method to ensure that it throws an exception. |
| | | * |
| | |
| | | schemaBackend.importLDIF(importConfig, DirectoryServer.getInstance().getServerContext()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the {@code getComponentEntryDN} method. |
| | | * |
| | |
| | | assertEquals(schemaBackend.getComponentEntryDN(), configEntryDN); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the {@code getClassName} method. |
| | | */ |
| | | /** Tests the {@code getClassName} method. */ |
| | | @Test |
| | | public void testGetClassName() |
| | | { |
| | | assertEquals(schemaBackend.getClassName(), SchemaBackend.class.getName()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Tests the {@code getAlerts} method. |
| | | */ |
| | | /** Tests the {@code getAlerts} method. */ |
| | | @Test |
| | | public void testGetAlerts() |
| | | { |