Made sure integration tests for article sample automatically start in-process LDAP server.

DirContextAdapter#setDn() now throws IllegalStateException if setDn is called on an 
instance in update mode (this was previously silently ignored)
Fixed problem in LdapTreeBuilder caused by the new behaviour of DN in DirContextAdapter
(i.e. that the actual DN instance of the DirContextAdapter is no longer returned by 
getDn()).
This commit is contained in:
Mattias Arthursson
2008-11-25 15:24:05 +00:00
parent 47f2360e34
commit bf2c3af0a2
6 changed files with 74 additions and 17 deletions

View File

@@ -14,22 +14,24 @@ public class LdapTreeBuilder {
}
public LdapTree getLdapTree(DistinguishedName root) {
DirContextOperations context = ldapTemplate.lookupContext(root.toString());
DirContextOperations context = ldapTemplate.lookupContext(root
.toString());
return getLdapTree(context);
}
private LdapTree getLdapTree(final DirContextOperations rootContext) {
final LdapTree ldapTree = new LdapTree(rootContext);
ldapTemplate.listBindings(rootContext.getDn(), new AbstractContextMapper() {
@Override
protected Object doMapFromContext(DirContextOperations ctx) {
DistinguishedName dn = (DistinguishedName) ctx.getDn();
dn.prepend((DistinguishedName) rootContext.getDn());
ldapTree.addSubTree(getLdapTree(ctx));
return null;
}
});
ldapTemplate.listBindings(rootContext.getDn(),
new AbstractContextMapper() {
@Override
protected Object doMapFromContext(DirContextOperations ctx) {
DistinguishedName dn = (DistinguishedName) ctx.getDn();
dn.prepend((DistinguishedName) rootContext.getDn());
ldapTree.addSubTree(getLdapTree(ldapTemplate
.lookupContext(dn)));
return null;
}
});
return ldapTree;
}