public void testAddAlias() throws Exception
{
DirContext ctx = ( DirContext ) getWiredContext( ldapServer ).lookup( BASE );
// Create entry
Attributes entry = new BasicAttributes( true );
Attribute entryOcls = new BasicAttribute( SchemaConstants.OBJECT_CLASS_AT );
entryOcls.add( SchemaConstants.TOP_OC );
entryOcls.add( SchemaConstants.ORGANIZATIONAL_UNIT_OC );
entry.put( entryOcls );
entry.put( SchemaConstants.OU_AT, "favorite" );
String entryRdn = "ou=favorite";
ctx.createSubcontext( entryRdn, entry );
// Create Alias
String aliasedObjectName = entryRdn + "," + ctx.getNameInNamespace();
Attributes alias = new BasicAttributes( true );
Attribute aliasOcls = new BasicAttribute( SchemaConstants.OBJECT_CLASS_AT );
aliasOcls.add( SchemaConstants.TOP_OC );
aliasOcls.add( SchemaConstants.EXTENSIBLE_OBJECT_OC );
aliasOcls.add( SchemaConstants.ALIAS_OC );
alias.put( aliasOcls );
alias.put( SchemaConstants.OU_AT, "bestFruit" );
alias.put( SchemaConstants.ALIASED_OBJECT_NAME_AT, aliasedObjectName );
String rdnAlias = "ou=bestFruit";
ctx.createSubcontext( rdnAlias, alias );
// Remove alias and entry
ctx.destroySubcontext( rdnAlias );