use of org.apache.directory.api.ldap.model.name.Ava in project directory-ldap-api by apache.
the class AvaSerializationTest method testNullUpValueStaticSerialization.
@Test
public void testNullUpValueStaticSerialization() throws LdapException, IOException, ClassNotFoundException {
Ava atav = new Ava(schemaManager, "CN", (String) null);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(baos);
try {
atav.writeExternal(out);
fail();
} catch (IOException ioe) {
String message = ioe.getMessage();
assertEquals("ERR_13619_CANNOT_SERIALIZE_AVA_VALUE_NULL Cannot serialize a wrong ATAV, the value should not be null", message);
}
}
use of org.apache.directory.api.ldap.model.name.Ava in project directory-ldap-api by apache.
the class AvaSerializationTest method testEmptyUpValueSerialization.
@Test
public void testEmptyUpValueSerialization() throws LdapException, IOException, ClassNotFoundException {
Ava atav = new Ava(schemaManager, "CN", "");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(baos);
atav.writeExternal(out);
ObjectInputStream in = null;
byte[] data = baos.toByteArray();
in = new ObjectInputStream(new ByteArrayInputStream(data));
Ava atav2 = new Ava(schemaManager);
atav2.readExternal(in);
assertEquals(atav, atav2);
}
use of org.apache.directory.api.ldap.model.name.Ava in project directory-ldap-api by apache.
the class AvaSerializationTest method testEmptyNormValueSerialization.
@Test
public void testEmptyNormValueSerialization() throws LdapException, IOException, ClassNotFoundException {
Ava atav = new Ava(schemaManager, "CN", "test");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(baos);
atav.writeExternal(out);
ObjectInputStream in = null;
byte[] data = baos.toByteArray();
in = new ObjectInputStream(new ByteArrayInputStream(data));
Ava atav2 = new Ava(schemaManager);
atav2.readExternal(in);
assertEquals(atav, atav2);
}
use of org.apache.directory.api.ldap.model.name.Ava in project directory-ldap-api by apache.
the class AvaTest method testAvaEscapedMiddleChar.
@Test
public void testAvaEscapedMiddleChar() throws LdapException {
// Trail char : 0x00
Ava atav = new Ava(schemaManager, "cn", new byte[] { 'a', 0x00, 'b' });
assertEquals("cn=a\\00b", atav.getName());
assertEquals("cn=a\\00b", atav.getEscaped());
// Trail char : 0x20 (it should not be escaped)
atav = new Ava(schemaManager, "cn", new byte[] { 'a', 0x20, 'b' });
assertEquals("cn=a b", atav.getName());
assertEquals("cn=a b", atav.getEscaped());
// Trail char : '#' (it should not be escaped)
atav = new Ava(schemaManager, "cn", new byte[] { 'a', '#', 'b' });
assertEquals("cn=a#b", atav.getName());
assertEquals("cn=a#b", atav.getEscaped());
// Trail char : ','
atav = new Ava(schemaManager, "cn", new byte[] { 'a', ',', 'b' });
assertEquals("cn=a\\,b", atav.getName());
assertEquals("cn=a\\,b", atav.getEscaped());
// Trail char : ';'
atav = new Ava(schemaManager, "cn", new byte[] { 'a', ';', 'b' });
assertEquals("cn=a\\;b", atav.getName());
assertEquals("cn=a\\;b", atav.getEscaped());
// Trail char : '+'
atav = new Ava(schemaManager, "cn", new byte[] { 'a', '+', 'b' });
assertEquals("cn=a\\+b", atav.getName());
assertEquals("cn=a\\+b", atav.getEscaped());
// Trail char : '"'
atav = new Ava(schemaManager, "cn", new byte[] { 'a', '"', 'b' });
assertEquals("cn=a\\\"b", atav.getName());
assertEquals("cn=a\\\"b", atav.getEscaped());
// Trail char : '<'
atav = new Ava(schemaManager, "cn", new byte[] { 'a', '<', 'b' });
assertEquals("cn=a\\<b", atav.getName());
assertEquals("cn=a\\<b", atav.getEscaped());
// Trail char : '>'
atav = new Ava(schemaManager, "cn", new byte[] { 'a', '>', 'b' });
assertEquals("cn=a\\>b", atav.getName());
assertEquals("cn=a\\>b", atav.getEscaped());
// Trail char : '\'
atav = new Ava(schemaManager, "cn", new byte[] { 'a', '\\', 'b' });
assertEquals("cn=a\\\\b", atav.getName());
assertEquals("cn=a\\\\b", atav.getEscaped());
}
use of org.apache.directory.api.ldap.model.name.Ava in project directory-ldap-api by apache.
the class AvaTest method testEqualsAtav1TypeSuperior.
/**
* Compare two atavs : the first one is superior because its type is
* superior
*/
@Test
public void testEqualsAtav1TypeSuperior() throws LdapException {
Ava atav1 = new Ava(schemaManager, "b", "b");
Ava atav2 = new Ava(schemaManager, "a", "b");
assertFalse(atav1.equals(atav2));
}
Aggregations