Import LDIF schema and LDIF content each time ApacheDS starts?

I want the embedded ApacheDS to launch a new schema / content when running my tests. I tried importing LDIF with these lines:

LdifFileLoader ldifLoader = new LdifFileLoader(service.getAdminSession(), "path/to/my/export.ldif"); ldifLoader.execute(); 

But now ApacheDS stores information in the directory server in the current working directory. I had to manually delete the directory server every time, and I wonder if this is correct ...

I exported the schema as LDIF, and I want to import it first. Can I import it using LdifFileLoader ? Or am I doing it wrong?

+4
source share
2 answers

Use DirectoryService # setWorkingDirectory (File) to change the working directory.

In the setUp () or tearDown () methods, you can delete this directory.

+4
source

Spring LDAP can create a server on the fly for you and load it using LDIF at startup. The server that it creates is an ApacheDS server.

  <security:ldap-server root="dc=example,dc=com" port="33389" ldif="classpath:EmbeddedServerRoot.ldif"/> 
+3
source

All Articles