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?
Use DirectoryService#setWorkingDirectory(File) to change the working directory.
In your setUp() or tearDown() methods, you can then delete this directory.
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"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With