* starting in the middle.
*/
@Test
public void testJournalWriting() throws Exception
{
Csn entryCsn = csnFactory.newInstance();
Csn firstCsn = entryCsn;
Csn csn100 = null;
for ( int i = 0; i < 1000; i++ )
{
if ( i == 100 )
{
csn100 = entryCsn;
}
Entry entry = new DefaultEntry( schemaManager, "ou=test" + i + ",ou=system",
"ObjectClass: top",
"ObjectClass: organizationalUnit",
"ou", "test" + i,
"entryCsn", entryCsn.toString()
);
ReplicaEventMessage replicaEventMessage = new ReplicaEventMessage( ChangeType.ADD, entry );
journal.put( entryCsn.toString(), replicaEventMessage );
journal.sync();
entryCsn = csnFactory.newInstance();
}
// Now check that the ReplicaEventMessages has been written
ReplicaEventMessage firstMessage = journal.get( firstCsn.toString() );
assertEquals( ChangeType.ADD, firstMessage.getChangeType() );
assertEquals( "test0", firstMessage.getEntry().get( "ou" ).getString() );
// Read entry from the 100th element
Cursor<Tuple<String, ReplicaEventMessage>> cursor = journal.cursor( csn100.toString() );
int pos = 100;
while ( cursor.next() )
{
Tuple<String, ReplicaEventMessage> tuple = cursor.get();