Search in sources :

Example 16 with DefaultSchemaManager

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());
}
Also used : LdapUnwillingToPerformException(org.apache.directory.api.ldap.model.exception.LdapUnwillingToPerformException) 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 17 with DefaultSchemaManager

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"));
}
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 18 with DefaultSchemaManager

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"));
}
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 19 with DefaultSchemaManager

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"));
}
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 20 with DefaultSchemaManager

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"));
}
Also used : LdapUnwillingToPerformException(org.apache.directory.api.ldap.model.exception.LdapUnwillingToPerformException) 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