Search in sources :

Example 56 with DefaultSchemaManager

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

the class SchemaManagerLoadTest method testLoadCollective.

/**
 * test loading the "Collective" schema, which depends on "system" and "core"
 */
@Test
public void testLoadCollective() throws Exception {
    LdifSchemaLoader loader = new LdifSchemaLoader(schemaRepository);
    SchemaManager schemaManager = new DefaultSchemaManager(loader);
    assertTrue(schemaManager.load("system"));
    assertTrue(schemaManager.load("core"));
    assertTrue(schemaManager.load("Collective"));
    assertTrue(schemaManager.getErrors().isEmpty());
    assertEquals(105, 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(249, schemaManager.getGlobalOidRegistry().size());
    assertEquals(3, schemaManager.getRegistries().getLoadedSchemas().size());
    assertNotNull(schemaManager.getRegistries().getLoadedSchema("system"));
    assertNotNull(schemaManager.getRegistries().getLoadedSchema("core"));
    assertNotNull(schemaManager.getRegistries().getLoadedSchema("collective"));
}
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 57 with DefaultSchemaManager

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

the class SchemaManagerLoadTest method testLoadSchemasWithDepsCoreInetOrgPersonAndBad.

// ---------------------------------------------------------------------------
// Test the load( Schema... ) method
// ---------------------------------------------------------------------------
/**
 * test loading the "InetOrgPerson", "core" and an empty schema. The empty schema
 * should be present in the registries, as it's a vaid schema
 */
@Test
public void testLoadSchemasWithDepsCoreInetOrgPersonAndBad() throws Exception {
    LdifSchemaLoader loader = new LdifSchemaLoader(schemaRepository);
    SchemaManager schemaManager = new DefaultSchemaManager(loader);
    Schema system = loader.getSchema("system");
    Schema core = loader.getSchema("core");
    Schema empty = new DefaultSchema(loader, "empty");
    Schema cosine = loader.getSchema("cosine");
    Schema inetOrgPerson = loader.getSchema("InetOrgPerson");
    assertTrue(schemaManager.load(system, core, empty, cosine, 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(5, schemaManager.getRegistries().getLoadedSchemas().size());
    assertNotNull(schemaManager.getRegistries().getLoadedSchema("system"));
    assertNotNull(schemaManager.getRegistries().getLoadedSchema("core"));
    assertNotNull(schemaManager.getRegistries().getLoadedSchema("cosine"));
    assertNotNull(schemaManager.getRegistries().getLoadedSchema("InetOrgPerson"));
    assertNotNull(schemaManager.getRegistries().getLoadedSchema("empty"));
}
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 58 with DefaultSchemaManager

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

the class JarLdifSchemaLoaderTest method testJarLdifSchemaLoader.

@Test
public void testJarLdifSchemaLoader() throws Exception {
    JarLdifSchemaLoader loader = new JarLdifSchemaLoader();
    SchemaManager sm = new DefaultSchemaManager(loader);
    sm.loadWithDeps("system");
    assertTrue(sm.getRegistries().getAttributeTypeRegistry().contains("cn"));
    assertFalse(sm.getRegistries().getAttributeTypeRegistry().contains("m-aux"));
    sm.loadWithDeps("apachemeta");
    assertTrue(sm.getRegistries().getAttributeTypeRegistry().contains("m-aux"));
}
Also used : JarLdifSchemaLoader(org.apache.directory.api.ldap.schema.loader.JarLdifSchemaLoader) DefaultSchemaManager(org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager) SchemaManager(org.apache.directory.api.ldap.model.schema.SchemaManager) DefaultSchemaManager(org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager) Test(org.junit.Test)

Example 59 with DefaultSchemaManager

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

the class MatchingRuleTest method setup.

@BeforeClass
public static void setup() throws Exception {
    workingDirectory = System.getProperty("workingDirectory");
    if (workingDirectory == null) {
        String path = MatchingRuleTest.class.getResource("").getPath();
        int targetPos = path.indexOf("target");
        workingDirectory = path.substring(0, targetPos + 6);
    }
    schemaRepository = new File(workingDirectory, "schema");
    // Cleanup the target directory
    FileUtils.deleteDirectory(schemaRepository);
    SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor(new File(workingDirectory));
    extractor.extractOrCopy();
    LdifSchemaLoader loader = new LdifSchemaLoader(schemaRepository);
    schemaManager = new DefaultSchemaManager(loader);
    for (Schema schema : loader.getAllSchemas()) {
        schema.enable();
    }
    schemaManager.loadAllEnabled();
}
Also used : Schema(org.apache.directory.api.ldap.model.schema.registries.Schema) SchemaLdifExtractor(org.apache.directory.api.ldap.schema.extractor.SchemaLdifExtractor) DefaultSchemaLdifExtractor(org.apache.directory.api.ldap.schema.extractor.impl.DefaultSchemaLdifExtractor) DefaultSchemaLdifExtractor(org.apache.directory.api.ldap.schema.extractor.impl.DefaultSchemaLdifExtractor) File(java.io.File) DefaultSchemaManager(org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager) BeforeClass(org.junit.BeforeClass)

Example 60 with DefaultSchemaManager

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

the class SchemaManagerLoadWithDepsTest method testLoadWithDepsCoreInetOrgPersonAndNis.

/**
 * test loading the "InetOrgPerson", "core" and a disabled schema
 */
@Test
public void testLoadWithDepsCoreInetOrgPersonAndNis() throws Exception {
    LdifSchemaLoader loader = new LdifSchemaLoader(schemaRepository);
    SchemaManager schemaManager = new DefaultSchemaManager(loader);
    Schema system = loader.getSchema("system");
    Schema core = loader.getSchema("core");
    Schema empty = new DefaultSchema(loader, "empty");
    Schema cosine = loader.getSchema("cosine");
    Schema inetOrgPerson = loader.getSchema("InetOrgPerson");
    assertTrue(schemaManager.load(system, core, empty, cosine, 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(5, 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 : 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)

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