* Test method for put( String, Value<?>... )
*/
@Test
public void testPutStringValueArray()
{
Entry entry = new DefaultServerEntry( schemaManager, EXAMPLE_DN );
Value<String> strValue1 = new ServerStringValue( atCN, "test1" );
Value<String> strValue2 = new ServerStringValue( atCN, "test2" );
Value<String> strValue3 = new ServerStringValue( atCN, "test3" );
Value<String> strNullValue = new ServerStringValue( atCN, null);
Value<byte[]> binValue1 = new ServerBinaryValue( atPwd, BYTES1 );
try
{
entry.put( (String)null, strValue1 );
fail();
}
catch ( IllegalArgumentException iae)
{
assertTrue( true );
}
try
{
entry.put( " ", strValue1 );
fail();
}
catch ( IllegalArgumentException iae)
{
assertTrue( true );
}
try
{
entry.put( "cnn", strValue1 );
fail();
}
catch ( IllegalArgumentException iae )
{
assertTrue( true );
}
EntryAttribute replaced = entry.put( "description", strNullValue );
assertNull( replaced );
assertEquals( 1, entry.size() );
assertNotNull( entry.get( "description" ) );
assertEquals( 1, entry.get( "description" ).size() );
assertNotNull( entry.get( "description" ).get() );
assertNull( entry.get( "description" ).get().get() );
replaced = entry.put( "CN", strValue3 );
assertNull( replaced );
assertEquals( 2, entry.size() );
assertNotNull( entry.get( "cn" ) );
assertEquals( 1, entry.get( "cn" ).size() );
assertNotNull( entry.get( "cn" ).get().get() );
assertTrue( entry.get( "cn" ).contains( strValue3 ) );
replaced = entry.put( "cN", strValue1, strValue2, strValue1 );
assertNotNull( replaced );
assertEquals( strValue3, replaced.get() );
assertEquals( 2, entry.size() );
assertNotNull( entry.get( "cn" ) );
assertEquals( 2, entry.get( "CN" ).size() );
EntryAttribute attribute = entry.get( "cn" );
assertTrue( attribute.contains( strValue1 ) );
assertTrue( attribute.contains( strValue2 ) );
assertEquals( "cn", attribute.getId() );
assertEquals( "cN", attribute.getUpId() );
// Bin values are not allowed, so the new CN will be empty
entry.put( "cn", binValue1 );
assertNull( entry.get( "cn" ).get() );
}