use of org.apache.directory.api.ldap.model.schema.Normalizer in project directory-ldap-api by apache.
the class SchemaManagerAddTest method testAddNewNormalizer.
// =========================================================================
// MatchingRuleUse addition tests
// -------------------------------------------------------------------------
// TODO
// =========================================================================
// NameForm addition tests
// -------------------------------------------------------------------------
// TODO
// =========================================================================
// Normalizer addition tests
// -------------------------------------------------------------------------
@Test
public void testAddNewNormalizer() throws Exception {
SchemaManager schemaManager = loadSystem();
int nrSize = schemaManager.getNormalizerRegistry().size();
int goidSize = schemaManager.getGlobalOidRegistry().size();
String oid = "0.0.0";
Normalizer normalizer = new NoOpNormalizer(oid);
assertTrue(schemaManager.add(normalizer));
List<Throwable> errors = schemaManager.getErrors();
assertEquals(0, errors.size());
assertEquals(nrSize + 1, schemaManager.getNormalizerRegistry().size());
assertEquals(goidSize, schemaManager.getGlobalOidRegistry().size());
Normalizer added = schemaManager.lookupNormalizerRegistry(oid);
assertNotNull(added);
assertEquals(normalizer.getClass().getName(), added.getFqcn());
}
use of org.apache.directory.api.ldap.model.schema.Normalizer in project directory-ldap-api by apache.
the class SchemaManagerAddTest method testAddAlreadyExistingNormalizer.
@Test
public void testAddAlreadyExistingNormalizer() throws Exception {
SchemaManager schemaManager = loadSystem();
int nrSize = schemaManager.getNormalizerRegistry().size();
int goidSize = schemaManager.getGlobalOidRegistry().size();
String oid = "0.0.0";
Normalizer normalizer = new NoOpNormalizer(oid);
assertTrue(schemaManager.add(normalizer));
Normalizer added = schemaManager.lookupNormalizerRegistry(oid);
assertNotNull(added);
assertEquals(normalizer.getClass().getName(), added.getFqcn());
List<Throwable> errors = schemaManager.getErrors();
assertEquals(0, errors.size());
assertEquals(nrSize + 1, schemaManager.getNormalizerRegistry().size());
assertEquals(goidSize, schemaManager.getGlobalOidRegistry().size());
Normalizer normalizer2 = new NoOpNormalizer(oid);
assertFalse(schemaManager.add(normalizer2));
errors = schemaManager.getErrors();
assertEquals(1, errors.size());
assertEquals(nrSize + 1, schemaManager.getNormalizerRegistry().size());
assertEquals(goidSize, schemaManager.getGlobalOidRegistry().size());
added = schemaManager.lookupNormalizerRegistry(oid);
assertNotNull(added);
assertEquals(normalizer.getClass().getName(), added.getFqcn());
}
use of org.apache.directory.api.ldap.model.schema.Normalizer in project directory-ldap-api by apache.
the class SchemaManagerAddTest method testAddNormalizerWithWrongFQCN.
/**
* Test that we can't add two Normalizers with the same class code.
*/
@Test
public void testAddNormalizerWithWrongFQCN() throws Exception {
SchemaManager schemaManager = loadSystem();
int nrSize = schemaManager.getNormalizerRegistry().size();
int goidSize = schemaManager.getGlobalOidRegistry().size();
String oid = "0.0.0";
Normalizer normalizer = new NoOpNormalizer(oid);
// using java.sql.ResultSet cause it is very unlikely to get loaded
// in ADS, as the FQCN is not the one expected
normalizer.setFqcn("java.sql.ResultSet");
assertFalse(schemaManager.add(normalizer));
List<Throwable> errors = schemaManager.getErrors();
errors = schemaManager.getErrors();
assertEquals(1, errors.size());
assertEquals(nrSize, schemaManager.getNormalizerRegistry().size());
assertEquals(goidSize, schemaManager.getGlobalOidRegistry().size());
try {
schemaManager.lookupNormalizerRegistry(oid);
fail();
} catch (Exception e) {
// Expected
assertTrue(true);
}
}
use of org.apache.directory.api.ldap.model.schema.Normalizer in project directory-ldap-api by apache.
the class SchemaManagerDelTest method testDeleteNonExistingNormalizer.
@Test
public void testDeleteNonExistingNormalizer() throws Exception {
SchemaManager schemaManager = loadSchema("system");
int nrSize = schemaManager.getNormalizerRegistry().size();
int goidSize = schemaManager.getGlobalOidRegistry().size();
Normalizer nr = new BooleanNormalizer();
nr.setOid("0.0");
assertFalse(schemaManager.delete(nr));
List<Throwable> errors = schemaManager.getErrors();
assertFalse(errors.isEmpty());
assertEquals(nrSize, schemaManager.getNormalizerRegistry().size());
assertEquals(goidSize, schemaManager.getGlobalOidRegistry().size());
}
use of org.apache.directory.api.ldap.model.schema.Normalizer in project directory-ldap-api by apache.
the class SchemaManagerDelTest method testDeleteExistingNormalizerUsedByMatchingRule.
@Test
public void testDeleteExistingNormalizerUsedByMatchingRule() throws Exception {
SchemaManager schemaManager = loadSchema("system");
int nrSize = schemaManager.getNormalizerRegistry().size();
int goidSize = schemaManager.getGlobalOidRegistry().size();
Normalizer nr = schemaManager.lookupNormalizerRegistry("2.5.13.0");
// shouldn't be deleted cause there is a MR associated with it
assertFalse(schemaManager.delete(nr));
List<Throwable> errors = schemaManager.getErrors();
assertFalse(errors.isEmpty());
assertTrue(errors.get(0) instanceof LdapProtocolErrorException);
assertNotNull(schemaManager.lookupNormalizerRegistry("2.5.13.0"));
assertEquals(nrSize, schemaManager.getNormalizerRegistry().size());
assertEquals(goidSize, schemaManager.getGlobalOidRegistry().size());
}
Aggregations