@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 |
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 |
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 |
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.
|
public static Entry generateDomainEntry(java.lang.String name, java.lang.String parentDN, 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.public static Entry generateDomainEntry(java.lang.String name, java.lang.String parentDN, 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.public static Entry generateOrgEntry(java.lang.String name, java.lang.String parentDN, 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.public static Entry generateOrgEntry(java.lang.String name, java.lang.String parentDN, 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.public static Entry generateOrgUnitEntry(java.lang.String name, java.lang.String parentDN, 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.public static Entry generateOrgUnitEntry(java.lang.String name, java.lang.String parentDN, 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.public static Entry generateCountryEntry(java.lang.String name, java.lang.String parentDN, 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.public static Entry generateCountryEntry(java.lang.String name, java.lang.String parentDN, 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.public 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)
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.public 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)
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.public static Entry generateGroupOfNamesEntry(java.lang.String name, java.lang.String parentDN, 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 Entry generateGroupOfNamesEntry(java.lang.String name, java.lang.String parentDN, 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 Entry generateGroupOfUniqueNamesEntry(java.lang.String name, java.lang.String parentDN, 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 Entry generateGroupOfUniqueNamesEntry(java.lang.String name, java.lang.String parentDN, 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(LDAPInterface conn, 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(LDAPInterface conn, java.lang.String dn, 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(LDAPInterface conn, 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(LDAPInterface conn, 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(LDAPInterface conn, java.lang.String dn, 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(LDAPInterface conn, 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.public static java.util.List<java.lang.String> getMissingEntryDNs(LDAPInterface conn, 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 java.util.List<java.lang.String> getMissingEntryDNs(LDAPInterface conn, 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(LDAPInterface conn, 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(LDAPInterface conn, 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.public static java.util.List<java.lang.String> getMissingAttributeNames(LDAPInterface conn, java.lang.String dn, 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 java.util.List<java.lang.String> getMissingAttributeNames(LDAPInterface conn, java.lang.String dn, 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(LDAPInterface conn, java.lang.String dn, 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(LDAPInterface conn, java.lang.String dn, 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.public static java.util.List<java.lang.String> getMissingAttributeValues(LDAPInterface conn, java.lang.String dn, java.lang.String attributeName, 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 java.util.List<java.lang.String> getMissingAttributeValues(LDAPInterface conn, java.lang.String dn, java.lang.String attributeName, 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(LDAPInterface conn, java.lang.String dn, java.lang.String attributeName, 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(LDAPInterface conn, java.lang.String dn, java.lang.String attributeName, 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(LDAPInterface conn, 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(LDAPInterface conn, java.lang.String dn, 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(LDAPInterface conn, java.lang.String dn, 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(LDAPInterface conn, java.lang.String dn, java.lang.String attributeName, 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(LDAPInterface conn, java.lang.String dn, java.lang.String attributeName, 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(LDAPResult result, 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(LDAPException exception, 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.public static LDAPResult assertResultCodeEquals(LDAPConnection conn, LDAPRequest request, 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(LDAPResult result, 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(LDAPException exception, 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.public static LDAPResult assertResultCodeNot(LDAPConnection conn, LDAPRequest request, 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(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(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(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(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(LDAPResult result, 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(LDAPException exception, 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 assertHasReferral(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(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(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(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.public static Control assertHasControl(LDAPResult result, 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.public static Control assertHasControl(LDAPException exception, 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.public static Control assertHasControl(SearchResultEntry entry, 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.public static Control assertHasControl(SearchResultReference reference, 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(LDAPResult result, 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(LDAPException exception, 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(SearchResultEntry entry, 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(SearchResultReference reference, 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(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(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.public static SearchResultEntry assertEntryReturned(SearchResult result, 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.public static SearchResultEntry assertEntryReturned(LDAPSearchException exception, 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(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(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(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(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(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(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(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(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(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(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(java.lang.String s1, 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.