* Test for method add( String, byte[]...)
*/
@Test
public void testAddStringByteArrayArray() throws Exception
{
Entry entry = new DefaultEntry( schemaManager, EXAMPLE_DN );
entry.add( "userPassword", ( byte[] ) null );
assertEquals( 1, entry.size() );
Attribute attributePWD = entry.get( "userPassword" );
assertEquals( 1, attributePWD.size() );
assertNotNull( attributePWD.get() );
assertNull( attributePWD.get().getValue() );
entry.clear();
entry.add( "userPassword", BYTES1, BYTES1, BYTES2 );
assertEquals( 1, entry.size() );
Attribute attributeJPG = entry.get( "userPassword" );
assertEquals( 2, attributeJPG.size() );
assertNotNull( attributeJPG.get() );
assertTrue( attributeJPG.contains( BYTES1 ) );
assertTrue( attributeJPG.contains( BYTES2 ) );
entry.clear();
try
{
// Cannot add an attribute which does not exist
entry.add( "wrongAT", BYTES1, BYTES2 );
fail();
}
catch ( LdapNoSuchAttributeException nsae )
{
assertTrue( true );
}
// Cannot add String values into a binary attribute
entry.add( "userPassword", "test", "test2" );
assertEquals( 2, entry.get( "userPassword" ).size() );
}