1   package com.atlassian.user.impl.ldap;
2   
3   import com.atlassian.ldap.server.LdapServer;
4   import com.atlassian.user.generic.AbstractSpringTest;
5   
6   public abstract class AbstractLdapTest extends AbstractSpringTest
7   {
8       private LdapServer ldapServer;
9   
10      /**
11       * Override this in subclasses to provide the LDAP configuration context for testing
12       */
13      protected abstract String getLdapConfigLocation();
14  
15      protected void onSetUp() throws Exception
16      {
17          super.onSetUp();
18          ldapServer.start();
19      }
20  
21  
22      protected void onTearDown() throws Exception
23      {
24          ldapServer.stop();
25          super.onTearDown();
26      }
27  
28      public void setLdapServer(LdapServer ldapServer)
29      {
30          this.ldapServer = ldapServer;
31      }
32  
33      protected String[] getConfigLocations()
34      {
35          return new String[]{
36              "classpath:com/atlassian/user/impl/ldap/ldapTestContext.xml",
37              "classpath:com/atlassian/user/impl/ldap/ldapTestServerContext.xml",
38              getLdapConfigLocation()
39          };
40      }
41  }