Search in sources :

Example 51 with DefaultSchemaManager

use of org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager in project directory-ldap-api by apache.

the class SchemaManagerLoadTest method testLoadApacheMeta.

/**
 * test loading the "apacheMeta" schema, which depends on "system"
 */
@Test
public void testLoadApacheMeta() throws Exception {
    LdifSchemaLoader loader = new LdifSchemaLoader(schemaRepository);
    SchemaManager schemaManager = new DefaultSchemaManager(loader);
    assertTrue(schemaManager.load("system"));
    assertTrue(schemaManager.load("apacheMeta"));
    assertTrue(schemaManager.getErrors().isEmpty());
    assertEquals(71, schemaManager.getAttributeTypeRegistry().size());
    assertEquals(40, schemaManager.getComparatorRegistry().size());
    assertEquals(40, schemaManager.getMatchingRuleRegistry().size());
    assertEquals(40, schemaManager.getNormalizerRegistry().size());
    assertEquals(22, schemaManager.getObjectClassRegistry().size());
    assertEquals(63, schemaManager.getSyntaxCheckerRegistry().size());
    assertEquals(64, schemaManager.getLdapSyntaxRegistry().size());
    assertEquals(197, schemaManager.getGlobalOidRegistry().size());
    assertEquals(2, schemaManager.getRegistries().getLoadedSchemas().size());
    assertNotNull(schemaManager.getRegistries().getLoadedSchema("system"));
    assertNotNull(schemaManager.getRegistries().getLoadedSchema("apachemeta"));
}
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 52 with DefaultSchemaManager

use of org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager in project directory-ldap-api by apache.

the class SchemaManagerLoadTest method loadNewSchemaBadDependencies.

/**
 * Test that we can't load a new schema with bad dependencies
 */
@Test
public void loadNewSchemaBadDependencies() throws Exception {
    LdifSchemaLoader loader = new LdifSchemaLoader(schemaRepository);
    SchemaManager schemaManager = new DefaultSchemaManager(loader);
    Schema dummy = new DefaultSchema(loader, "dummy");
    dummy.addDependencies("bad");
    assertFalse(schemaManager.load(dummy));
    assertFalse(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("dummy"));
}
Also used : Schema(org.apache.directory.api.ldap.model.schema.registries.Schema) DefaultSchema(org.apache.directory.api.ldap.model.schema.registries.DefaultSchema) DefaultSchema(org.apache.directory.api.ldap.model.schema.registries.DefaultSchema) 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 53 with DefaultSchemaManager

use of org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager in project directory-ldap-api by apache.

the class SchemaManagerLoadTest method testLoadKrb5Kdc.

/**
 * test loading the "Krb5Kdc" schema, which depends on "system" and "core"
 */
@Test
public void testLoadKrb5Kdc() throws Exception {
    LdifSchemaLoader loader = new LdifSchemaLoader(schemaRepository);
    SchemaManager schemaManager = new DefaultSchemaManager(loader);
    assertTrue(schemaManager.load("system"));
    assertTrue(schemaManager.load("core"));
    assertTrue(schemaManager.load("Krb5Kdc"));
    assertTrue(schemaManager.getErrors().isEmpty());
    assertEquals(107, schemaManager.getAttributeTypeRegistry().size());
    assertEquals(36, schemaManager.getComparatorRegistry().size());
    assertEquals(42, schemaManager.getMatchingRuleRegistry().size());
    assertEquals(35, schemaManager.getNormalizerRegistry().size());
    assertEquals(39, schemaManager.getObjectClassRegistry().size());
    assertEquals(59, schemaManager.getSyntaxCheckerRegistry().size());
    assertEquals(66, schemaManager.getLdapSyntaxRegistry().size());
    assertEquals(254, schemaManager.getGlobalOidRegistry().size());
    assertEquals(3, schemaManager.getRegistries().getLoadedSchemas().size());
    assertNotNull(schemaManager.getRegistries().getLoadedSchema("system"));
    assertNotNull(schemaManager.getRegistries().getLoadedSchema("core"));
    assertNotNull(schemaManager.getRegistries().getLoadedSchema("Krb5Kdc"));
}
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 54 with DefaultSchemaManager

use of org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager in project directory-ldap-api by apache.

the class SchemaManagerLoadTest method testLoadOther.

/**
 * test loading the "other" schema, which depends on "system", "core",
 * "apache" and "apacheMeta". As we don't have any cross dependencies
 * with any of this other schemas, we can only load core and system
 */
@Test
public void testLoadOther() throws Exception {
    LdifSchemaLoader loader = new LdifSchemaLoader(schemaRepository);
    SchemaManager schemaManager = new DefaultSchemaManager(loader);
    assertTrue(schemaManager.load("system"));
    assertTrue(schemaManager.load("core"));
    assertTrue(schemaManager.load("other"));
    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(3, schemaManager.getRegistries().getLoadedSchemas().size());
    assertNotNull(schemaManager.getRegistries().getLoadedSchema("system"));
    assertNotNull(schemaManager.getRegistries().getLoadedSchema("core"));
    assertNotNull(schemaManager.getRegistries().getLoadedSchema("other"));
}
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 55 with DefaultSchemaManager

use of org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager in project directory-ldap-api by apache.

the class SchemaManagerLoadTest method testLoadWrongSchema.

/**
 * Test loading a wrong schema
 */
@Test
public void testLoadWrongSchema() throws Exception {
    LdifSchemaLoader loader = new LdifSchemaLoader(schemaRepository);
    SchemaManager schemaManager = new DefaultSchemaManager(loader);
    assertTrue(schemaManager.load("system"));
    try {
        schemaManager.loadWithDeps("bad");
        fail();
    } catch (LdapUnwillingToPerformException lonse) {
    // expected
    }
    assertTrue(schemaManager.getErrors().isEmpty());
    assertEquals(38, schemaManager.getAttributeTypeRegistry().size());
    assertEquals(35, schemaManager.getComparatorRegistry().size());
    assertEquals(35, schemaManager.getMatchingRuleRegistry().size());
    assertEquals(35, 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("bad"));
}
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