Search in sources :

Example 11 with DefaultSchemaManager

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"));
}
Also used : SchemaManager(org.apache.directory.api.ldap.model.schema.SchemaManager) DefaultSchemaManager(org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager) DefaultSchemaManager(org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager) Test(org.junit.Test)

Example 12 with DefaultSchemaManager

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"));
}
Also used : AttributeType(org.apache.directory.api.ldap.model.schema.AttributeType) SchemaManager(org.apache.directory.api.ldap.model.schema.SchemaManager) DefaultSchemaManager(org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager) DefaultSchemaManager(org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager) Test(org.junit.Test)

Example 13 with DefaultSchemaManager

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"));
}
Also used : SchemaManager(org.apache.directory.api.ldap.model.schema.SchemaManager) DefaultSchemaManager(org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager) DefaultSchemaManager(org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 14 with DefaultSchemaManager

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"));
}
Also used : DefaultSchemaLdifExtractor(org.apache.directory.api.ldap.schema.extractor.impl.DefaultSchemaLdifExtractor) SchemaLdifExtractor(org.apache.directory.api.ldap.schema.extractor.SchemaLdifExtractor) DefaultSchemaLdifExtractor(org.apache.directory.api.ldap.schema.extractor.impl.DefaultSchemaLdifExtractor) SchemaManager(org.apache.directory.api.ldap.model.schema.SchemaManager) DefaultSchemaManager(org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager) File(java.io.File) DefaultSchemaManager(org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager) Test(org.junit.Test)

Example 15 with DefaultSchemaManager

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"));
}
Also used : SchemaManager(org.apache.directory.api.ldap.model.schema.SchemaManager) DefaultSchemaManager(org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager) DefaultSchemaManager(org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager) Test(org.junit.Test)

Aggregations

DefaultSchemaManager (org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager)64 SchemaManager (org.apache.directory.api.ldap.model.schema.SchemaManager)55 Test (org.junit.Test)41 BeforeClass (org.junit.BeforeClass)11 JarLdifSchemaLoader (org.apache.directory.api.ldap.schema.loader.JarLdifSchemaLoader)9 File (java.io.File)7 Schema (org.apache.directory.api.ldap.model.schema.registries.Schema)7 InstanceLayout (org.apache.directory.server.core.api.InstanceLayout)6 SchemaPartition (org.apache.directory.server.core.api.schema.SchemaPartition)6 IOException (java.io.IOException)5 LdapException (org.apache.directory.api.ldap.model.exception.LdapException)4 LdapUnwillingToPerformException (org.apache.directory.api.ldap.model.exception.LdapUnwillingToPerformException)4 SchemaLoader (org.apache.directory.api.ldap.model.schema.registries.SchemaLoader)4 DefaultSchema (org.apache.directory.api.ldap.model.schema.registries.DefaultSchema)3 SchemaLdifExtractor (org.apache.directory.api.ldap.schema.extractor.SchemaLdifExtractor)3 DefaultSchemaLdifExtractor (org.apache.directory.api.ldap.schema.extractor.impl.DefaultSchemaLdifExtractor)3 CacheService (org.apache.directory.server.core.api.CacheService)3 CacheManager (net.sf.ehcache.CacheManager)2 CacheConfiguration (net.sf.ehcache.config.CacheConfiguration)2 Configuration (net.sf.ehcache.config.Configuration)2