PersistentSearchControlTest.java revision ea1068c292e9b341af6d6b563cd8988a96be20a9
/*
* 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 2006-2010 Sun Microsystems, Inc.
* Portions Copyright 2014-2015 ForgeRock AS
*/
@SuppressWarnings("javadoc")
public class PersistentSearchControlTest extends ControlsTestCase
{
private static final String CANNOT_DECODE_CHANGE_NOTIF_CONTROL_NO_VALUE =
"Cannot decode the provided entry change notification control because it "
+ "does not have a value";
private static final String CANNOT_DECODE_PERSISTENT_SEARCH_CONTROL_NO_VALUE =
"Cannot decode the provided persistent search control because it does not have a value";
/**
* Create correct values
*/
public Object[][] createPersistentSearchChangeTypeData()
{
}
/**
* Test if int value are ok
*/
throws Exception
{
{
}
}
/**
* Test If we have only the required values
*/
throws Exception
{
// Retrieve the values
// Check if we have the correct number
// Check if we have the correct int value
{
}
}
/**
* Test invalid int values
*/
throws Exception
{
for (int i=-10 ; i< 10 ; i++)
{
try
{
fail();
}
catch (LDAPException e)
{
"The provided integer value " + i
+ " does not correspond to any persistent search change type");
}
}
}
/**
* Test int to type
*/
throws Exception
{
for (int i = 1; i <= 15; i++)
{
{
if ((i & key) != 0)
{
}
}
{
}
}
// We should have an exception
try
{
fail();
}
catch (LDAPException expected)
{
"The provided integer value indicated that there were no persistent search change types, which is not allowed");
}
// We should have an exception
int i = 16;
try
{
fail();
}
catch (LDAPException expected)
{
"The provided integer value " + i
+ " was outside the range of acceptable values for an encoded change type set");
}
}
/**
* Test type to int
*/
throws Exception
{
for (int i = 1; i <= 15; i++)
{
assertEquals(ret, i);
}
}
throws Exception
{
for (int i = 1; i <= 15; i++)
{
{
if (exceptedRet == null)
{
}
else
{
}
}
}
}
/**
* Create values for PersistentSearchControl
*/
public Object[][] createPasswordPolicyResponseControlData()
{
return new Object[][]
{
{true, false, true },
{false, false, false }, };
}
/**
* Test PersistentSearchControl
*/
public void checkPersistentSearchControlTest(
throws Exception
{
// Test constructor
// CheclPersistentSearchControlTest(Set<PersistentSearchChangeType>
// changeTypes,
// boolean changesOnly, boolean returnECs
for (int i = 1; i <= 15; i++)
{
}
// Test constructor
// CString oid, boolean isCritical,
// Set<PersistentSearchChangeType> changeTypes,
// boolean changesOnly, boolean returnECs
for (int i = 1; i <= 15; i++)
{
}
for (int i = 1; i <= 15; i++)
{
// Check the toString
"PersistentSearchControl(changeTypes=\"" + changeTypes
// check null value for the control
try
{
fail();
}
catch (DirectoryException expected)
{
}
// check invalid value for the control
try
{
fail();
}
catch (DirectoryException expected)
{
"Cannot decode the provided persistent search control");
}
}
}
/**
* Create values for EntryChangeNotificationControl
*/
public Object[][] createEntryChangeNotificationControlData()
{
return new Object[][]
{
{ true, 1, "cn=test" },
{ false, 2, "dc=example,dc=com" },
{ true, 3, "cn=test, dc=example,dc=com" },
{ false, 4, "cn= new test, dc=example,dc=com" } };
}
/**
* Test EntryChangeNotificationControl
*/
public void checkEntryChangeNotificationControlTest(
throws Exception
{
// Test constructor EntryChangeNotificationControl
// (PersistentSearchChangeType changeType,long changeNumber)
{
try
{
}
catch (DirectoryException e)
{
fail();
}
}
// Test constructor EntryChangeNotificationControl
// (PersistentSearchChangeType changeType, DN previousDN, long
// changeNumber)
{
try
{
}
catch (DirectoryException e)
{
"couldn't decode a control with previousDN "
+ "not null and type=modDN");
}
}
// Test constructor EntryChangeNotificationControl(boolean
// isCritical, PersistentSearchChangeType changeType,
// DN previousDN, long changeNumber)
{
try
{
}
catch (DirectoryException e)
{
"couldn't decode a control with previousDN "
+ "not null and type=modDN");
}
}
// Check error on decode
try
{
fail();
}
catch (DirectoryException expected)
{
}
}
{
{
}
{
}
}
/**
* Tests the maximum persistent search limit imposed by the server.
*/
@Test
public void testMaxPSearch() throws Exception
{
//Modify the configuration to allow only 1 concurrent persistent search.
//Create a persistent search request.
.setTypesOnly(true)
.addAttribute("cn")
public void run() {
try {
}
}
},"Persistent Search Test");
t.start();
t.join(2000);
//Create a persistent search request.
{
"-D", "cn=Directory Manager",
"-w", "password",
"-h", "127.0.0.1",
"-b", "o=test",
"-s", "sub",
"-C","ps:add:true:true",
"--noPropertiesFile",
"(objectClass=*)"
};
//cancel the persisting persistent search.
}
}