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));
}
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);
}
}
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 "));
}
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());
}
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));
}
Aggregations