ServerSideSortControlTestCase.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 server side sort request
* and response controls.
*/
public class ServerSideSortControlTestCase
extends ControlsTestCase
{
/** The givenName attribute type. */
private AttributeType givenNameType;
/** The sn attribute type. */
private AttributeType snType;
/** The DN for "Aaccf Johnson". */
/** The DN for "Aaron Zimmerman". */
/** The DN for "Albert Smith". */
/** The DN for "Albert Zimmerman". */
/** The DN for "lowercase mcgee". */
/** The DN for "Mararet Jones". */
/** The DN for "Mary Jones". */
/** The DN for "Sam Zweck". */
/** 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 with different sort
* order values.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testRequestConstructor1() throws Exception
{
new SortKey(givenNameType, true));
}
/**
* Tests the second constructor for the request control with different sort
* order strings.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test
public void testRequestConstructor2() throws Exception
{
}
/**
* Tests performing an internal search using the server-side sort control to
* sort the entries in order of ascending givenName values.
*
* @throws Exception If an unexpected problem occurred.
*/
@Test
public void testInternalSearchGivenNameAscending()
throws Exception
{
populateDB();
SearchRequest request = newSearchRequest("dc=example,dc=com", SearchScope.WHOLE_SUBTREE, "(objectClass=person)")
}
/**
* Tests performing an internal search using the server-side sort control to
* sort the entries in order of ascending givenName values using a specific
* ordering matching rule.
*
* @throws Exception If an unexpected problem occurred.
*/
@Test
public void testInternalSearchGivenNameAscendingCaseExact() throws Exception
{
populateDB();
SearchRequest request = newSearchRequest("dc=example,dc=com", SearchScope.WHOLE_SUBTREE, "(objectClass=person)")
}
/**
* Tests performing an internal search using the server-side sort control to
* sort the entries in order of descending givenName values.
*
* @throws Exception If an unexpected problem occurred.
*/
@Test
public void testInternalSearchGivenNameDescending() throws Exception
{
populateDB();
SearchRequest request = newSearchRequest("dc=example,dc=com", SearchScope.WHOLE_SUBTREE, "(objectClass=person)")
}
/**
* Tests performing an internal search using the server-side sort control to
* sort the entries in order of descending givenName values using a specific
* ordering matching rule.
*
* @throws Exception If an unexpected problem occurred.
*/
@Test
public void testInternalSearchGivenNameDescendingCaseExact() throws Exception
{
populateDB();
SearchRequest request = newSearchRequest("dc=example,dc=com", SearchScope.WHOLE_SUBTREE, "(objectClass=person)")
}
/**
* Tests performing an internal search using the server-side sort control to
* sort the entries in order of ascending givenName and ascending sn values.
*
* @throws Exception If an unexpected problem occurred.
*/
@Test
public void testInternalSearchGivenNameAscendingSnAscending() throws Exception
{
populateDB();
SearchRequest request = newSearchRequest("dc=example,dc=com", SearchScope.WHOLE_SUBTREE, "(objectClass=person)")
}
/**
* Tests performing an internal search using the server-side sort control to
* sort the entries in order of ascending givenName and descending sn values.
*
* @throws Exception If an unexpected problem occurred.
*/
@Test
public void testInternalSearchGivenNameAscendingSnDescending()
throws Exception
{
populateDB();
SearchRequest request = newSearchRequest("dc=example,dc=com", SearchScope.WHOLE_SUBTREE, "(objectClass=person)")
}
/**
* Tests performing an internal search using the CRITICAL server-side sort control with
* an undefined attribute type.
*
* @throws Exception If an unexpected problem occurred.
*/
@Test
public void testCriticalSortWithUndefinedAttribute() throws Exception
{
populateDB();
SearchRequest request = newSearchRequest("dc=example,dc=com", SearchScope.WHOLE_SUBTREE, "(objectClass=person)")
}
/**
* Tests performing an internal search using the server-side sort control with
* an undefined ordering rule.
*
* @throws Exception If an unexpected problem occurred.
*/
@Test
public void testInternalSearchUndefinedOrderingRule() throws Exception
{
populateDB();
SearchRequest request = newSearchRequest("dc=example,dc=com", SearchScope.WHOLE_SUBTREE, "(objectClass=person)")
}
/**
* Tests performing an internal search using the non-critical server-side
* sort control to sort the entries
*
* @throws Exception If an unexpected problem occurred.
*/
@Test
public void testNonCriticalSortWithUndefinedAttribute() throws Exception
{
populateDB();
SearchRequest request = newSearchRequest("dc=example,dc=com", SearchScope.WHOLE_SUBTREE, "(objectClass=person)")
}
{
}
private ServerSideSortResponseControl getServerSideSortResponseControl(InternalSearchOperation internalSearch)
throws Exception
{
}
private ServerSideSortResponseControl getServerSideSortResponseControl(List<Control> responseControls)
throws DirectoryException
{
if (c instanceof ServerSideSortResponseControl)
{
return (ServerSideSortResponseControl) c;
}
}
{
for (Entry e : searchEntries)
{
}
return results;
}
}