@Test
public void testFailMoveEntryAlreadyExists() throws Exception
{
LdapConnection connection = getAdminConnection( ldapServer );
Entry entry = new DefaultClientEntry( new DN( "ou=users,ou=groups,ou=system" ) );
entry.add( SchemaConstants.OBJECT_CLASS_AT, "OrganizationalUnit" );
entry.add( SchemaConstants.OU_AT, "users" );
connection.add( entry );
ModifyDnResponse resp = connection.rename( entry.getDn(), new RDN( "ou=users" ) );
assertEquals( ResultCodeEnum.ENTRY_ALREADY_EXISTS, resp.getLdapResult().getResultCode() );
Entry userzEntry = new DefaultClientEntry( new DN( "ou=userz,ou=groups,ou=system" ) );
userzEntry.add( SchemaConstants.OBJECT_CLASS_AT, "OrganizationalUnit" );
userzEntry.add( SchemaConstants.OU_AT, "userz" );
connection.add( userzEntry );
ModifyDnResponse modResp = connection.rename( "ou=userz,ou=groups,ou=system", "ou=users", true );
assertEquals( ResultCodeEnum.ENTRY_ALREADY_EXISTS, modResp.getLdapResult().getResultCode() );