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());
}
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());
}
Aggregations