* @throws Exception
*/
@Test
public void testLdifDeleteExistingEntry() throws Exception
{
DN adminDn = new DN( "uid=admin,ou=system" ).normalize( schemaManager.getNormalizerMapping() );
CoreSession session = new MockCoreSession( new LdapPrincipal( adminDn, AuthenticationLevel.STRONG ), new MockDirectoryService( 1 ) );
AddOperationContext addCtx = new AddOperationContext( session );
ClonedServerEntry entry1 = createEntry( "dc=test,ou=test,ou=system" );
entry1.put( "ObjectClass", "top", "domain" );
entry1.put( "dc", "test" );
addCtx.setEntry( entry1 );
partition.add( addCtx );
ClonedServerEntry 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 );
ClonedServerEntry 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 );
DeleteOperationContext delCtx = new DeleteOperationContext( session );
DN dn = new DN( "dc=test1,dc=test,ou=test,ou=system" );
dn.normalize( schemaManager.getNormalizerMapping() );
delCtx.setDn( dn );
partition.delete( delCtx );
assertTrue( new File( wkdir, "ou=test,ou=system" ).exists() );
assertTrue( new File( wkdir, "ou=test,ou=system.ldif" ).exists() );
assertTrue( new File( wkdir, "ou=test,ou=system/dc=test" ).exists() );
assertTrue( new File( wkdir, "ou=test,ou=system/dc=test.ldif" ).exists() );
assertFalse( new File( wkdir, "ou=test,ou=system/dc=test/dc=test1" ).exists() );
assertFalse( new File( wkdir, "ou=test,ou=system/dc=test/dc=test1.ldif" ).exists() );
assertFalse( new File( wkdir, "ou=test,ou=system/dc=test/dc=test2" ).exists() );
assertTrue( new File( wkdir, "ou=test,ou=system/dc=test/dc=test2.ldif" ).exists() );
dn = new DN( "dc=test2,dc=test,ou=test,ou=system" );
dn.normalize( schemaManager.getNormalizerMapping() );
delCtx.setDn( dn );
partition.delete( delCtx );