// now modify entries included by the subentry to have collectiveExclusions
// -------------------------------------------------------------------
ModificationItem[] items = new ModificationItem[] {
new ModificationItem( DirContext.ADD_ATTRIBUTE,
new LockableAttributeImpl( "collectiveExclusions", "c-ou" ) ) };
super.sysRoot.modifyAttributes( "ou=services,ou=configuration", items );
entries = getAllEntries();
// entry should not show the c-ou collective attribute anymore
attributes = ( Attributes ) entries.get( "ou=services,ou=configuration,ou=system" );
c_ou = attributes.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
super.sysRoot.createSubcontext( "cn=testsubentry2", getTestSubentry2() );
entries = getAllEntries();
attributes = ( Attributes ) entries.get( "ou=services,ou=configuration,ou=system" );
c_ou = attributes.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
attributes = ( Attributes ) entries.get( "ou=interceptors,ou=configuration,ou=system" );
c_ou = attributes.get( "c-ou" );
assertNotNull( "a collective c-ou attribute should be present", c_ou );
assertTrue( c_ou.contains( "configuration" ) );
assertTrue( c_ou.contains( "configuration2" ) );
// -------------------------------------------------------------------
// now add the subentry for the c-st collective attribute
// -------------------------------------------------------------------
super.sysRoot.createSubcontext( "cn=testsubentry3", getTestSubentry3() );
entries = getAllEntries();
// the new attribute c-st should appear in the node with the c-ou exclusion
attributes = ( Attributes ) entries.get( "ou=services,ou=configuration,ou=system" );
Attribute c_st = attributes.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
attributes = ( Attributes ) entries.get( "ou=interceptors,ou=configuration,ou=system" );
c_ou = attributes.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 = attributes.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
// -------------------------------------------------------------------
items = new ModificationItem[] {
new ModificationItem( DirContext.REPLACE_ATTRIBUTE,
new LockableAttributeImpl( "collectiveExclusions", "excludeAllCollectiveAttributes" ) ) };
super.sysRoot.modifyAttributes( "ou=interceptors,ou=configuration", items );
entries = getAllEntries();
// none of the attributes should appear any longer
attributes = ( Attributes ) entries.get( "ou=interceptors,ou=configuration,ou=system" );