Package org.lsc.opendj
Class EmbeddedOpenDJ
java.lang.Object
org.lsc.opendj.EmbeddedOpenDJ
Embedded OpenDJ directory
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic void
addEntries
(String... lines) Adds the provided set of entries to the Directory Server using internal operations.static void
addEntries
(List<org.opends.server.types.Entry> entries) Adds the provided set of entries to the Directory Server using internal operations.static org.opends.server.types.ResultCode
addEntry
(org.opends.server.types.Entry entry) Adds the provided entry to the Directory Server using an internal operation.static List
<org.opends.server.types.Entry> entriesFromLdifString
(String ldif) Returns a modifiable List of entries parsed from the provided LDIF.static org.opends.server.types.Entry
entryFromLdifString
(String ldif) This is used as a convenience when and LDIF string only includes a single entry.static String
getPathToConfigFile
(String fileName) Search for a file in the possible configuration locations: As a resource on the classpath (historical method) As a file in the configuration directorystatic void
importLdif
(String ldif) static void
initializeTestBackend
(boolean createBaseEntry, String dn) static void
Test main classstatic List
<org.opends.server.types.Entry> makeEntries
(String... lines) This is a convience method that constructs an List of EntryS from the specified lines of LDIF.static org.opends.server.types.Entry
This is a convience method that constructs an Entry from the specified lines of LDIF.static String
This method provides the minor convenience of not having to specify the newline character at the end of every line of LDIF in test code.static void
shutdownServer
(String reason) Sets the system context root to null.static void
Initialize the server.
-
Field Details
-
PROPERTY_WORKING_DIR
The of the system property that specifies the target working directory, where OpenDJ do its business (db datas, locks, logs, etc)- See Also:
-
DEFAULT_WORKING_DIR_NAME
A default value for the working dir- See Also:
-
SERVER_STARTED
public static boolean SERVER_STARTED
-
-
Method Details
-
startServer
public static void startServer() throws IOException, org.opends.server.types.InitializationException, URISyntaxExceptionInitialize the server. We completely override the super class server set up.- Throws:
IOException
org.opends.server.types.InitializationException
URISyntaxException
-
shutdownServer
Sets the system context root to null.- Parameters:
reason
- Message to log when shutting down
-
main
Test main class- Parameters:
args
-
-
entriesFromLdifString
public static List<org.opends.server.types.Entry> entriesFromLdifString(String ldif) throws IOException, org.opends.server.util.LDIFException Returns a modifiable List of entries parsed from the provided LDIF. It's best to call this after the server has been initialized so that schema checking happens.Also take a look at the makeLdif method below since this makes expressing LDIF a little bit cleaner.
- Parameters:
ldif
- of the entries to parse.- Returns:
- a List of EntryS parsed from the ldif string.
- Throws:
IOException
org.opends.server.util.LDIFException
- See Also:
-
entryFromLdifString
This is used as a convenience when and LDIF string only includes a single entry. It's best to call this after the server has been initialized so that schema checking happens.Also take a look at the makeLdif method below since this makes expressing LDIF a little bit cleaner.
- Parameters:
ldif
- Line of LDIF- Returns:
- the first Entry parsed from the ldif String
- Throws:
Exception
- If an unexpected problem occurs.- See Also:
-
makeLdif
This method provides the minor convenience of not having to specify the newline character at the end of every line of LDIF in test code. This is an admittedly small advantage, but it does make things a little easier and less error prone. For example, thisprivate static final String JOHN_SMITH_LDIF = TestCaseUtils.makeLdif("dn: cn=John Smith,dc=example,dc=com", "objectclass: inetorgperson", "cn: John Smith", "sn: Smith", "givenname: John");
is alittle easier to work with thanprivate static final String JOHN_SMITH_LDIF = "dn: cn=John Smith,dc=example,dc=com\n" + "objectclass: inetorgperson\n" + "cn: John Smith\n" + "sn: Smith\n" + "givenname: John\n";
- Parameters:
lines
- Lines of LDIF without newline characters- Returns:
- the concatenation of each line followed by a newline character
-
makeEntry
This is a convience method that constructs an Entry from the specified lines of LDIF. Here's a sample usageEntry john = TestCaseUtils.makeEntry("dn: cn=John Smith,dc=example,dc=com", "objectclass: inetorgperson", "cn: John Smith", "sn: Smith", "givenname: John");
- Parameters:
lines
- Lines of LDIF- Returns:
- Entry constructed from the specified lines of LDIF
- Throws:
Exception
- See Also:
-
makeEntries
public static List<org.opends.server.types.Entry> makeEntries(String... lines) throws org.opends.server.util.LDIFException, IOException This is a convience method that constructs an List of EntryS from the specified lines of LDIF. Here's a sample usageList<Entry> smiths = TestCaseUtils.makeEntries("dn: cn=John Smith,dc=example,dc=com", "objectclass: inetorgperson", "cn: John Smith", "sn: Smith", "givenname: John", "", "dn: cn=Jane Smith,dc=example,dc=com", "objectclass: inetorgperson", "cn: Jane Smith", "sn: Smith", "givenname: Jane");
- Parameters:
lines
- Lines of LDIF- Returns:
- List of EntryS constructed from the specified lines of LDIF
- Throws:
IOException
org.opends.server.util.LDIFException
- See Also:
-
addEntry
public static org.opends.server.types.ResultCode addEntry(org.opends.server.types.Entry entry) Adds the provided entry to the Directory Server using an internal operation.- Parameters:
entry
- The entry to be added.- Returns:
- the error code
-
addEntries
Adds the provided set of entries to the Directory Server using internal operations.- Parameters:
entries
- The entries to be added.
-
addEntries
public static void addEntries(String... lines) throws org.opends.server.util.LDIFException, IOException Adds the provided set of entries to the Directory Server using internal operations.- Parameters:
lines
- The lines defining the entries to add. If there are multiple entries, then they should be separated by blank lines.- Throws:
IOException
org.opends.server.util.LDIFException
-
initializeTestBackend
- Throws:
Exception
-
importLdif
- Throws:
IOException
org.opends.server.util.LDIFException
-
getPathToConfigFile
Search for a file in the possible configuration locations:
- As a resource on the classpath (historical method)
- As a file in the configuration directory
This method first looks on the classpath, then if that fails, looks in the configuration directory. Finally, it returns the absolute path name to the file.
.- Parameters:
fileName
- Name of the file or directory to locate.- Returns:
- Absolute path name to the file, or null.
-