Fixed LDAP-189, The constructor DefaultDirContextValidator(int searchScope) does not actually set scope in SearchControls

This commit is contained in:
Ulrik Sandberg
2010-10-17 21:59:01 +00:00
parent ed2b0180f8
commit 1952987fd5
2 changed files with 19 additions and 0 deletions

View File

@@ -99,6 +99,7 @@ public class DefaultDirContextValidator implements DirContextValidator {
*/
public DefaultDirContextValidator(int searchScope) {
this.searchControls = new SearchControls();
this.searchControls.setSearchScope(searchScope);
this.searchControls.setCountLimit(1);
this.searchControls.setReturningAttributes(new String[] { "objectclass" });
this.searchControls.setTimeLimit(500);

View File

@@ -69,7 +69,25 @@ public class DefaultDirContextValidatorTest extends TestCase {
namingEnumerationControl.verify();
dirContextControl.verify();
}
// LDAP-189
public void testSearchScopeOneLevelScopeSetInConstructorIsUsed() throws Exception {
DefaultDirContextValidator tested = new DefaultDirContextValidator(SearchControls.ONELEVEL_SCOPE);
assertEquals("ONELEVEL_SCOPE, ", SearchControls.ONELEVEL_SCOPE, tested.getSearchControls().getSearchScope());
}
// LDAP-189
public void testSearchScopeSubTreeScopeSetInConstructorIsUsed() throws Exception {
DefaultDirContextValidator tested = new DefaultDirContextValidator(SearchControls.SUBTREE_SCOPE);
assertEquals("SUBTREE_SCOPE, ", SearchControls.SUBTREE_SCOPE, tested.getSearchControls().getSearchScope());
}
// LDAP-189
public void testSearchScopeObjectScopeSetInConstructorIsUsed() throws Exception {
DefaultDirContextValidator tested = new DefaultDirContextValidator(SearchControls.OBJECT_SCOPE);
assertEquals("OBJECT_SCOPE, ", SearchControls.OBJECT_SCOPE, tested.getSearchControls().getSearchScope());
}
public void testProperties() throws Exception {
final DefaultDirContextValidator dirContextValidator = new DefaultDirContextValidator();