Blog

02 Apr, 2009

Embedded Java LDAP server for unit testing

Posted by: admin In: Programming

I’ve just spent about a day trying different embeddable Java LDAP servers. To save you from all the trouble I came across I’m going to share some of my experiences.

Basically you have three choices when it comes to  embeddable Java LDAP servers (at least open source). First of you have Sun’s OpenDS, they have a page dedicated to Tips and tricks for writing unit tests. I have to say that I’m not very impressed by OpenDS. Don’t take me wrong it might be a fantastic LDAP server, but it certainly does not give me the feeling of being very embeddable! First of all the documentation refers to a mysterious class TestCaseUtils. I’ve checked builds from version 1.0.something to 1.2.something without finding it. The second drawback is that OpenDS is like a flesh-eating-configuration-monster sent back in time to kill the spirit of any developers getting near it. It comes with a 2000+ lines ldif config file, which is supposed to work for servers running embedded as well. It would be nice if they could provide a minimal configuration file for embedded use. To me it complained a lot about errors in the bundled schemas. Oh that’s right you need to set up a directory structure for config files, schemas and locks. Again, not very embeddable!

The second and third choise is ApacheDS. You have the newer version 1.5. with support for fancy things like triggers and stuff and you have the older 1.0 series. Both LDAPv3 compatible. The project is very well documented and they even maintain something they call Apache Directory Studio, which is a graphical LDAP GUI based on Eclipse. Very nice! If you don’t need the fancy stuff implemented in the 1.5 series I really recommend that you go for the older 1.0 series for your unit testing. You’ll find jars in Maven repos and it’s really simple to get started. It just works the way you expect it to! Just follow this guide and you will be unit testing your LDAP code in no time.

At the time I’m writing this 1.5.4 is the newest version of the 1.5 series. They have a guide for doing unit testing with 1.5 as well, but due to some problems it won’t work with 1.5.4 so you’ll have to build the trunk for your self or track down a Maven snapshot repo (good luck!).

Happy testing!

1 Response to "Embedded Java LDAP server for unit testing"

1 | Jan Peter Stotz

May 18th, 2009 at 16:09

Avatar

ApacheDS 1.0.2 is nice and not that large but 5.5 MB in 29 JARs is not what I would call an “embeddable application”.

Comment Form