Test Smarter – the New UnboundID LDAP SDK for Java

    

Posted by Neil Wilson on 3/23/11 4:00 AM

A directory service is only as useful as the applications that take advantage of it. In many environments, that includes home-grown applications, and the more effectively you can write and maintain those applications, the greater their overall value. With the UnboundID LDAP SDK for Java, we aim to provide a very robust and full-featured API that helps you develop directory-enabled applications as quickly and easily as possible. However, we also realize that testing is an essential part of development, and in last week's 2.1.0 release we've added a number of new features to make that part of development easier as well.

The biggest new feature is the introduction of the in-memory directory server, a surprisingly feature-rich LDAP server that's also very easy to use. With just a couple of lines of code, you can fire up a server with full LDAPv3 support including a number of controls and extended operations, and that also provides a number of test-friendly features like the ability to easily populate the server, to create and restore point-in-time snapshots of the data, and to validate that the server contains the expected set of content. You can have any number of instances running concurrently in the same JVM, and you can easily start and stop them at will so you can do things like test your application's fault tolerance and failover capabilities. Since all of the data is stored in memory, it's fast and lightweight, and you can easily clear the server or reset it to a known state between tests.

Even if your application will target a specific type of directory server in production, there can still be a significant advantage to testing with the in-memory directory server whenever possible. It's almost certainly easier and faster to create and manage simple directory server instances in your test code than to have to coordinate with external server instances, and you don't have to worry about what data they might already contain. It's also good to test with a variety of servers from time to time to ensure that you're keeping your application standards compliant and not unnecessarily tied to any one directory implementation so that there won’t be any surprises if the production server is swapped out.

Another new feature in the 2.1.0 release is the LDAPTestUtils class, which provides a number of convenience methods that can be useful when writing test cases. There are methods for generating various kinds of entries (e.g., users, groups, organizations, etc.), methods for verifying the contents of an LDAP directory server, and methods for verifying the results of operations processed against a directory. None of these methods do anything particularly groundbreaking, but we've already employed some of them in our own unit tests and it's surprising how simple things like this can help streamline the development process.

Even if you're not yet using the UnboundID LDAP SDK in your directory-enabled applications, you may still find it useful in helping to test them. And if you are already using our LDAP SDK, then getting access to these new features is as simple as replacing the LDAP SDK jar file or updating your Maven dependency to the latest version. In addition to providing 95% code coverage, the extensive test suite that we use for the LDAP SDK itself includes a number of tests to ensure that we don't break compatibility between releases, so you shouldn't need to worry about an LDAP SDK upgrade breaking your application.

Topics: Legacy IAM Modernization