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