com.evolveum.midpoint.test.ldap
Class OpenDJController

java.lang.Object
  extended by com.evolveum.midpoint.test.ldap.AbstractResourceController
      extended by com.evolveum.midpoint.test.ldap.OpenDJController

public class OpenDJController
extends AbstractResourceController

This class controls embedded OpenDJ instance. It is used in Unit tests. It configures and starts and stops the instance. It can even manage a "template" configuration of OpenDJ and copy it to working instance configuration.

Author:
Radovan Semancik

Field Summary
protected  File configFile
           
protected  org.opends.server.protocols.internal.InternalClientConnection internalConnection
           
protected  File serverRoot
           
protected  File templateRoot
           
 
Fields inherited from class com.evolveum.midpoint.test.ldap.AbstractResourceController
resource
 
Constructor Summary
OpenDJController()
           
OpenDJController(String serverRoot)
           
OpenDJController(String serverRoot, String templateServerRoot)
           
 
Method Summary
 org.opends.server.types.Entry addEntryFromLdifFile(String filename)
           
static void assertAttribute(org.opends.server.types.SearchResultEntry response, String name, String... values)
           
static void assertNoAttribute(org.opends.server.types.SearchResultEntry response, String name)
           
 Set<String> asSet(List<org.opends.server.types.Attribute> attributes)
           
static void copyDirectory(File src, File dst)
          Copy a directory and its contents.
static void deleteDirectory(File dir)
          Delete a directory and its contents.
 org.opends.server.util.ChangeRecordEntry executeLdifChange(String filename)
           
static String getAttributeValue(org.opends.server.types.SearchResultEntry response, String name)
           
 File getConfigFile()
          Get the value of configFile File name of primary OpenDS configuration file.
 org.opends.server.protocols.internal.InternalClientConnection getInternalConnection()
          Get the value of internalConnection The connection to the OpenDS instance.
 File getServerRoot()
          Get the value of serverRoot.
 File getTemplateServerRoot()
          Get the value of templateServerRoot The top directory of template OpenDS installation.
 boolean isAccountEnabled(org.opends.server.types.SearchResultEntry ldapEntry)
           
 void refreshFromTemplate()
          Refresh working OpenDS installation from the template.
 org.opends.server.types.SearchResultEntry searchAndAssertByEntryUuid(String entryUuid)
           
 org.opends.server.types.SearchResultEntry searchByEntryUuid(String entryUuid)
           
 org.opends.server.types.SearchResultEntry searchByUid(String string)
           
 void setConfigFile(File configFile)
          Set the value of configFile File name of primary OpenDS configuration file.
 void setServerRoot(File serverRoot)
          Set the value of serverRoot The top directory of working OpenDS installation.
 org.opends.server.protocols.internal.InternalClientConnection start()
          Start the embedded OpenDJ directory server.
 org.opends.server.protocols.internal.InternalClientConnection startCleanServer()
          Start the embedded OpenDJ directory server using files coppied from the template.
 void stop()
          Stop the embedded OpenDS server.
 
Methods inherited from class com.evolveum.midpoint.test.ldap.AbstractResourceController
getAttributePath, getAttributeQName, getNamespace, getResource, setResource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serverRoot

protected File serverRoot

configFile

protected File configFile

templateRoot

protected File templateRoot

internalConnection

protected org.opends.server.protocols.internal.InternalClientConnection internalConnection
Constructor Detail

OpenDJController

public OpenDJController()

OpenDJController

public OpenDJController(String serverRoot)

OpenDJController

public OpenDJController(String serverRoot,
                        String templateServerRoot)
Method Detail

getServerRoot

public File getServerRoot()
Get the value of serverRoot. The top directory of working OpenDS installation. The OpenDS placed in this directory will be used during the tests.

Returns:
the value of serverRoot

setServerRoot

public void setServerRoot(File serverRoot)
Set the value of serverRoot The top directory of working OpenDS installation. The OpenDS placed in this directory will be used during the tests.

Parameters:
serverRoot - new value of serverRoot

getConfigFile

public File getConfigFile()
Get the value of configFile File name of primary OpenDS configuration file. Normally /config/config.ldif

Returns:
the value of configFile

setConfigFile

public void setConfigFile(File configFile)
Set the value of configFile File name of primary OpenDS configuration file. Normally /config/config.ldif

Parameters:
configFile - new value of configFile

getTemplateServerRoot

public File getTemplateServerRoot()
Get the value of templateServerRoot The top directory of template OpenDS installation. All the files from this directory will be copied to the working OpenDS directory (serverRoot). This usually happens before the tests.

Returns:
the value of templateServerRoot

getInternalConnection

public org.opends.server.protocols.internal.InternalClientConnection getInternalConnection()
Get the value of internalConnection The connection to the OpenDS instance. It can be used to fetch and manipulate the data.

Returns:
the value of internelConnection

refreshFromTemplate

public void refreshFromTemplate()
                         throws IOException,
                                URISyntaxException
Refresh working OpenDS installation from the template. The existing working OpenDS installation (in serverRoot) will be discarded and replaced by a fresh known-state setup (from templateServerRoot).

Throws:
IOException
URISyntaxException

startCleanServer

public org.opends.server.protocols.internal.InternalClientConnection startCleanServer()
                                                                               throws IOException,
                                                                                      URISyntaxException
Start the embedded OpenDJ directory server using files coppied from the template.

Returns:
Throws:
IOException
URISyntaxException

start

public org.opends.server.protocols.internal.InternalClientConnection start()
Start the embedded OpenDJ directory server. Configuration and databases from serverRoot location will be used.

Returns:

stop

public void stop()
Stop the embedded OpenDS server.


copyDirectory

public static void copyDirectory(File src,
                                 File dst)
                          throws IOException
Copy a directory and its contents.

Parameters:
src - The name of the directory to copy.
dst - The name of the destination directory.
Throws:
IOException - If the directory could not be copied.

deleteDirectory

public static void deleteDirectory(File dir)
                            throws IOException
Delete a directory and its contents.

Parameters:
dir - The name of the directory to delete.
Throws:
IOException - If the directory could not be deleted.

asSet

public Set<String> asSet(List<org.opends.server.types.Attribute> attributes)

searchByEntryUuid

public org.opends.server.types.SearchResultEntry searchByEntryUuid(String entryUuid)
                                                            throws org.opends.server.types.DirectoryException
Throws:
org.opends.server.types.DirectoryException

searchAndAssertByEntryUuid

public org.opends.server.types.SearchResultEntry searchAndAssertByEntryUuid(String entryUuid)
                                                                     throws org.opends.server.types.DirectoryException
Throws:
org.opends.server.types.DirectoryException

searchByUid

public org.opends.server.types.SearchResultEntry searchByUid(String string)
                                                      throws org.opends.server.types.DirectoryException
Throws:
org.opends.server.types.DirectoryException

isAccountEnabled

public boolean isAccountEnabled(org.opends.server.types.SearchResultEntry ldapEntry)

getAttributeValue

public static String getAttributeValue(org.opends.server.types.SearchResultEntry response,
                                       String name)

assertAttribute

public static void assertAttribute(org.opends.server.types.SearchResultEntry response,
                                   String name,
                                   String... values)

assertNoAttribute

public static void assertNoAttribute(org.opends.server.types.SearchResultEntry response,
                                     String name)

addEntryFromLdifFile

public org.opends.server.types.Entry addEntryFromLdifFile(String filename)
                                                   throws IOException,
                                                          org.opends.server.util.LDIFException
Throws:
IOException
org.opends.server.util.LDIFException

executeLdifChange

public org.opends.server.util.ChangeRecordEntry executeLdifChange(String filename)
                                                           throws IOException,
                                                                  org.opends.server.util.LDIFException
Throws:
IOException
org.opends.server.util.LDIFException


Copyright © 2013 evolveum. All Rights Reserved.