public void testAddExistingNthAttributesDirServer664() throws Exception
{
DirContext ctx = ( DirContext ) getWiredContext( getLdapServer() ).lookup( BASE );
// Change description attribute
Attributes attrs = new BasicAttributes( true );
attrs.put( new BasicAttribute( "telephoneNumber", "1" ) );
attrs.put( new BasicAttribute( "telephoneNumber", "2" ) );
attrs.put( new BasicAttribute( "telephoneNumber", "3" ) );
attrs.put( new BasicAttribute( "telephoneNumber", "4" ) );
attrs.put( new BasicAttribute( "telephoneNumber", "5" ) );
attrs.put( new BasicAttribute( "telephoneNumber", "6" ) );
attrs.put( new BasicAttribute( "telephoneNumber", "7" ) );
attrs.put( new BasicAttribute( "telephoneNumber", "8" ) );
attrs.put( new BasicAttribute( "telephoneNumber", "9" ) );
attrs.put( new BasicAttribute( "telephoneNumber", "10" ) );
attrs.put( new BasicAttribute( "telephoneNumber", "11" ) );
attrs.put( new BasicAttribute( "telephoneNumber", "12" ) );
attrs.put( new BasicAttribute( "telephoneNumber", "13" ) );
attrs.put( new BasicAttribute( "telephoneNumber", "14" ) );
Attribute attr = new BasicAttribute( "description", PERSON_DESCRIPTION );
attrs.put( attr );
try
{
ctx.modifyAttributes( RDN_TORI_AMOS, DirContext.ADD_ATTRIBUTE, attrs );
fail( "Adding an already existing atribute value should fail." );
}
catch ( AttributeInUseException e )
{
// expected behaviour
}
// Verify, that attribute is still there, and is the only one
attrs = ctx.getAttributes( RDN_TORI_AMOS );
attr = attrs.get( "description" );
assertNotNull( attr );
assertTrue( attr.contains( PERSON_DESCRIPTION ) );
assertEquals( 1, attr.size() );
}