Changed test to use tested class rather than interface name. Added test for service detection style URLs.

This commit is contained in:
Luke Taylor 2006-01-01 15:11:54 +00:00
parent 53dcdf7e89
commit e81be72bd7
1 changed files with 14 additions and 8 deletions

View File

@ -4,18 +4,23 @@ import javax.naming.Context;
import javax.naming.directory.DirContext; import javax.naming.directory.DirContext;
import java.util.Hashtable; import java.util.Hashtable;
import org.springframework.dao.DataAccessResourceFailureException;
import org.acegisecurity.BadCredentialsException; import org.acegisecurity.BadCredentialsException;
/** /**
* Tests {@link InitialDirContextFactory}. * Tests {@link DefaultInitialDirContextFactory}.
* *
* @author Luke Taylor * @author Luke Taylor
* @version $Id$ * @version $Id$
*/ */
public class InitialDirContextFactoryTests extends AbstractLdapServerTestCase { public class DefaultInitialDirContextFactoryTests extends AbstractLdapServerTestCase {
DefaultInitialDirContextFactory idf; DefaultInitialDirContextFactory idf;
public void setUp() {
idf = new DefaultInitialDirContextFactory(PROVIDER_URL);
idf.setInitialContextFactory(CONTEXT_FACTORY);
idf.setExtraEnvVars(EXTRA_ENV);
}
// public void testNonLdapUrlIsRejected() throws Exception { // public void testNonLdapUrlIsRejected() throws Exception {
// DefaultInitialDirContextFactory idf = new DefaultInitialDirContextFactory(); // DefaultInitialDirContextFactory idf = new DefaultInitialDirContextFactory();
// //
@ -29,10 +34,10 @@ public class InitialDirContextFactoryTests extends AbstractLdapServerTestCase {
// } // }
// } // }
public void setUp() { public void testServiceLocationUrlIsSupported() {
idf = new DefaultInitialDirContextFactory(PROVIDER_URL); idf = new DefaultInitialDirContextFactory("ldap:///dc=acegisecurity,dc=org");
idf.setInitialContextFactory(CONTEXT_FACTORY); assertEquals("dc=acegisecurity,dc=org", idf.getRootDn());
idf.setExtraEnvVars(EXTRA_ENV);
} }
public void testConnectionFailure() throws Exception { public void testConnectionFailure() throws Exception {
@ -46,7 +51,7 @@ public class InitialDirContextFactoryTests extends AbstractLdapServerTestCase {
try { try {
idf.newInitialDirContext(); idf.newInitialDirContext();
fail("Connection succeeded unexpectedly"); fail("Connection succeeded unexpectedly");
} catch(DataAccessResourceFailureException expected) { } catch(LdapDataAccessException expected) {
} }
} }
@ -83,6 +88,7 @@ public class InitialDirContextFactoryTests extends AbstractLdapServerTestCase {
"bobspassword"); "bobspassword");
// We don't want pooling for specific users. // We don't want pooling for specific users.
// assertNull(ctx.getEnvironment().get("com.sun.jndi.ldap.connect.pool")); // assertNull(ctx.getEnvironment().get("com.sun.jndi.ldap.connect.pool"));
// com.sun.jndi.ldap.LdapPoolManager.showStats(System.out);
ctx.close(); ctx.close();
} }