use of org.apache.directory.api.ldap.model.schema.AttributeType in project directory-ldap-api by apache.
the class BinaryValueAttributeTypeTest method testServerBinaryValueEmptyValue.
/**
* Test the constructor with an empty value
*/
@Test
public void testServerBinaryValueEmptyValue() throws LdapInvalidAttributeValueException {
AttributeType attribute = EntryUtils.getBytesAttributeType();
Value value = new Value(attribute, Strings.EMPTY_BYTES);
assertTrue(Arrays.equals(Strings.EMPTY_BYTES, value.getBytes()));
assertFalse(value.isNull());
}
use of org.apache.directory.api.ldap.model.schema.AttributeType in project directory-ldap-api by apache.
the class BinaryValueAttributeTypeTest method testServerBinaryValue.
/**
* Test the constructor with a value
*/
@Test
public void testServerBinaryValue() throws LdapInvalidAttributeValueException {
AttributeType attribute = EntryUtils.getBytesAttributeType();
byte[] val = new byte[] { 0x01 };
Value value = new Value(attribute, val);
assertTrue(Arrays.equals(val, value.getBytes()));
assertFalse(value.isNull());
assertTrue(Arrays.equals(val, value.getBytes()));
}
use of org.apache.directory.api.ldap.model.schema.AttributeType in project directory-ldap-api by apache.
the class BinaryValueAttributeTypeTest method testGetNormalizedValue.
/**
* Test the getNormValue method
*/
@Test
public void testGetNormalizedValue() throws LdapInvalidAttributeValueException {
AttributeType attribute = EntryUtils.getBytesAttributeType();
Value value = new Value(attribute, (byte[]) null);
assertNull(value.getBytes());
value = new Value(attribute, Strings.EMPTY_BYTES);
assertTrue(Arrays.equals(Strings.EMPTY_BYTES, value.getBytes()));
value = new Value(attribute, BYTES2);
assertTrue(Arrays.equals(BYTES2, value.getBytes()));
}
use of org.apache.directory.api.ldap.model.schema.AttributeType in project directory-ldap-api by apache.
the class BinaryValueAttributeTypeTest 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.getBytesAttributeType();
new Value(attribute, (byte[]) null);
new Value(attribute, Strings.EMPTY_BYTES);
new Value(attribute, new byte[] { 0x01, 0x02 });
try {
new Value(attribute, new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 });
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 BinaryValueAttributeTypeTest method testHashCode.
/**
* Tests to make sure the hashCode method is working properly.
* @throws Exception on errors
*/
@Test
public void testHashCode() throws LdapInvalidAttributeValueException {
AttributeType attribute = EntryUtils.getBytesAttributeType();
Value v0 = new Value(attribute, new byte[] { 0x01, 0x02 });
Value v1 = new Value(attribute, new byte[] { (byte) 0x81, (byte) 0x82 });
Value v2 = new Value(attribute, new byte[] { 0x01, 0x02 });
assertNotSame(v0.hashCode(), v1.hashCode());
assertNotSame(v1.hashCode(), v2.hashCode());
assertEquals(v0.hashCode(), v2.hashCode());
assertNotSame(v0, v1);
assertEquals(v0, v2);
assertNotSame(v1, v2);
Value v3 = new Value(attribute, new byte[] { 0x01, 0x03 });
assertFalse(v3.equals(v0));
assertFalse(v3.equals(v1));
assertFalse(v3.equals(v2));
}
Aggregations