### Question:
SingleFileLdifPartition extends AbstractLdifPartition { @Override public void rename( RenameOperationContext renameContext ) throws LdapException { synchronized ( lock ) { super.rename( renameContext ); dirty = true; rewritePartitionData( renameContext.getTransaction() ); } } SingleFileLdifPartition( SchemaManager schemaManager, DnFactory dnFactory ); @Override void add( AddOperationContext addContext ); @Override void modify( ModifyOperationContext modifyContext ); @Override void rename( RenameOperationContext renameContext ); @Override void move( MoveOperationContext moveContext ); @Override void moveAndRename( MoveAndRenameOperationContext opContext ); @Override Entry delete( PartitionTxn partitionTxn, String id ); void setEnableRewriting( PartitionTxn partitionTxn, boolean enableRewriting );  }### Answer:
@Test public void testLdifRenameAndDeleteOldRDN() throws Exception { SingleFileLdifPartition partition = injectEntries(); Dn childDn1 = new Dn( schemaManager, "cn=child1,ou=test,ou=system" ); Rdn newRdn = new Rdn( SchemaConstants.CN_AT + "=" + "renamedChild1" ); RenameOperationContext renameOpCtx = new RenameOperationContext( mockSession, childDn1, newRdn, true ); renameOpCtx.setPartition( partition ); renameOpCtx.setTransaction( partition.beginWriteTransaction() ); partition.rename( renameOpCtx ); partition = reloadPartition(); childDn1 = new Dn( schemaManager, "cn=renamedChild1,ou=test,ou=system" ); LookupOperationContext lookupContext = new LookupOperationContext( mockSession, childDn1 ); lookupContext.setPartition( partition ); Entry entry; try ( PartitionTxn partitionTxn = partition.beginReadTransaction() ) { lookupContext.setTransaction( partitionTxn ); entry = partition.lookup( lookupContext ); } catch ( IOException ioe ) { throw new LdapOtherException( ioe.getMessage(), ioe ); } assertNotNull( entry ); assertFalse( entry.get( "cn" ).contains( "child1" ) ); }
@Test public void testLdifRenameAndRetainOldRDN() throws Exception { SingleFileLdifPartition partition = injectEntries(); Dn childDn1 = new Dn( schemaManager, "cn=child1,ou=test,ou=system" ); Rdn newRdn = new Rdn( SchemaConstants.CN_AT + "=" + "renamedChild1" ); RenameOperationContext renameOpCtx = new RenameOperationContext( mockSession, childDn1, newRdn, false ); renameOpCtx.setPartition( partition ); renameOpCtx.setTransaction( partition.beginWriteTransaction() ); partition.rename( renameOpCtx ); partition = reloadPartition(); childDn1 = new Dn( schemaManager, "cn=renamedChild1,ou=test,ou=system" ); LookupOperationContext lookupContext = new LookupOperationContext( mockSession, childDn1 ); lookupContext.setPartition( partition ); Entry entry; try ( PartitionTxn partitionTxn = partition.beginReadTransaction() ) { lookupContext.setTransaction( partitionTxn ); entry = partition.lookup( lookupContext ); } catch ( IOException ioe ) { throw new LdapOtherException( ioe.getMessage(), ioe ); } assertNotNull( entry ); assertTrue( entry.get( "cn" ).contains( "child1" ) ); }