public final class LdapTestUtils extends Object
Modifier and Type | Method and Description |
---|---|
static void |
cleanAndSetup(ContextSource contextSource,
Name rootNode,
Resource ldifFile) |
static void |
clearSubContexts(ContextSource contextSource,
Name name)
Clear the directory sub-tree starting with the node represented by the
supplied distinguished name.
|
static void |
clearSubContexts(DirContext ctx,
Name name)
Clear the directory sub-tree starting with the node represented by the
supplied distinguished name.
|
static void |
loadLdif(ContextSource contextSource,
Resource ldifFile)
Load an Ldif file into an LDAP server.
|
static void |
loadLdif(com.unboundid.ldap.listener.InMemoryDirectoryServer directoryServer,
Resource ldifFile) |
static void |
shutdownEmbeddedServer()
Shuts down the embedded server, if there is one.
|
static void |
startEmbeddedServer(int port,
String defaultPartitionSuffix,
String defaultPartitionName)
Start an embedded Apache Directory Server.
|
public static void startEmbeddedServer(int port, String defaultPartitionSuffix, String defaultPartitionName)
port
- the port on which the server will be listening.defaultPartitionSuffix
- The default base suffix that will be used
for the LDAP server.defaultPartitionName
- The name to use in the directory server
configuration for the default base suffix.IllegalStateException
- if an embedded server is already started.public static void shutdownEmbeddedServer() throws Exception
Exception
public static void clearSubContexts(ContextSource contextSource, Name name) throws NamingException
contextSource
- the ContextSource to use for getting a DirContext.name
- the distinguished name of the root node.NamingException
- if anything goes wrong removing the sub-tree.public static void clearSubContexts(DirContext ctx, Name name) throws NamingException
ctx
- The DirContext to use for cleaning the tree.name
- the distinguished name of the root node.NamingException
- if anything goes wrong removing the sub-tree.public static void loadLdif(ContextSource contextSource, Resource ldifFile) throws IOException
contextSource
- ContextSource to use for getting a DirContext to
interact with the LDAP server.ldifFile
- a Resource representing a valid LDIF file.IOException
- if the Resource cannot be read.public static void cleanAndSetup(ContextSource contextSource, Name rootNode, Resource ldifFile) throws NamingException, IOException
NamingException
IOException
public static void loadLdif(com.unboundid.ldap.listener.InMemoryDirectoryServer directoryServer, Resource ldifFile) throws IOException
IOException