// -------------------------------------------------------------------
// now modify entries included by the subentry to have collectiveExclusions
// -------------------------------------------------------------------
ModificationItem[] items = new ModificationItem[]
{ new ModificationItem( DirContext.ADD_ATTRIBUTE,
new BasicAttribute( "collectiveExclusions", "c-ou" ) ) };
getSystemContext( service ).modifyAttributes( "ou=services,ou=configuration", items );
// entry should not show the c-ou collective attribute anymore
attributes = getSystemContext( service ).getAttributes( "ou=services,ou=configuration" );
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
getSystemContext( service ).createSubcontext( "cn=testsubentry2", getTestSubentry2() );
attributes = getSystemContext( service ).getAttributes( "ou=services,ou=configuration" );
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 = getSystemContext( service ).getAttributes( "ou=interceptors,ou=configuration" );
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" ) );
// request the collective attribute specifically
attributes = getSystemContext( service ).getAttributes(
"ou=interceptors,ou=configuration", new String[] { "c-ou" } );
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" ) );
// unspecify the collective attribute in the returning attribute list
attributes = getSystemContext( service ).getAttributes(
"ou=interceptors,ou=configuration", new String[] { "objectClass" } );
c_ou = attributes.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
// -------------------------------------------------------------------
getSystemContext( service ).createSubcontext( "cn=testsubentry3", getTestSubentry3() );
// the new attribute c-st should appear in the node with the c-ou exclusion
attributes = getSystemContext( service ).getAttributes( "ou=services,ou=configuration" );
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 = getSystemContext( service ).getAttributes( "ou=interceptors,ou=configuration" );
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 BasicAttribute( "collectiveExclusions",
"excludeAllCollectiveAttributes" ) ) };
getSystemContext( service ).modifyAttributes( "ou=interceptors,ou=configuration", items );
// none of the attributes should appear any longer
attributes = getSystemContext( service ).getAttributes( "ou=interceptors,ou=configuration" );