use of org.apache.directory.api.ldap.model.schema.ObjectClass in project directory-ldap-api by apache.
the class ObjectClassDescriptionSchemaParserTest method testMicrosoftAds2000Locality.
@Test
public void testMicrosoftAds2000Locality() throws ParseException, NamingException {
String value = "( 2.5.6.3 NAME 'locality' SUP top STRUCTURAL MUST (l ) MAY (st $ street $ searchGuide $ seeAlso ) )";
ObjectClass objectClass = parser.parseObjectClassDescription(value);
assertEquals("2.5.6.3", objectClass.getOid());
assertEquals(1, objectClass.getNames().size());
assertEquals("locality", objectClass.getNames().get(0));
assertNull(objectClass.getDescription());
assertEquals(1, objectClass.getSuperiorOids().size());
assertEquals("top", objectClass.getSuperiorOids().get(0));
assertEquals(ObjectClassTypeEnum.STRUCTURAL, objectClass.getType());
assertEquals(1, objectClass.getMustAttributeTypeOids().size());
assertEquals("l", objectClass.getMustAttributeTypeOids().get(0));
assertEquals(4, objectClass.getMayAttributeTypeOids().size());
assertEquals("st", objectClass.getMayAttributeTypeOids().get(0));
assertEquals("street", objectClass.getMayAttributeTypeOids().get(1));
assertEquals("searchGuide", objectClass.getMayAttributeTypeOids().get(2));
assertEquals("seeAlso", objectClass.getMayAttributeTypeOids().get(3));
assertEquals(0, objectClass.getExtensions().size());
}
use of org.apache.directory.api.ldap.model.schema.ObjectClass in project directory-ldap-api by apache.
the class ObjectClassDescriptionSchemaParserTest method testKind.
/**
* Tests kind (ABSTRACT, AUXILIARY, STRUCTURAL)
*
* @throws ParseException
*/
@Test
public void testKind() throws ParseException {
String value = null;
ObjectClass objectClass = null;
// DEFAULT is STRUCTURAL
value = "( 1.1 )";
objectClass = parser.parseObjectClassDescription(value);
assertEquals(ObjectClassTypeEnum.STRUCTURAL, objectClass.getType());
// ABSTRACT
value = "( 1.1 ABSTRACT )";
objectClass = parser.parseObjectClassDescription(value);
assertEquals(ObjectClassTypeEnum.ABSTRACT, objectClass.getType());
// AUXILIARY, tab
value = "\t(\t1.1\tAUXILIARY\t)\t";
objectClass = parser.parseObjectClassDescription(value);
assertEquals(ObjectClassTypeEnum.AUXILIARY, objectClass.getType());
// STRUCTURAL, no space
value = "(1.1 STRUCTURAL)";
objectClass = parser.parseObjectClassDescription(value);
assertEquals(ObjectClassTypeEnum.STRUCTURAL, objectClass.getType());
// STRUCTURAL, case-insensitive
value = "(1.1 sTrUcTuRaL )";
objectClass = parser.parseObjectClassDescription(value);
assertEquals(ObjectClassTypeEnum.STRUCTURAL, objectClass.getType());
// invalid
value = "( 1.1 FOO )";
try {
objectClass = parser.parseObjectClassDescription(value);
fail("Exception expected, invalid KIND value");
} catch (ParseException pe) {
// expected
}
}
use of org.apache.directory.api.ldap.model.schema.ObjectClass in project directory-ldap-api by apache.
the class OpenLdapSchemaParserTest method testParseOpenLdapCollectiveSchema.
@Test
public void testParseOpenLdapCollectiveSchema() throws Exception {
InputStream input = getClass().getResourceAsStream("collective.schema");
parser.parse(input);
List<MutableAttributeType> attributeTypes = parser.getAttributeTypes();
List<ObjectClass> objectClassTypes = parser.getObjectClassTypes();
Map<String, OpenLdapObjectIdentifierMacro> objectIdentifierMacros = parser.getObjectIdentifierMacros();
assertEquals(13, attributeTypes.size());
assertEquals(0, objectClassTypes.size());
assertEquals(0, objectIdentifierMacros.size());
for (AttributeType attributeTypeLiteral : attributeTypes) {
assertTrue(attributeTypeLiteral.isCollective());
}
}
use of org.apache.directory.api.ldap.model.schema.ObjectClass in project directory-ldap-api by apache.
the class OpenLdapSchemaParserTest method testObjectClassWithExtensionsParse.
@Test
public void testObjectClassWithExtensionsParse() throws Exception {
String objectClassData = "objectclass ( 2.5.6.6 NAME 'person'\n" + " DESC 'RFC2256: a person'\n" + " SUP top STRUCTURAL\n" + " MUST ( sn $ cn )\n" + " MAY ( userPassword $ telephoneNumber $ seeAlso $ description ) \n" + " X-extension 'test' X-otherExtension ( 'test1' 'test2' ) )";
parser.parse(objectClassData);
List<ObjectClass> objectClassesList = parser.getObjectClassTypes();
Map<String, ObjectClass> objectClasses = mapObjectClasses(objectClassesList);
ObjectClass objectClass = objectClasses.get("2.5.6.6");
assertNotNull(objectClass);
assertEquals("2.5.6.6", objectClass.getOid());
assertEquals("person", objectClass.getName());
assertEquals("RFC2256: a person", objectClass.getDescription());
assertEquals(ObjectClassTypeEnum.STRUCTURAL, objectClass.getType());
assertEquals("sn", objectClass.getMustAttributeTypeOids().get(0));
assertEquals("cn", objectClass.getMustAttributeTypeOids().get(1));
assertEquals("userPassword", objectClass.getMayAttributeTypeOids().get(0));
assertEquals("telephoneNumber", objectClass.getMayAttributeTypeOids().get(1));
assertEquals("seeAlso", objectClass.getMayAttributeTypeOids().get(2));
assertEquals("description", objectClass.getMayAttributeTypeOids().get(3));
Map<String, List<String>> extensions = objectClass.getExtensions();
assertNotNull(extensions);
List<String> ext1 = objectClass.getExtension("X-extension");
assertNotNull(ext1);
assertEquals(1, ext1.size());
assertTrue(ext1.contains("test"));
List<String> ext2 = objectClass.getExtension("X-otherExtension");
assertNotNull(ext2);
assertEquals(2, ext2.size());
assertTrue(ext2.contains("test1"));
assertTrue(ext2.contains("test2"));
}
use of org.apache.directory.api.ldap.model.schema.ObjectClass in project directory-ldap-api by apache.
the class OpenLdapSchemaParserTest method testObjectClassParse.
@Test
public void testObjectClassParse() throws Exception {
String objectClassData = "objectclass ( 2.5.6.6 NAME 'person'\n" + " DESC 'RFC2256: a person'\n" + " SUP top STRUCTURAL\n" + " MUST ( sn $ cn )\n" + " MAY ( userPassword $ telephoneNumber $ seeAlso $ description ) )";
parser.parse(objectClassData);
List<ObjectClass> objectClassesList = parser.getObjectClassTypes();
Map<String, ObjectClass> objectClasses = mapObjectClasses(objectClassesList);
ObjectClass objectClass = objectClasses.get("2.5.6.6");
assertNotNull(objectClass);
assertEquals("2.5.6.6", objectClass.getOid());
assertEquals("person", objectClass.getName());
assertEquals("RFC2256: a person", objectClass.getDescription());
assertEquals(ObjectClassTypeEnum.STRUCTURAL, objectClass.getType());
assertEquals("sn", objectClass.getMustAttributeTypeOids().get(0));
assertEquals("cn", objectClass.getMustAttributeTypeOids().get(1));
assertEquals("userPassword", objectClass.getMayAttributeTypeOids().get(0));
assertEquals("telephoneNumber", objectClass.getMayAttributeTypeOids().get(1));
assertEquals("seeAlso", objectClass.getMayAttributeTypeOids().get(2));
assertEquals("description", objectClass.getMayAttributeTypeOids().get(3));
}
Aggregations