{
DN name = new DN( "uid=akarasulu,ou=users,dc=example,dc=com" );
ModificationOperation mod = ModificationOperation.REMOVE_ATTRIBUTE;
AttributeType ocAt = schemaManager.lookupAttributeTypeRegistry( "objectClass" );
ServerAttribute entryObjectClasses = new DefaultServerAttribute( "objectClass", ocAt );
entryObjectClasses.add( "top", "person", "organizationalPerson" );
// this should pass
SchemaChecker.preventStructuralClassRemovalOnModifyRemove(
schemaManager,
name,
mod,
new DefaultServerAttribute( "cn", schemaManager.lookupAttributeTypeRegistry( "cn" ) ),
entryObjectClasses );
// this should succeed since person is left and is structural
ServerAttribute objectClassesRemoved = new DefaultServerAttribute(
"objectClass", ocAt );
objectClassesRemoved.add( "person" );
SchemaChecker.preventStructuralClassRemovalOnModifyRemove( schemaManager, name, mod, objectClassesRemoved,
entryObjectClasses );
// this should fail since only top is left
objectClassesRemoved = new DefaultServerAttribute( "objectClass", ocAt );
objectClassesRemoved.add( "person", "organizationalPerson" );
try
{
SchemaChecker.preventStructuralClassRemovalOnModifyRemove( schemaManager, name, mod, objectClassesRemoved,
entryObjectClasses );