use of org.apache.directory.api.ldap.model.schema.AttributeType in project directory-ldap-api by apache.
the class AttributeTypeDescriptionSchemaParserTest method testCollective.
/**
* Tests COLLECTIVE
*
* @throws ParseException
*/
@Test
public void testCollective() throws ParseException {
String value = null;
AttributeType attributeType = null;
// not collective
value = "( 1.1 SYNTAX 1.1 NAME 'test' DESC 'Descripton' )";
attributeType = parser.parseAttributeTypeDescription(value);
assertFalse(attributeType.isCollective());
// single-value
value = "(1.1 SYNTAX 1.1 NAME 'test' DESC 'Descripton' COLLECTIVE )";
attributeType = parser.parseAttributeTypeDescription(value);
assertTrue(attributeType.isCollective());
// single-value
value = "(1.1 SYNTAX 1.1 COLLECTIVE)";
attributeType = parser.parseAttributeTypeDescription(value);
assertTrue(attributeType.isCollective());
// ivalid
value = "(1.1 SYNTAX 1.1 NAME 'test' DESC 'Descripton' COLLECTIV )";
try {
attributeType = parser.parseAttributeTypeDescription(value);
fail("Exception expected, invalid COLLECTIVE value");
} catch (ParseException pe) {
// expected
}
}
use of org.apache.directory.api.ldap.model.schema.AttributeType in project directory-ldap-api by apache.
the class AttributeTypeDescriptionSchemaParserTest method testNoUserModificatonConstraint.
/**
* Test no-user-modification constraint:
* NO-USER-MODIFICATION requires an operational USAGE
*
* @throws ParseException
*/
@Test
public void testNoUserModificatonConstraint() throws ParseException {
String value = null;
AttributeType attributeType = null;
value = "( 1.1 SYNTAX 1.1 NO-USER-MODIFICATION USAGE directoryOperation )";
attributeType = parser.parseAttributeTypeDescription(value);
assertFalse(attributeType.isUserModifiable());
assertEquals(UsageEnum.DIRECTORY_OPERATION, attributeType.getUsage());
value = "( 1.1 SYNTAX 1.1 NO-USER-MODIFICATION USAGE dSAOperation )";
attributeType = parser.parseAttributeTypeDescription(value);
assertFalse(attributeType.isUserModifiable());
assertEquals(UsageEnum.DSA_OPERATION, attributeType.getUsage());
value = "( 1.1 SYNTAX 1.1 NO-USER-MODIFICATION USAGE distributedOperation )";
attributeType = parser.parseAttributeTypeDescription(value);
assertFalse(attributeType.isUserModifiable());
assertEquals(UsageEnum.DISTRIBUTED_OPERATION, attributeType.getUsage());
if (!parser.isQuirksMode()) {
value = "( 1.1 SYNTAX 1.1 NO-USER-MODIFICATION USAGE userApplications )";
try {
parser.parseAttributeTypeDescription(value);
fail("Exception expected, NO-USER-MODIFICATION requires an operational USAGE");
} catch (ParseException pe) {
// expected
}
value = "( 1.1 SYNTAX 1.1 NO-USER-MODIFICATION )";
try {
parser.parseAttributeTypeDescription(value);
fail("Exception expected, NO-USER-MODIFICATION requires an operational USAGE");
} catch (ParseException pe) {
// expected
}
}
}
use of org.apache.directory.api.ldap.model.schema.AttributeType in project directory-ldap-api by apache.
the class AttributeTypeDescriptionSchemaParserTest method testSubstring.
/**
* Tests SUBSTRING and its values.
* Very similar to SUP, so here are less test cases.
*
* @throws ParseException
*/
@Test
public void testSubstring() throws ParseException {
String value = null;
AttributeType attributeType = null;
// no SUBSTR
value = "( 1.1 SYNTAX 1.1 )";
attributeType = parser.parseAttributeTypeDescription(value);
assertNull(attributeType.getSubstringOid());
// SUBSTR numericoid
value = "( 1.1 SYNTAX 1.1 SUBSTR 1.2.3.4567.8.9.0 )";
attributeType = parser.parseAttributeTypeDescription(value);
assertEquals("1.2.3.4567.8.9.0", attributeType.getSubstringOid());
// SUBSTR descr, no space
value = "(1.1 SYNTAX1.1 SUBSTRabcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789)";
attributeType = parser.parseAttributeTypeDescription(value);
assertEquals("abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789", attributeType.getSubstringOid());
// SUBSTR descr, newline
value = "\r\n(\r\n1.1\r\nSYNTAX\r\n1.1\r\nSUBSTR\r\nabcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789\r\n)\r\n";
attributeType = parser.parseAttributeTypeDescription(value);
assertEquals("abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789", attributeType.getSubstringOid());
// quoted value
value = "( 1.1 SYNTAX 1.1 SUBSTR 'caseIgnoreSubstringsMatch' )";
attributeType = parser.parseAttributeTypeDescription(value);
assertEquals("caseIgnoreSubstringsMatch", attributeType.getSubstringOid());
// quote value in parentheses
value = "( 1.1 SYNTAX 1.1 SUBSTR ('caseIgnoreSubstringsMatch') )";
attributeType = parser.parseAttributeTypeDescription(value);
assertEquals("caseIgnoreSubstringsMatch", attributeType.getSubstringOid());
}
use of org.apache.directory.api.ldap.model.schema.AttributeType in project directory-ldap-api by apache.
the class AttributeTypeDescriptionSchemaParserTest method testUsage.
/**
* Tests usage
*
* @throws ParseException
*/
@Test
public void testUsage() throws ParseException {
String value = null;
AttributeType attributeType = null;
// DEFAULT is userApplications
value = "( 1.1 SYNTAX 1.1 )";
attributeType = parser.parseAttributeTypeDescription(value);
assertEquals(UsageEnum.USER_APPLICATIONS, attributeType.getUsage());
// userApplications
value = "( 1.1 SYNTAX 1.1 USAGE userApplications )";
attributeType = parser.parseAttributeTypeDescription(value);
assertEquals(UsageEnum.USER_APPLICATIONS, attributeType.getUsage());
// directoryOperation
value = "( 1.1 SYNTAX 1.1 USAGE directoryOperation )";
attributeType = parser.parseAttributeTypeDescription(value);
assertEquals(UsageEnum.DIRECTORY_OPERATION, attributeType.getUsage());
// distributedOperation, tabs
value = "\t(\t1.1\tSYNTAX\t1.1\tUSAGE\tdistributedOperation\t)\t";
attributeType = parser.parseAttributeTypeDescription(value);
assertEquals(UsageEnum.DISTRIBUTED_OPERATION, attributeType.getUsage());
// dSAOperation, no space
value = "(1.1 SYNTAX1.1 USAGEdSAOperation)";
attributeType = parser.parseAttributeTypeDescription(value);
assertEquals(UsageEnum.DSA_OPERATION, attributeType.getUsage());
// directoryOperation, case insensitivity
value = "( 1.1 SYNTAX 1.1 USAGE DiReCtOrYoPeRaTiOn )";
attributeType = parser.parseAttributeTypeDescription(value);
assertEquals(UsageEnum.DIRECTORY_OPERATION, attributeType.getUsage());
// ivalid
value = "( 1.1 SYNTAX 1.1 USAGE abc )";
try {
attributeType = parser.parseAttributeTypeDescription(value);
fail("Exception expected, invalid USAGE value");
} catch (ParseException pe) {
// expected
}
}
use of org.apache.directory.api.ldap.model.schema.AttributeType in project directory-ldap-api by apache.
the class AttributeTypeDescriptionSchemaParserTest method testOrdering.
/**
* Tests ORDERING and its values.
* Very similar to SUP, so here are less test cases.
*
* @throws ParseException
*/
@Test
public void testOrdering() throws ParseException {
String value = null;
AttributeType attributeType = null;
// no ORDERING
value = "( 1.1 SYNTAX 1.1 )";
attributeType = parser.parseAttributeTypeDescription(value);
assertNull(attributeType.getOrderingOid());
// ORDERING numericoid
value = "( 1.1 SYNTAX 1.1 ORDERING 1.2.3.4567.8.9.0 )";
attributeType = parser.parseAttributeTypeDescription(value);
assertEquals("1.2.3.4567.8.9.0", attributeType.getOrderingOid());
// ORDERING descr, no space
value = "(1.1 SYNTAX1.1 ORDERINGabcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789)";
attributeType = parser.parseAttributeTypeDescription(value);
assertEquals("abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789", attributeType.getOrderingOid());
// ORDERING descr, newline
value = "\r(\r1.1\rSYNTAX\r1.1\rORDERING\rabcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789\r)\r";
attributeType = parser.parseAttributeTypeDescription(value);
assertEquals("abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789", attributeType.getOrderingOid());
// quoted value
value = "( 1.1 SYNTAX 1.1 ORDERING 'generalizedTimeOrderingMatch' )";
attributeType = parser.parseAttributeTypeDescription(value);
assertEquals("generalizedTimeOrderingMatch", attributeType.getOrderingOid());
// quote value in parentheses
value = "( 1.1 SYNTAX 1.1 ORDERING ('generalizedTimeOrderingMatch') )";
attributeType = parser.parseAttributeTypeDescription(value);
assertEquals("generalizedTimeOrderingMatch", attributeType.getOrderingOid());
}
Aggregations