use of org.apache.directory.api.ldap.model.exception.LdapSchemaException in project directory-ldap-api by apache.
the class SchemaManagerAddTest method testAddMatchingRuleNoSyntax.
/**
* Try to inject a new MatchingRule without a syntax
*/
@Test
public void testAddMatchingRuleNoSyntax() throws Exception {
SchemaManager schemaManager = loadSystem();
int mrrSize = schemaManager.getMatchingRuleRegistry().size();
int goidSize = schemaManager.getGlobalOidRegistry().size();
MatchingRule matchingRule = new MatchingRule("1.1.0");
// It should fail (no syntax)
assertFalse(schemaManager.add(matchingRule));
List<Throwable> errors = schemaManager.getErrors();
assertEquals(1, errors.size());
Throwable error = errors.get(0);
assertTrue(error instanceof LdapSchemaException);
assertFalse(isMRPresent(schemaManager, "1.1.0"));
assertEquals(mrrSize, schemaManager.getMatchingRuleRegistry().size());
assertEquals(goidSize, schemaManager.getGlobalOidRegistry().size());
}
use of org.apache.directory.api.ldap.model.exception.LdapSchemaException 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());
}
use of org.apache.directory.api.ldap.model.exception.LdapSchemaException 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.exception.LdapSchemaException in project directory-ldap-api by apache.
the class SchemaManagerAddTest method testAddMatchingRuleNotExistingSyntax.
/**
* Try to inject a new MatchingRule with a not existing Syntax
*/
@Test
public void testAddMatchingRuleNotExistingSyntax() throws Exception {
SchemaManager schemaManager = loadSystem();
int mrrSize = schemaManager.getMatchingRuleRegistry().size();
int goidSize = schemaManager.getGlobalOidRegistry().size();
MutableMatchingRule matchingRule = new MutableMatchingRule("1.1.0");
matchingRule.setNames("Test");
matchingRule.setSyntaxOid("1.1.1");
// It should fail
assertFalse(schemaManager.add(matchingRule));
List<Throwable> errors = schemaManager.getErrors();
assertEquals(1, errors.size());
Throwable error = errors.get(0);
assertTrue(error instanceof LdapSchemaException);
assertEquals(mrrSize, schemaManager.getMatchingRuleRegistry().size());
assertEquals(goidSize, schemaManager.getGlobalOidRegistry().size());
}
use of org.apache.directory.api.ldap.model.exception.LdapSchemaException 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