* operations replace RDN attributes.
*/
public void testPreventRdnChangeOnModifyReplace() throws Exception
{
int mod = DirContext.REPLACE_ATTRIBUTE;
Name name = new LdapName( "ou=user,dc=example,dc=com" );
Attributes attributes = new BasicAttributes( true );
attributes.put( "cn", "does not matter" );
// postive test which should pass
SchemaChecker.preventRdnChangeOnModifyReplace( name, mod, attributes );
// test should fail since we are removing the ou attribute
attributes.put( new BasicAttribute( "ou" ) );
try
{
SchemaChecker.preventRdnChangeOnModifyReplace( name, mod, attributes );
fail( "should never get here due to a LdapSchemaViolationException being thrown" );
}
catch ( LdapSchemaViolationException e )
{
assertEquals( ResultCodeEnum.NOTALLOWEDONRDN, e.getResultCode() );
}
// test success using more than one attribute for the Rdn but not modifying rdn attribute
name = new LdapName( "ou=users+cn=system users,dc=example,dc=com" );
attributes = new BasicAttributes( true );
attributes.put( "sn", "does not matter" );
SchemaChecker.preventRdnChangeOnModifyReplace( name, mod, attributes );
// test for failure when modifying Rdn attribute in multi attribute Rdn