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