views:

422

answers:

2

Hi guys!

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?

+1  A: 

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

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

Kevin
+1  A: 

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"/>
harschware