*/
@Test
public void testModifyEntry() throws Exception
{
SingleFileLdifPartition partition = createPartition( null, true );
AddOperationContext addCtx = new AddOperationContext( mockSession );
addCtx.setEntry( contextEntry );
partition.add( addCtx );
ModifyOperationContext modOpCtx = new ModifyOperationContext( mockSession );
modOpCtx.setEntry( contextEntry );
List<Modification> modItems = new ArrayList<Modification>();
Attribute attribute = new DefaultAttribute( schemaManager.lookupAttributeTypeRegistry( "description" ) );
attribute.add( "this is description" );
Modification mod = new DefaultModification();
mod.setOperation( ModificationOperation.ADD_ATTRIBUTE );
mod.setAttribute( attribute );
modItems.add( mod );
modOpCtx.setModItems( modItems );
modOpCtx.setDn( contextEntry.getDn() );
partition.modify( modOpCtx );
RandomAccessFile file = new RandomAccessFile( new File( partition.getPartitionPath() ), "r" );
assertEquals( getEntryLdifLen( modOpCtx.getAlteredEntry() ), file.length() );
// perform the above operation, this time without causing change to the entry's size
modOpCtx = new ModifyOperationContext( mockSession );
modOpCtx.setEntry( new ClonedServerEntry( contextEntry ) );
modItems = new ArrayList<Modification>();
attribute = new DefaultAttribute( schemaManager.lookupAttributeTypeRegistry( "description" ) );
attribute.add( "siht si noitpircsed" ); // reversed "this is description"
mod = new DefaultModification();
mod.setOperation( ModificationOperation.REPLACE_ATTRIBUTE );
mod.setAttribute( attribute );
modItems.add( mod );
modOpCtx.setModItems( modItems );
modOpCtx.setDn( contextEntry.getDn() );
partition.modify( modOpCtx );
assertEquals( getEntryLdifLen( modOpCtx.getAlteredEntry() ), file.length() );
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=test,dc=test,ou=test,ou=system" );
entry2.put( "ObjectClass", "top", "domain" );
entry2.put( "dc", "test" );
addCtx.setEntry( entry2 );
partition.add( addCtx );
// now perform a modification on the entry present in middle of LDIF file
modOpCtx = new ModifyOperationContext( mockSession );