Made mock context factory a standalone class
This commit is contained in:
parent
859185eebd
commit
316798ef9e
|
@ -0,0 +1,29 @@
|
||||||
|
package org.acegisecurity.ldap;
|
||||||
|
|
||||||
|
import javax.naming.directory.DirContext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Luke Taylor
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class MockInitialDirContextFactory implements InitialDirContextFactory {
|
||||||
|
DirContext ctx;
|
||||||
|
String baseDn;
|
||||||
|
|
||||||
|
public MockInitialDirContextFactory(DirContext ctx, String baseDn) {
|
||||||
|
this.baseDn = baseDn;
|
||||||
|
this.ctx = ctx;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DirContext newInitialDirContext() {
|
||||||
|
return ctx;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DirContext newInitialDirContext(String username, String password) {
|
||||||
|
return ctx;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRootDn() {
|
||||||
|
return baseDn;
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,7 +2,7 @@ package org.acegisecurity.providers.ldap.authenticator;
|
||||||
|
|
||||||
import org.jmock.Mock;
|
import org.jmock.Mock;
|
||||||
import org.jmock.MockObjectTestCase;
|
import org.jmock.MockObjectTestCase;
|
||||||
import org.acegisecurity.ldap.InitialDirContextFactory;
|
import org.acegisecurity.ldap.MockInitialDirContextFactory;
|
||||||
|
|
||||||
import javax.naming.directory.DirContext;
|
import javax.naming.directory.DirContext;
|
||||||
import javax.naming.directory.BasicAttributes;
|
import javax.naming.directory.BasicAttributes;
|
||||||
|
@ -36,26 +36,4 @@ public class PasswordComparisonAuthenticatorMockTests extends MockObjectTestCase
|
||||||
mockCtx.expects(atLeastOnce()).method("close");
|
mockCtx.expects(atLeastOnce()).method("close");
|
||||||
authenticator.authenticate("Bob", "bobspassword");
|
authenticator.authenticate("Bob", "bobspassword");
|
||||||
}
|
}
|
||||||
|
|
||||||
class MockInitialDirContextFactory implements InitialDirContextFactory {
|
|
||||||
DirContext ctx;
|
|
||||||
String baseDn;
|
|
||||||
|
|
||||||
public MockInitialDirContextFactory(DirContext ctx, String baseDn) {
|
|
||||||
this.baseDn = baseDn;
|
|
||||||
this.ctx = ctx;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DirContext newInitialDirContext() {
|
|
||||||
return ctx;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DirContext newInitialDirContext(String username, String password) {
|
|
||||||
return ctx;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRootDn() {
|
|
||||||
return baseDn;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue