Java Code Examples for org.apache.directory.api.ldap.model.schema.SchemaManager#loadWithDeps()

The following examples show how to use org.apache.directory.api.ldap.model.schema.SchemaManager#loadWithDeps() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SchemaManagerLoadWithDepsTest.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * test loading the "system" schema
 */
@Test
public void testLoadSystem() throws Exception
{
    LdifSchemaLoader loader = new LdifSchemaLoader( schemaRepository );
    SchemaManager schemaManager = new DefaultSchemaManager( loader );

    schemaManager.loadWithDeps( "system" );

    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" ) );
}
 
Example 2
Source File: SchemaManagerLoadWithDepsTest.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * test loading the "core" schema, which depends on "system"
 */
@Test
public void testLoadCore() throws Exception
{
    LdifSchemaLoader loader = new LdifSchemaLoader( schemaRepository );
    SchemaManager schemaManager = new DefaultSchemaManager( loader );

    schemaManager.loadWithDeps( "core" );

    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( 2, schemaManager.getRegistries().getLoadedSchemas().size() );
    assertNotNull( schemaManager.getRegistries().getLoadedSchema( "system" ) );
    assertNotNull( schemaManager.getRegistries().getLoadedSchema( "core" ) );
}
 
Example 3
Source File: SchemaManagerLoadWithDepsTest.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * test loading the "apache" schema, which depends on "system" and "core"
 */
@Test
public void testLoadApache() throws Exception
{
    LdifSchemaLoader loader = new LdifSchemaLoader( schemaRepository );
    SchemaManager schemaManager = new DefaultSchemaManager( loader );

    schemaManager.loadWithDeps( "apache" );

    assertTrue( schemaManager.getErrors().isEmpty() );
    assertEquals( 148, schemaManager.getAttributeTypeRegistry().size() );
    assertEquals( 44, schemaManager.getComparatorRegistry().size() );
    assertEquals( 50, schemaManager.getMatchingRuleRegistry().size() );
    assertEquals( 43, schemaManager.getNormalizerRegistry().size() );
    assertEquals( 53, schemaManager.getObjectClassRegistry().size() );
    assertEquals( 62, schemaManager.getSyntaxCheckerRegistry().size() );
    assertEquals( 73, schemaManager.getLdapSyntaxRegistry().size() );
    assertEquals( 324, schemaManager.getGlobalOidRegistry().size() );

    assertEquals( 3, schemaManager.getRegistries().getLoadedSchemas().size() );
    assertNotNull( schemaManager.getRegistries().getLoadedSchema( "system" ) );
    assertNotNull( schemaManager.getRegistries().getLoadedSchema( "core" ) );
    assertNotNull( schemaManager.getRegistries().getLoadedSchema( "apache" ) );
}
 
Example 4
Source File: SchemaManagerLoadWithDepsTest.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * 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 );

    schemaManager.loadWithDeps( "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" ) );
}
 
Example 5
Source File: SchemaManagerLoadWithDepsTest.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * test loading the "java" schema, which depends on "system" and "core"
 */
@Test
public void testLoadJava() throws Exception
{
    LdifSchemaLoader loader = new LdifSchemaLoader( schemaRepository );
    SchemaManager schemaManager = new DefaultSchemaManager( loader );

    schemaManager.loadWithDeps( "Java" );

    assertTrue( schemaManager.getErrors().isEmpty() );
    assertEquals( 99, schemaManager.getAttributeTypeRegistry().size() );
    assertEquals( 36, schemaManager.getComparatorRegistry().size() );
    assertEquals( 42, schemaManager.getMatchingRuleRegistry().size() );
    assertEquals( 35, schemaManager.getNormalizerRegistry().size() );
    assertEquals( 41, schemaManager.getObjectClassRegistry().size() );
    assertEquals( 59, schemaManager.getSyntaxCheckerRegistry().size() );
    assertEquals( 66, schemaManager.getLdapSyntaxRegistry().size() );
    assertEquals( 248, schemaManager.getGlobalOidRegistry().size() );

    assertEquals( 3, schemaManager.getRegistries().getLoadedSchemas().size() );
    assertNotNull( schemaManager.getRegistries().getLoadedSchema( "system" ) );
    assertNotNull( schemaManager.getRegistries().getLoadedSchema( "core" ) );
    assertNotNull( schemaManager.getRegistries().getLoadedSchema( "Java" ) );
}
 
Example 6
Source File: SchemaManagerLoadWithDepsTest.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * test loading the "other" schema, which depends on "system", "core",
 * "apache" and "apacheMeta"
 */
@Test
public void testLoadOther() throws Exception
{
    LdifSchemaLoader loader = new LdifSchemaLoader( schemaRepository );
    SchemaManager schemaManager = new DefaultSchemaManager( loader );

    schemaManager.loadWithDeps( "other" );

    assertTrue( schemaManager.getErrors().isEmpty() );
    assertEquals( 181, schemaManager.getAttributeTypeRegistry().size() );
    assertEquals( 49, schemaManager.getComparatorRegistry().size() );
    assertEquals( 55, schemaManager.getMatchingRuleRegistry().size() );
    assertEquals( 48, schemaManager.getNormalizerRegistry().size() );
    assertEquals( 66, schemaManager.getObjectClassRegistry().size() );
    assertEquals( 66, schemaManager.getSyntaxCheckerRegistry().size() );
    assertEquals( 78, schemaManager.getLdapSyntaxRegistry().size() );
    assertEquals( 380, schemaManager.getGlobalOidRegistry().size() );

    assertEquals( 5, schemaManager.getRegistries().getLoadedSchemas().size() );
    assertNotNull( schemaManager.getRegistries().getLoadedSchema( "system" ) );
    assertNotNull( schemaManager.getRegistries().getLoadedSchema( "core" ) );
    assertNotNull( schemaManager.getRegistries().getLoadedSchema( "apache" ) );
    assertNotNull( schemaManager.getRegistries().getLoadedSchema( "apacheMeta" ) );
    assertNotNull( schemaManager.getRegistries().getLoadedSchema( "other" ) );
}
 
Example 7
Source File: SchemaManagerLoadWithDepsTest.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * test loading the "cosine" schema, which depends on "system" and "core"
 */
@Test
public void testLoadCosine() throws Exception
{
    LdifSchemaLoader loader = new LdifSchemaLoader( schemaRepository );
    SchemaManager schemaManager = new DefaultSchemaManager( loader.getAllSchemas() );

    schemaManager.loadWithDeps( "cosine" );

    assertTrue( schemaManager.getErrors().isEmpty() );
    assertEquals( 133, schemaManager.getAttributeTypeRegistry().size() );
    assertEquals( 36, schemaManager.getComparatorRegistry().size() );
    assertEquals( 42, schemaManager.getMatchingRuleRegistry().size() );
    assertEquals( 35, schemaManager.getNormalizerRegistry().size() );
    assertEquals( 49, schemaManager.getObjectClassRegistry().size() );
    assertEquals( 59, schemaManager.getSyntaxCheckerRegistry().size() );
    assertEquals( 66, schemaManager.getLdapSyntaxRegistry().size() );
    assertEquals( 290, schemaManager.getGlobalOidRegistry().size() );

    assertEquals( 3, schemaManager.getRegistries().getLoadedSchemas().size() );
    assertNotNull( schemaManager.getRegistries().getLoadedSchema( "system" ) );
    assertNotNull( schemaManager.getRegistries().getLoadedSchema( "core" ) );
    assertNotNull( schemaManager.getRegistries().getLoadedSchema( "cosine" ) );
}
 
Example 8
Source File: SchemaManagerLoadWithDepsTest.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * test loading the "InetOrgPerson" schema, which depends on "system", "core"
 * and "cosine"
 */
@Test
public void testLoadInetOrgPerson() throws Exception
{
    LdifSchemaLoader loader = new LdifSchemaLoader( schemaRepository );
    SchemaManager schemaManager = new DefaultSchemaManager( loader );

    schemaManager.loadWithDeps( "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( 4, schemaManager.getRegistries().getLoadedSchemas().size() );
    assertNotNull( schemaManager.getRegistries().getLoadedSchema( "system" ) );
    assertNotNull( schemaManager.getRegistries().getLoadedSchema( "core" ) );
    assertNotNull( schemaManager.getRegistries().getLoadedSchema( "cosine" ) );
    assertNotNull( schemaManager.getRegistries().getLoadedSchema( "InetOrgPerson" ) );
}
 
Example 9
Source File: SchemaManagerLoadWithDepsTest.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * 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 );

    schemaManager.loadWithDeps( "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" ) );
}
 
Example 10
Source File: SchemaManagerLoadWithDepsTest.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * test loading the "nis" schema, which depends on "system", "core" and "cosine",
 * but is disabled
 */
@Test
public void testLoadNis() throws Exception
{
    LdifSchemaLoader loader = new LdifSchemaLoader( schemaRepository );
    SchemaManager schemaManager = new DefaultSchemaManager( loader );

    schemaManager.loadWithDeps( "nis" );

    assertTrue( 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( "system" ) );
    assertNull( schemaManager.getRegistries().getLoadedSchema( "core" ) );
    assertNull( schemaManager.getRegistries().getLoadedSchema( "cosine" ) );
}
 
Example 11
Source File: SchemaManagerLoadWithDepsTest.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * test loading the "rfc2307bis" schema, which depends on "system", "nis" and "core",
 * but is disabled
 */
@Test
public void testLoadRfc2307Bis() throws Exception
{
    LdifSchemaLoader loader = new LdifSchemaLoader( schemaRepository );
    SchemaManager schemaManager = new DefaultSchemaManager( loader );

    schemaManager.loadWithDeps( "rfc2307bis" );

    assertTrue( 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( "system" ) );
    assertNull( schemaManager.getRegistries().getLoadedSchema( "nis" ) );
    assertNull( schemaManager.getRegistries().getLoadedSchema( "core" ) );
}
 
Example 12
Source File: SchemaManagerLoadWithDepsTest.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * test loading the "InetOrgPerson", "core" and a disabled schema
 */
@Test
public void testLoadCoreInetOrgPersonAndNis() throws Exception
{
    LdifSchemaLoader loader = new LdifSchemaLoader( schemaRepository );
    SchemaManager schemaManager = new DefaultSchemaManager( loader );

    schemaManager.loadWithDeps( "core", "nis", "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( 4, schemaManager.getRegistries().getLoadedSchemas().size() );
    assertNotNull( schemaManager.getRegistries().getLoadedSchema( "system" ) );
    assertNotNull( schemaManager.getRegistries().getLoadedSchema( "core" ) );
    assertNotNull( schemaManager.getRegistries().getLoadedSchema( "cosine" ) );
    assertNotNull( schemaManager.getRegistries().getLoadedSchema( "InetOrgPerson" ) );
}
 
Example 13
Source File: SchemaManagerLoadWithDepsTest.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * test loading the "InetOrgPerson" and "core" schema, which depends on "system" and "cosine"
 */
@Test
public void testLoadCoreAndInetOrgPerson() throws Exception
{
    LdifSchemaLoader loader = new LdifSchemaLoader( schemaRepository );
    SchemaManager schemaManager = new DefaultSchemaManager( loader );

    schemaManager.loadWithDeps( "core", "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( 4, schemaManager.getRegistries().getLoadedSchemas().size() );
    assertNotNull( schemaManager.getRegistries().getLoadedSchema( "system" ) );
    assertNotNull( schemaManager.getRegistries().getLoadedSchema( "core" ) );
    assertNotNull( schemaManager.getRegistries().getLoadedSchema( "cosine" ) );
    assertNotNull( schemaManager.getRegistries().getLoadedSchema( "InetOrgPerson" ) );
}
 
Example 14
Source File: JarLdifSchemaLoaderTest.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
@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" ) );
}
 
Example 15
Source File: SchemaManagerAddTest.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
/**
 * Addition of an OC with a collective AT present in MUST or MAY.
 */
@Test
public void testAddObjectClassNoSuperiorCollectiveATInMustOrMay() throws Exception
{
    SchemaManager schemaManager = loadSystem();
    schemaManager.loadWithDeps( "collective" );
    int ocrSize = schemaManager.getObjectClassRegistry().size();
    int goidSize = schemaManager.getGlobalOidRegistry().size();

    // Check a addition in MUST
    ObjectClass objectClassMust = new ObjectClass( "1.1.1" );
    objectClassMust.addMustAttributeTypeOids( "c-o", "ref" );

    // collective attribute in MUST : failure expected
    assertFalse( schemaManager.add( objectClassMust ) );

    assertEquals( 1, schemaManager.getErrors().size() );
    assertTrue( schemaManager.getErrors().get( 0 ) instanceof LdapSchemaException );

    assertFalse( isOCPresent( schemaManager, "1.1.1" ) );

    assertEquals( ocrSize, schemaManager.getObjectClassRegistry().size() );
    assertEquals( goidSize, schemaManager.getGlobalOidRegistry().size() );

    // Check an addition in MAY
    ObjectClass objectClassMay = new ObjectClass( "1.1.1" );
    objectClassMay.addMayAttributeTypeOids( "c-o", "ref" );

    // collective attribute in MAY : failure expected
    assertFalse( schemaManager.add( objectClassMay ) );

    assertEquals( 1, schemaManager.getErrors().size() );
    assertTrue( schemaManager.getErrors().get( 0 ) instanceof LdapSchemaException );

    assertFalse( isOCPresent( schemaManager, "1.1.1" ) );

    assertEquals( ocrSize, schemaManager.getObjectClassRegistry().size() );
    assertEquals( goidSize, schemaManager.getGlobalOidRegistry().size() );
}
 
Example 16
Source File: SchemaManagerAddTest.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
private SchemaManager loadSystem() throws Exception
{
    LdifSchemaLoader loader = new LdifSchemaLoader( schemaRepository );
    SchemaManager schemaManager = new DefaultSchemaManager( loader );

    String schemaName = "system";

    schemaManager.loadWithDeps( schemaName );

    return schemaManager;
}
 
Example 17
Source File: SchemaManagerLoadWithDepsTest.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
/**
 * test loading the "InetOrgPerson", "core" and a bad schema
 */
@Test
public void testLoadCoreInetOrgPersonAndBad() throws Exception
{
    LdifSchemaLoader loader = new LdifSchemaLoader( schemaRepository );
    SchemaManager schemaManager = new DefaultSchemaManager( loader );

    try
    {
        schemaManager.loadWithDeps( "core", "bad", "InetOrgPerson" );
        fail();
    }
    catch ( LdapUnwillingToPerformException lonse )
    {
        // expected
    }

    // No SchemaObject should be loaded as we had an error
    assertTrue( 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( "system" ) );
    assertNull( schemaManager.getRegistries().getLoadedSchema( "core" ) );
    assertNull( schemaManager.getRegistries().getLoadedSchema( "cosine" ) );
    assertNull( schemaManager.getRegistries().getLoadedSchema( "InetOrgPerson" ) );
}
 
Example 18
Source File: SchemaManagerLoadWithDepsTest.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
/**
 * Test loading a wrong schema
 */
@Test
public void testLoadWrongSchema() throws Exception
{
    LdifSchemaLoader loader = new LdifSchemaLoader( schemaRepository );
    SchemaManager schemaManager = new DefaultSchemaManager( loader );

    try
    {
        schemaManager.loadWithDeps( "bad" );
        fail();
    }
    catch ( LdapUnwillingToPerformException lonse )
    {
        // expected
    }

    assertTrue( 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() );
}
 
Example 19
Source File: SchemaManagerLoadTest.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
/**
 * 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" ) );
}
 
Example 20
Source File: SchemaManagerDelTest.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
private SchemaManager loadSchema( String schemaName ) throws Exception
{
    LdifSchemaLoader loader = new LdifSchemaLoader( schemaRepository );
    SchemaManager schemaManager = new DefaultSchemaManager( loader );

    schemaManager.loadWithDeps( schemaName );

    return schemaManager;
}