Search in sources :

Example 41 with DefaultSchemaManager

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

the class QuirkySchemaTest method testLoadMinimalSchema.

/**
 * Try to load a very minimal (and correct) schema. It has just 'person' objectclass and all
 * the necessary attributes, matching rules and syntaxes. Load it in strict mode.
 * This test is here mostly to make sure that the test itself works.
 */
@Test
public void testLoadMinimalSchema() throws Exception {
    LdapConnection connection = createFakeConnection("src/test/resources/schema-minimal.ldif");
    DefaultSchemaLoader loader = new DefaultSchemaLoader(connection);
    Collection<Schema> allEnabled = loader.getAllEnabled();
    assertEquals(1, allEnabled.size());
    Schema schema = allEnabled.iterator().next();
    assertNotNull(schema);
    assertEquals(26, schema.getContent().size());
    SchemaManager schemaManager = new DefaultSchemaManager(loader);
    boolean loaded = schemaManager.loadAllEnabled();
    if (!loaded) {
        fail("Schema load failed : " + Exceptions.printErrors(schemaManager.getErrors()));
    }
    assertTrue(schemaManager.getRegistries().getAttributeTypeRegistry().contains("cn"));
    ObjectClass person = schemaManager.getRegistries().getObjectClassRegistry().lookup("person");
    assertNotNull(person);
    assertEquals(2, person.getMustAttributeTypes().size());
    assertEquals(4, person.getMayAttributeTypes().size());
}
Also used : ObjectClass(org.apache.directory.api.ldap.model.schema.ObjectClass) Schema(org.apache.directory.api.ldap.model.schema.registries.Schema) 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 42 with DefaultSchemaManager

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

the class ACIItemParserTest method init.

/**
 * Initialization
 */
@BeforeClass
public static void init() throws Exception {
    JarLdifSchemaLoader loader = new JarLdifSchemaLoader();
    SchemaManager schemaManager = new DefaultSchemaManager(loader);
    schemaManager.loadAllEnabled();
    parser = new ACIItemParser(schemaManager);
}
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) BeforeClass(org.junit.BeforeClass)

Example 43 with DefaultSchemaManager

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

the class SchemaAwareEntryTest method setUpBeforeClass.

/**
 * @throws java.lang.Exception
 */
@BeforeClass
public static void setUpBeforeClass() throws Exception {
    exampleDn = new Dn("dc=example,dc=com");
    schemaManager = new DefaultSchemaManager();
}
Also used : Dn(org.apache.directory.api.ldap.model.name.Dn) DefaultSchemaManager(org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager) BeforeClass(org.junit.BeforeClass)

Example 44 with DefaultSchemaManager

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

the class SchemaAwareValueSerializationTest method setup.

/**
 * Initialize OIDs maps for normalization
 */
@BeforeClass
public static void setup() throws Exception {
    schemaManager = new DefaultSchemaManager();
    cn = schemaManager.getAttributeType("cn");
    dc = schemaManager.getAttributeType("dc");
    userCertificate = schemaManager.getAttributeType("userCertificate");
    bv1 = new Value(userCertificate, DATA);
    bv2 = new Value(userCertificate, Strings.EMPTY_BYTES);
    bv3 = new Value(userCertificate, (byte[]) null);
    bv1n = new Value(userCertificate, DATA);
    bv2n = new Value(userCertificate, Strings.EMPTY_BYTES);
    bv3n = new Value(userCertificate, (byte[]) null);
    sv1 = new Value(cn, "test");
    sv2 = new Value(dc, "");
    sv3 = new Value(dc, (String) null);
    sv1n = new Value(cn, "test");
    sv2n = new Value(dc, "");
    sv3n = new Value(dc, (String) null);
}
Also used : Value(org.apache.directory.api.ldap.model.entry.Value) DefaultSchemaManager(org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager) BeforeClass(org.junit.BeforeClass)

Example 45 with DefaultSchemaManager

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

the class MultiThreadedTest method setup.

@BeforeClass
public static void setup() throws Exception {
    schemaManager = new DefaultSchemaManager();
    referenceDn = new Dn(schemaManager, "dc=example,dc=com");
    sharedDn = new Dn(schemaManager, "dc=example,dc=com");
    referenceRdn = new Rdn(schemaManager, "ou=system");
    sharedRdn = new Rdn(schemaManager, "ou=system");
    referenceAva = new Ava(schemaManager, "ou", "System");
    sharedAva = new Ava(schemaManager, "ou", "System");
}
Also used : DefaultSchemaManager(org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager) BeforeClass(org.junit.BeforeClass)

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