assertNull( "the c-ou collective attribute should not be present", c_ou );
// -------------------------------------------------------------------
// now modify entries included by the subentry to have collectiveExclusions
// -------------------------------------------------------------------
Modification modification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE,
new DefaultAttribute( "collectiveExclusions", "c-ou" ) );
connection.modify( "ou=services,ou=configuration, ou=system", modification );
// entry should not show the c-ou collective attribute anymore
entry = connection.lookup( "ou=services,ou=configuration,ou=system" );
c_ou = entry.get( "c-ou" );
if ( c_ou != null )
{
assertEquals( "the c-ou collective attribute should not be present", 0, c_ou.size() );
}
// now add more collective subentries - the c-ou should still not show due to exclusions
Entry subentry2 = getTestSubentry2( "cn=testsubentry2,ou=system" );
connection.add( subentry2 );
entry = connection.lookup( "ou=services,ou=configuration,ou=system" );
c_ou = entry.get( "c-ou" );
if ( c_ou != null )
{
assertEquals( "the c-ou collective attribute should not be present", 0, c_ou.size() );
}
// entries without the collectiveExclusion should still show both values of c-ou
entry = connection.lookup( "ou=interceptors,ou=configuration,ou=system" );
c_ou = entry.get( "c-ou" );
assertNotNull( "a collective c-ou attribute should be present", c_ou );
assertTrue( c_ou.contains( "configuration" ) );
assertTrue( c_ou.contains( "configuration2" ) );
// request the collective attribute specifically
entry = connection.lookup( "ou=interceptors,ou=configuration,ou=system", "c-ou" );
c_ou = entry.get( "c-ou" );
assertNotNull( "a collective c-ou attribute should be present", c_ou );
assertTrue( c_ou.contains( "configuration" ) );
assertTrue( c_ou.contains( "configuration2" ) );
// unspecify the collective attribute in the returning attribute list
entry = connection.lookup( "ou=interceptors,ou=configuration,ou=system", "objectClass" );
c_ou = entry.get( "c-ou" );
assertNull( "a collective c-ou attribute should not be present", c_ou );
// -------------------------------------------------------------------
// now add the subentry for the c-st collective attribute
// -------------------------------------------------------------------
connection.add( getTestSubentry3( "cn=testsubentry3,ou=system" ) );
// the new attribute c-st should appear in the node with the c-ou exclusion
entry = connection.lookup( "ou=services,ou=configuration,ou=system" );
Attribute c_st = entry.get( "c-st" );
assertNotNull( "a collective c-st attribute should be present", c_st );
assertTrue( c_st.contains( "FL" ) );
// in node without exclusions both values of c-ou should appear with c-st value
entry = connection.lookup( "ou=interceptors,ou=configuration,ou=system" );
c_ou = entry.get( "c-ou" );
assertNotNull( "a collective c-ou attribute should be present", c_ou );
assertTrue( c_ou.contains( "configuration" ) );
assertTrue( c_ou.contains( "configuration2" ) );
c_st = entry.get( "c-st" );
assertNotNull( "a collective c-st attribute should be present", c_st );
assertTrue( c_st.contains( "FL" ) );
// -------------------------------------------------------------------
// now modify an entry to exclude all collective attributes
// -------------------------------------------------------------------
modification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultAttribute(
"collectiveExclusions", "excludeAllCollectiveAttributes" ) );
connection.modify( "ou=interceptors,ou=configuration, ou=system", modification );
// none of the attributes should appear any longer
entry = connection.lookup( "ou=interceptors,ou=configuration,ou=system" );