Search in sources :

Example 1 with LdapProtocolErrorException

use of org.apache.directory.api.ldap.model.exception.LdapProtocolErrorException in project directory-ldap-api by apache.

the class SchemaManagerDelTest method testDeleteExistingComaparatorUsedByMatchingRule.

@Test
public void testDeleteExistingComaparatorUsedByMatchingRule() throws Exception {
    SchemaManager schemaManager = loadSchema("system");
    int ctrSize = schemaManager.getComparatorRegistry().size();
    int goidSize = schemaManager.getGlobalOidRegistry().size();
    LdapComparator<?> lc = schemaManager.lookupComparatorRegistry("2.5.13.0");
    // shouldn't be deleted cause there is a MR associated with it
    assertFalse(schemaManager.delete(lc));
    List<Throwable> errors = schemaManager.getErrors();
    assertFalse(errors.isEmpty());
    assertTrue(errors.get(0) instanceof LdapProtocolErrorException);
    assertNotNull(schemaManager.lookupComparatorRegistry("2.5.13.0"));
    assertEquals(ctrSize, schemaManager.getComparatorRegistry().size());
    assertEquals(goidSize, schemaManager.getGlobalOidRegistry().size());
}
Also used : LdapProtocolErrorException(org.apache.directory.api.ldap.model.exception.LdapProtocolErrorException) SchemaManager(org.apache.directory.api.ldap.model.schema.SchemaManager) DefaultSchemaManager(org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager) Test(org.junit.Test)

Example 2 with LdapProtocolErrorException

use of org.apache.directory.api.ldap.model.exception.LdapProtocolErrorException in project directory-ldap-api by apache.

the class SchemaManagerDelTest method testDeleteExistingObjectClassUsedByAnotherObjectClass.

@Test
public void testDeleteExistingObjectClassUsedByAnotherObjectClass() throws Exception {
    SchemaManager schemaManager = loadSchema("system");
    int ocSize = schemaManager.getObjectClassRegistry().size();
    int goidSize = schemaManager.getGlobalOidRegistry().size();
    ObjectClass oc = new ObjectClass("2.5.6.0");
    // shouldn't delete the 'top' OC
    assertFalse(schemaManager.delete(oc));
    List<Throwable> errors = schemaManager.getErrors();
    assertFalse(errors.isEmpty());
    assertTrue(errors.get(0) instanceof LdapProtocolErrorException);
    assertEquals(ocSize, schemaManager.getObjectClassRegistry().size());
    assertEquals(goidSize, schemaManager.getGlobalOidRegistry().size());
}
Also used : ObjectClass(org.apache.directory.api.ldap.model.schema.ObjectClass) LdapProtocolErrorException(org.apache.directory.api.ldap.model.exception.LdapProtocolErrorException) SchemaManager(org.apache.directory.api.ldap.model.schema.SchemaManager) DefaultSchemaManager(org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager) Test(org.junit.Test)

Example 3 with LdapProtocolErrorException

use of org.apache.directory.api.ldap.model.exception.LdapProtocolErrorException in project directory-ldap-api by apache.

the class SchemaManagerDelTest method testDeleteExistingMatchingRuleUsedByRemovedAttributeType.

/**
 * Check that a MatcingRule which has been used by a deleted AttributeType
 * can be removed
 */
@Test
public void testDeleteExistingMatchingRuleUsedByRemovedAttributeType() throws Exception {
    SchemaManager schemaManager = loadSchema("system");
    int mrrSize = schemaManager.getMatchingRuleRegistry().size();
    int atrSize = schemaManager.getAttributeTypeRegistry().size();
    int goidSize = schemaManager.getGlobalOidRegistry().size();
    String AT_OID = "2.5.18.9";
    String MR_OID = "2.5.13.13";
    // Check that the AT and MR are present
    assertTrue(isAttributeTypePresent(schemaManager, AT_OID));
    assertTrue(isMatchingRulePresent(schemaManager, MR_OID));
    // Now try to remove the MR
    MatchingRule matchingRule = schemaManager.lookupMatchingRuleRegistry(MR_OID);
    // shouldn't be deleted cause there is a AT associated with it
    assertFalse(schemaManager.delete(matchingRule));
    List<Throwable> errors = schemaManager.getErrors();
    assertFalse(errors.isEmpty());
    assertTrue(errors.get(0) instanceof LdapProtocolErrorException);
    // Now delete the using AT : it should be OK
    MutableAttributeType at = new MutableAttributeType(AT_OID);
    assertTrue(schemaManager.delete(at));
    assertEquals(atrSize - 1, schemaManager.getAttributeTypeRegistry().size());
    assertEquals(goidSize - 1, schemaManager.getGlobalOidRegistry().size());
    assertFalse(isAttributeTypePresent(schemaManager, AT_OID));
    // and try to delete the MatchingRule again
    assertTrue(schemaManager.delete(matchingRule));
    assertFalse(isMatchingRulePresent(schemaManager, MR_OID));
    assertEquals(mrrSize - 1, schemaManager.getMatchingRuleRegistry().size());
    assertEquals(goidSize - 2, schemaManager.getGlobalOidRegistry().size());
}
Also used : LdapProtocolErrorException(org.apache.directory.api.ldap.model.exception.LdapProtocolErrorException) SchemaManager(org.apache.directory.api.ldap.model.schema.SchemaManager) DefaultSchemaManager(org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager) MutableAttributeType(org.apache.directory.api.ldap.model.schema.MutableAttributeType) MatchingRule(org.apache.directory.api.ldap.model.schema.MatchingRule) Test(org.junit.Test)

Example 4 with LdapProtocolErrorException

use of org.apache.directory.api.ldap.model.exception.LdapProtocolErrorException in project directory-ldap-api by apache.

the class SchemaManagerDelTest method testDeleteExistingSyntaxUsedByRemovedAttributeType.

/**
 * Check that a Syntax which has been used by a deleted AttributeType
 * can be removed
 */
@Test
public void testDeleteExistingSyntaxUsedByRemovedAttributeType() throws Exception {
    SchemaManager schemaManager = loadSchema("system");
    int srSize = schemaManager.getLdapSyntaxRegistry().size();
    int atrSize = schemaManager.getAttributeTypeRegistry().size();
    int goidSize = schemaManager.getGlobalOidRegistry().size();
    String AT_OID = "1.3.6.1.4.1.1466.101.120.16";
    String S_OID = "1.3.6.1.4.1.1466.115.121.1.54";
    // Check that the AT and S are present
    assertTrue(isAttributeTypePresent(schemaManager, AT_OID));
    assertTrue(isSyntaxPresent(schemaManager, S_OID));
    // Now try to remove the S
    LdapSyntax syntax = schemaManager.lookupLdapSyntaxRegistry(S_OID);
    // shouldn't be deleted cause there is a AT associated with it
    assertFalse(schemaManager.delete(syntax));
    List<Throwable> errors = schemaManager.getErrors();
    assertFalse(errors.isEmpty());
    assertTrue(errors.get(0) instanceof LdapProtocolErrorException);
    // Now delete the using AT : it should be OK
    MutableAttributeType at = new MutableAttributeType(AT_OID);
    assertTrue(schemaManager.delete(at));
    assertEquals(atrSize - 1, schemaManager.getAttributeTypeRegistry().size());
    assertEquals(goidSize - 1, schemaManager.getGlobalOidRegistry().size());
    assertFalse(isAttributeTypePresent(schemaManager, AT_OID));
    // and try to delete the syntax again
    assertTrue(schemaManager.delete(syntax));
    assertFalse(isSyntaxPresent(schemaManager, S_OID));
    assertEquals(srSize - 1, schemaManager.getLdapSyntaxRegistry().size());
    assertEquals(goidSize - 2, schemaManager.getGlobalOidRegistry().size());
}
Also used : LdapProtocolErrorException(org.apache.directory.api.ldap.model.exception.LdapProtocolErrorException) LdapSyntax(org.apache.directory.api.ldap.model.schema.LdapSyntax) SchemaManager(org.apache.directory.api.ldap.model.schema.SchemaManager) DefaultSchemaManager(org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager) MutableAttributeType(org.apache.directory.api.ldap.model.schema.MutableAttributeType) Test(org.junit.Test)

Example 5 with LdapProtocolErrorException

use of org.apache.directory.api.ldap.model.exception.LdapProtocolErrorException in project directory-ldap-api by apache.

the class SchemaManagerDelTest method testDeleteExistingSyntaxUsedByRemovedMatchingRule.

/**
 * Check that a Syntax which has been used by a deleted MatchingRule
 * can be removed
 */
@Test
public void testDeleteExistingSyntaxUsedByRemovedMatchingRule() throws Exception {
    SchemaManager schemaManager = loadSchema("system");
    int srSize = schemaManager.getLdapSyntaxRegistry().size();
    int mrrSize = schemaManager.getMatchingRuleRegistry().size();
    int goidSize = schemaManager.getGlobalOidRegistry().size();
    String MR_OID = "2.5.13.11";
    String S_OID = "1.3.6.1.4.1.1466.115.121.1.41";
    // Check that the MR and S are present
    assertTrue(isMatchingRulePresent(schemaManager, MR_OID));
    assertTrue(isSyntaxPresent(schemaManager, S_OID));
    // Now try to remove the S
    LdapSyntax syntax = schemaManager.lookupLdapSyntaxRegistry(S_OID);
    // shouldn't be deleted cause there is a MR associated with it
    assertFalse(schemaManager.delete(syntax));
    List<Throwable> errors = schemaManager.getErrors();
    assertFalse(errors.isEmpty());
    assertTrue(errors.get(0) instanceof LdapProtocolErrorException);
    // Now delete the using MR : it should be OK
    MatchingRule mr = new MatchingRule(MR_OID);
    assertTrue(schemaManager.delete(mr));
    assertEquals(mrrSize - 1, schemaManager.getMatchingRuleRegistry().size());
    assertEquals(goidSize - 1, schemaManager.getGlobalOidRegistry().size());
    assertFalse(isMatchingRulePresent(schemaManager, MR_OID));
    // and try to delete the syntax again
    assertTrue(schemaManager.delete(syntax));
    assertFalse(isSyntaxPresent(schemaManager, S_OID));
    assertEquals(srSize - 1, schemaManager.getLdapSyntaxRegistry().size());
    assertEquals(goidSize - 2, schemaManager.getGlobalOidRegistry().size());
}
Also used : LdapProtocolErrorException(org.apache.directory.api.ldap.model.exception.LdapProtocolErrorException) LdapSyntax(org.apache.directory.api.ldap.model.schema.LdapSyntax) SchemaManager(org.apache.directory.api.ldap.model.schema.SchemaManager) DefaultSchemaManager(org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager) MatchingRule(org.apache.directory.api.ldap.model.schema.MatchingRule) Test(org.junit.Test)

Aggregations

LdapProtocolErrorException (org.apache.directory.api.ldap.model.exception.LdapProtocolErrorException)14 SchemaManager (org.apache.directory.api.ldap.model.schema.SchemaManager)10 DefaultSchemaManager (org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager)10 Test (org.junit.Test)10 MatchingRule (org.apache.directory.api.ldap.model.schema.MatchingRule)4 LdapSyntax (org.apache.directory.api.ldap.model.schema.LdapSyntax)3 Schema (org.apache.directory.api.ldap.model.schema.registries.Schema)3 LdapOtherException (org.apache.directory.api.ldap.model.exception.LdapOtherException)2 LoadableSchemaObject (org.apache.directory.api.ldap.model.schema.LoadableSchemaObject)2 MutableAttributeType (org.apache.directory.api.ldap.model.schema.MutableAttributeType)2 Normalizer (org.apache.directory.api.ldap.model.schema.Normalizer)2 SchemaObject (org.apache.directory.api.ldap.model.schema.SchemaObject)2 SyntaxChecker (org.apache.directory.api.ldap.model.schema.SyntaxChecker)2 BooleanNormalizer (org.apache.directory.api.ldap.model.schema.normalizers.BooleanNormalizer)2 Registries (org.apache.directory.api.ldap.model.schema.registries.Registries)2 BooleanSyntaxChecker (org.apache.directory.api.ldap.model.schema.syntaxCheckers.BooleanSyntaxChecker)2 AuthenticationException (javax.naming.AuthenticationException)1 AuthenticationNotSupportedException (javax.naming.AuthenticationNotSupportedException)1 CommunicationException (javax.naming.CommunicationException)1 ContextNotEmptyException (javax.naming.ContextNotEmptyException)1