use of org.apache.directory.api.ldap.model.schema.AttributeType in project directory-ldap-api by apache.
the class SchemaAwareAttributeTest method testAddNullValue.
@Test
public void testAddNullValue() throws Exception {
AttributeType at = TestEntryUtils.getIA5StringAttributeType();
DefaultAttribute attr = new DefaultAttribute(at);
// Add a null value
attr.add(new Value(at, (String) null));
assertEquals(1, attr.size());
assertTrue(attr.getAttributeType().getSyntax().isHumanReadable());
Value value = attr.get();
assertTrue(value instanceof Value);
assertNull(((Value) value).getValue());
}
use of org.apache.directory.api.ldap.model.schema.AttributeType in project directory-ldap-api by apache.
the class SchemaAwareAttributeTest method testGetAttribute.
@Test
public void testGetAttribute() throws Exception {
AttributeType at = TestEntryUtils.getIA5StringAttributeType();
DefaultAttribute attr = new DefaultAttribute(at);
attr.add("Test1");
attr.add("Test2");
attr.add("Test3");
assertEquals("1.1", attr.getId());
assertEquals(3, attr.size());
assertTrue(attr.contains("Test1"));
assertTrue(attr.contains("Test2"));
assertTrue(attr.contains("Test3"));
}
use of org.apache.directory.api.ldap.model.schema.AttributeType in project directory-ldap-api by apache.
the class DefaultSchemaLoader method loadAttributeTypes.
private void loadAttributeTypes(Attribute attributeTypes) throws LdapException {
if (attributeTypes == null) {
return;
}
for (Value value : attributeTypes) {
String desc = value.getValue();
try {
AttributeType attributeType = AT_DESCR_SCHEMA_PARSER.parseAttributeTypeDescription(desc);
updateSchemas(attributeType);
} catch (ParseException pe) {
throw new LdapException(pe);
}
}
}
use of org.apache.directory.api.ldap.model.schema.AttributeType in project directory-ldap-api by apache.
the class ProtectedItem_MaxValueCountTest method initNames.
/**
* Initialize name instances
*/
@Before
public void initNames() throws Exception {
MaxValueCountElem mvciA = new MaxValueCountElem(new AttributeType("aa"), 1);
MaxValueCountElem mvciB = new MaxValueCountElem(new AttributeType("bb"), 2);
MaxValueCountElem mvciC = new MaxValueCountElem(new AttributeType("cc"), 3);
MaxValueCountElem mvciD = new MaxValueCountElem(new AttributeType("dd"), 4);
Set<MaxValueCountElem> colA = new HashSet<MaxValueCountElem>();
colA.add(mvciA);
colA.add(mvciB);
colA.add(mvciC);
Set<MaxValueCountElem> colB = new HashSet<MaxValueCountElem>();
colB.add(mvciA);
colB.add(mvciB);
colB.add(mvciC);
Set<MaxValueCountElem> colC = new HashSet<MaxValueCountElem>();
colC.add(mvciB);
colC.add(mvciC);
colC.add(mvciD);
maxValueCountA = new MaxValueCountItem(colA);
maxValueCountACopy = new MaxValueCountItem(colA);
maxValueCountB = new MaxValueCountItem(colB);
maxValueCountC = new MaxValueCountItem(colC);
}
use of org.apache.directory.api.ldap.model.schema.AttributeType in project directory-ldap-api by apache.
the class ProtectedItem_RestrictedByTest method initNames.
/**
* Initialize name instances
*/
@Before
public void initNames() throws Exception {
RestrictedByElem rbiA = new RestrictedByElem(new AttributeType("aa"), new AttributeType("aa"));
RestrictedByElem rbiB = new RestrictedByElem(new AttributeType("bb"), new AttributeType("bb"));
RestrictedByElem rbiC = new RestrictedByElem(new AttributeType("cc"), new AttributeType("cc"));
RestrictedByElem rbiD = new RestrictedByElem(new AttributeType("dd"), new AttributeType("dd"));
Set<RestrictedByElem> colA = new HashSet<RestrictedByElem>();
colA.add(rbiA);
colA.add(rbiB);
colA.add(rbiC);
Set<RestrictedByElem> colB = new HashSet<RestrictedByElem>();
colB.add(rbiA);
colB.add(rbiB);
colB.add(rbiC);
Set<RestrictedByElem> colC = new HashSet<RestrictedByElem>();
colC.add(rbiB);
colC.add(rbiC);
colC.add(rbiD);
restrictedByA = new RestrictedByItem(colA);
restrictedByACopy = new RestrictedByItem(colA);
restrictedByB = new RestrictedByItem(colB);
restrictedByC = new RestrictedByItem(colC);
}
Aggregations