Made mock context factory a standalone class

This commit is contained in:
Luke Taylor 2006-05-20 17:47:36 +00:00
parent 859185eebd
commit 316798ef9e
2 changed files with 30 additions and 23 deletions

View File

@ -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;
}
}

View File

@ -2,7 +2,7 @@ package org.acegisecurity.providers.ldap.authenticator;
import org.jmock.Mock;
import org.jmock.MockObjectTestCase;
import org.acegisecurity.ldap.InitialDirContextFactory;
import org.acegisecurity.ldap.MockInitialDirContextFactory;
import javax.naming.directory.DirContext;
import javax.naming.directory.BasicAttributes;
@ -36,26 +36,4 @@ public class PasswordComparisonAuthenticatorMockTests extends MockObjectTestCase
mockCtx.expects(atLeastOnce()).method("close");
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;
}
}
}