Why not take a look at Spring Security's LDAP integration tests and use those as a guide?
At the moment, these just use an LDAP template to clear out data that each test has created if necessary (for speed), but there is also a commented-out Junit @After
method which does reload an LDIF file. The CoreSession
is obtained by calling getAdminSession()
on the server instance (a DefaultDirectoryService
).
If you really have to run the tests using an XML application context, using the <ldap-server />
element, you can use:
getBeanByName(BeanIds.EMBEDDED_APACHE_DS).getService()
to get access to the DefaultDirectoryService
instance.