SubtreeSpecificationModifier modifier = new SubtreeSpecificationModifier();
modifier.setRefinement( refinement );
modifier.setMinBaseDistance( 1 );
modifier.setMaxBaseDistance( 3 );
modifier.setBase( new LdapName( "ou=users" ) );
SubtreeSpecification ss = modifier.getSubtreeSpecification();
Name apDn = new LdapName( "ou=system" );
Name entryDn = new LdapName( "ou=users,ou=system" );
Attribute objectClasses = new BasicAttribute( "objectClass", "person" );
assertFalse( evaluator.evaluate( ss, apDn, entryDn, objectClasses ) );
entryDn = new LdapName( "uid=akarasulu,ou=users,ou=system" );
assertTrue( evaluator.evaluate( ss, apDn, entryDn, objectClasses ) );
entryDn = new LdapName( "ou=system" );
assertFalse( evaluator.evaluate( ss, apDn, entryDn, objectClasses ) );
entryDn = new LdapName( "ou=twolevels,uid=akarasulu,ou=users,ou=system" );
assertTrue( evaluator.evaluate( ss, apDn, entryDn, objectClasses ) );
entryDn = new LdapName( "ou=threelevels,ou=twolevels,uid=akarasulu,ou=users,ou=system" );
assertTrue( evaluator.evaluate( ss, apDn, entryDn, objectClasses ) );
entryDn = new LdapName( "ou=fourlevels,ou=threelevels,ou=twolevels,uid=akarasulu,ou=users,ou=system" );
assertFalse( evaluator.evaluate( ss, apDn, entryDn, objectClasses ) );
// now change the refinement so the entry is rejected
objectClasses = new BasicAttribute( "objectClass", "organizationalUnit" );
assertFalse( evaluator.evaluate( ss, apDn, entryDn, objectClasses ) );
entryDn = new LdapName( "uid=akarasulu,ou=users,ou=system" );
assertFalse( evaluator.evaluate( ss, apDn, entryDn, objectClasses ) );
entryDn = new LdapName( "ou=system" );
assertFalse( evaluator.evaluate( ss, apDn, entryDn, objectClasses ) );
entryDn = new LdapName( "ou=twolevels,uid=akarasulu,ou=users,ou=system" );
assertFalse( evaluator.evaluate( ss, apDn, entryDn, objectClasses ) );
entryDn = new LdapName( "ou=threelevels,ou=twolevels,uid=akarasulu,ou=users,ou=system" );
assertFalse( evaluator.evaluate( ss, apDn, entryDn, objectClasses ) );
entryDn = new LdapName( "ou=fourlevels,ou=threelevels,ou=twolevels,uid=akarasulu,ou=users,ou=system" );
assertFalse( evaluator.evaluate( ss, apDn, entryDn, objectClasses ) );
}