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"));
}
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"));
}
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"));
}
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"));
}
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"));
}
Aggregations