* @throws Exception
*/
@Test
public void testLdifDeleteExistingEntry() throws Exception
{
SingleFileLdifPartition partition = createPartition( null, true );
AddOperationContext addCtx = new AddOperationContext( mockSession );
addCtx.setEntry( contextEntry );
partition.add( addCtx );
DeleteOperationContext delOpCtx = new DeleteOperationContext( mockSession );
delOpCtx.setDn( contextEntry.getDn() );
partition.delete( delOpCtx );
RandomAccessFile file = new RandomAccessFile( new File( partition.getPartitionPath() ), "r" );
assertEquals( 0L, file.length() );
addCtx = new AddOperationContext( mockSession );
addCtx.setEntry( contextEntry );
partition.add( addCtx );
Entry entry1 = createEntry( "dc=test,ou=test,ou=system" );
entry1.put( "ObjectClass", "top", "domain" );
entry1.put( "dc", "test" );
addCtx.setEntry( entry1 );
partition.add( addCtx );
Entry entry2 = createEntry( "dc=test1,dc=test,ou=test,ou=system" );
entry2.put( "ObjectClass", "top", "domain" );
entry2.put( "dc", "test1" );
addCtx.setEntry( entry2 );
partition.add( addCtx );
Entry entry3 = createEntry( "dc=test2,dc=test,ou=test,ou=system" );
entry3.put( "ObjectClass", "top", "domain" );
entry3.put( "dc", "test2" );
addCtx.setEntry( entry3 );
partition.add( addCtx );
Entry entryMvrdn = createEntry( "dc=mvrdn+objectClass=domain,dc=test,ou=test,ou=system" );
entryMvrdn.put( "ObjectClass", "top", "domain" );
entryMvrdn.put( "dc", "mvrdn" );
addCtx.setEntry( entryMvrdn );
partition.add( addCtx );
DeleteOperationContext delCtx = new DeleteOperationContext( mockSession );
delCtx.setDn( entryMvrdn.getDn() );
partition.delete( delCtx );
partition = reloadPartition();
assertExists( partition, entry1 );
assertExists( partition, entry2 );
assertExists( partition, entry3 );