* Create a person entry with multivalued Rdn and check its name.
*/
@Test
public void testMultiValuedRdnName() throws Exception
{
LdapContext ctx = ( LdapContext ) getWiredContext( getLdapServer() ).lookup( BASE );
Attributes attrs = getPersonAttributes( "Bush", "Kate Bush" );
String rdn = "cn=Kate Bush+sn=Bush";
DirContext entry = ctx.createSubcontext( rdn, attrs );
String nameInNamespace = entry.getNameInNamespace();
SearchControls sctls = new SearchControls();
sctls.setSearchScope( SearchControls.OBJECT_SCOPE );
String filter = "(sn=Bush)";
NamingEnumeration<SearchResult> enm = ctx.search( rdn, filter, sctls );
if ( enm.hasMore() )
{
SearchResult sr = enm.next();
assertNotNull( sr );
assertEquals( "Name in namespace", nameInNamespace, sr.getNameInNamespace() );
}
else
{
fail( "Entry not found:" + nameInNamespace );
}
enm.close();
// Now search with the sn=Bush+cn=Kate Bush RDN
String mixedRdn = "sn=Bush+cn=Kate Bush";
enm = ctx.search( mixedRdn, filter, sctls );
if ( enm.hasMore() )
{
SearchResult sr = enm.next();
assertNotNull( sr );
Dn expectedDn = new Dn( mixedRdn + ",ou=system" );
assertEquals( "Name in namespace", expectedDn, sr.getNameInNamespace() );
}
else
{
fail( "Entry not found:" + nameInNamespace );
}
ctx.destroySubcontext( rdn );
}