use of org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager in project directory-ldap-api by apache.
the class SchemaManagerLoadTest method testLoadCore.
/**
* test loading the "core" schema, which depends on "system"
*/
@Test
public void testLoadCore() throws Exception {
LdifSchemaLoader loader = new LdifSchemaLoader(schemaRepository);
SchemaManager schemaManager = new DefaultSchemaManager(loader);
// Check that we can't load a schema without its dependencies
assertFalse(schemaManager.load("core"));
assertTrue(schemaManager.load("system"));
assertTrue(schemaManager.load("core"));
assertTrue(schemaManager.getErrors().isEmpty());
assertEquals(92, schemaManager.getAttributeTypeRegistry().size());
assertEquals(36, schemaManager.getComparatorRegistry().size());
assertEquals(42, schemaManager.getMatchingRuleRegistry().size());
assertEquals(35, schemaManager.getNormalizerRegistry().size());
assertEquals(36, schemaManager.getObjectClassRegistry().size());
assertEquals(59, schemaManager.getSyntaxCheckerRegistry().size());
assertEquals(66, schemaManager.getLdapSyntaxRegistry().size());
assertEquals(236, schemaManager.getGlobalOidRegistry().size());
assertEquals(2, schemaManager.getRegistries().getLoadedSchemas().size());
assertNotNull(schemaManager.getRegistries().getLoadedSchema("system"));
assertNotNull(schemaManager.getRegistries().getLoadedSchema("core"));
}
use of org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager in project directory-ldap-api by apache.
the class SchemaManagerLoadTest method testLoadNis.
/**
* test loading the "nis" schema, which depends on "system", "core" and "cosine",
* but is disabled
*/
@Test
public void testLoadNis() throws Exception {
LdifSchemaLoader loader = new LdifSchemaLoader(schemaRepository);
SchemaManager schemaManager = new DefaultSchemaManager(loader);
assertTrue(schemaManager.load("system"));
assertTrue(schemaManager.load("core"));
assertTrue(schemaManager.load("cosine"));
assertFalse(schemaManager.load("nis"));
AttributeType at = schemaManager.getAttributeType("uidNumber");
// if nis schema was loaded then the at will not be null
assertNull(at);
assertTrue(schemaManager.getErrors().isEmpty());
assertEquals(133, schemaManager.getAttributeTypeRegistry().size());
assertEquals(36, schemaManager.getComparatorRegistry().size());
assertEquals(42, schemaManager.getMatchingRuleRegistry().size());
assertEquals(35, schemaManager.getNormalizerRegistry().size());
assertEquals(49, schemaManager.getObjectClassRegistry().size());
assertEquals(59, schemaManager.getSyntaxCheckerRegistry().size());
assertEquals(66, schemaManager.getLdapSyntaxRegistry().size());
assertEquals(290, schemaManager.getGlobalOidRegistry().size());
assertEquals(3, schemaManager.getRegistries().getLoadedSchemas().size());
assertNotNull(schemaManager.getRegistries().getLoadedSchema("system"));
assertNotNull(schemaManager.getRegistries().getLoadedSchema("core"));
assertNotNull(schemaManager.getRegistries().getLoadedSchema("cosine"));
assertNull(schemaManager.getRegistries().getLoadedSchema("nis"));
}
use of org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager in project directory-ldap-api by apache.
the class SchemaManagerLoadTest method testLoadCoreInetOrgPersonAndNis.
/**
* test loading the "InetOrgPerson", "core" and a disabled schema
*/
@Ignore("ignoring for the moment to let the other tests run on CI")
@Test
public void testLoadCoreInetOrgPersonAndNis() throws Exception {
LdifSchemaLoader loader = new LdifSchemaLoader(schemaRepository);
SchemaManager schemaManager = new DefaultSchemaManager(loader);
assertTrue(schemaManager.load("system"));
// Try to load a disabled schema when the registries does
// ot allow disabled schema to be loaded
assertFalse(schemaManager.load("core", "nis", "cosine", "InetOrgPerson"));
assertFalse(schemaManager.getErrors().isEmpty());
assertEquals(38, schemaManager.getAttributeTypeRegistry().size());
assertEquals(35, schemaManager.getComparatorRegistry().size());
assertEquals(35, schemaManager.getMatchingRuleRegistry().size());
assertEquals(34, schemaManager.getNormalizerRegistry().size());
assertEquals(9, schemaManager.getObjectClassRegistry().size());
assertEquals(59, schemaManager.getSyntaxCheckerRegistry().size());
assertEquals(59, schemaManager.getLdapSyntaxRegistry().size());
assertEquals(141, schemaManager.getGlobalOidRegistry().size());
assertEquals(1, schemaManager.getRegistries().getLoadedSchemas().size());
assertNotNull(schemaManager.getRegistries().getLoadedSchema("system"));
assertNull(schemaManager.getRegistries().getLoadedSchema("nis"));
assertNull(schemaManager.getRegistries().getLoadedSchema("core"));
assertNull(schemaManager.getRegistries().getLoadedSchema("cosine"));
assertNull(schemaManager.getRegistries().getLoadedSchema("InetOrgPerson"));
}
use of org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager in project directory-ldap-api by apache.
the class LdifSchemaLoaderTest method testLoader.
@Test
public void testLoader() throws Exception {
SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor(new File(workingDirectory));
extractor.extractOrCopy();
LdifSchemaLoader loader = new LdifSchemaLoader(new File(workingDirectory, "schema"));
SchemaManager sm = new DefaultSchemaManager(loader);
boolean loaded = sm.loadAllEnabled();
if (!loaded) {
fail("Schema load failed : " + Exceptions.printErrors(sm.getErrors()));
}
assertTrue(sm.getRegistries().getAttributeTypeRegistry().contains("cn"));
}
use of org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager in project directory-ldap-api by apache.
the class SchemaManagerLoadWithDepsTest method testLoadRfc2307Bis.
/**
* test loading the "rfc2307bis" schema, which depends on "system", "nis" and "core",
* but is disabled
*/
@Test
public void testLoadRfc2307Bis() throws Exception {
LdifSchemaLoader loader = new LdifSchemaLoader(schemaRepository);
SchemaManager schemaManager = new DefaultSchemaManager(loader);
schemaManager.loadWithDeps("rfc2307bis");
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("nis"));
assertNull(schemaManager.getRegistries().getLoadedSchema("core"));
}
Aggregations