use of org.apache.directory.api.ldap.model.schema.ObjectClass in project directory-ldap-api by apache.
the class SchemaManagerAddTest method testAddObjectClassNoSuperiorValid.
// =========================================================================
// ObjectClass addition tests
// -------------------------------------------------------------------------
// -------------------------------------------------------------------------
// First, not defined superior
// -------------------------------------------------------------------------
/**
* Addition of a valid OC
*/
@Test
public void testAddObjectClassNoSuperiorValid() throws Exception {
SchemaManager schemaManager = loadSystem();
int ocrSize = schemaManager.getObjectClassRegistry().size();
int goidSize = schemaManager.getGlobalOidRegistry().size();
ObjectClass objectClass = new ObjectClass("1.1.1");
assertTrue(schemaManager.add(objectClass));
assertEquals(0, schemaManager.getErrors().size());
ObjectClass added = schemaManager.lookupObjectClassRegistry("1.1.1");
assertNotNull(added);
assertEquals(ocrSize + 1, schemaManager.getObjectClassRegistry().size());
assertEquals(goidSize + 1, schemaManager.getGlobalOidRegistry().size());
}
use of org.apache.directory.api.ldap.model.schema.ObjectClass in project directory-ldap-api by apache.
the class SchemaManagerAddTest method testAddObjectClassSuperiorsATInMustPresentInSuperiorsMay.
/**
* Addition of an OC with some AT present in MUST and in MAY in one of its
* superior
*/
@Test
public void testAddObjectClassSuperiorsATInMustPresentInSuperiorsMay() 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", "OpenLDAProotDSE");
objectClass.addMustAttributeTypeOids("aliasedObjectName", "cn");
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(2, added.getSuperiors().size());
Set<String> expectedSups = new HashSet<String>();
expectedSups.add("alias");
expectedSups.add("OpenLDAProotDSE");
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.ObjectClass in project directory-ldap-api by apache.
the class SchemaManagerDelTest method testDeleteNonExistingObjectClass.
@Test
public void testDeleteNonExistingObjectClass() throws Exception {
SchemaManager schemaManager = loadSchema("system");
int ocSize = schemaManager.getObjectClassRegistry().size();
int goidSize = schemaManager.getGlobalOidRegistry().size();
ObjectClass oc = new ObjectClass("0.1.1");
assertFalse(schemaManager.delete(oc));
assertEquals(ocSize, schemaManager.getObjectClassRegistry().size());
assertEquals(goidSize, schemaManager.getGlobalOidRegistry().size());
}
use of org.apache.directory.api.ldap.model.schema.ObjectClass in project directory-ldap-api by apache.
the class SchemaManagerDelTest method testDeleteExistingObjectClassUsedByAnotherObjectClass.
@Test
public void testDeleteExistingObjectClassUsedByAnotherObjectClass() throws Exception {
SchemaManager schemaManager = loadSchema("system");
int ocSize = schemaManager.getObjectClassRegistry().size();
int goidSize = schemaManager.getGlobalOidRegistry().size();
ObjectClass oc = new ObjectClass("2.5.6.0");
// shouldn't delete the 'top' OC
assertFalse(schemaManager.delete(oc));
List<Throwable> errors = schemaManager.getErrors();
assertFalse(errors.isEmpty());
assertTrue(errors.get(0) instanceof LdapProtocolErrorException);
assertEquals(ocSize, schemaManager.getObjectClassRegistry().size());
assertEquals(goidSize, schemaManager.getGlobalOidRegistry().size());
}
use of org.apache.directory.api.ldap.model.schema.ObjectClass in project directory-ldap-api by apache.
the class SchemaManagerDelTest method testDeleteExistingObjectClass.
// =========================================================================
// ObjectClass deletion tests
// -------------------------------------------------------------------------
@Test
public void testDeleteExistingObjectClass() throws Exception {
SchemaManager schemaManager = loadSchema("system");
int ocSize = schemaManager.getObjectClassRegistry().size();
int goidSize = schemaManager.getGlobalOidRegistry().size();
ObjectClass oc = new ObjectClass("2.5.17.2");
assertTrue(schemaManager.delete(oc));
assertEquals(ocSize - 1, schemaManager.getObjectClassRegistry().size());
assertEquals(goidSize - 1, schemaManager.getGlobalOidRegistry().size());
try {
schemaManager.lookupObjectClassRegistry("2.5.17.2");
fail();
} catch (Exception e) {
// expected
}
}
Aggregations