use of org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager in project directory-ldap-api by apache.
the class SchemaManagerLoadWithDepsTest method testLoadWrongSchema.
/**
* Test loading a wrong schema
*/
@Test
public void testLoadWrongSchema() throws Exception {
LdifSchemaLoader loader = new LdifSchemaLoader(schemaRepository);
SchemaManager schemaManager = new DefaultSchemaManager(loader);
try {
schemaManager.loadWithDeps("bad");
fail();
} catch (LdapUnwillingToPerformException lonse) {
// expected
}
assertTrue(schemaManager.getErrors().isEmpty());
assertEquals(0, schemaManager.getAttributeTypeRegistry().size());
assertEquals(0, schemaManager.getComparatorRegistry().size());
assertEquals(0, schemaManager.getMatchingRuleRegistry().size());
assertEquals(0, schemaManager.getNormalizerRegistry().size());
assertEquals(0, schemaManager.getObjectClassRegistry().size());
assertEquals(0, schemaManager.getSyntaxCheckerRegistry().size());
assertEquals(0, schemaManager.getLdapSyntaxRegistry().size());
assertEquals(0, schemaManager.getGlobalOidRegistry().size());
assertEquals(0, schemaManager.getRegistries().getLoadedSchemas().size());
}
use of org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager in project directory-ldap-api by apache.
the class SchemaManagerLoadWithDepsTest method testLoadCoreInetOrgPersonAndNis.
/**
* test loading the "InetOrgPerson", "core" and a disabled schema
*/
@Test
public void testLoadCoreInetOrgPersonAndNis() throws Exception {
LdifSchemaLoader loader = new LdifSchemaLoader(schemaRepository);
SchemaManager schemaManager = new DefaultSchemaManager(loader);
schemaManager.loadWithDeps("core", "nis", "InetOrgPerson");
assertTrue(schemaManager.getErrors().isEmpty());
assertEquals(142, schemaManager.getAttributeTypeRegistry().size());
assertEquals(36, schemaManager.getComparatorRegistry().size());
assertEquals(42, schemaManager.getMatchingRuleRegistry().size());
assertEquals(35, schemaManager.getNormalizerRegistry().size());
assertEquals(50, schemaManager.getObjectClassRegistry().size());
assertEquals(59, schemaManager.getSyntaxCheckerRegistry().size());
assertEquals(66, schemaManager.getLdapSyntaxRegistry().size());
assertEquals(300, schemaManager.getGlobalOidRegistry().size());
assertEquals(4, schemaManager.getRegistries().getLoadedSchemas().size());
assertNotNull(schemaManager.getRegistries().getLoadedSchema("system"));
assertNotNull(schemaManager.getRegistries().getLoadedSchema("core"));
assertNotNull(schemaManager.getRegistries().getLoadedSchema("cosine"));
assertNotNull(schemaManager.getRegistries().getLoadedSchema("InetOrgPerson"));
}
use of org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager in project directory-ldap-api by apache.
the class SchemaManagerLoadWithDepsTest method testLoadInetOrgPerson.
/**
* test loading the "InetOrgPerson" schema, which depends on "system", "core"
* and "cosine"
*/
@Test
public void testLoadInetOrgPerson() throws Exception {
LdifSchemaLoader loader = new LdifSchemaLoader(schemaRepository);
SchemaManager schemaManager = new DefaultSchemaManager(loader);
schemaManager.loadWithDeps("InetOrgPerson");
assertTrue(schemaManager.getErrors().isEmpty());
assertEquals(142, schemaManager.getAttributeTypeRegistry().size());
assertEquals(36, schemaManager.getComparatorRegistry().size());
assertEquals(42, schemaManager.getMatchingRuleRegistry().size());
assertEquals(35, schemaManager.getNormalizerRegistry().size());
assertEquals(50, schemaManager.getObjectClassRegistry().size());
assertEquals(59, schemaManager.getSyntaxCheckerRegistry().size());
assertEquals(66, schemaManager.getLdapSyntaxRegistry().size());
assertEquals(300, schemaManager.getGlobalOidRegistry().size());
assertEquals(4, schemaManager.getRegistries().getLoadedSchemas().size());
assertNotNull(schemaManager.getRegistries().getLoadedSchema("system"));
assertNotNull(schemaManager.getRegistries().getLoadedSchema("core"));
assertNotNull(schemaManager.getRegistries().getLoadedSchema("cosine"));
assertNotNull(schemaManager.getRegistries().getLoadedSchema("InetOrgPerson"));
}
use of org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager in project directory-ldap-api by apache.
the class SchemaManagerLoadWithDepsTest method testLoadCoreAndInetOrgPerson.
/**
* test loading the "InetOrgPerson" and "core" schema, which depends on "system" and "cosine"
*/
@Test
public void testLoadCoreAndInetOrgPerson() throws Exception {
LdifSchemaLoader loader = new LdifSchemaLoader(schemaRepository);
SchemaManager schemaManager = new DefaultSchemaManager(loader);
schemaManager.loadWithDeps("core", "InetOrgPerson");
assertTrue(schemaManager.getErrors().isEmpty());
assertEquals(142, schemaManager.getAttributeTypeRegistry().size());
assertEquals(36, schemaManager.getComparatorRegistry().size());
assertEquals(42, schemaManager.getMatchingRuleRegistry().size());
assertEquals(35, schemaManager.getNormalizerRegistry().size());
assertEquals(50, schemaManager.getObjectClassRegistry().size());
assertEquals(59, schemaManager.getSyntaxCheckerRegistry().size());
assertEquals(66, schemaManager.getLdapSyntaxRegistry().size());
assertEquals(300, schemaManager.getGlobalOidRegistry().size());
assertEquals(4, schemaManager.getRegistries().getLoadedSchemas().size());
assertNotNull(schemaManager.getRegistries().getLoadedSchema("system"));
assertNotNull(schemaManager.getRegistries().getLoadedSchema("core"));
assertNotNull(schemaManager.getRegistries().getLoadedSchema("cosine"));
assertNotNull(schemaManager.getRegistries().getLoadedSchema("InetOrgPerson"));
}
use of org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager in project directory-ldap-api by apache.
the class SchemaManagerLoadWithDepsTest method testLoadCoreInetOrgPersonAndBad.
/**
* test loading the "InetOrgPerson", "core" and a bad schema
*/
@Test
public void testLoadCoreInetOrgPersonAndBad() throws Exception {
LdifSchemaLoader loader = new LdifSchemaLoader(schemaRepository);
SchemaManager schemaManager = new DefaultSchemaManager(loader);
try {
schemaManager.loadWithDeps("core", "bad", "InetOrgPerson");
fail();
} catch (LdapUnwillingToPerformException lonse) {
// expected
}
// No SchemaObject should be loaded as we had an error
assertTrue(schemaManager.getErrors().isEmpty());
assertEquals(0, schemaManager.getAttributeTypeRegistry().size());
assertEquals(0, schemaManager.getComparatorRegistry().size());
assertEquals(0, schemaManager.getMatchingRuleRegistry().size());
assertEquals(0, schemaManager.getNormalizerRegistry().size());
assertEquals(0, schemaManager.getObjectClassRegistry().size());
assertEquals(0, schemaManager.getSyntaxCheckerRegistry().size());
assertEquals(0, schemaManager.getLdapSyntaxRegistry().size());
assertEquals(0, schemaManager.getGlobalOidRegistry().size());
assertEquals(0, schemaManager.getRegistries().getLoadedSchemas().size());
assertNull(schemaManager.getRegistries().getLoadedSchema("system"));
assertNull(schemaManager.getRegistries().getLoadedSchema("core"));
assertNull(schemaManager.getRegistries().getLoadedSchema("cosine"));
assertNull(schemaManager.getRegistries().getLoadedSchema("InetOrgPerson"));
}
Aggregations