use of org.apache.directory.api.ldap.model.name.Ava in project directory-ldap-api by apache.
the class AvaSerializationTest method testStringAtavStaticSerialization.
/**
* Test serialization of a simple ATAV
*/
@Test
public void testStringAtavStaticSerialization() 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 AvaSerializationTest method testEmptyUpValueStaticSerialization.
@Test
public void testEmptyUpValueStaticSerialization() 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 testBinaryAtavSerialization.
@Test
public void testBinaryAtavSerialization() throws LdapException, IOException, ClassNotFoundException {
byte[] upValue = Strings.getBytesUtf8(" Test ");
Ava atav = new Ava(schemaManager, "CN", upValue);
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 testEmptyNormValueStaticSerialization.
@Test
public void testEmptyNormValueStaticSerialization() 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 testSerializationPerf.
@Test
@Ignore
public void testSerializationPerf() throws LdapException, IOException, ClassNotFoundException {
Ava atav = new Ava(schemaManager, "cn", "This is a serialization test");
long t0 = System.currentTimeMillis();
for (int j = 0; j < 1000; j++) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(baos);
for (int i = 0; i < 100000; i++) {
atav.writeExternal(out);
out.flush();
}
out.close();
baos.close();
}
long t1 = System.currentTimeMillis();
System.out.println("delta AVA new serialization : " + (t1 - t0));
}
Aggregations