Search in sources :

Example 31 with MutableAttributeType

use of org.apache.directory.api.ldap.model.schema.MutableAttributeType in project directory-ldap-api by apache.

the class OpenLdapSchemaParserTest method testSimpleAttributeTypeParse.

@Test
public void testSimpleAttributeTypeParse() throws Exception {
    String attributeTypeData = "# adding a comment  \n" + "attributetype ( 2.5.4.2 NAME 'knowledgeInformation'\n" + "        DESC 'RFC2256: knowledge information'\n" + "        EQUALITY caseIgnoreMatch\n" + "        SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{32768} )";
    parser.parse(attributeTypeData);
    List<MutableAttributeType> attributeTypeList = parser.getAttributeTypes();
    Map<String, AttributeType> attributeTypes = mapAttributeTypes(attributeTypeList);
    AttributeType type = attributeTypes.get("2.5.4.2");
    assertNotNull(type);
    assertEquals("2.5.4.2", type.getOid());
    assertEquals("knowledgeInformation", type.getName());
    assertEquals("RFC2256: knowledge information", type.getDescription());
    assertEquals("1.3.6.1.4.1.1466.115.121.1.15", type.getSyntaxOid());
    assertEquals(32768, type.getSyntaxLength());
}
Also used : AttributeType(org.apache.directory.api.ldap.model.schema.AttributeType) MutableAttributeType(org.apache.directory.api.ldap.model.schema.MutableAttributeType) MutableAttributeType(org.apache.directory.api.ldap.model.schema.MutableAttributeType) Test(org.junit.Test)

Example 32 with MutableAttributeType

use of org.apache.directory.api.ldap.model.schema.MutableAttributeType in project directory-ldap-api by apache.

the class OpenLdapSchemaParserTest method testParseOpenLdapCoreSchema.

@Test
public void testParseOpenLdapCoreSchema() throws Exception {
    InputStream input = getClass().getResourceAsStream("core.schema");
    parser.parse(input);
    List<MutableAttributeType> attributeTypes = parser.getAttributeTypes();
    List<ObjectClass> objectClassTypes = parser.getObjectClassTypes();
    Map<String, OpenLdapObjectIdentifierMacro> objectIdentifierMacros = parser.getObjectIdentifierMacros();
    assertEquals(52, attributeTypes.size());
    assertEquals(27, objectClassTypes.size());
    assertEquals(0, objectIdentifierMacros.size());
}
Also used : ObjectClass(org.apache.directory.api.ldap.model.schema.ObjectClass) OpenLdapObjectIdentifierMacro(org.apache.directory.api.ldap.model.schema.syntaxCheckers.OpenLdapObjectIdentifierMacro) InputStream(java.io.InputStream) MutableAttributeType(org.apache.directory.api.ldap.model.schema.MutableAttributeType) Test(org.junit.Test)

Example 33 with MutableAttributeType

use of org.apache.directory.api.ldap.model.schema.MutableAttributeType in project directory-ldap-api by apache.

the class OpenLdapSchemaParserTest method testParseOpenLdapInetOrgPersonSchema.

@Test
public void testParseOpenLdapInetOrgPersonSchema() throws Exception {
    InputStream input = getClass().getResourceAsStream("inetorgperson.schema");
    parser.parse(input);
    List<MutableAttributeType> attributeTypes = parser.getAttributeTypes();
    List<ObjectClass> objectClassTypes = parser.getObjectClassTypes();
    Map<String, OpenLdapObjectIdentifierMacro> objectIdentifierMacros = parser.getObjectIdentifierMacros();
    assertEquals(9, attributeTypes.size());
    assertEquals(1, objectClassTypes.size());
    assertEquals(0, objectIdentifierMacros.size());
}
Also used : ObjectClass(org.apache.directory.api.ldap.model.schema.ObjectClass) OpenLdapObjectIdentifierMacro(org.apache.directory.api.ldap.model.schema.syntaxCheckers.OpenLdapObjectIdentifierMacro) InputStream(java.io.InputStream) MutableAttributeType(org.apache.directory.api.ldap.model.schema.MutableAttributeType) Test(org.junit.Test)

Example 34 with MutableAttributeType

use of org.apache.directory.api.ldap.model.schema.MutableAttributeType in project directory-ldap-api by apache.

the class OpenLdapSchemaParserTest method testAttributeTypeParseWithSpaceDesc.

/**
 * Test that we can handle a DESC which contains only spaces
 */
@Test
public void testAttributeTypeParseWithSpaceDesc() throws Exception {
    String attributeTypeData = "# adding a comment  \n" + "attributetype ( 2.5.4.2 NAME 'knowledgeInformation'\n" + "        DESC '  '\n" + "        EQUALITY caseIgnoreMatch\n" + "        SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{32768} )";
    parser.parse(attributeTypeData);
    List<MutableAttributeType> attributeTypeList = parser.getAttributeTypes();
    Map<String, AttributeType> attributeTypes = mapAttributeTypes(attributeTypeList);
    AttributeType type = attributeTypes.get("2.5.4.2");
    assertNotNull(type);
    assertEquals("2.5.4.2", type.getOid());
    assertEquals("knowledgeInformation", type.getName());
    assertEquals("  ", type.getDescription());
    assertEquals("1.3.6.1.4.1.1466.115.121.1.15", type.getSyntaxOid());
    assertEquals(32768, type.getSyntaxLength());
}
Also used : AttributeType(org.apache.directory.api.ldap.model.schema.AttributeType) MutableAttributeType(org.apache.directory.api.ldap.model.schema.MutableAttributeType) MutableAttributeType(org.apache.directory.api.ldap.model.schema.MutableAttributeType) Test(org.junit.Test)

Example 35 with MutableAttributeType

use of org.apache.directory.api.ldap.model.schema.MutableAttributeType in project directory-ldap-api by apache.

the class SchemaUtilsTest method getAttributeTypes.

public AttributeType[] getAttributeTypes() {
    MutableAttributeType[] ats = new MutableAttributeType[5];
    ats[0] = new MutableAttributeType("2.5.4.41");
    ats[0].addName("name");
    ats[0].setSyntax(getSyntaxes()[1]);
    ats[0].setSyntaxLength(32768);
    ats[0].setEquality(getMatchingRules()[0]);
    ats[0].setSubstring(getMatchingRules()[1]);
    // ( 2.5.4.3 NAME 'cn' SUP name )
    ats[1] = new MutableAttributeType("2.5.4.3");
    ats[1].addName("cn", "commonName");
    ats[2] = new MutableAttributeType("2.5.4.41");
    ats[2].addName("name");
    ats[2].setSyntax(getSyntaxes()[1]);
    ats[2].setSyntaxLength(32768);
    ats[2].setEquality(getMatchingRules()[0]);
    ats[2].setSubstring(getMatchingRules()[1]);
    ats[3] = new MutableAttributeType("2.5.4.41");
    ats[3].addName("name");
    ats[3].setSyntax(getSyntaxes()[1]);
    ats[3].setSyntaxLength(32768);
    ats[3].setEquality(getMatchingRules()[0]);
    ats[3].setSubstring(getMatchingRules()[1]);
    ats[4] = new MutableAttributeType("2.5.4.41");
    ats[4].addName("name");
    ats[4].setSyntax(getSyntaxes()[1]);
    ats[4].setSyntaxLength(32768);
    ats[4].setEquality(getMatchingRules()[0]);
    ats[4].setSubstring(getMatchingRules()[1]);
    return ats;
}
Also used : MutableAttributeType(org.apache.directory.api.ldap.model.schema.MutableAttributeType)

Aggregations

MutableAttributeType (org.apache.directory.api.ldap.model.schema.MutableAttributeType)55 Test (org.junit.Test)37 SchemaManager (org.apache.directory.api.ldap.model.schema.SchemaManager)24 DefaultSchemaManager (org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager)24 AttributeType (org.apache.directory.api.ldap.model.schema.AttributeType)18 LdapSchemaException (org.apache.directory.api.ldap.model.exception.LdapSchemaException)17 LdapException (org.apache.directory.api.ldap.model.exception.LdapException)10 LdapSyntax (org.apache.directory.api.ldap.model.schema.LdapSyntax)7 PrepareString (org.apache.directory.api.ldap.model.schema.PrepareString)7 MutableMatchingRule (org.apache.directory.api.ldap.model.schema.MutableMatchingRule)6 SyntaxChecker (org.apache.directory.api.ldap.model.schema.SyntaxChecker)6 Normalizer (org.apache.directory.api.ldap.model.schema.Normalizer)5 ObjectClass (org.apache.directory.api.ldap.model.schema.ObjectClass)5 DeepTrimToLowerNormalizer (org.apache.directory.api.ldap.model.schema.normalizers.DeepTrimToLowerNormalizer)5 OpenLdapObjectIdentifierMacro (org.apache.directory.api.ldap.model.schema.syntaxCheckers.OpenLdapObjectIdentifierMacro)5 InputStream (java.io.InputStream)4 MatchingRule (org.apache.directory.api.ldap.model.schema.MatchingRule)4 ByteArrayComparator (org.apache.directory.api.ldap.model.schema.comparators.ByteArrayComparator)4 LdapInvalidDnException (org.apache.directory.api.ldap.model.exception.LdapInvalidDnException)2 LdapProtocolErrorException (org.apache.directory.api.ldap.model.exception.LdapProtocolErrorException)2