*/
@Test
public void tesPutServerAttributeElipsis() throws Exception
{
Dn dn = new Dn( schemaManager, "cn=test" );
DefaultEntry entry = new DefaultEntry( schemaManager, dn );
// first test a null SA addition. It should be allowed.
try
{
entry.put( ( Attribute ) null );
fail();
}
catch ( IllegalArgumentException iae )
{
assertTrue( true );
}
// Adding some serverAttributes
//AttributeType atCo = registries.lookupAttributeTypeRegistry( "countryName" );
AttributeType atGN = schemaManager.lookupAttributeTypeRegistry( "givenname" );
AttributeType atStreet = schemaManager.lookupAttributeTypeRegistry( "2.5.4.9" );
Attribute sa = new DefaultAttribute( atL, "france" );
entry.put( sa );
assertEquals( 1, entry.size() );
assertNotNull( entry.get( "l" ) );
assertEquals( "france", entry.get( "l" ).get().getString() );
Attribute sb = new DefaultAttribute( atC, "countryTest" );
Attribute sc = new DefaultAttribute( atGN, "test" );
Attribute sd = new DefaultAttribute( atStreet, "testStreet" );
entry.put( sb, sc, sd );
assertEquals( 4, entry.size() );
assertNotNull( entry.get( atC ) );
assertEquals( "countryTest", entry.get( atC ).get().getString() );
assertNotNull( entry.get( atGN ) );
assertEquals( "test", entry.get( atGN ).get().getString() );
assertNotNull( entry.get( atStreet ) );
assertEquals( "testStreet", entry.get( atStreet ).get().getString() );
// Test a replacement
Attribute sbb = new DefaultAttribute( atC, "countryTestTest" );
Attribute scc = new DefaultAttribute( atGN, "testtest" );
List<Attribute> result = entry.put( sbb, scc );
assertEquals( 2, result.size() );
assertEquals( "countryTest", result.get( 0 ).get().getString() );
assertEquals( "test", result.get( 1 ).get().getString() );
assertEquals( 4, entry.size() );
assertNotNull( entry.get( atC ) );
assertEquals( "countryTestTest", entry.get( atC ).get().getString() );
assertNotNull( entry.get( atGN ) );
assertEquals( "testtest", entry.get( atGN ).get().getString() );
assertNotNull( entry.get( atStreet ) );
assertEquals( "testStreet", entry.get( atStreet ).get().getString() );
// test an ObjectClass replacement
AttributeType OBJECT_CLASS_AT = schemaManager.lookupAttributeTypeRegistry( SchemaConstants.OBJECT_CLASS_AT );
Attribute oc = new DefaultAttribute( "OBJECTCLASS", OBJECT_CLASS_AT, "person", "inetorgperson" );
List<Attribute> oldOc = entry.put( oc );
assertNotNull( oldOc );
assertEquals( 0, oldOc.size() );
assertNotNull( entry.get( "objectClass" ) );
Attribute newOc = entry.get( "objectClass" );
assertNotNull( newOc );
assertEquals( OBJECT_CLASS_AT, newOc.getAttributeType() );
assertEquals( 2, newOc.size() );
assertEquals( "OBJECTCLASS", newOc.getUpId() );