use of org.apache.directory.api.ldap.model.schema.MutableAttributeType in project directory-ldap-api by apache.
the class OpenLdapSchemaParserTest method testSimpleAttributeTypeNoLength.
@Test
public void testSimpleAttributeTypeNoLength() throws Exception {
String attributeTypeData = "attributetype ( 2.5.4.14 NAME 'searchGuide'\n" + " DESC 'RFC2256: search guide, obsoleted by enhancedSearchGuide'\n" + " SYNTAX 1.3.6.1.4.1.1466.115.121.1.25 )";
parser.parse(attributeTypeData);
List<MutableAttributeType> attributeTypes = parser.getAttributeTypes();
Map<String, AttributeType> mapAttributeTypes = mapAttributeTypes(attributeTypes);
AttributeType attributeType = mapAttributeTypes.get("2.5.4.14");
assertNotNull(attributeType);
assertEquals("2.5.4.14", attributeType.getOid());
assertEquals("searchGuide", attributeType.getName());
assertEquals("RFC2256: search guide, obsoleted by enhancedSearchGuide", attributeType.getDescription());
assertEquals("1.3.6.1.4.1.1466.115.121.1.25", attributeType.getSyntaxOid());
}
use of org.apache.directory.api.ldap.model.schema.MutableAttributeType in project directory-ldap-api by apache.
the class OpenLdapSchemaParserTest method testDescWithSpaces.
@Test
public void testDescWithSpaces() throws Exception {
String attributeTypeData = "attributetype ( 1.3.6.1.4.1.8104.1.1.37 NAME 'versionNumber'\n" + " DESC 'versionNumber ' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch\n" + " SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE)";
parser.parse(attributeTypeData);
List<MutableAttributeType> attributeTypes = parser.getAttributeTypes();
Map<String, AttributeType> mapAttributeTypes = mapAttributeTypes(attributeTypes);
AttributeType attributeType = mapAttributeTypes.get("1.3.6.1.4.1.8104.1.1.37");
assertNotNull(attributeType);
assertEquals("1.3.6.1.4.1.8104.1.1.37", attributeType.getOid());
assertEquals("versionNumber", attributeType.getName());
assertEquals("versionNumber ", attributeType.getDescription());
assertEquals("1.3.6.1.4.1.1466.115.121.1.15", attributeType.getSyntaxOid());
assertTrue(attributeType.isSingleValued());
}
use of org.apache.directory.api.ldap.model.schema.MutableAttributeType in project directory-ldap-api by apache.
the class OpenLdapSchemaParserTest method testAttributeTypeParseWithDescQuotes.
@Test
public void testAttributeTypeParseWithDescQuotes() 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 testOpenLdapObjectIdentifiereMacros.
@Test
public void testOpenLdapObjectIdentifiereMacros() throws Exception {
InputStream input = getClass().getResourceAsStream("dyngroup.schema");
parser.parse(input);
List<MutableAttributeType> attributeTypes = parser.getAttributeTypes();
List<ObjectClass> objectClassTypes = parser.getObjectClassTypes();
Map<String, OpenLdapObjectIdentifierMacro> objectIdentifierMacros = parser.getObjectIdentifierMacros();
assertEquals(2, attributeTypes.size());
assertEquals(2, objectClassTypes.size());
assertEquals(8, objectIdentifierMacros.size());
// check that all macros are resolved
for (OpenLdapObjectIdentifierMacro macro : objectIdentifierMacros.values()) {
assertTrue(macro.isResolved());
assertNotNull(macro.getResolvedOid());
assertTrue(macro.getResolvedOid().matches("[0-9]+(\\.[0-9]+)+"));
}
// check that OIDs in attribute types and object classes are resolved
for (ObjectClass objectClass : objectClassTypes) {
List<String> asList = objectClass.getNames();
if (asList.contains("groupOfURLs")) {
assertEquals("2.16.840.1.113730.3.2.33", objectClass.getOid());
} else if (asList.contains("dgIdentityAux")) {
assertEquals("1.3.6.1.4.1.4203.666.11.8.2.1", objectClass.getOid());
} else {
fail("object class 'groupOfURLs' or 'dgIdentityAux' expected");
}
}
for (AttributeType attributeType : attributeTypes) {
List<String> asList = attributeType.getNames();
if (asList.contains("memberURL")) {
assertEquals("2.16.840.1.113730.3.1.198", attributeType.getOid());
} else if (asList.contains("dgIdentity")) {
assertEquals("1.3.6.1.4.1.4203.666.11.8.1.1", attributeType.getOid());
} else {
fail("attribute type 'memberURL' or 'dgIdentity' expected");
}
}
}
use of org.apache.directory.api.ldap.model.schema.MutableAttributeType in project directory-ldap-api by apache.
the class AttributeTypeRegistryTest method testRegister.
@Test
public void testRegister() throws LdapException {
MutableAttributeType at0 = new MutableAttributeType("1.1");
at0.addName("t", "test", "Test", "T");
atRegistry.register(at0);
assertTrue(atRegistry.contains("1.1"));
assertTrue(atRegistry.contains("t"));
assertTrue(atRegistry.contains("T"));
assertTrue(atRegistry.contains("tEsT"));
assertEquals("1.1", atRegistry.getOidByName("T"));
try {
atRegistry.register(at0);
fail();
} catch (LdapException ne) {
assertTrue(true);
}
}
Aggregations