Removed unused methods and added some extra tests.
This commit is contained in:
parent
aa0d7c5380
commit
859185eebd
|
@ -55,14 +55,6 @@ public class LdapUtils {
|
|||
}
|
||||
}
|
||||
|
||||
public static String escapeNameForFilter(String name) {
|
||||
// TODO: Implement escaping as defined in RFC 2254
|
||||
// Think this is probably not needed as filter args should be escaped automatically
|
||||
// by the search methods.
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the part of a DN relative to a supplied base context.
|
||||
* <p>
|
||||
|
|
|
@ -14,7 +14,11 @@
|
|||
*/
|
||||
package org.acegisecurity.ldap;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.jmock.MockObjectTestCase;
|
||||
import org.jmock.Mock;
|
||||
|
||||
import javax.naming.directory.DirContext;
|
||||
import javax.naming.Context;
|
||||
|
||||
/**
|
||||
* Tests {@link LdapUtils}
|
||||
|
@ -22,7 +26,7 @@ import junit.framework.TestCase;
|
|||
* @author Luke Taylor
|
||||
* @version $Id$
|
||||
*/
|
||||
public class LdapUtilsTests extends TestCase {
|
||||
public class LdapUtilsTests extends MockObjectTestCase {
|
||||
|
||||
public void testRootDnsAreParsedFromUrlsCorrectly() {
|
||||
assertEquals("", LdapUtils.parseRootDnFromUrl("ldap://monkeymachine"));
|
||||
|
@ -33,4 +37,21 @@ public class LdapUtilsTests extends TestCase {
|
|||
assertEquals("dc=acegisecurity,dc=org", LdapUtils.parseRootDnFromUrl("ldap://monkeymachine/dc=acegisecurity,dc=org"));
|
||||
assertEquals("dc=acegisecurity,dc=org/ou=blah", LdapUtils.parseRootDnFromUrl("ldap://monkeymachine.co.uk/dc=acegisecurity,dc=org/ou=blah"));
|
||||
}
|
||||
|
||||
public void testGetRelativeNameReturnsFullDnWithEmptyBaseName() throws Exception {
|
||||
Mock mockCtx = mock(DirContext.class);
|
||||
|
||||
mockCtx.expects(atLeastOnce()).method("getNameInNamespace").will(returnValue(""));
|
||||
|
||||
assertEquals("cn=jane,dc=acegisecurity,dc=org",
|
||||
LdapUtils.getRelativeName("cn=jane,dc=acegisecurity,dc=org", (Context) mockCtx.proxy()));
|
||||
}
|
||||
|
||||
public void testGetRelativeNameReturnsEmptyStringForDnEqualToBaseName() throws Exception {
|
||||
Mock mockCtx = mock(DirContext.class);
|
||||
|
||||
mockCtx.expects(atLeastOnce()).method("getNameInNamespace").will(returnValue("dc=acegisecurity,dc=org"));
|
||||
|
||||
assertEquals("", LdapUtils.getRelativeName("dc=acegisecurity,dc=org", (Context) mockCtx.proxy()));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue