Removed unused methods and added some extra tests.

This commit is contained in:
Luke Taylor 2006-05-20 17:46:10 +00:00
parent aa0d7c5380
commit 859185eebd
2 changed files with 23 additions and 10 deletions

View File

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

View File

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