* Test method for pu( String, Value<?>... )
*/
@Test
public void testPutStringValueArray()
{
Entry entry = new DefaultEntry( EXAMPLE_DN );
Value<String> strValueTop = new StringValue( "top" );
Value<String> strValuePerson = new StringValue( "person" );
Value<String> strValueTop2 = new StringValue( "top" );
Value<String> strNullValue = new StringValue( ( String ) null );
Value<byte[]> binValue1 = new BinaryValue( BYTES1 );
Value<byte[]> binValue2 = new BinaryValue( BYTES2 );
Value<byte[]> binValue3 = new BinaryValue( BYTES1 );
Value<byte[]> binNullValue = new BinaryValue( ( byte[] ) null );
try
{
entry.put( ( String ) null, strValueTop );
fail();
}
catch ( IllegalArgumentException iae )
{
assertTrue( true );
}
try
{
entry.put( " ", strValueTop );
fail();
}
catch ( IllegalArgumentException iae )
{
assertTrue( true );
}
entry.put( "sn", strNullValue );
assertEquals( 1, entry.size() );
assertNotNull( "sn", entry.get( "sn" ) );
assertEquals( 1, entry.get( "sn" ).size() );
assertNull( entry.get( "sn" ).get().getValue() );
entry.clear();
entry.put( "ObjectClass", strValueTop, strValuePerson, strValueTop2, strNullValue );
assertEquals( 1, entry.size() );
assertNotNull( "objectclass", entry.get( "objectclass" ) );
assertEquals( 3, entry.get( "OBJECTCLASS" ).size() );
Attribute attribute = entry.get( "objectClass" );
assertTrue( attribute.contains( "top" ) );
assertTrue( attribute.contains( "person" ) );
assertTrue( attribute.contains( ( String ) null ) );
assertEquals( "objectclass", attribute.getId() );
assertEquals( "ObjectClass", attribute.getUpId() );
entry.clear();
entry.put( "userpassword", strNullValue );
assertEquals( 1, entry.size() );
assertNotNull( "userpassword", entry.get( "userpassword" ) );
assertEquals( 1, entry.get( "userpassword" ).size() );
assertNull( entry.get( "userpassword" ).get().getValue() );
entry.clear();
entry.put( "userPassword", binValue1, binValue2, binValue3, binNullValue );
assertEquals( 1, entry.size() );
assertNotNull( "userpassword", entry.get( "userpassword" ) );
assertEquals( 3, entry.get( "userpassword" ).size() );
attribute = entry.get( "userpassword" );
assertTrue( attribute.contains( BYTES1 ) );
assertTrue( attribute.contains( BYTES2 ) );
assertTrue( attribute.contains( ( byte[] ) null ) );
assertEquals( "userpassword", attribute.getId() );
assertEquals( "userPassword", attribute.getUpId() );