Search in sources :

Example 96 with AttributeType

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());
}
Also used : AttributeType(org.apache.directory.api.ldap.model.schema.AttributeType) Value(org.apache.directory.api.ldap.model.entry.Value) DefaultAttribute(org.apache.directory.api.ldap.model.entry.DefaultAttribute) Test(org.junit.Test)

Example 97 with AttributeType

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"));
}
Also used : AttributeType(org.apache.directory.api.ldap.model.schema.AttributeType) DefaultAttribute(org.apache.directory.api.ldap.model.entry.DefaultAttribute) Test(org.junit.Test)

Example 98 with AttributeType

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);
        }
    }
}
Also used : AttributeType(org.apache.directory.api.ldap.model.schema.AttributeType) Value(org.apache.directory.api.ldap.model.entry.Value) ParseException(java.text.ParseException) LdapException(org.apache.directory.api.ldap.model.exception.LdapException)

Example 99 with AttributeType

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);
}
Also used : AttributeType(org.apache.directory.api.ldap.model.schema.AttributeType) MaxValueCountItem(org.apache.directory.api.ldap.aci.protectedItem.MaxValueCountItem) MaxValueCountElem(org.apache.directory.api.ldap.aci.protectedItem.MaxValueCountElem) HashSet(java.util.HashSet) Before(org.junit.Before)

Example 100 with AttributeType

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);
}
Also used : AttributeType(org.apache.directory.api.ldap.model.schema.AttributeType) RestrictedByItem(org.apache.directory.api.ldap.aci.protectedItem.RestrictedByItem) RestrictedByElem(org.apache.directory.api.ldap.aci.protectedItem.RestrictedByElem) HashSet(java.util.HashSet) Before(org.junit.Before)

Aggregations

AttributeType (org.apache.directory.api.ldap.model.schema.AttributeType)135 Test (org.junit.Test)68 MutableAttributeType (org.apache.directory.api.ldap.model.schema.MutableAttributeType)42 LdapException (org.apache.directory.api.ldap.model.exception.LdapException)25 ParseException (java.text.ParseException)15 DefaultAttribute (org.apache.directory.api.ldap.model.entry.DefaultAttribute)15 Value (org.apache.directory.api.ldap.model.entry.Value)15 Attribute (org.apache.directory.api.ldap.model.entry.Attribute)11 LdapInvalidAttributeValueException (org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueException)11 HashSet (java.util.HashSet)10 LdapSchemaException (org.apache.directory.api.ldap.model.exception.LdapSchemaException)10 ObjectClass (org.apache.directory.api.ldap.model.schema.ObjectClass)10 MatchingRule (org.apache.directory.api.ldap.model.schema.MatchingRule)9 IOException (java.io.IOException)7 LdapInvalidDnException (org.apache.directory.api.ldap.model.exception.LdapInvalidDnException)7 Before (org.junit.Before)7 SchemaManager (org.apache.directory.api.ldap.model.schema.SchemaManager)6 DefaultSchemaManager (org.apache.directory.api.ldap.schema.manager.impl.DefaultSchemaManager)6 ArrayList (java.util.ArrayList)5 Dn (org.apache.directory.api.ldap.model.name.Dn)4