use of org.apache.directory.api.ldap.model.schema.MutableAttributeType in project directory-ldap-api by apache.
the class SchemaManagerAddTest method testAddAttributeTypeNoSupInvalidEqualityMR.
/**
* Try to inject an AttributeType with an invalid EQUALITY MR
*/
@Test
public void testAddAttributeTypeNoSupInvalidEqualityMR() throws Exception {
SchemaManager schemaManager = loadSystem();
int atrSize = schemaManager.getAttributeTypeRegistry().size();
int goidSize = schemaManager.getGlobalOidRegistry().size();
MutableAttributeType attributeType = new MutableAttributeType("1.1.0");
attributeType.setEqualityOid("0.0");
attributeType.setOrderingOid(null);
attributeType.setSubstringOid(null);
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.schema.MutableAttributeType in project directory-ldap-api by apache.
the class SchemaManagerAddTest method testAddAttributeTypeNoSupValidMR.
/**
* Try to inject an AttributeType with valid MRs
*/
@Test
public void testAddAttributeTypeNoSupValidMR() throws Exception {
SchemaManager schemaManager = loadSystem();
int atrSize = schemaManager.getAttributeTypeRegistry().size();
int goidSize = schemaManager.getGlobalOidRegistry().size();
MutableAttributeType attributeType = new MutableAttributeType("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.setUsage(UsageEnum.USER_APPLICATIONS);
// It should not fail
assertTrue(schemaManager.add(attributeType));
assertTrue(isATPresent(schemaManager, "1.1.0"));
assertEquals(atrSize + 1, schemaManager.getAttributeTypeRegistry().size());
assertEquals(goidSize + 1, schemaManager.getGlobalOidRegistry().size());
}
use of org.apache.directory.api.ldap.model.schema.MutableAttributeType in project directory-ldap-api by apache.
the class SchemaManagerAddTest method testAddAttributeTypeNoSupNoUserModificationUserAplication.
/**
* Try to inject an AttributeType which is a NO-USER-MODIFICATION and userApplication
*/
@Test
public void testAddAttributeTypeNoSupNoUserModificationUserAplication() throws Exception {
SchemaManager schemaManager = loadSystem();
int atrSize = schemaManager.getAttributeTypeRegistry().size();
int goidSize = schemaManager.getGlobalOidRegistry().size();
MutableAttributeType attributeType = new MutableAttributeType("1.1.0");
attributeType.setEqualityOid("2.5.13.1");
attributeType.setOrderingOid(null);
attributeType.setSubstringOid(null);
attributeType.setSyntaxOid("1.3.6.1.4.1.1466.115.121.1.26");
attributeType.setUsage(UsageEnum.USER_APPLICATIONS);
attributeType.setUserModifiable(false);
// 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.schema.MutableAttributeType in project directory-ldap-api by apache.
the class SchemaManagerAddTest method testAddAttributeTypeNoSupNoSyntaxNoSuperior.
// =========================================================================
// For each test, we will check many different things.
// If the test is successful, we want to know if the SchemaObject
// Registry has grown : its size must be one bigger. If the SchemaObject
// is not loadable, then the GlobalOidRegistry must also have grown.
// =========================================================================
// AttributeType addition tests
// -------------------------------------------------------------------------
// First, not defined superior
// -------------------------------------------------------------------------
/**
* Try to inject an AttributeType without any superior nor Syntax : it's invalid
*/
@Test
public void testAddAttributeTypeNoSupNoSyntaxNoSuperior() throws Exception {
SchemaManager schemaManager = loadSystem();
int atrSize = schemaManager.getAttributeTypeRegistry().size();
int goidSize = schemaManager.getGlobalOidRegistry().size();
MutableAttributeType attributeType = new MutableAttributeType("1.1.0");
attributeType.setEqualityOid("2.5.13.1");
attributeType.setOrderingOid(null);
attributeType.setSubstringOid(null);
// 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.schema.MutableAttributeType in project directory-ldap-api by apache.
the class SchemaManagerAddTest method testAddAttributeTypeNoSupInvalidOrderingMR.
/**
* Try to inject an AttributeType with an invalid ORDERING MR
*/
@Test
public void testAddAttributeTypeNoSupInvalidOrderingMR() 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("0.0");
attributeType.setSubstringOid(null);
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());
}
Aggregations