4

I have an application that uses a LDAP server, and I need to write some unit tests. I started mocking LDAP DirContext and others, but it makes too difficult for my current tests, so I thought I using an embedded LDAP server.

This link does not work: http://directory.apache.org/apacheds/1.5/42-using-apacheds-for-unit-tests.html -> Embedding ApacheDS - Conference Materials -> Code Examples (requires Maven 2.x) (SVN)

Does anyone have the code example for it or any alternative to ApacheDS?

Oliver
  • 3,815
  • 8
  • 35
  • 63
David Portabella
  • 12,390
  • 27
  • 101
  • 182

1 Answers1

12

Instead of mocking, use the in-memory directory server provided by the UnboundID LDAP SDK. This is a fully-fledged server and its use will result in realistic responses from a directory server, which will lead to more complete testing and more robust code.

see also

hennr
  • 2,632
  • 2
  • 23
  • 26
Terry Gardner
  • 10,957
  • 2
  • 28
  • 38
  • thanks for the info; i'll try a bit more with ApacheDS, and otherwise i'll turn to the one you mention. – David Portabella Apr 27 '12 at 11:03
  • 3
    after viewing @Terry's answer and blog i ended up creating this: https://github.com/trevershick/ldap-test-utils . It's what i use now to do in memory ldap testing. UnboundID is great. – Trever Shick Feb 05 '13 at 21:59
  • Note that the original poster was asking specifically about using ApacheDS in Unit Tests, not UnboundID. – nicciglen Sep 11 '21 at 18:32