Search in sources :

Example 16 with Ava

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());
}
Also used : Ava(org.apache.directory.api.ldap.model.name.Ava) Test(org.junit.Test)

Example 17 with Ava

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());
}
Also used : Ava(org.apache.directory.api.ldap.model.name.Ava) Test(org.junit.Test)

Example 18 with Ava

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());
}
Also used : Ava(org.apache.directory.api.ldap.model.name.Ava) Test(org.junit.Test)

Example 19 with Ava

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));
}
Also used : Ava(org.apache.directory.api.ldap.model.name.Ava) Test(org.junit.Test)

Example 20 with Ava

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));
}
Also used : Ava(org.apache.directory.api.ldap.model.name.Ava) Test(org.junit.Test)

Aggregations

Ava (org.apache.directory.api.ldap.model.name.Ava)44 Test (org.junit.Test)39 ByteArrayOutputStream (java.io.ByteArrayOutputStream)14 ObjectOutputStream (java.io.ObjectOutputStream)14 Rdn (org.apache.directory.api.ldap.model.name.Rdn)12 ByteArrayInputStream (java.io.ByteArrayInputStream)8 ObjectInputStream (java.io.ObjectInputStream)8 IOException (java.io.IOException)5 Dn (org.apache.directory.api.ldap.model.name.Dn)3 DefaultAttribute (org.apache.directory.api.ldap.model.entry.DefaultAttribute)2 LdapInvalidDnException (org.apache.directory.api.ldap.model.exception.LdapInvalidDnException)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Attribute (org.apache.directory.api.ldap.model.entry.Attribute)1 DefaultModification (org.apache.directory.api.ldap.model.entry.DefaultModification)1 Modification (org.apache.directory.api.ldap.model.entry.Modification)1 Value (org.apache.directory.api.ldap.model.entry.Value)1 Anonymizer (org.apache.directory.api.ldap.model.ldif.anonymizer.Anonymizer)1 BinaryAnonymizer (org.apache.directory.api.ldap.model.ldif.anonymizer.BinaryAnonymizer)1 CaseSensitiveStringAnonymizer (org.apache.directory.api.ldap.model.ldif.anonymizer.CaseSensitiveStringAnonymizer)1