com.zimory.ldapunit:ldapunit-core

Set up and expect LDAP server contents

License

License

GroupId

GroupId

com.zimory.ldapunit
ArtifactId

ArtifactId

ldapunit-core
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

Set up and expect LDAP server contents

Download ldapunit-core

How to add to project

<!-- https://jarcasting.com/artifacts/com.zimory.ldapunit/ldapunit-core/ -->
<dependency>
    <groupId>com.zimory.ldapunit</groupId>
    <artifactId>ldapunit-core</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.zimory.ldapunit/ldapunit-core/
implementation 'com.zimory.ldapunit:ldapunit-core:1.0.0'
// https://jarcasting.com/artifacts/com.zimory.ldapunit/ldapunit-core/
implementation ("com.zimory.ldapunit:ldapunit-core:1.0.0")
'com.zimory.ldapunit:ldapunit-core:jar:1.0.0'
<dependency org="com.zimory.ldapunit" name="ldapunit-core" rev="1.0.0">
  <artifact name="ldapunit-core" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.zimory.ldapunit', module='ldapunit-core', version='1.0.0')
)
libraryDependencies += "com.zimory.ldapunit" % "ldapunit-core" % "1.0.0"
[com.zimory.ldapunit/ldapunit-core "1.0.0"]

Dependencies

compile (6)

Group / Artifact Type Version
org.slf4j : slf4j-api jar 1.6.4
com.google.guava : guava jar 14.0.1
junit : junit jar 4.11
org.mockito : mockito-core jar 1.9.5
org.hamcrest : hamcrest-all jar 1.3
com.unboundid : unboundid-ldapsdk jar 2.3.1

test (1)

Group / Artifact Type Version
org.slf4j : slf4j-log4j12 jar 1.6.4

Project Modules

There are no modules declared in this project.

LdapUnit

Set up and expect LDAP server contents.

Example usage

Test

import com.google.common.base.Supplier;
import com.unboundid.ldap.listener.InMemoryDirectoryServer;

import org.junit.Rule
import org.junit.Test;

import com.zimory.ldapunit.core.ShouldMatchLdapDataSet;
import com.zimory.ldapunit.core.UsingLdapDataSet;
import com.zimory.ldapunit.core.LdapWatcher;
import com.zimory.ldapunit.core.DirectoryServerAccess;
import com.zimory.ldapunit.core.InMemoryDirectoryServerAccess;

public class SomeIT extends AbstractIT {

    private static final String ROOT_CONTEXT_DN = "dc=example,dc=com";

    @Inject
    private InMemoryDirectoryServer ldapServer;

    @Rule
    public LdapWatcher ldapWatcher = new LdapWatcher(new Supplier<DirectoryServerAccess>() {
        @Override
        public DirectoryServerAccess get() {
            return new InMemoryDirectoryServerAccess(ldapServer, ROOT_CONTEXT_DN);
        }
    });

    @Test
    @UsingLdapDataSet
    @ShouldMatchLdapDataSet
    public void findAndAddNewEntry() throws Exception {
        ldapServer.assertEntryExists("cn=SomeUser," + ROOT_CONTEXT_DN);
        ldapServer.add(new Entry("cn=SomeOtherUser," + ROOT_CONTEXT_DN, new Attribute("objectClass", "top")));
    }

}

Datasets

/ldifs/findAndAddNewEntry.ldif

dn: cn=SomeUser,dc=example,dc=com
cn: SomeUser
objectClass: top

/ldifs/expected-findAndAddNewEntry.ldif

dn: cn=SomeUser,dc=example,dc=com
cn: SomeUser
objectClass: top

dn: cn=SomeOtherUser,dc=example,dc=com
cn: SomeOtherUser
objectClass: top

LDAP servers

Using com.unboundid.ldap.listener.InMemoryDirectoryServer

Just instantiate com.zimory.ldapunit.core.InMemoryDirectoryServerAccess as shown in the example above and pass it to the LdapWatcher rule.

Using some other LDAP server implementation

Provide an implementation of the com.zimory.ldapunit.core.DirectoryServerAccess interface yourself.

Distribution

<dependency>
    <groupId>com.zimory.ldapunit</groupId>
    <artifactId>ldapunit-core</artifactId>
    <version>1.0.0</version>
</dependency>
com.zimory.ldapunit

Zimory GmbH

Versions

Version
1.0.0