01: /* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited
02: *
03: * Licensed under the Apache License, Version 2.0 (the "License");
04: * you may not use this file except in compliance with the License.
05: * You may obtain a copy of the License at
06: *
07: * http://www.apache.org/licenses/LICENSE-2.0
08: *
09: * Unless required by applicable law or agreed to in writing, software
10: * distributed under the License is distributed on an "AS IS" BASIS,
11: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: * See the License for the specific language governing permissions and
13: * limitations under the License.
14: */
15:
16: package org.acegisecurity.ldap;
17:
18: import junit.framework.TestCase;
19:
20: import org.apache.directory.server.core.jndi.CoreContextFactory;
21:
22: import java.util.Hashtable;
23:
24: /**
25: *
26: *
27: * @author Luke Taylor
28: * @version $Id: AbstractLdapServerTestCase.java 1775 2007-02-04 20:06:36Z luke_t $
29: */
30: public abstract class AbstractLdapServerTestCase extends TestCase {
31: //~ Static fields/initializers =====================================================================================
32:
33: private static final String ROOT_DN = "dc=acegisecurity,dc=org";
34: protected static final String MANAGER_USER = "cn=manager,"
35: + ROOT_DN;
36: protected static final String MANAGER_PASSWORD = "acegisecurity";
37:
38: // External server config
39: // private static final String PROVIDER_URL = "ldap://monkeymachine:389/"+ROOT_DN;
40: // private static final String CONTEXT_FACTORY = "com.sun.jndi.ldap.LdapCtxFactory";
41: // private static final Hashtable EXTRA_ENV = new Hashtable();
42:
43: // Embedded (non-networked) server config
44: private static final LdapTestServer SERVER = new LdapTestServer();
45: private static final String PROVIDER_URL = ROOT_DN;
46: private static final String CONTEXT_FACTORY = CoreContextFactory.class
47: .getName();
48: private static final Hashtable EXTRA_ENV = SERVER
49: .getConfiguration().toJndiEnvironment();
50:
51: //~ Instance fields ================================================================================================
52:
53: private DefaultInitialDirContextFactory idf;
54:
55: //~ Constructors ===================================================================================================
56:
57: protected AbstractLdapServerTestCase() {
58: }
59:
60: protected AbstractLdapServerTestCase(String string) {
61: super (string);
62: }
63:
64: //~ Methods ========================================================================================================
65:
66: protected DefaultInitialDirContextFactory getInitialCtxFactory() {
67: return idf;
68: }
69:
70: protected void onSetUp() {
71: }
72:
73: public final void setUp() {
74: idf = new DefaultInitialDirContextFactory(PROVIDER_URL);
75: idf.setInitialContextFactory(CONTEXT_FACTORY);
76: idf.setExtraEnvVars(EXTRA_ENV);
77:
78: onSetUp();
79: }
80: }
|