com.evolveum.midpoint.test.ldap
Class OpenDJController

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

public class OpenDJController
extends java.lang.Object

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

Author:
semancik

Field Summary
protected  java.io.File configFile
           
protected  org.opends.server.protocols.internal.InternalClientConnection internalConnection
           
protected  java.io.File serverRoot
           
protected  java.io.File templateServerRoot
           
 
Constructor Summary
OpenDJController()
           
OpenDJController(java.io.File ldapDataDir)
           
OpenDJController(java.io.File ldapDataDir, java.io.File templateDir)
           
OpenDJController(java.lang.String ldapDataDir)
           
 
Method Summary
 java.util.Set<java.lang.String> asSet(java.util.List<org.opends.server.types.Attribute> attributes)
           
static void copyDirectory(java.io.File src, java.io.File dst)
          Copy a directory and its contents.
static void copyFile(java.io.File src, java.io.File dst)
          Copy a file.
static void deleteDirectory(java.io.File dir)
          Delete a directory and its contents.
 java.io.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.
 java.io.File getServerRoot()
          Get the value of serverRoot.
 java.io.File getTemplateServerRoot()
          Get the value of templateServerRoot The top directory of template OpenDS installation.
 void refreshFromTemplate()
          Refresh working OpenDS installation from the template.
 void setConfigFile(java.io.File configFile)
          Set the value of configFile File name of primary OpenDS configuration file.
 void setInternalConnection(org.opends.server.protocols.internal.InternalClientConnection internalConnection)
          Set the value of internalConnection The connection to the OpenDS instance.
 void setServerRoot(java.io.File serverRoot)
          Set the value of serverRoot The top directory of working OpenDS installation.
 void setTemplateServerRoot(java.io.File templateServerRoot)
          Set the value of templateServerRoot The top directory of template OpenDS installation.
 org.opends.server.protocols.internal.InternalClientConnection start()
          Start the embedded OpenDS directory server.
 void stop()
          Stop the embedded OpenDS server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serverRoot

protected java.io.File serverRoot

configFile

protected java.io.File configFile

templateServerRoot

protected java.io.File templateServerRoot

internalConnection

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

OpenDJController

public OpenDJController()

OpenDJController

public OpenDJController(java.io.File ldapDataDir)

OpenDJController

public OpenDJController(java.io.File ldapDataDir,
                        java.io.File templateDir)

OpenDJController

public OpenDJController(java.lang.String ldapDataDir)
Method Detail

getServerRoot

public java.io.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(java.io.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 java.io.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(java.io.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 java.io.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

setTemplateServerRoot

public void setTemplateServerRoot(java.io.File templateServerRoot)
Set 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.

Parameters:
templateServerRoot - new 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

setInternalConnection

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

Parameters:
internelConnection - new value of internelConnection

refreshFromTemplate

public void refreshFromTemplate()
                         throws java.io.IOException
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:
java.io.IOException

start

public org.opends.server.protocols.internal.InternalClientConnection start()
Start the embedded OpenDS 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(java.io.File src,
                                 java.io.File dst)
                          throws java.io.IOException
Copy a directory and its contents.

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

deleteDirectory

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

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

copyFile

public static void copyFile(java.io.File src,
                            java.io.File dst)
                     throws java.io.IOException
Copy a file.

Parameters:
src - The name of the source file.
dst - The name of the destination file.
Throws:
java.io.IOException - If the file could not be copied.

asSet

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


Copyright © 2011 evolveum. All Rights Reserved.