Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Importing a schema LDIF and content LDIF on every startup of ApacheDS?

I want my embedded ApacheDS to start up with a fresh schema/content when I run my tests. I tried to import a LDIF with this lines:

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

But now ApacheDS stores the information in a directory server-work in the current working directory. I had to manually delete the directory server-work every time and I wonder if that is the right way...

I exported the schema as LDIF too and I want to import it first. Can I import it with LdifFileLoader too? Or am I doing it in a wrong way at all?

like image 256
cringe Avatar asked Mar 01 '23 04:03

cringe


2 Answers

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

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

like image 159
Kevin Avatar answered Mar 29 '23 23:03

Kevin


Spring LDAP can be build a server on the fly for you and load it with an LDIF on startup. The server it builds is an ApacheDS server.

 <security:ldap-server root="dc=example,dc=com" port="33389" ldif="classpath:EmbeddedServerRoot.ldif"/>
like image 45
harschware Avatar answered Mar 30 '23 00:03

harschware