String zuluTime = DateUtils.getGeneralizedTime();
long revision = 1L;
LdapPrincipal principal = new LdapPrincipal( schemaManager, adminDn, AuthenticationLevel.SIMPLE,
Strings.getBytesUtf8( "secret" ) );
ChangeLogEvent event = new ChangeLogEvent( revision, zuluTime, principal, forward, reverse );
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream( baos );
ChangeLogEventSerializer.serialize( event, out );
byte[] data = baos.toByteArray();
ObjectInputStream in = new ObjectInputStream( new ByteArrayInputStream( data ) );
ChangeLogEvent read = ChangeLogEventSerializer.deserialize( schemaManager, in );
// The read event should not be equal to the written event, as
// the principal's password has not been stored
assertNotSame( event, read );
LdapPrincipal readPrincipal = read.getCommitterPrincipal();
assertEquals( principal.getAuthenticationLevel(), readPrincipal.getAuthenticationLevel() );
assertEquals( principal.getName(), readPrincipal.getName() );
assertEquals( principal.getDn(), readPrincipal.getDn() );
assertNull( readPrincipal.getUserPasswords() );
assertEquals( zuluTime, read.getZuluTime() );
assertEquals( revision, read.getRevision() );
assertEquals( forward, read.getForwardLdif() );
assertEquals( reverse, read.getReverseLdifs().get( 0 ) );
}