*/
@Test
public void testAddUpIdServerValueElipsis() throws Exception
{
Dn dn = new Dn( schemaManager, "cn=test" );
Entry entry = new DefaultEntry( schemaManager, dn );
AttributeType atPassword = schemaManager.lookupAttributeTypeRegistry( "userPassword" );
byte[] b1 = Strings.getBytesUtf8( "test1" );
byte[] b2 = Strings.getBytesUtf8( "test2" );
byte[] b3 = Strings.getBytesUtf8( "test3" );
Value<String> test1 = new StringValue( atEMail, "test1" );
Value<String> test2 = new StringValue( atEMail, "test2" );
Value<String> test3 = new StringValue( atEMail, "test3" );
Value<byte[]> testB1 = new BinaryValue( atPassword, b1 );
Value<byte[]> testB2 = new BinaryValue( atPassword, b2 );
Value<byte[]> testB3 = new BinaryValue( atPassword, b3 );
// Test a simple addition in atDC
entry.add( "eMail", test1 );
assertNotNull( entry.get( atEMail ) );
assertEquals( 1, entry.get( atEMail ).size() );
assertEquals( "test1", entry.get( atEMail ).get().getString() );
assertTrue( entry.containsAttribute( atEMail ) );
assertEquals( "eMail", entry.get( atEMail ).getUpId() );
// Test some more addition
entry.add( "eMail", test2, test3 );
assertNotNull( entry.get( atEMail ) );
assertEquals( 3, entry.get( atEMail ).size() );
assertTrue( entry.contains( atEMail, "test1" ) );
assertTrue( entry.contains( atEMail, "test2" ) );
assertTrue( entry.contains( atEMail, "test3" ) );
assertTrue( entry.containsAttribute( atEMail ) );
assertEquals( "eMail", entry.get( atEMail ).getUpId() );
// Test some addition of existing values
entry.add( "eMail", test2 );
assertNotNull( entry.get( atEMail ) );
assertEquals( 3, entry.get( atEMail ).size() );
assertTrue( entry.contains( atEMail, "test1" ) );
assertTrue( entry.contains( atEMail, "test2" ) );
assertTrue( entry.contains( atEMail, "test3" ) );
// Test the addition of a null value
entry.add( "eMail", ( String ) null );
assertNotNull( entry.get( atEMail ) );
assertEquals( 4, entry.get( atEMail ).size() );
assertTrue( entry.contains( atEMail, "test1" ) );
assertTrue( entry.contains( atEMail, "test2" ) );
assertTrue( entry.contains( atEMail, "test3" ) );
assertTrue( entry.contains( atEMail, ( String ) null ) );
entry.clear();
// Test the addition of a String value. It should be converted to a byte array
byte[] test4 = Strings.getBytesUtf8( "test4" );
entry.add( "eMail", test4 );
assertFalse( entry.contains( "cN", test4 ) );
// Now, work with a binary attribute
// Test a simple addition
entry.add( "userPASSWORD", testB1 );
assertNotNull( entry.get( atPassword ) );
assertEquals( 1, entry.get( atPassword ).size() );
assertTrue( Arrays.equals( b1, entry.get( atPassword ).get().getBytes() ) );
assertTrue( entry.containsAttribute( atPassword ) );
assertEquals( "userPASSWORD", entry.get( atPassword ).getUpId() );
// Test some more addition
entry.add( "userPASSWORD", testB2, testB3 );
assertNotNull( entry.get( atPassword ) );
assertEquals( 3, entry.get( atPassword ).size() );
assertTrue( entry.contains( atPassword, b1 ) );
assertTrue( entry.contains( atPassword, b2 ) );
assertTrue( entry.contains( atPassword, b3 ) );
// Test some addition of existing values
entry.add( "userPASSWORD", testB2 );
assertNotNull( entry.get( atPassword ) );
assertEquals( 3, entry.get( atPassword ).size() );
assertTrue( entry.contains( atPassword, b1 ) );
assertTrue( entry.contains( atPassword, b2 ) );
assertTrue( entry.contains( atPassword, b3 ) );
// Test the addition of a null value
entry.add( "userPASSWORD", ( byte[] ) null );
assertNotNull( entry.get( atPassword ) );
assertEquals( 4, entry.get( atPassword ).size() );
assertTrue( entry.contains( atPassword, b1 ) );
assertTrue( entry.contains( atPassword, b2 ) );
assertTrue( entry.contains( atPassword, b3 ) );
assertTrue( entry.contains( atPassword, ( byte[] ) null ) );
entry.clear();
// Test the addition of a String value. It should be converted to a byte array
byte[] b4 = Strings.getBytesUtf8( "test4" );
entry.add( "userPASSWORD", "test4" );
assertNotNull( entry.get( atPassword ) );
assertEquals( 1, entry.get( atPassword ).size() );
assertTrue( entry.contains( atPassword, b4 ) );
}