*/
@Test
public void tesPutUpIDAtBytesElipsis() throws Exception
{
Dn dn = new Dn( schemaManager, "cn=test" );
DefaultEntry entry = new DefaultEntry( schemaManager, dn );
AttributeType atPassword = schemaManager.lookupAttributeTypeRegistry( "userPassword" );
// Test that we get an error when the ID or AT are null
try
{
entry.put( null, ( AttributeType ) null, ( String ) null );
fail();
}
catch ( IllegalArgumentException iae )
{
assertTrue( true );
}
// Test an empty AT
entry.put( "userPassword", atPassword, ( byte[] ) null );
assertEquals( 1, entry.size() );
assertEquals( "userPassword", entry.get( atPassword ).getUpId() );
assertTrue( entry.containsAttribute( "userPassword" ) );
assertNull( entry.get( atPassword ).get().getValue() );
// Check that we can use a null AttributeType
entry.put( "userPassword", ( AttributeType ) null, ( byte[] ) null );
assertEquals( 1, entry.size() );
assertEquals( "userPassword", entry.get( atPassword ).getUpId() );
assertTrue( entry.containsAttribute( "userPassword" ) );
assertNull( entry.get( atPassword ).get().getValue() );
// Test that we can use a null upId
entry.put( null, atPassword, ( byte[] ) null );
assertEquals( 1, entry.size() );
assertEquals( "userPassword", entry.get( atPassword ).getUpId() );
assertTrue( entry.containsAttribute( "userPassword" ) );
assertNull( entry.get( atPassword ).get().getValue() );
// Test that if we use an upId which is not compatible
// with the AT, it is changed to the AT default name
try
{
entry.put( "sn", atPassword, ( byte[] ) null );
fail();
}
catch ( IllegalArgumentException iae )
{
assertTrue( true );
}
assertEquals( "2.5.4.35", entry.get( atPassword ).getId() );
// Test that we can add some new attributes with values
byte[] test1 = Strings.getBytesUtf8( "test1" );
byte[] test2 = Strings.getBytesUtf8( "test2" );
byte[] test3 = Strings.getBytesUtf8( "test3" );
Attribute result = entry.put( "UserPassword", atPassword, test1, test2, test3 );
assertNotNull( result );
assertEquals( "userPassword", result.getUpId() );
assertEquals( 1, entry.size() );
assertEquals( "UserPassword", entry.get( atPassword ).getUpId() );
assertNotNull( entry.get( atPassword ).get() );
assertEquals( 3, entry.get( atPassword ).size() );
assertTrue( entry.contains( "UserPassword", test1 ) );
assertTrue( entry.contains( "userPassword", test2 ) );
assertTrue( entry.contains( "2.5.4.35", test3 ) );
}