Free trial

How to test your OpenDJ plugin

A problem you might face while extending the OpenDJ functionality with a plugin is to develop proper unit tests. OpenDJ comes with a set of tools to facilitate the testing, but since they are tightly integrated within the build framework, you might find it difficult to execute your unit tests from outside of the framework. This article will try to give you short guidelines on how to integrate and execute your tests.

The test

OpenDJ inherited it’s framework from the OpenDS days which means the old documentation still provides valid guidelines and tips on how to get started with your own unit tests. It would help you get familiar with the utility classes you can use to make your test execution easier. The most relevant documents are:

Of course, if you are not already familiar with TestNG, it is the right moment to get to know it better.
Apart from the documentation mentioned above, you will find it very useful to examine some of the existing unit test classes:

The environment

Before you start working on your tests, you have to check out the OpenDJ source file tree. Say, you are developing a plugin for the 2.4 branch, so you would need the latest stable release:

mkdir opendj-dev
cd opendj-dev
svn co
cd b2.4

Now, your tests should go to:  ‘tests/unit-testing/src/server/<package>/<unit test Java class>’ where:

  • <package> is the package which your plugin belongs to, and
  • <unit test Java class> is the Java class that implements the unit test(s).

For example, let’s assume we have a plugin called ‘example plugin’ and we made put it in the ‘com.example.plugins’ package (‘com.example.pluginsExamplePlugin). The path would be, say: ‘tests/unit-testing/src/server/com/example/plugins/’.

Given that your plugin is built separately from the OpenDJ sources, and that the execution of the unit test requires OpenDJ server to be running, you have to make your plugin available to the built-in test instance (and not just the plugin, but also all the libraries you plugin depends on, schema files, etc.). For that to work you need to do the following:

  • create a directory: ‘lib/extensions’;
  • copy your plugin JAR (and the dependencies) to the following locations: ‘lib’ and ‘lib/extensions’;
  • copy your schema file to: ‘resources/schema’.

You should be ready to execute your tests using:

./ test -Dtest.classes=<your unit test>

If we take our ‘example plugin’, you would do the following:

# let’s assume you are located in opendj-dev/b2.4

mkdir lib/extensions

cp <path to>/example-plugin.jar lib

cp <path to>/example-plugin.jar lib/extensions

cp <path to>/99-example-plugin.ldif resources/schema

./ test -Dtest.classes=com.example.plugins.ExamplePluginTestCase

Testing and Maven

As previously mentioned, the testing framework of OpenDJ is very tightly integrated with the build process and makes it unavailable to the other frameworks and tools such as Maven.  If you have chosen Maven to develop your plugin, you will not be able to execute unit tests using OpenDJ tools and the workaround is to follow the guide above 🙂

idm java ldap maven opendj qa testing

Leave a Reply

Related articles


Let’s make LLMs generate JSON!

In this article, we are going to talk about three tools that can, at least in theory, force any local LLM to produce structured output: LM Format Enforcer, Outlines, and Guidance. After a short description of each tool, we will evaluate their performance on a few test cases ranging from book recommendations to extracting information from HTML. And the best for the end, we will show you how forcing LLMs to produce a structured output can be used to solve a very common problem in many businesses: extracting structured records from free-form text.

Notiondipity: What I learned about browser extension development

Me and many of my colleagues at profiq use Notion for note-taking and work organization. Our workspaces contain a lot of knowledge about our work, plans, or the articles or books we read. At some point, a thought came to my mind: couldn’t we use all this knowledge to come up with project ideas suited to our skills and interests?

From ChatGPT to Smart Agents: The Next Frontier in App Integration

It has been over a year since OpenAI introduced ChatGPT and brought the power of AI and large language models (LLMs) to the average consumer. But we could argue that introducing APIs for seamlessly integrating large language models into apps developed by companies and independent hackers all over the world can be the true game changer in the long term. Developers are having heated discussions about how we can utilize this technology to develop truly useful apps that provide real value instead of just copying what OpenAI does. We want to contribute to this discussion by showing you how we think about developing autonomous agents at profiq. But first a bit of background.