use of org.apache.directory.api.ldap.model.exception.LdapSchemaException in project directory-ldap-api by apache.
the class SchemaManagerAddTest method testAddObjectClassNoSuperiorWithExistingOCName.
/**
* Addition of an OC with an existing OC name
*/
@Test
public void testAddObjectClassNoSuperiorWithExistingOCName() throws Exception {
SchemaManager schemaManager = loadSystem();
int ocrSize = schemaManager.getObjectClassRegistry().size();
int goidSize = schemaManager.getGlobalOidRegistry().size();
ObjectClass objectClass = new ObjectClass("1.1.0");
objectClass.setNames("Test", "referral");
assertFalse(schemaManager.add(objectClass));
assertEquals(1, schemaManager.getErrors().size());
Throwable error = schemaManager.getErrors().get(0);
assertTrue(error instanceof LdapSchemaException);
assertFalse(isOCPresent(schemaManager, "1.1.0"));
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 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.exception.LdapSchemaException in project directory-ldap-api by apache.
the class SchemaManagerAddTest method testAddMatchingRuleExistingName.
/**
* Try to inject a new MatchingRule with an existing name
*/
@Test
public void testAddMatchingRuleExistingName() 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", "objectIdentifierMatch");
matchingRule.setSyntaxOid("1.3.6.1.4.1.1466.115.121.1.26");
// It should fail (name already registered)
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 testAddMatchingRuleNotExistingSchema.
/**
* Try to inject a new MatchingRule with an existing AT name
*/
@Test
public void testAddMatchingRuleNotExistingSchema() 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.3.6.1.4.1.1466.115.121.1.26");
matchingRule.setSchemaName("bad");
// 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);
// Check that the new MR has been injected
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 testAddAttributeTypeNameAlreadyExist.
/**
* Try to inject an AttributeType with an already attributed name
*/
@Test
public void testAddAttributeTypeNameAlreadyExist() throws Exception {
SchemaManager schemaManager = loadSystem();
int atrSize = schemaManager.getAttributeTypeRegistry().size();
int goidSize = schemaManager.getGlobalOidRegistry().size();
MutableAttributeType attributeType = new MutableAttributeType("1.1.1.0");
attributeType.setEqualityOid("2.5.13.1");
attributeType.setOrderingOid("2.5.13.1");
attributeType.setSubstringOid("2.5.13.1");
attributeType.setSyntaxOid("1.3.6.1.4.1.1466.115.121.1.26");
attributeType.setNames("Test", "cn");
// It should fail
assertFalse(schemaManager.add(attributeType));
List<Throwable> errors = schemaManager.getErrors();
assertEquals(1, errors.size());
Throwable error = errors.get(0);
assertTrue(error instanceof LdapSchemaException);
// The AT must not be there
assertFalse(isATPresent(schemaManager, "1.1.1.0"));
assertEquals(atrSize, schemaManager.getAttributeTypeRegistry().size());
assertEquals(goidSize, schemaManager.getGlobalOidRegistry().size());
}
Aggregations