use of org.apache.directory.api.ldap.model.name.Ava in project directory-ldap-api by apache.
the class AvaTest method testAvaUTF2.
@Test
public void testAvaUTF2() throws LdapException {
// The '¡' char (U+00A1)
Ava atav = new Ava(schemaManager, "cn", new byte[] { (byte) 0xC2, (byte) 0xA1 });
assertEquals("cn=\u00A1", atav.toString());
assertEquals("cn=\u00A1", atav.getName());
// Some octets, which are not UTF-2
atav = new Ava(schemaManager, "cn", new byte[] { (byte) 0xFE, (byte) 0xC2, (byte) 0xC0, (byte) 0xC2 });
assertEquals("cn=\\FE\\C2\\C0\\C2", atav.getName());
assertEquals("cn=\\FE\\C2\\C0\\C2", atav.getEscaped());
}
use of org.apache.directory.api.ldap.model.name.Ava in project directory-ldap-api by apache.
the class AvaTest method testAvaUTF3.
@Test
public void testAvaUTF3() throws LdapException {
// UTF-3 starting with 0xE0
// 0x090E unicode is 0xE0 0xA4 0x8E UTF-8, ie DEVANAGARI LETTER SHORT E ('ऎ')
Ava atav = new Ava(schemaManager, "cn", new byte[] { (byte) 0xE0, (byte) 0xA4, (byte) 0x8E });
assertEquals("cn=\u090E", atav.getName());
assertEquals("cn=\u090E", atav.getEscaped());
// UTF-3 between 0xE1 and 0xEC
// 0x1000 unicode is 0xE1 0x80 0x80 UTF-8, ie MYANMAR LETTER KA ('က')
atav = new Ava(schemaManager, "cn", new byte[] { (byte) 0xE1, (byte) 0x80, (byte) 0x80 });
assertEquals("cn=\u1000", atav.getName());
assertEquals("cn=\u1000", atav.getEscaped());
// 0xCFFF unicode is 0xEC 0xBF 0xBF UTF-8 ('쿿')
atav = new Ava(schemaManager, "cn", new byte[] { (byte) 0xEC, (byte) 0xBF, (byte) 0xBF });
assertEquals("cn=\uCFFF", atav.getName());
assertEquals("cn=\uCFFF", atav.getEscaped());
// UTF-3 starting with 0xED
// 0xD000 unicode is 0xED 0x80 0x80 UTF-8 ('퀀')
atav = new Ava(schemaManager, "cn", new byte[] { (byte) 0xED, (byte) 0x80, (byte) 0x80 });
assertEquals("cn=\uD000", atav.getName());
assertEquals("cn=\uD000", atav.getEscaped());
// UTF-3 starting with 0xEE or 0xEF
// 0xFC00 unicode is 0xEF 0xB0 0x80 UTF-8, ie ARABIC LIGATURE YEH WITH HAMZA ABOVE WITH JEEM ISOLATED FORM ('ﰀ')
atav = new Ava(schemaManager, "cn", new byte[] { (byte) 0xEF, (byte) 0xB0, (byte) 0x80 });
assertEquals("cn=\uFC00", atav.getName());
assertEquals("cn=\uFC00", atav.getEscaped());
// Some octets, which are not UTF-3
atav = new Ava(schemaManager, "cn", new byte[] { (byte) 0xE0, 0x61, (byte) 0xE0, (byte) 0xA0, 0x61 });
assertEquals("cn=\\E0a\\E0\\A0a", atav.getName());
assertEquals("cn=\\E0a\\E0\\A0a", atav.getEscaped());
// Some octets, which are not UTF-3
atav = new Ava(schemaManager, "cn", new byte[] { (byte) 0xE0, (byte) 0xA0 });
assertEquals("cn=\\E0\\A0", atav.getName());
assertEquals("cn=\\E0\\A0", atav.getEscaped());
}
use of org.apache.directory.api.ldap.model.name.Ava in project directory-ldap-api by apache.
the class AvaTest method testLdapRDNSimple.
/**
* test a simple AttributeTypeAndValue : a = b
*/
@Test
public void testLdapRDNSimple() throws LdapException {
Ava atav = new Ava(schemaManager, "a", "b");
assertEquals("a=b", atav.toString());
assertEquals("a=b", atav.getName());
}
use of org.apache.directory.api.ldap.model.name.Ava in project directory-ldap-api by apache.
the class AvaTest method testEqualsAttributeEquals.
/**
* Compares two equals atavs
*/
@Test
public void testEqualsAttributeEquals() throws LdapException {
Ava atav1 = new Ava(schemaManager, "a", "b");
Ava atav2 = new Ava(schemaManager, "a", "b");
assertTrue(atav1.equals(atav2));
}
use of org.apache.directory.api.ldap.model.name.Ava in project directory-ldap-api by apache.
the class AvaTest method testEqualsAtav1ValueSuperior.
/**
* Compare two atavs : the first one is superior because its type is
* superior
*/
@Test
public void testEqualsAtav1ValueSuperior() throws LdapException {
Ava atav1 = new Ava(schemaManager, "a", "b");
Ava atav2 = new Ava(schemaManager, "a", "a");
assertFalse(atav1.equals(atav2));
}
Aggregations