use of org.apache.directory.api.ldap.model.schema.MutableObjectClass in project directory-ldap-api by apache.
the class SchemaManagerAddTest method testAddObjectClassSuperiorsAbstractWithStructuralInSup.
/**
* Addition of an ABSTRACT OC with some STRUCTURAL superior
*/
@Test
public void testAddObjectClassSuperiorsAbstractWithStructuralInSup() 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.ABSTRACT);
objectClass.addSuperiorOids("referral");
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 testAddObjectClassNoSuperiorNonExistingAtInMust.
/**
* Addition of an OC with not existing AT in MUST
*/
@Test
public void testAddObjectClassNoSuperiorNonExistingAtInMust() 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", "none", "userPassword");
assertFalse(schemaManager.add(objectClass));
assertEquals(1, schemaManager.getErrors().size());
Throwable error = schemaManager.getErrors().get(0);
assertTrue(error 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 testAddObjectClassSuperiorsNonExistingOCInSup.
/**
* Addition of an OC with a non existing OC in SUP
*/
@Test
public void testAddObjectClassSuperiorsNonExistingOCInSup() 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("alias", "refessal");
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 testAddObjectClassSuperiorsValid.
// -------------------------------------------------------------------------
// Then, with superiors
// -------------------------------------------------------------------------
/**
* Addition of a valid OC with some superiors
*/
@Test
public void testAddObjectClassSuperiorsValid() 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("alias", "referral", "top");
assertTrue(schemaManager.add(objectClass));
assertEquals(0, schemaManager.getErrors().size());
ObjectClass added = schemaManager.lookupObjectClassRegistry("1.1.1");
assertNotNull(added);
assertTrue(added.getNames().contains("Test"));
assertNotNull(added.getSuperiors());
assertEquals(3, added.getSuperiors().size());
Set<String> expectedSups = new HashSet<String>();
expectedSups.add("alias");
expectedSups.add("referral");
expectedSups.add("top");
for (ObjectClass addedOC : added.getSuperiors()) {
assertTrue(expectedSups.contains(addedOC.getName()));
expectedSups.remove(addedOC.getName());
}
assertEquals(ocrSize + 1, schemaManager.getObjectClassRegistry().size());
assertEquals(goidSize + 1, schemaManager.getGlobalOidRegistry().size());
}
use of org.apache.directory.api.ldap.model.schema.MutableObjectClass in project directory-ldap-api by apache.
the class SchemaManagerAddTest method testAddObjectClassNoSuperiorATMoreThanOnceInMust.
/**
* Addition of an OC with an AT present more than once in MUST
*/
@Test
public void testAddObjectClassNoSuperiorATMoreThanOnceInMust() 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", "2.5.4.3");
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