@ThreadSafety(level=COMPLETELY_THREADSAFE) public final class LDAPTestUtils extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static void |
assertAttributeExists(LDAPInterface conn,
java.lang.String dn,
java.util.Collection<java.lang.String> attributeNames)
Ensures that the specified entry exists in the directory with all of the
specified attributes.
|
static void |
assertAttributeExists(LDAPInterface conn,
java.lang.String dn,
java.lang.String... attributeNames)
Ensures that the specified entry exists in the directory with all of the
specified attributes.
|
static void |
assertAttributeMissing(LDAPInterface conn,
java.lang.String dn,
java.util.Collection<java.lang.String> attributeNames)
Ensures that the specified entry exists in the directory but does not
contain any of the specified attributes.
|
static void |
assertAttributeMissing(LDAPInterface conn,
java.lang.String dn,
java.lang.String... attributeNames)
Ensures that the specified entry exists in the directory but does not
contain any of the specified attributes.
|
static void |
assertContainsDiagnosticMessage(LDAPException exception)
Ensures that the provided LDAP exception contains a diagnostic message.
|
static void |
assertContainsDiagnosticMessage(LDAPResult result)
Ensures that the provided LDAP result contains a diagnostic message.
|
static void |
assertContainsMatchedDN(LDAPException exception)
Ensures that the provided LDAP exception contains a matched DN value.
|
static void |
assertContainsMatchedDN(LDAPResult result)
Ensures that the provided LDAP result contains a matched DN value.
|
static void |
assertDiagnosticMessageEquals(LDAPException exception,
java.lang.String diagnosticMessage)
Ensures that the provided LDAP exception has the given diagnostic message.
|
static void |
assertDiagnosticMessageEquals(LDAPResult result,
java.lang.String diagnosticMessage)
Ensures that the provided LDAP result has the given diagnostic message.
|
static void |
assertDNsEqual(java.lang.String s1,
java.lang.String s2)
Ensures that the two provided strings represent the same DN.
|
static void |
assertEntriesExist(LDAPInterface conn,
java.util.Collection<java.lang.String> dns)
Ensures that all of the entries with the provided DNs exist in the
directory.
|
static void |
assertEntriesExist(LDAPInterface conn,
java.lang.String... dns)
Ensures that all of the entries with the provided DNs exist in the
directory.
|
static void |
assertEntriesReturnedEquals(LDAPSearchException exception,
int expectedEntryCount)
Ensures that the provided search exception indicates that the expected
number of entries were returned.
|
static void |
assertEntriesReturnedEquals(SearchResult result,
int expectedEntryCount)
Ensures that the provided search result indicates that the expected number
of entries were returned.
|
static void |
assertEntryExists(LDAPInterface conn,
Entry entry)
Ensures that an entry exists in the directory with the same DN and all
attribute values contained in the provided entry.
|
static void |
assertEntryExists(LDAPInterface conn,
java.lang.String dn)
Ensures that an entry with the provided DN exists in the directory.
|
static void |
assertEntryExists(LDAPInterface conn,
java.lang.String dn,
java.lang.String filter)
Ensures that an entry with the provided DN exists in the directory.
|
static void |
assertEntryMissing(LDAPInterface conn,
java.lang.String dn)
Ensures that the specified entry does not exist in the directory.
|
static int |
assertEntryReturned(LDAPSearchException exception)
Ensures that the provided search exception indicates that at least one
search result entry was returned.
|
static SearchResultEntry |
assertEntryReturned(LDAPSearchException exception,
java.lang.String dn)
Ensures that the specified search result entry was included in provided
search exception.
|
static int |
assertEntryReturned(SearchResult result)
Ensures that the provided search result indicates that at least one search
result entry was returned.
|
static SearchResultEntry |
assertEntryReturned(SearchResult result,
java.lang.String dn)
Ensures that the specified search result entry was included in provided
search result.
|
static Control |
assertHasControl(LDAPException exception,
java.lang.String oid)
Ensures that the provided LDAP exception includes at least one control with
the specified OID.
|
static Control |
assertHasControl(LDAPResult result,
java.lang.String oid)
Ensures that the provided LDAP result includes at least one control with
the specified OID.
|
static Control |
assertHasControl(SearchResultEntry entry,
java.lang.String oid)
Ensures that the provided search result entry includes at least one control
with the specified OID.
|
static Control |
assertHasControl(SearchResultReference reference,
java.lang.String oid)
Ensures that the provided search result reference includes at least one
control with the specified OID.
|
static void |
assertHasReferral(LDAPException exception)
Ensures that the provided LDAP exception has one or more referral URLs.
|
static void |
assertHasReferral(LDAPResult result)
Ensures that the provided LDAP result has one or more referral URLs.
|
static void |
assertMatchedDNEquals(LDAPException exception,
java.lang.String matchedDN)
Ensures that the provided LDAP exception has the given matched DN value.
|
static void |
assertMatchedDNEquals(LDAPResult result,
java.lang.String matchedDN)
Ensures that the provided LDAP result has the given matched DN value.
|
static void |
assertMissingControl(LDAPException exception,
java.lang.String oid)
Ensures that the provided LDAP exception does not include any control with
the specified OID.
|
static void |
assertMissingControl(LDAPResult result,
java.lang.String oid)
Ensures that the provided LDAP result does not include any control with
the specified OID.
|
static void |
assertMissingControl(SearchResultEntry entry,
java.lang.String oid)
Ensures that the provided search result entry does not includes any control
with the specified OID.
|
static void |
assertMissingControl(SearchResultReference reference,
java.lang.String oid)
Ensures that the provided search result reference does not includes any
control with the specified OID.
|
static void |
assertMissingDiagnosticMessage(LDAPException exception)
Ensures that the provided LDAP exception does not contain a diagnostic
message.
|
static void |
assertMissingDiagnosticMessage(LDAPResult result)
Ensures that the provided LDAP result does not contain a diagnostic
message.
|
static void |
assertMissingMatchedDN(LDAPException exception)
Ensures that the provided LDAP exception does not contain a matched DN
value.
|
static void |
assertMissingMatchedDN(LDAPResult result)
Ensures that the provided LDAP result does not contain a matched DN value.
|
static void |
assertMissingReferral(LDAPException exception)
Ensures that the provided LDAP exception does not have any referral URLs.
|
static void |
assertMissingReferral(LDAPResult result)
Ensures that the provided LDAP result does not have any referral URLs.
|
static void |
assertNoEntriesReturned(LDAPSearchException exception)
Ensures that the provided search exception indicates that no search result
entries were returned.
|
static void |
assertNoEntriesReturned(SearchResult result)
Ensures that the provided search result indicates that no search result
entries were returned.
|
static void |
assertNoReferencesReturned(LDAPSearchException exception)
Ensures that the provided search exception indicates that no search result
references were returned.
|
static void |
assertNoReferencesReturned(SearchResult result)
Ensures that the provided search result indicates that no search result
references were returned.
|
static int |
assertReferenceReturned(LDAPSearchException exception)
Ensures that the provided search exception indicates that at least one
search result reference was returned.
|
static int |
assertReferenceReturned(SearchResult result)
Ensures that the provided search result indicates that at least one search
result reference was returned.
|
static void |
assertReferencesReturnedEquals(LDAPSearchException exception,
int expectedReferenceCount)
Ensures that the provided search exception indicates that the expected
number of references were returned.
|
static void |
assertReferencesReturnedEquals(SearchResult result,
int expectedReferenceCount)
Ensures that the provided search result indicates that the expected number
of references were returned.
|
static LDAPResult |
assertResultCodeEquals(LDAPConnection conn,
LDAPRequest request,
ResultCode... acceptableResultCodes)
Processes the provided request using the given connection and ensures that
the result code matches one of the provided acceptable values.
|
static void |
assertResultCodeEquals(LDAPException exception,
ResultCode... acceptableResultCodes)
Ensures that the result code for the provided LDAP exception matches one of
the given acceptable result codes.
|
static void |
assertResultCodeEquals(LDAPResult result,
ResultCode... acceptableResultCodes)
Ensures that the result code for the provided result matches one of the
given acceptable result codes.
|
static LDAPResult |
assertResultCodeNot(LDAPConnection conn,
LDAPRequest request,
ResultCode... unacceptableResultCodes)
Processes the provided request using the given connection and ensures that
the result code does not match any of the given unacceptable values.
|
static void |
assertResultCodeNot(LDAPException exception,
ResultCode... unacceptableResultCodes)
Ensures that the result code for the provided result does not match any of
the given unacceptable result codes.
|
static void |
assertResultCodeNot(LDAPResult result,
ResultCode... unacceptableResultCodes)
Ensures that the result code for the provided result does not match any of
the given unacceptable result codes.
|
static void |
assertValueExists(LDAPInterface conn,
java.lang.String dn,
java.lang.String attributeName,
java.util.Collection<java.lang.String> attributeValues)
Ensures that the specified entry exists in the directory with all of the
specified values for the given attribute.
|
static void |
assertValueExists(LDAPInterface conn,
java.lang.String dn,
java.lang.String attributeName,
java.lang.String... attributeValues)
Ensures that the specified entry exists in the directory with all of the
specified values for the given attribute.
|
static void |
assertValueMissing(LDAPInterface conn,
java.lang.String dn,
java.lang.String attributeName,
java.util.Collection<java.lang.String> attributeValues)
Ensures that the specified entry exists in the directory but does not
contain any of the specified attribute values.
|
static void |
assertValueMissing(LDAPInterface conn,
java.lang.String dn,
java.lang.String attributeName,
java.lang.String... attributeValues)
Ensures that the specified entry exists in the directory but does not
contain any of the specified attribute values.
|
static boolean |
entryExists(LDAPInterface conn,
Entry entry)
Indicates whether the specified entry exists in the server.
|
static boolean |
entryExists(LDAPInterface conn,
java.lang.String dn)
Indicates whether the specified entry exists in the server.
|
static boolean |
entryExists(LDAPInterface conn,
java.lang.String dn,
java.lang.String filter)
Indicates whether the specified entry exists in the server and matches the
given filter.
|
static Entry |
generateCountryEntry(java.lang.String name,
java.lang.String parentDN,
Attribute... additionalAttributes)
Generates a country entry with the provided information.
|
static Entry |
generateCountryEntry(java.lang.String name,
java.lang.String parentDN,
java.util.Collection<Attribute> additionalAttributes)
Generates a country entry with the provided information.
|
static Entry |
generateDomainEntry(java.lang.String name,
java.lang.String parentDN,
Attribute... additionalAttributes)
Generates a domain entry with the provided information.
|
static Entry |
generateDomainEntry(java.lang.String name,
java.lang.String parentDN,
java.util.Collection<Attribute> additionalAttributes)
Generates a domain entry with the provided information.
|
static Entry |
generateGroupOfNamesEntry(java.lang.String name,
java.lang.String parentDN,
java.util.Collection<java.lang.String> memberDNs)
Generates a group entry with the provided information.
|
static Entry |
generateGroupOfNamesEntry(java.lang.String name,
java.lang.String parentDN,
java.lang.String... memberDNs)
Generates a group entry with the provided information.
|
static Entry |
generateGroupOfUniqueNamesEntry(java.lang.String name,
java.lang.String parentDN,
java.util.Collection<java.lang.String> memberDNs)
Generates a group entry with the provided information.
|
static Entry |
generateGroupOfUniqueNamesEntry(java.lang.String name,
java.lang.String parentDN,
java.lang.String... memberDNs)
Generates a group entry with the provided information.
|
static Entry |
generateOrgEntry(java.lang.String name,
java.lang.String parentDN,
Attribute... additionalAttributes)
Generates an organization entry with the provided information.
|
static Entry |
generateOrgEntry(java.lang.String name,
java.lang.String parentDN,
java.util.Collection<Attribute> additionalAttributes)
Generates an organization entry with the provided information.
|
static Entry |
generateOrgUnitEntry(java.lang.String name,
java.lang.String parentDN,
Attribute... additionalAttributes)
Generates an organizationalUnit entry with the provided information.
|
static Entry |
generateOrgUnitEntry(java.lang.String name,
java.lang.String parentDN,
java.util.Collection<Attribute> additionalAttributes)
Generates an organizationalUnit entry with the provided information.
|
static Entry |
generateUserEntry(java.lang.String uid,
java.lang.String parentDN,
java.lang.String firstName,
java.lang.String lastName,
java.lang.String password,
Attribute... additionalAttributes)
Generates a user entry with the provided information.
|
static Entry |
generateUserEntry(java.lang.String uid,
java.lang.String parentDN,
java.lang.String firstName,
java.lang.String lastName,
java.lang.String password,
java.util.Collection<Attribute> additionalAttributes)
Generates a user entry with the provided information.
|
static java.util.List<java.lang.String> |
getMissingAttributeNames(LDAPInterface conn,
java.lang.String dn,
java.util.Collection<java.lang.String> attributeNames)
Retrieves a list containing all of the named attributes which do not exist
in the target entry.
|
static java.util.List<java.lang.String> |
getMissingAttributeNames(LDAPInterface conn,
java.lang.String dn,
java.lang.String... attributeNames)
Retrieves a list containing all of the named attributes which do not exist
in the target entry.
|
static java.util.List<java.lang.String> |
getMissingAttributeValues(LDAPInterface conn,
java.lang.String dn,
java.lang.String attributeName,
java.util.Collection<java.lang.String> attributeValues)
Retrieves a list of all provided attribute values which are missing from
the specified entry.
|
static java.util.List<java.lang.String> |
getMissingAttributeValues(LDAPInterface conn,
java.lang.String dn,
java.lang.String attributeName,
java.lang.String... attributeValues)
Retrieves a list of all provided attribute values which are missing from
the specified entry.
|
static java.util.List<java.lang.String> |
getMissingEntryDNs(LDAPInterface conn,
java.util.Collection<java.lang.String> dns)
Retrieves a list containing the DNs of the entries which are missing from
the directory server.
|
static java.util.List<java.lang.String> |
getMissingEntryDNs(LDAPInterface conn,
java.lang.String... dns)
Retrieves a list containing the DNs of the entries which are missing from
the directory server.
|
@NotNull public static Entry generateDomainEntry(@NotNull java.lang.String name, @Nullable java.lang.String parentDN, @Nullable Attribute... additionalAttributes)
name
- The name for the domain, which will be used
as the value of the "dc" attribute. It must
not be null
.parentDN
- The DN of the entry below which the new
entry should be placed. It may be
null
if the new entry should not have
a parent.additionalAttributes
- A set of additional attributes to include in
the generated entry. It may be null
or empty if no additional attributes should
be included.@NotNull public static Entry generateDomainEntry(@NotNull java.lang.String name, @Nullable java.lang.String parentDN, @Nullable java.util.Collection<Attribute> additionalAttributes)
name
- The name for the domain, which will be used
as the value of the "dc" attribute. It must
not be null
.parentDN
- The DN of the entry below which the new
entry should be placed. It may be
null
if the new entry should not have
a parent.additionalAttributes
- A set of additional attributes to include in
the generated entry. It may be null
or empty if no additional attributes should
be included.@NotNull public static Entry generateOrgEntry(@NotNull java.lang.String name, @Nullable java.lang.String parentDN, @Nullable Attribute... additionalAttributes)
name
- The name for the organization, which will be
used as the value of the "o" attribute. It
must not be null
.parentDN
- The DN of the entry below which the new
entry should be placed. It may be
null
if the new entry should not have
a parent.additionalAttributes
- A set of additional attributes to include in
the generated entry. It may be null
or empty if no additional attributes should
be included.@NotNull public static Entry generateOrgEntry(@NotNull java.lang.String name, @Nullable java.lang.String parentDN, @Nullable java.util.Collection<Attribute> additionalAttributes)
name
- The name for the organization, which will be
used as the value of the "o" attribute. It
must not be null
.parentDN
- The DN of the entry below which the new
entry should be placed. It may be
null
if the new entry should not have
a parent.additionalAttributes
- A set of additional attributes to include in
the generated entry. It may be null
or empty if no additional attributes should
be included.@NotNull public static Entry generateOrgUnitEntry(@NotNull java.lang.String name, @Nullable java.lang.String parentDN, @Nullable Attribute... additionalAttributes)
name
- The name for the organizationalUnit, which
will be used as the value of the "ou"
attribute. It must not be null
.parentDN
- The DN of the entry below which the new
entry should be placed. It may be
null
if the new entry should not have
a parent.additionalAttributes
- A set of additional attributes to include in
the generated entry. It may be null
or empty if no additional attributes should
be included.@NotNull public static Entry generateOrgUnitEntry(@NotNull java.lang.String name, @Nullable java.lang.String parentDN, @Nullable java.util.Collection<Attribute> additionalAttributes)
name
- The name for the organizationalUnit, which
will be used as the value of the "ou"
attribute. It must not be null
.parentDN
- The DN of the entry below which the new
entry should be placed. It may be
null
if the new entry should not have
a parent.additionalAttributes
- A set of additional attributes to include in
the generated entry. It may be null
or empty if no additional attributes should
be included.@NotNull public static Entry generateCountryEntry(@NotNull java.lang.String name, @Nullable java.lang.String parentDN, @Nullable Attribute... additionalAttributes)
name
- The name for the country (typically a
two-character country code), which will be
used as the value of the "c" attribute. It
must not be null
.parentDN
- The DN of the entry below which the new
entry should be placed. It may be
null
if the new entry should not have
a parent.additionalAttributes
- A set of additional attributes to include in
the generated entry. It may be null
or empty if no additional attributes should
be included.@NotNull public static Entry generateCountryEntry(@NotNull java.lang.String name, @Nullable java.lang.String parentDN, @Nullable java.util.Collection<Attribute> additionalAttributes)
name
- The name for the country (typically a
two-character country code), which will be
used as the value of the "c" attribute. It
must not be null
.parentDN
- The DN of the entry below which the new
entry should be placed. It may be
null
if the new entry should not have
a parent.additionalAttributes
- A set of additional attributes to include in
the generated entry. It may be null
or empty if no additional attributes should
be included.@NotNull public static Entry generateUserEntry(@NotNull java.lang.String uid, @Nullable java.lang.String parentDN, @NotNull java.lang.String firstName, @NotNull java.lang.String lastName, @Nullable java.lang.String password, @Nullable Attribute... additionalAttributes)
uid
- The value to use for the "uid: attribute. It
must not be null
.parentDN
- The DN of the entry below which the new
entry should be placed. It may be
null
if the new entry should not have
a parent.firstName
- The first name for the user. It must not be
null
.lastName
- The last name for the user. It must not be
null
.password
- The password for the user. It may be
null
if the user should not have a
password.additionalAttributes
- A set of additional attributes to include in
the generated entry. It may be null
or empty if no additional attributes should
be included.@NotNull public static Entry generateUserEntry(@NotNull java.lang.String uid, @Nullable java.lang.String parentDN, @NotNull java.lang.String firstName, @NotNull java.lang.String lastName, @Nullable java.lang.String password, @Nullable java.util.Collection<Attribute> additionalAttributes)
uid
- The value to use for the "uid: attribute. It
must not be null
.parentDN
- The DN of the entry below which the new
entry should be placed. It may be
null
if the new entry should not have
a parent.firstName
- The first name for the user. It must not be
null
.lastName
- The last name for the user. It must not be
null
.password
- The password for the user. It may be
null
if the user should not have a
password.additionalAttributes
- A set of additional attributes to include in
the generated entry. It may be null
or empty if no additional attributes should
be included.@NotNull public static Entry generateGroupOfNamesEntry(@NotNull java.lang.String name, @Nullable java.lang.String parentDN, @NotNull java.lang.String... memberDNs)
name
- The name for the group, which will be used as the value
of the "cn" attribute. It must not be null
.parentDN
- The DN of the entry below which the new entry should be
placed. It may be null
if the new entry should
not have a parent.memberDNs
- The DNs of the users that should be listed as members of
the group.@NotNull public static Entry generateGroupOfNamesEntry(@NotNull java.lang.String name, @Nullable java.lang.String parentDN, @NotNull java.util.Collection<java.lang.String> memberDNs)
name
- The name for the group, which will be used as the value
of the "cn" attribute. It must not be null
.parentDN
- The DN of the entry below which the new entry should be
placed. It may be null
if the new entry should
not have a parent.memberDNs
- The DNs of the users that should be listed as members of
the group.@NotNull public static Entry generateGroupOfUniqueNamesEntry(@NotNull java.lang.String name, @Nullable java.lang.String parentDN, @NotNull java.lang.String... memberDNs)
name
- The name for the group, which will be used as the value
of the "cn" attribute. It must not be null
.parentDN
- The DN of the entry below which the new entry should be
placed. It may be null
if the new entry should
not have a parent.memberDNs
- The DNs of the users that should be listed as members of
the group.@NotNull public static Entry generateGroupOfUniqueNamesEntry(@NotNull java.lang.String name, @Nullable java.lang.String parentDN, @NotNull java.util.Collection<java.lang.String> memberDNs)
name
- The name for the group, which will be used as the value
of the "cn" attribute. It must not be null
.parentDN
- The DN of the entry below which the new entry should be
placed. It may be null
if the new entry should
not have a parent.memberDNs
- The DNs of the users that should be listed as members of
the group.public static boolean entryExists(@NotNull LDAPInterface conn, @NotNull java.lang.String dn) throws LDAPException
conn
- The connection to use to communicate with the directory
server.dn
- The DN of the entry for which to make the determination.true
if the entry exists, or false
if not.LDAPException
- If a problem is encountered while trying to
communicate with the directory server.public static boolean entryExists(@NotNull LDAPInterface conn, @NotNull java.lang.String dn, @NotNull java.lang.String filter) throws LDAPException
conn
- The connection to use to communicate with the directory
server.dn
- The DN of the entry for which to make the determination.filter
- The filter the entry is expected to match.true
if the entry exists and matches the specified filter,
or false
if not.LDAPException
- If a problem is encountered while trying to
communicate with the directory server.public static boolean entryExists(@NotNull LDAPInterface conn, @NotNull Entry entry) throws LDAPException
true
only if the target entry exists and contains all values
for all attributes of the provided entry. The entry will be allowed to
have attribute values not included in the provided entry.conn
- The connection to use to communicate with the directory
server.entry
- The entry to compare against the directory server.true
if the entry exists in the server and is a superset
of the provided entry, or false
if not.LDAPException
- If a problem is encountered while trying to
communicate with the directory server.public static void assertEntryExists(@NotNull LDAPInterface conn, @NotNull java.lang.String dn) throws LDAPException, java.lang.AssertionError
conn
- The connection to use to communicate with the directory
server.dn
- The DN of the entry for which to make the determination.LDAPException
- If a problem is encountered while trying to
communicate with the directory server.java.lang.AssertionError
- If the target entry does not exist.public static void assertEntryExists(@NotNull LDAPInterface conn, @NotNull java.lang.String dn, @NotNull java.lang.String filter) throws LDAPException, java.lang.AssertionError
conn
- The connection to use to communicate with the directory
server.dn
- The DN of the entry for which to make the determination.filter
- A filter that the target entry must match.LDAPException
- If a problem is encountered while trying to
communicate with the directory server.java.lang.AssertionError
- If the target entry does not exist or does not
match the provided filter.public static void assertEntryExists(@NotNull LDAPInterface conn, @NotNull Entry entry) throws LDAPException, java.lang.AssertionError
conn
- The connection to use to communicate with the directory
server.entry
- The entry expected to be present in the directory server.LDAPException
- If a problem is encountered while trying to
communicate with the directory server.java.lang.AssertionError
- If the target entry does not exist or does not
match the provided filter.@NotNull public static java.util.List<java.lang.String> getMissingEntryDNs(@NotNull LDAPInterface conn, @NotNull java.lang.String... dns) throws LDAPException
conn
- The connection to use to communicate with the directory
server.dns
- The DNs of the entries to try to find in the server.LDAPException
- If a problem is encountered while trying to
communicate with the directory server.@NotNull public static java.util.List<java.lang.String> getMissingEntryDNs(@NotNull LDAPInterface conn, @NotNull java.util.Collection<java.lang.String> dns) throws LDAPException
conn
- The connection to use to communicate with the directory
server.dns
- The DNs of the entries to try to find in the server.LDAPException
- If a problem is encountered while trying to
communicate with the directory server.public static void assertEntriesExist(@NotNull LDAPInterface conn, @NotNull java.lang.String... dns) throws LDAPException, java.lang.AssertionError
conn
- The connection to use to communicate with the directory
server.dns
- The DNs of the entries for which to make the determination.LDAPException
- If a problem is encountered while trying to
communicate with the directory server.java.lang.AssertionError
- If any of the target entries does not exist.public static void assertEntriesExist(@NotNull LDAPInterface conn, @NotNull java.util.Collection<java.lang.String> dns) throws LDAPException, java.lang.AssertionError
conn
- The connection to use to communicate with the directory
server.dns
- The DNs of the entries for which to make the determination.LDAPException
- If a problem is encountered while trying to
communicate with the directory server.java.lang.AssertionError
- If any of the target entries does not exist.@Nullable public static java.util.List<java.lang.String> getMissingAttributeNames(@NotNull LDAPInterface conn, @NotNull java.lang.String dn, @NotNull java.lang.String... attributeNames) throws LDAPException
conn
- The connection to use to communicate with the
directory server.dn
- The DN of the entry to examine.attributeNames
- The names of the attributes expected to be present
in the target entry.null
if the target
entry does not exist.LDAPException
- If a problem is encountered while trying to
communicate with the directory server.@Nullable public static java.util.List<java.lang.String> getMissingAttributeNames(@NotNull LDAPInterface conn, @NotNull java.lang.String dn, @NotNull java.util.Collection<java.lang.String> attributeNames) throws LDAPException
conn
- The connection to use to communicate with the
directory server.dn
- The DN of the entry to examine.attributeNames
- The names of the attributes expected to be present
in the target entry.null
if the target
entry does not exist.LDAPException
- If a problem is encountered while trying to
communicate with the directory server.public static void assertAttributeExists(@NotNull LDAPInterface conn, @NotNull java.lang.String dn, @NotNull java.lang.String... attributeNames) throws LDAPException, java.lang.AssertionError
conn
- The connection to use to communicate with the
directory server.dn
- The DN of the entry to examine.attributeNames
- The names of the attributes that are expected to be
present in the provided entry.LDAPException
- If a problem is encountered while trying to
communicate with the directory server.java.lang.AssertionError
- If the target entry does not exist or does not
contain all of the specified attributes.public static void assertAttributeExists(@NotNull LDAPInterface conn, @NotNull java.lang.String dn, @NotNull java.util.Collection<java.lang.String> attributeNames) throws LDAPException, java.lang.AssertionError
conn
- The connection to use to communicate with the
directory server.dn
- The DN of the entry to examine.attributeNames
- The names of the attributes that are expected to be
present in the provided entry.LDAPException
- If a problem is encountered while trying to
communicate with the directory server.java.lang.AssertionError
- If the target entry does not exist or does not
contain all of the specified attributes.@Nullable public static java.util.List<java.lang.String> getMissingAttributeValues(@NotNull LDAPInterface conn, @NotNull java.lang.String dn, @NotNull java.lang.String attributeName, @NotNull java.lang.String... attributeValues) throws LDAPException
conn
- The connection to use to communicate with the
directory server.dn
- The DN of the entry to examine.attributeName
- The attribute expected to be present in the target
entry with the given values.attributeValues
- The values expected to be present in the target
entry.null
if the target entry does not exist.LDAPException
- If a problem is encountered while trying to
communicate with the directory server.@Nullable public static java.util.List<java.lang.String> getMissingAttributeValues(@NotNull LDAPInterface conn, @NotNull java.lang.String dn, @NotNull java.lang.String attributeName, @NotNull java.util.Collection<java.lang.String> attributeValues) throws LDAPException
conn
- The connection to use to communicate with the
directory server.dn
- The DN of the entry to examine.attributeName
- The attribute expected to be present in the target
entry with the given values.attributeValues
- The values expected to be present in the target
entry.null
if the target entry does not exist.LDAPException
- If a problem is encountered while trying to
communicate with the directory server.public static void assertValueExists(@NotNull LDAPInterface conn, @NotNull java.lang.String dn, @NotNull java.lang.String attributeName, @NotNull java.lang.String... attributeValues) throws LDAPException, java.lang.AssertionError
conn
- The connection to use to communicate with the
directory server.dn
- The DN of the entry to examine.attributeName
- The name of the attribute to examine.attributeValues
- The set of values which must exist for the given
attribute.LDAPException
- If a problem is encountered while trying to
communicate with the directory server.java.lang.AssertionError
- If the target entry does not exist, does not
contain the specified attribute, or that attribute
does not have all of the specified values.public static void assertValueExists(@NotNull LDAPInterface conn, @NotNull java.lang.String dn, @NotNull java.lang.String attributeName, @NotNull java.util.Collection<java.lang.String> attributeValues) throws LDAPException, java.lang.AssertionError
conn
- The connection to use to communicate with the
directory server.dn
- The DN of the entry to examine.attributeName
- The name of the attribute to examine.attributeValues
- The set of values which must exist for the given
attribute.LDAPException
- If a problem is encountered while trying to
communicate with the directory server.java.lang.AssertionError
- If the target entry does not exist, does not
contain the specified attribute, or that attribute
does not have all of the specified values.public static void assertEntryMissing(@NotNull LDAPInterface conn, @NotNull java.lang.String dn) throws LDAPException, java.lang.AssertionError
conn
- The connection to use to communicate with the directory
server.dn
- The DN of the entry expected to be missing.LDAPException
- If a problem is encountered while trying to
communicate with the directory server.java.lang.AssertionError
- If the target entry is found in the server.public static void assertAttributeMissing(@NotNull LDAPInterface conn, @NotNull java.lang.String dn, @NotNull java.lang.String... attributeNames) throws LDAPException, java.lang.AssertionError
conn
- The connection to use to communicate with the
directory server.dn
- The DN of the entry expected to be present.attributeNames
- The names of the attributes expected to be missing
from the entry.LDAPException
- If a problem is encountered while trying to
communicate with the directory server.java.lang.AssertionError
- If the target entry is missing from the server, or
if it contains any of the target attributes.public static void assertAttributeMissing(@NotNull LDAPInterface conn, @NotNull java.lang.String dn, @NotNull java.util.Collection<java.lang.String> attributeNames) throws LDAPException, java.lang.AssertionError
conn
- The connection to use to communicate with the
directory server.dn
- The DN of the entry expected to be present.attributeNames
- The names of the attributes expected to be missing
from the entry.LDAPException
- If a problem is encountered while trying to
communicate with the directory server.java.lang.AssertionError
- If the target entry is missing from the server, or
if it contains any of the target attributes.public static void assertValueMissing(@NotNull LDAPInterface conn, @NotNull java.lang.String dn, @NotNull java.lang.String attributeName, @NotNull java.lang.String... attributeValues) throws LDAPException, java.lang.AssertionError
conn
- The connection to use to communicate with the
directory server.dn
- The DN of the entry expected to be present.attributeName
- The name of the attribute to examine.attributeValues
- The values expected to be missing from the target
entry.LDAPException
- If a problem is encountered while trying to
communicate with the directory server.java.lang.AssertionError
- If the target entry is missing from the server, or
if it contains any of the target attribute values.public static void assertValueMissing(@NotNull LDAPInterface conn, @NotNull java.lang.String dn, @NotNull java.lang.String attributeName, @NotNull java.util.Collection<java.lang.String> attributeValues) throws LDAPException, java.lang.AssertionError
conn
- The connection to use to communicate with the
directory server.dn
- The DN of the entry expected to be present.attributeName
- The name of the attribute to examine.attributeValues
- The values expected to be missing from the target
entry.LDAPException
- If a problem is encountered while trying to
communicate with the directory server.java.lang.AssertionError
- If the target entry is missing from the server, or
if it contains any of the target attribute values.public static void assertResultCodeEquals(@NotNull LDAPResult result, @NotNull ResultCode... acceptableResultCodes) throws java.lang.AssertionError
result
- The LDAP result to examine.acceptableResultCodes
- The set of result codes that are considered
acceptable.java.lang.AssertionError
- If the result code from the provided result did
not match any of the acceptable values.public static void assertResultCodeEquals(@NotNull LDAPException exception, @NotNull ResultCode... acceptableResultCodes) throws java.lang.AssertionError
exception
- The LDAP exception to examine.acceptableResultCodes
- The set of result codes that are considered
acceptable.java.lang.AssertionError
- If the result code from the provided exception did
not match any of the acceptable values.@NotNull public static LDAPResult assertResultCodeEquals(@NotNull LDAPConnection conn, @NotNull LDAPRequest request, @NotNull ResultCode... acceptableResultCodes) throws java.lang.AssertionError
conn
- The connection to use to communicate with
the directory server.request
- The request to be processed.acceptableResultCodes
- The set of result codes that are considered
acceptable.java.lang.AssertionError
- If the result code returned by the server did not
match any acceptable values.public static void assertResultCodeNot(@NotNull LDAPResult result, @NotNull ResultCode... unacceptableResultCodes) throws java.lang.AssertionError
result
- The LDAP result to examine.unacceptableResultCodes
- The set of result codes that are
considered unacceptable.java.lang.AssertionError
- If the result code from the provided result
matched any of the unacceptable values.public static void assertResultCodeNot(@NotNull LDAPException exception, @NotNull ResultCode... unacceptableResultCodes) throws java.lang.AssertionError
exception
- The LDAP exception to examine.unacceptableResultCodes
- The set of result codes that are
considered unacceptable.java.lang.AssertionError
- If the result code from the provided result
matched any of the unacceptable values.@NotNull public static LDAPResult assertResultCodeNot(@NotNull LDAPConnection conn, @NotNull LDAPRequest request, @NotNull ResultCode... unacceptableResultCodes) throws java.lang.AssertionError
conn
- The connection to use to communicate with
the directory server.request
- The request to be processed.unacceptableResultCodes
- The set of result codes that are
considered unacceptable.java.lang.AssertionError
- If the result code from the provided result
matched any of the unacceptable values.public static void assertContainsMatchedDN(@NotNull LDAPResult result) throws java.lang.AssertionError
result
- The LDAP result to examine.java.lang.AssertionError
- If the provided result did not contain a matched
DN value.public static void assertContainsMatchedDN(@NotNull LDAPException exception) throws java.lang.AssertionError
exception
- The LDAP exception to examine.java.lang.AssertionError
- If the provided exception did not contain a
matched DN value.public static void assertMissingMatchedDN(@NotNull LDAPResult result) throws java.lang.AssertionError
result
- The LDAP result to examine.java.lang.AssertionError
- If the provided result contained a matched DN
value.public static void assertMissingMatchedDN(@NotNull LDAPException exception) throws java.lang.AssertionError
exception
- The LDAP exception to examine.java.lang.AssertionError
- If the provided exception contained a matched DN
value.public static void assertMatchedDNEquals(@NotNull LDAPResult result, @NotNull java.lang.String matchedDN) throws LDAPException, java.lang.AssertionError
result
- The LDAP result to examine.matchedDN
- The matched DN value expected to be found in the
provided result. It must not be null
.LDAPException
- If either the found or expected matched DN values
could not be parsed as a valid DN.java.lang.AssertionError
- If the provided LDAP result did not contain a
matched DN, or if it had a matched DN that
differed from the expected value.public static void assertMatchedDNEquals(@NotNull LDAPException exception, @NotNull java.lang.String matchedDN) throws LDAPException, java.lang.AssertionError
exception
- The LDAP exception to examine.matchedDN
- The matched DN value expected to be found in the
provided exception. It must not be null
.LDAPException
- If either the found or expected matched DN values
could not be parsed as a valid DN.java.lang.AssertionError
- If the provided LDAP exception did not contain a
matched DN, or if it had a matched DN that
differed from the expected value.public static void assertContainsDiagnosticMessage(@NotNull LDAPResult result) throws java.lang.AssertionError
result
- The LDAP result to examine.java.lang.AssertionError
- If the provided result did not contain a
diagnostic message.public static void assertContainsDiagnosticMessage(@NotNull LDAPException exception) throws java.lang.AssertionError
exception
- The LDAP exception to examine.java.lang.AssertionError
- If the provided exception did not contain a
diagnostic message.public static void assertMissingDiagnosticMessage(@NotNull LDAPResult result) throws java.lang.AssertionError
result
- The LDAP result to examine.java.lang.AssertionError
- If the provided result contained a diagnostic
message.public static void assertMissingDiagnosticMessage(@NotNull LDAPException exception) throws java.lang.AssertionError
exception
- The LDAP exception to examine.java.lang.AssertionError
- If the provided exception contained a diagnostic
message.public static void assertDiagnosticMessageEquals(@NotNull LDAPResult result, @NotNull java.lang.String diagnosticMessage) throws java.lang.AssertionError
result
- The LDAP result to examine.diagnosticMessage
- The diagnostic message expected to be found in
the provided result. It must not be
null
.java.lang.AssertionError
- If the provided LDAP result did not contain a
diagnostic message, or if it had a diagnostic
message that differed from the expected value.public static void assertDiagnosticMessageEquals(@NotNull LDAPException exception, @NotNull java.lang.String diagnosticMessage) throws java.lang.AssertionError
exception
- The LDAP exception to examine.diagnosticMessage
- The diagnostic message expected to be found in
the provided exception. It must not be
null
.java.lang.AssertionError
- If the provided LDAP exception did not contain a
diagnostic message, or if it had a diagnostic
message that differed from the expected value.public static void assertHasReferral(@NotNull LDAPResult result) throws java.lang.AssertionError
result
- The LDAP result to examine.java.lang.AssertionError
- If the provided result does not have any referral
URLs.public static void assertHasReferral(@NotNull LDAPException exception) throws java.lang.AssertionError
exception
- The LDAP exception to examine.java.lang.AssertionError
- If the provided exception does not have any
referral URLs.public static void assertMissingReferral(@NotNull LDAPResult result) throws java.lang.AssertionError
result
- The LDAP result to examine.java.lang.AssertionError
- If the provided result has one or more referral
URLs.public static void assertMissingReferral(@NotNull LDAPException exception) throws java.lang.AssertionError
exception
- The LDAP exception to examine.java.lang.AssertionError
- If the provided exception has one or more referral
URLs.@NotNull public static Control assertHasControl(@NotNull LDAPResult result, @NotNull java.lang.String oid) throws java.lang.AssertionError
result
- The LDAP result to examine.oid
- The OID of the control which is expected to be present in
the result.java.lang.AssertionError
- If the provided LDAP result does not include any
control with the specified OID.@NotNull public static Control assertHasControl(@NotNull LDAPException exception, @NotNull java.lang.String oid) throws java.lang.AssertionError
exception
- The LDAP exception to examine.oid
- The OID of the control which is expected to be present
in the exception.java.lang.AssertionError
- If the provided LDAP exception does not include
any control with the specified OID.@NotNull public static Control assertHasControl(@NotNull SearchResultEntry entry, @NotNull java.lang.String oid) throws java.lang.AssertionError
entry
- The search result entry to examine.oid
- The OID of the control which is expected to be present in
the search result entry.java.lang.AssertionError
- If the provided search result entry does not
include any control with the specified OID.@NotNull public static Control assertHasControl(@NotNull SearchResultReference reference, @NotNull java.lang.String oid) throws java.lang.AssertionError
reference
- The search result reference to examine.oid
- The OID of the control which is expected to be present
in the search result reference.java.lang.AssertionError
- If the provided search result reference does not
include any control with the specified OID.public static void assertMissingControl(@NotNull LDAPResult result, @NotNull java.lang.String oid) throws java.lang.AssertionError
result
- The LDAP result to examine.oid
- The OID of the control which is not expected to be present
in the result.java.lang.AssertionError
- If the provided LDAP result includes any control
with the specified OID.public static void assertMissingControl(@NotNull LDAPException exception, @NotNull java.lang.String oid) throws java.lang.AssertionError
exception
- The LDAP exception to examine.oid
- The OID of the control which is not expected to be
present in the exception.java.lang.AssertionError
- If the provided LDAP exception includes any
control with the specified OID.public static void assertMissingControl(@NotNull SearchResultEntry entry, @NotNull java.lang.String oid) throws java.lang.AssertionError
entry
- The search result entry to examine.oid
- The OID of the control which is not expected to be present
in the search result entry.java.lang.AssertionError
- If the provided search result entry includes any
control with the specified OID.public static void assertMissingControl(@NotNull SearchResultReference reference, @NotNull java.lang.String oid) throws java.lang.AssertionError
reference
- The search result reference to examine.oid
- The OID of the control which is not expected to be
present in the search result reference.java.lang.AssertionError
- If the provided search result reference includes
any control with the specified OID.public static int assertEntryReturned(@NotNull SearchResult result) throws java.lang.AssertionError
result
- The search result to examine.java.lang.AssertionError
- If the provided search result indicates that no
entries were returned.public static int assertEntryReturned(@NotNull LDAPSearchException exception) throws java.lang.AssertionError
exception
- The search exception to examine.java.lang.AssertionError
- If the provided search exception indicates that no
entries were returned.@NotNull public static SearchResultEntry assertEntryReturned(@NotNull SearchResult result, @NotNull java.lang.String dn) throws LDAPException, java.lang.AssertionError
result
- The search result to examine.dn
- The DN of the entry expected to be included in the
search result.LDAPException
- If the provided string cannot be parsed as a valid
DN.java.lang.AssertionError
- If the specified entry was not included in the
set of entries that were returned, or if a search
result listener was used which makes the
determination impossible.@NotNull public static SearchResultEntry assertEntryReturned(@NotNull LDAPSearchException exception, @NotNull java.lang.String dn) throws LDAPException, java.lang.AssertionError
exception
- The search exception to examine.dn
- The DN of the entry expected to be included in the
search exception.LDAPException
- If the provided string cannot be parsed as a valid
DN.java.lang.AssertionError
- If the specified entry was not included in the
set of entries that were returned, or if a search
result listener was used which makes the
determination impossible.public static void assertNoEntriesReturned(@NotNull SearchResult result) throws java.lang.AssertionError
result
- The search result to examine.java.lang.AssertionError
- If the provided search result indicates that one
or more entries were returned.public static void assertNoEntriesReturned(@NotNull LDAPSearchException exception) throws java.lang.AssertionError
exception
- The search exception to examine.java.lang.AssertionError
- If the provided search exception indicates that
one or more entries were returned.public static void assertEntriesReturnedEquals(@NotNull SearchResult result, int expectedEntryCount) throws java.lang.AssertionError
result
- The search result to examine.expectedEntryCount
- The number of expected search result entries.java.lang.AssertionError
- If the number of entries returned does not match
the expected value.public static void assertEntriesReturnedEquals(@NotNull LDAPSearchException exception, int expectedEntryCount) throws java.lang.AssertionError
exception
- The search exception to examine.expectedEntryCount
- The number of expected search result entries.java.lang.AssertionError
- If the number of entries returned does not match
the expected value.public static int assertReferenceReturned(@NotNull SearchResult result) throws java.lang.AssertionError
result
- The search result to examine.java.lang.AssertionError
- If the provided search result indicates that no
references were returned.public static int assertReferenceReturned(@NotNull LDAPSearchException exception) throws java.lang.AssertionError
exception
- The search exception to examine.java.lang.AssertionError
- If the provided search exception indicates that no
references were returned.public static void assertNoReferencesReturned(@NotNull SearchResult result) throws java.lang.AssertionError
result
- The search result to examine.java.lang.AssertionError
- If the provided search result indicates that one
or more references were returned.public static void assertNoReferencesReturned(@NotNull LDAPSearchException exception) throws java.lang.AssertionError
exception
- The search exception to examine.java.lang.AssertionError
- If the provided search exception indicates that
one or more references were returned.public static void assertReferencesReturnedEquals(@NotNull SearchResult result, int expectedReferenceCount) throws java.lang.AssertionError
result
- The search result to examine.expectedReferenceCount
- The number of expected search result
references.java.lang.AssertionError
- If the number of references returned does not
match the expected value.public static void assertReferencesReturnedEquals(@NotNull LDAPSearchException exception, int expectedReferenceCount) throws java.lang.AssertionError
exception
- The search exception to examine.expectedReferenceCount
- The number of expected search result
references.java.lang.AssertionError
- If the number of references returned does not
match the expected value.public static void assertDNsEqual(@NotNull java.lang.String s1, @NotNull java.lang.String s2) throws java.lang.AssertionError
s1
- The first string to compare.s2
- The second string to compare.java.lang.AssertionError
- If either string doesn't represent a valid DN, or
if they do not represent the same DN.