Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring embedded ldap server in unit tests

Tags:

I am currently trying to use an embedded ldap server for unit tests.

In Spring Security, you can quickly define an embedded ldap server for testing with the tag with some sample data loaded from the specified ldif.

I will be using Spring Ldap to perform ldap operations, and thinking of testing the usual CRUD features of my User service object.

Is there, however, a way to ensure that the entries in the embedded server to be in the same consistent state (sort of like a delete all and reload the ldif entries) for each test I am running?

I thought of the following: 1) Indicate that the method dirties the context, and force a recreation of the embedded ldap server, which sounds painful as it would have to restart the server for every method 2) Create the test entries in a test organization, such that I can unbind them and simply load in the ldif file again there.

I prefer 2, but it seems like the Spring LDAP has no good helpers to load and send across the content of a ldif file.

Any suggestions on how you perform ldap testing with an embedded ldap server of spring, or of the two possible solutions I mention?

Thanks