Search in sources :

Example 21 with AttributeType

use of org.apache.directory.api.ldap.model.schema.AttributeType in project directory-ldap-api by apache.

the class BinaryValueAttributeTypeTest method testCompareTo.

/**
 * Test the compareTo method
 */
@Test
public void testCompareTo() throws LdapInvalidAttributeValueException {
    AttributeType at1 = EntryUtils.getBytesAttributeType();
    Value v0 = new Value(at1, BYTES1);
    Value v1 = new Value(at1, BYTES1);
    assertEquals(0, v0.compareTo(v1));
    assertEquals(0, v1.compareTo(v0));
    Value v2 = new Value(at1, (byte[]) null);
    assertEquals(1, v0.compareTo(v2));
    assertEquals(-1, v2.compareTo(v0));
}
Also used : AttributeType(org.apache.directory.api.ldap.model.schema.AttributeType) MutableAttributeType(org.apache.directory.api.ldap.model.schema.MutableAttributeType) Test(org.junit.Test)

Example 22 with AttributeType

use of org.apache.directory.api.ldap.model.schema.AttributeType in project directory-ldap-api by apache.

the class StringValueAttributeTypeTest method testIsValid.

/**
 * Test the isValid method
 *
 * The SyntaxChecker does not accept values longer than 5 chars.
 */
@Test
public void testIsValid() throws LdapInvalidAttributeValueException {
    AttributeType attribute = EntryUtils.getIA5StringAttributeType();
    new Value(attribute, (String) null);
    new Value(attribute, "");
    new Value(attribute, "TEST");
    try {
        new Value(attribute, "testlong");
        fail();
    } catch (LdapInvalidAttributeValueException liave) {
        assertTrue(true);
    }
}
Also used : AttributeType(org.apache.directory.api.ldap.model.schema.AttributeType) LdapInvalidAttributeValueException(org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueException) Test(org.junit.Test)

Example 23 with AttributeType

use of org.apache.directory.api.ldap.model.schema.AttributeType in project directory-ldap-api by apache.

the class StringValueAttributeTypeTest method testApply.

/**
 * Test the normalize method
 */
@Test
public void testApply() throws LdapException {
    AttributeType attribute = EntryUtils.getIA5StringAttributeType();
    Value sv = Value.createValue(attribute);
    sv = new Value(at, sv);
    assertEquals(0, sv.compareTo((String) null));
    sv = new Value(attribute, "");
    sv = new Value(at, sv);
    assertEquals(0, sv.compareTo("  "));
    sv = new Value(attribute, "  A   TEST  ");
    assertEquals(0, sv.compareTo(" a  test "));
}
Also used : AttributeType(org.apache.directory.api.ldap.model.schema.AttributeType) Test(org.junit.Test)

Example 24 with AttributeType

use of org.apache.directory.api.ldap.model.schema.AttributeType in project directory-ldap-api by apache.

the class StringValueAttributeTypeTest method testBadConstructor.

/**
 * Test the constructor with bad AttributeType
 */
@Test
public void testBadConstructor() {
    // create a AT without any syntax
    AttributeType attribute = new EntryUtils.AT("1.1.3.1");
    Value value = Value.createValue(attribute);
    assertTrue(value.isHumanReadable());
}
Also used : AttributeType(org.apache.directory.api.ldap.model.schema.AttributeType) Test(org.junit.Test)

Example 25 with AttributeType

use of org.apache.directory.api.ldap.model.schema.AttributeType in project directory-ldap-api by apache.

the class StringValueAttributeTypeTest method testCompareTo.

/**
 * Test the compareTo method
 */
@Test
public void testCompareTo() throws LdapInvalidAttributeValueException {
    AttributeType at1 = EntryUtils.getCaseIgnoringAttributeNoNumbersType();
    Value v0 = new Value(at1, "Alex");
    Value v1 = new Value(at1, "ALEX");
    assertEquals(0, v0.compareTo(v1));
    assertEquals(0, v1.compareTo(v0));
    Value v2 = new Value(at1, (String) null);
    assertEquals(1, v0.compareTo(v2));
    assertEquals(-1, v2.compareTo(v0));
}
Also used : AttributeType(org.apache.directory.api.ldap.model.schema.AttributeType) Test(org.junit.Test)

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