From e81be72bd79df9098364a855d8be673d89ad7c58 Mon Sep 17 00:00:00 2001 From: Luke Taylor Date: Sun, 1 Jan 2006 15:11:54 +0000 Subject: [PATCH] Changed test to use tested class rather than interface name. Added test for service detection style URLs. --- ...DefaultInitialDirContextFactoryTests.java} | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) rename core/src/test/java/org/acegisecurity/providers/ldap/{InitialDirContextFactoryTests.java => DefaultInitialDirContextFactoryTests.java} (91%) diff --git a/core/src/test/java/org/acegisecurity/providers/ldap/InitialDirContextFactoryTests.java b/core/src/test/java/org/acegisecurity/providers/ldap/DefaultInitialDirContextFactoryTests.java similarity index 91% rename from core/src/test/java/org/acegisecurity/providers/ldap/InitialDirContextFactoryTests.java rename to core/src/test/java/org/acegisecurity/providers/ldap/DefaultInitialDirContextFactoryTests.java index 8a49a5f1c7..e4d9955590 100644 --- a/core/src/test/java/org/acegisecurity/providers/ldap/InitialDirContextFactoryTests.java +++ b/core/src/test/java/org/acegisecurity/providers/ldap/DefaultInitialDirContextFactoryTests.java @@ -4,18 +4,23 @@ import javax.naming.Context; import javax.naming.directory.DirContext; import java.util.Hashtable; -import org.springframework.dao.DataAccessResourceFailureException; import org.acegisecurity.BadCredentialsException; /** - * Tests {@link InitialDirContextFactory}. + * Tests {@link DefaultInitialDirContextFactory}. * * @author Luke Taylor * @version $Id$ */ -public class InitialDirContextFactoryTests extends AbstractLdapServerTestCase { +public class DefaultInitialDirContextFactoryTests extends AbstractLdapServerTestCase { DefaultInitialDirContextFactory idf; + public void setUp() { + idf = new DefaultInitialDirContextFactory(PROVIDER_URL); + idf.setInitialContextFactory(CONTEXT_FACTORY); + idf.setExtraEnvVars(EXTRA_ENV); + } + // public void testNonLdapUrlIsRejected() throws Exception { // DefaultInitialDirContextFactory idf = new DefaultInitialDirContextFactory(); // @@ -29,10 +34,10 @@ public class InitialDirContextFactoryTests extends AbstractLdapServerTestCase { // } // } - public void setUp() { - idf = new DefaultInitialDirContextFactory(PROVIDER_URL); - idf.setInitialContextFactory(CONTEXT_FACTORY); - idf.setExtraEnvVars(EXTRA_ENV); + public void testServiceLocationUrlIsSupported() { + idf = new DefaultInitialDirContextFactory("ldap:///dc=acegisecurity,dc=org"); + assertEquals("dc=acegisecurity,dc=org", idf.getRootDn()); + } public void testConnectionFailure() throws Exception { @@ -46,7 +51,7 @@ public class InitialDirContextFactoryTests extends AbstractLdapServerTestCase { try { idf.newInitialDirContext(); fail("Connection succeeded unexpectedly"); - } catch(DataAccessResourceFailureException expected) { + } catch(LdapDataAccessException expected) { } } @@ -83,6 +88,7 @@ public class InitialDirContextFactoryTests extends AbstractLdapServerTestCase { "bobspassword"); // We don't want pooling for specific users. // assertNull(ctx.getEnvironment().get("com.sun.jndi.ldap.connect.pool")); +// com.sun.jndi.ldap.LdapPoolManager.showStats(System.out); ctx.close(); }