Search in sources :

Example 16 with MutableObjectClass

use of org.apache.directory.api.ldap.model.schema.MutableObjectClass in project directory-ldap-api by apache.

the class SchemaManagerAddTest method testAddObjectClassSuperiorsStructuralWithAuxiliaryInSup.

/**
 * Addition of an STRUCTURAL OC with some AUXILIARY superior
 */
@Test
public void testAddObjectClassSuperiorsStructuralWithAuxiliaryInSup() throws Exception {
    SchemaManager schemaManager = loadSystem();
    int ocrSize = schemaManager.getObjectClassRegistry().size();
    int goidSize = schemaManager.getGlobalOidRegistry().size();
    MutableObjectClass objectClass = new MutableObjectClass("1.1.1");
    objectClass.setNames("Test");
    objectClass.setType(ObjectClassTypeEnum.STRUCTURAL);
    objectClass.addSuperiorOids("extensibleObject");
    assertFalse(schemaManager.add(objectClass));
    assertTrue(schemaManager.getErrors().get(0) instanceof LdapSchemaException);
    assertFalse(isOCPresent(schemaManager, "1.1.1"));
    assertEquals(ocrSize, schemaManager.getObjectClassRegistry().size());
    assertEquals(goidSize, schemaManager.getGlobalOidRegistry().size());
}
Also used : LdapSchemaException(org.apache.directory.api.ldap.model.exception.LdapSchemaException) SchemaManager(org.apache.directory.api.ldap.model.schema.SchemaManager) DefaultSchemaManager(org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager) MutableObjectClass(org.apache.directory.api.ldap.model.schema.MutableObjectClass) Test(org.junit.Test)

Example 17 with MutableObjectClass

use of org.apache.directory.api.ldap.model.schema.MutableObjectClass in project directory-ldap-api by apache.

the class SchemaManagerAddTest method testAddObjectClassNoSuperiorATInMustAndMay.

/**
 * Addition of an OC with an AT present in MUST and MAY.
 */
@Test
public void testAddObjectClassNoSuperiorATInMustAndMay() throws Exception {
    SchemaManager schemaManager = loadSystem();
    int ocrSize = schemaManager.getObjectClassRegistry().size();
    int goidSize = schemaManager.getGlobalOidRegistry().size();
    MutableObjectClass objectClass = new MutableObjectClass("1.1.1");
    objectClass.addMustAttributeTypeOids("cn", "ref");
    objectClass.addMayAttributeTypeOids("2.5.4.3");
    // Same AT i MAY and MUST : should fail
    assertFalse(schemaManager.add(objectClass));
    assertEquals(1, schemaManager.getErrors().size());
    assertTrue(schemaManager.getErrors().get(0) instanceof LdapSchemaException);
    assertFalse(isOCPresent(schemaManager, "1.1.1"));
    assertEquals(ocrSize, schemaManager.getObjectClassRegistry().size());
    assertEquals(goidSize, schemaManager.getGlobalOidRegistry().size());
}
Also used : LdapSchemaException(org.apache.directory.api.ldap.model.exception.LdapSchemaException) SchemaManager(org.apache.directory.api.ldap.model.schema.SchemaManager) DefaultSchemaManager(org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager) MutableObjectClass(org.apache.directory.api.ldap.model.schema.MutableObjectClass) Test(org.junit.Test)

Aggregations

MutableObjectClass (org.apache.directory.api.ldap.model.schema.MutableObjectClass)17 SchemaManager (org.apache.directory.api.ldap.model.schema.SchemaManager)16 DefaultSchemaManager (org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager)16 Test (org.junit.Test)16 LdapSchemaException (org.apache.directory.api.ldap.model.exception.LdapSchemaException)14 HashSet (java.util.HashSet)2 ObjectClass (org.apache.directory.api.ldap.model.schema.ObjectClass)2 Attribute (org.apache.directory.api.ldap.model.entry.Attribute)1 DefaultAttribute (org.apache.directory.api.ldap.model.entry.DefaultAttribute)1 LdapUnwillingToPerformException (org.apache.directory.api.ldap.model.exception.LdapUnwillingToPerformException)1 DefaultSchema (org.apache.directory.api.ldap.model.schema.registries.DefaultSchema)1 Schema (org.apache.directory.api.ldap.model.schema.registries.Schema)1