use of org.apache.directory.api.ldap.model.exception.LdapSchemaException in project directory-ldap-api by apache.
the class SchemaManagerAddTest method testAddAttributeTypeAlreadyExist.
/**
* Try to inject an AttributeType which already exist
*/
@Test
public void testAddAttributeTypeAlreadyExist() throws Exception {
SchemaManager schemaManager = loadSystem();
int atrSize = schemaManager.getAttributeTypeRegistry().size();
int goidSize = schemaManager.getGlobalOidRegistry().size();
MutableAttributeType attributeType = new MutableAttributeType("2.5.18.4");
attributeType.setEqualityOid("2.5.13.1");
attributeType.setOrderingOid("2.5.13.1");
attributeType.setSubstringOid("2.5.13.1");
// 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 be there
assertTrue(isATPresent(schemaManager, "2.5.18.4"));
// Check that it hasen't changed
AttributeType original = schemaManager.lookupAttributeTypeRegistry("2.5.18.4");
assertEquals("distinguishedNameMatch", original.getEqualityOid());
assertEquals(atrSize, schemaManager.getAttributeTypeRegistry().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 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.exception.LdapSchemaException in project directory-ldap-api by apache.
the class SchemaManagerAddTest method testAddAttributeTypeSupWithOwnSup.
/**
* Try to inject an AttributeType with itself as a superior
*/
@Test
public void testAddAttributeTypeSupWithOwnSup() throws Exception {
SchemaManager schemaManager = loadSystem();
int atrSize = schemaManager.getAttributeTypeRegistry().size();
int goidSize = schemaManager.getGlobalOidRegistry().size();
MutableAttributeType attributeType = new MutableAttributeType("1.1.0");
attributeType.setEqualityOid(null);
attributeType.setOrderingOid(null);
attributeType.setSubstringOid(null);
attributeType.setSuperiorOid("1.1.0");
attributeType.setUsage(UsageEnum.DISTRIBUTED_OPERATION);
// 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);
assertFalse(isATPresent(schemaManager, "1.1.0"));
assertEquals(atrSize, schemaManager.getAttributeTypeRegistry().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 testAddAttributeTypeNoSupInvalidSubstringMR.
/**
* Try to inject an AttributeType with an invalid SUBSTR MR
*/
@Test
public void testAddAttributeTypeNoSupInvalidSubstringMR() throws Exception {
SchemaManager schemaManager = loadSystem();
int atrSize = schemaManager.getAttributeTypeRegistry().size();
int goidSize = schemaManager.getGlobalOidRegistry().size();
MutableAttributeType attributeType = new MutableAttributeType("1.1.0");
attributeType.setEqualityOid(null);
attributeType.setOrderingOid(null);
attributeType.setSubstringOid("0.0");
attributeType.setSyntaxOid("1.3.6.1.4.1.1466.115.121.1.26");
attributeType.setUsage(UsageEnum.USER_APPLICATIONS);
// 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);
assertFalse(isATPresent(schemaManager, "1.1.0"));
assertEquals(atrSize, schemaManager.getAttributeTypeRegistry().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 testAddSyntaxExistingOid.
/**
* Try to inject a Syntax with an existing OID
*/
@Test
public void testAddSyntaxExistingOid() throws Exception {
SchemaManager schemaManager = loadSystem();
int sSize = schemaManager.getLdapSyntaxRegistry().size();
int goidSize = schemaManager.getGlobalOidRegistry().size();
LdapSyntax syntax = new LdapSyntax("2.5.4.3");
// It should fail
assertFalse(schemaManager.add(syntax));
List<Throwable> errors = schemaManager.getErrors();
assertEquals(1, errors.size());
Throwable error = errors.get(0);
assertTrue(error instanceof LdapSchemaException);
assertEquals(sSize, schemaManager.getLdapSyntaxRegistry().size());
assertEquals(goidSize, schemaManager.getGlobalOidRegistry().size());
}
Aggregations