Load entries from LDIF file

The following example demonstrates how to use the LDAP Maven Plugin to load directory contents from LDIF format before integration tests are performed.

  • LDAP Directory Server

    In this example we are assuming that Apache Directory Server is being used and is installed locally on port 10389 with the default administration account (uid=admin,ou=system) and password (secret). Furthermore, we are assuming that the base DN has not been modified from the default (o=sevenSeas).

Create LDIF file

Create a file called load.ldif with the following contents:

dn: ou=People,o=sevenSeas
changetype: add
ou: People
objectclass: organizationalUnit

dn: cn=Bart Simpson,ou=People,o=sevenSeas
changetype: add
cn: Bart Simpson
sn: Simpson
givenName: Bart
uid: bsimpson
objectclass: inetOrgPerson

dn: cn=Lisa Simpson,ou=People,o=sevenSeas
cn: Lisa Simpson
sn: Simpson
givenName: Lisa
uid: lsimpson
title: Kid
objectclass: inetOrgPerson

dn: cn=Maggie simpson,ou=People,o=sevenSeas
cn: Maggie Simpson
sn: Simpson
givenName: Maggie
uid: msimpson1
title: Baby
objectclass: inetOrgPerson

dn: cn=Homer Simpson,ou=People,o=sevenSeas
changetype: add
cn: Homer Simpson
sn: Simpson
givenName: Homer
uid: hsimpson
title: Parent
objectclass: inetOrgPerson

dn: cn=Marge Simpson,ou=People,o=sevenSeas
changetype: add
cn: Marge Simpson
sn: Simpson
givenName: Marge
uid: msimpson
title: Parent
objectclass: inetOrgPerson

Configure a POM

Add the following configuration to your project POM to load the data during test preparation: