VLVControlTestCase.java revision 9aa1482c49865483f798f91ef7d16f03cc3ec811
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at legal-notices/CDDLv1_0.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2008-2009 Sun Microsystems, Inc.
* Portions Copyright 2014-2015 ForgeRock AS
*/
/**
* This class contains a number of test cases for the virtual list view request
* and response controls.
*/
public class VLVControlTestCase
extends ControlsTestCase
{
/** The givenName attribute type. */
private AttributeType givenNameType;
/** The sn attribute type. */
private AttributeType snType;
/** The DN for "Aaccf Johnson". */
private DN aaccfJohnsonDN;
/** The DN for "Aaron Zimmerman". */
private DN aaronZimmermanDN;
/** The DN for "Albert Smith". */
private DN albertSmithDN;
/** The DN for "Albert Zimmerman". */
private DN albertZimmermanDN;
/** The DN for "lowercase mcgee". */
private DN lowercaseMcGeeDN;
/** The DN for "Mararet Jones". */
private DN margaretJonesDN;
/** The DN for "Mary Jones". */
private DN maryJonesDN;
/** The DN for "Sam Zweck". */
private DN samZweckDN;
/** The DN for "Zorro". */
/**
* Make sure that the server is running.
*
* @throws Exception If an unexpected problem occurs.
*/
public void startServer()
throws Exception
{
}
/**
* Populates the JE DB with a set of test data.
*
* @throws Exception If an unexpected problem occurs.
*/
private void populateDB()
throws Exception
{
"dn: uid=albert.zimmerman,dc=example,dc=com",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: albert.zimmerman",
"givenName: Albert",
"sn: Zimmerman",
"cn: Albert Zimmerman",
"",
"dn: uid=albert.smith,dc=example,dc=com",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: albert.smith",
"givenName: Albert",
"sn: Smith",
"cn: Albert Smith",
"",
"dn: uid=aaron.zimmerman,dc=example,dc=com",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: albert.zimmerman",
"givenName: Aaron",
"givenName: Zeke",
"sn: Zimmerman",
"cn: Aaron Zimmerman",
"",
"dn: uid=mary.jones,dc=example,dc=com",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: mary.jones",
"givenName: Mary",
"sn: Jones",
"cn: Mary Jones",
"",
"dn: uid=margaret.jones,dc=example,dc=com",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: margaret.jones",
"givenName: Margaret",
"givenName: Maggie",
"sn: Jones",
"sn: Smith",
"cn: Maggie Jones-Smith",
"",
"dn: uid=aaccf.johnson,dc=example,dc=com",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: aaccf.johnson",
"givenName: Aaccf",
"sn: Johnson",
"cn: Aaccf Johnson",
"",
"dn: uid=sam.zweck,dc=example,dc=com",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: sam.zweck",
"givenName: Sam",
"sn: Zweck",
"cn: Sam Zweck",
"",
"dn: uid=lowercase.mcgee,dc=example,dc=com",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: lowercase.mcgee",
"givenName: lowercase",
"sn: mcgee",
"cn: lowercase mcgee",
"",
"dn: uid=zorro,dc=example,dc=com",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"uid: zorro",
"sn: Zorro",
"cn: Zorro"
);
}
/**
* Tests the first constructor for the request control.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testRequestConstructor1()
throws Exception
{
}
/**
* Tests the second constructor for the request control with a null context
* ID.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testRequestConstructor2NullContextID()
throws Exception
{
}
/**
* Tests the second constructor for the request control with a non-null
* context ID.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testRequestConstructor2NonNullContextID()
throws Exception
{
}
/**
* Tests the third constructor for the request control.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testRequestConstructor3()
throws Exception
{
"a");
}
/**
* Tests the fourth constructor for the request control with a null context
* ID.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testRequestConstructor4NullContextID()
throws Exception
{
"a");
}
/**
* Tests the fourth constructor for the request control with a non-null
* context ID.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testRequestConstructor4NonNullContextID()
throws Exception
{
"a");
}
/**
* Tests the ASN.1 encoding for the response control.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testASN1ValueEncoding()
throws Exception
{
// Should start as an octet string with a nested sequence
// Should be an sequence start
// Should be an integer with targetPosition
// Should be an integer with contentCount
// Should be an enumerated with virtualListViewResult
// Should be an octet string with contextID
}
/**
* Tests the first constructor for the response control.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testResponseConstructor1()
throws Exception
{
}
/**
* Tests the second constructor for the response control with a null context
* ID.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testResponseConstructor2NullContextID()
throws Exception
{
}
/**
* Tests the second constructor for the response control with a non-null
* context ID.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testResponseConstructor2NonNullContextID()
throws Exception
{
}
/**
* Tests performing an internal search using the VLV control to retrieve a
* subset of the entries using an offset of one.
*
* @throws Exception If an unexpected problem occurred.
*/
@Test
public void testInternalSearchByOffsetOneOffset() throws Exception
{
populateDB();
SearchRequest request = newSearchRequest("dc=example,dc=com", SearchScope.WHOLE_SUBTREE, "(objectClass=person)")
for (Control c : responseControls)
{
{
}
{
}
else
{
}
}
}
/**
* Tests performing an internal search using the VLV control to retrieve a
* subset of the entries using an offset of zero, which should be treated like
* an offset of one.
*
* @throws Exception If an unexpected problem occurred.
*/
@Test
public void testInternalSearchByOffsetZeroOffset()
throws Exception
{
populateDB();
SearchRequest request = newSearchRequest("dc=example,dc=com", SearchScope.WHOLE_SUBTREE, "(objectClass=person)")
for (Control c : responseControls)
{
{
}
{
}
else
{
}
}
}
/**
* Tests performing an internal search using the VLV control to retrieve a
* subset of the entries using an offset that isn't at the beginning of the
* result set but is still completely within the bounds of that set.
*
* @throws Exception If an unexpected problem occurred.
*/
@Test
public void testInternalSearchByOffsetThreeOffset()
throws Exception
{
populateDB();
SearchRequest request = newSearchRequest("dc=example,dc=com", SearchScope.WHOLE_SUBTREE, "(objectClass=person)")
for (Control c : responseControls)
{
{
}
{
}
else
{
}
}
}
/**
* Tests performing an internal search using the VLV control with a negative
* target offset.
*
* @throws Exception If an unexpected problem occurred.
*/
@Test
public void testInternalSearchByOffsetNegativeOffset()
throws Exception
{
populateDB();
SearchRequest request = newSearchRequest("dc=example,dc=com", SearchScope.WHOLE_SUBTREE, "(objectClass=person)")
// It will be successful because it's not a critical control.
}
/**
* Tests performing an internal search using the VLV control with an offset of
* one but a beforeCount that puts the start position at a negative value.
*
* @throws Exception If an unexpected problem occurred.
*/
@Test
public void testInternalSearchByOffsetNegativeStartPosition()
throws Exception
{
populateDB();
SearchRequest request = newSearchRequest("dc=example,dc=com", SearchScope.WHOLE_SUBTREE, "(objectClass=person)")
// It will be successful because it's not a critical control.
}
/**
* Tests performing an internal search using the VLV control with a start
* start position beyond the end of the result set.
*
* @throws Exception If an unexpected problem occurred.
*/
@Test
public void testInternalSearchByOffsetStartPositionTooHigh() throws Exception
{
populateDB();
SearchRequest request = newSearchRequest("dc=example,dc=com", SearchScope.WHOLE_SUBTREE, "(objectClass=person)")
}
/**
* Tests performing an internal search using the VLV control with a start
* start position within the bounds of the list but not enough remaining
* entries to meet the afterCount
*
* @throws Exception If an unexpected problem occurred.
*/
@Test
public void testInternalSearchByOffsetIncompleteAfterCount() throws Exception
{
populateDB();
SearchRequest request = newSearchRequest("dc=example,dc=com", SearchScope.WHOLE_SUBTREE, "(objectClass=person)")
for (Control c : responseControls)
{
{
}
{
}
else
{
}
}
}
/**
* Tests performing an internal search using the VLV control to retrieve a
* subset of the entries using an assertion value before any actual value in
* the list.
*
* @throws Exception If an unexpected problem occurred.
*/
@Test
public void testInternalSearchByValueBeforeAll()
throws Exception
{
populateDB();
SearchRequest request = newSearchRequest("dc=example,dc=com", SearchScope.WHOLE_SUBTREE, "(objectClass=person)")
for (Control c : responseControls)
{
{
}
{
}
else
{
}
}
}
/**
* Tests performing an internal search using the VLV control to retrieve a
* subset of the entries using an assertion value that matches the first value
* in the list.
*
* @throws Exception If an unexpected problem occurred.
*/
@Test
public void testInternalSearchByValueMatchesFirst()
throws Exception
{
populateDB();
SearchRequest request = newSearchRequest("dc=example,dc=com", SearchScope.WHOLE_SUBTREE, "(objectClass=person)")
for (Control c : responseControls)
{
{
}
{
}
else
{
}
}
}
/**
* Tests performing an internal search using the VLV control to retrieve a
* subset of the entries using an assertion value that matches the third value
* in the list.
*
* @throws Exception If an unexpected problem occurred.
*/
@Test
public void testInternalSearchByValueMatchesThird()
throws Exception
{
populateDB();
SearchRequest request = newSearchRequest("dc=example,dc=com", SearchScope.WHOLE_SUBTREE, "(objectClass=person)")
for (Control c : responseControls)
{
{
}
{
}
else
{
}
}
}
/**
* Tests performing an internal search using the VLV control to retrieve a
* subset of the entries using an assertion value that matches the third value
* in the list and includes a nonzero before count.
*
* @throws Exception If an unexpected problem occurred.
*/
@Test
public void testInternalSearchByValueMatchesThirdWithBeforeCount()
throws Exception
{
populateDB();
SearchRequest request = newSearchRequest("dc=example,dc=com", SearchScope.WHOLE_SUBTREE, "(objectClass=person)")
for (Control c : responseControls)
{
{
}
{
}
else
{
}
}
}
{
{
}
return results;
}
/**
* Tests performing an internal search using the VLV control to retrieve a
* subset of the entries using an assertion value that is after all values in
* the list.
*
* @throws Exception If an unexpected problem occurred.
*/
@Test
public void testInternalSearchByValueAfterAll() throws Exception
{
populateDB();
SearchRequest request = newSearchRequest("dc=example,dc=com", SearchScope.WHOLE_SUBTREE, "(objectClass=person)")
// It will be successful because the control isn't critical.
}
private ServerSideSortResponseControl getServerSideSortResponseControl(Control c) throws DirectoryException
{
if (c instanceof LDAPControl)
{
}
return (ServerSideSortResponseControl) c;
}
private VLVResponseControl getVLVResponseControl(List<Control> responseControls) throws DirectoryException
{
for (Control c : responseControls)
{
{
return getVLVResponseControl(c);
}
}
fail("Expected to find VLVResponseControl");
return null;
}
{
if (c instanceof LDAPControl)
{
}
return (VLVResponseControl) c;
}
}