From ba70ccc9b974e015683cfdbf2b3b4b17f094e1db Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Thu, 16 Oct 2014 13:41:38 +0000
Subject: [PATCH] Converted opendj3 code to use SearchRequest like API
---
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/LDAPSyntaxTest.java | 116 +-----
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/protocols/http/SdkConnectionAdapter.java | 4
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/CollationMatchingRuleTest.java | 134 +------
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/protocols/internal/InternalSearchOperationTestCase.java | 105 +----
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/protocols/internal/InternalLDAPOutputStream.java | 49 +-
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/AttributeTypeSyntaxTest.java | 71 +--
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/protocols/ldap/LDAPBinaryOptionTestCase.java | 99 ++---
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/StringPrepProfileTestCase.java | 45 -
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/TimeBasedMatchingRuleTest.java | 113 +-----
opendj-sdk/opendj3-server-dev/src/server/org/opends/server/protocols/internal/InternalSearchOperation.java | 70 ---
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/core/ModifyOperationTestCase.java | 60 --
opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/core/SearchOperationTestCase.java | 206 +++--------
12 files changed, 265 insertions(+), 807 deletions(-)
diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/protocols/http/SdkConnectionAdapter.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/protocols/http/SdkConnectionAdapter.java
index 88af6cf..42f09f0 100644
--- a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/protocols/http/SdkConnectionAdapter.java
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/protocols/http/SdkConnectionAdapter.java
@@ -398,10 +398,10 @@
{
final int messageID = nextMessageID.getAndIncrement();
return enqueueOperation(new SearchOperationBasis(clientConnection, messageID, messageID,
- to(request.getControls()), valueOf(request.getName()),
+ to(request.getControls()), to(request.getName()),
request.getScope(), request.getDereferenceAliasesPolicy(),
request.getSizeLimit(), request.getTimeLimit(),
- request.isTypesOnly(), to(request.getFilter()),
+ request.isTypesOnly(), toSearchFilter(request.getFilter()),
new LinkedHashSet<String>(request.getAttributes())), entryHandler);
}
diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/protocols/internal/InternalLDAPOutputStream.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/protocols/internal/InternalLDAPOutputStream.java
index 166a123..0517e4c 100644
--- a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/protocols/internal/InternalLDAPOutputStream.java
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/protocols/internal/InternalLDAPOutputStream.java
@@ -26,30 +26,28 @@
*/
package org.opends.server.protocols.internal;
-
-
-import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.OutputStream;
import java.util.List;
import org.forgerock.i18n.LocalizableMessage;
-import org.opends.server.core.*;
import org.forgerock.opendj.io.ASN1;
import org.forgerock.opendj.io.ASN1Reader;
-import org.opends.server.protocols.ldap.*;
-import org.opends.server.types.*;
+import org.forgerock.opendj.ldap.ByteSequenceReader;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ByteStringBuilder;
-import org.forgerock.opendj.ldap.ByteSequenceReader;
+import org.opends.server.core.*;
+import org.opends.server.protocols.ldap.*;
+import org.opends.server.types.*;
+import static org.forgerock.opendj.ldap.DecodeException.*;
import static org.opends.messages.ProtocolMessages.*;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
+import static org.opends.server.protocols.internal.Requests.*;
import static org.opends.server.protocols.ldap.LDAPConstants.*;
import static org.opends.server.util.ServerConstants.*;
-
-
/**
* This class provides an implementation of a
* {@code java.io.OutputStream} that can be used to facilitate
@@ -737,17 +735,30 @@
throws IOException
{
int messageID = message.getMessageID();
- SearchRequestProtocolOp request =
- message.getSearchRequestProtocolOp();
+ SearchRequestProtocolOp request = message.getSearchRequestProtocolOp();
InternalClientConnection conn = socket.getConnection();
- InternalSearchOperation op =
- new InternalSearchOperation(conn, nextOperationID(),
- messageID, message.getControls(), request.getBaseDN(),
- request.getScope(), request.getDereferencePolicy(),
- request.getSizeLimit(), request.getTimeLimit(),
- request.getTypesOnly(), request.getFilter(),
- request.getAttributes(), this);
+ DN baseDN = null;
+ SearchFilter filter;
+ try
+ {
+ baseDN = DN.valueOf(request.getBaseDN().toString());
+ filter = request.getFilter().toSearchFilter();
+ }
+ catch (DirectoryException e)
+ {
+ final String cause = (baseDN == null ? "baseDN" : "filter");
+ throw error(LocalizableMessage.raw("Could not decode " + cause), e);
+ }
+ SearchRequest sr = newSearchRequest(baseDN, request.getScope(), filter)
+ .setDereferenceAliasesPolicy(request.getDereferencePolicy())
+ .setSizeLimit(request.getSizeLimit())
+ .setTimeLimit(request.getTimeLimit())
+ .setTypesOnly(request.getTypesOnly())
+ .addAttribute(request.getAttributes())
+ .addControl(message.getControls());
+ InternalSearchOperation op = new InternalSearchOperation(
+ conn, nextOperationID(), messageID, sr, this);
op.run();
SearchResultDoneProtocolOp searchDone =
@@ -773,6 +784,7 @@
* @param searchEntry The matching search result entry to be
* processed.
*/
+ @Override
@org.opends.server.types.PublicAPI(
stability=org.opends.server.types.StabilityLevel.PRIVATE,
mayInstantiate=false,
@@ -803,6 +815,7 @@
* @param searchReference The search result reference to be
* processed.
*/
+ @Override
@org.opends.server.types.PublicAPI(
stability=org.opends.server.types.StabilityLevel.PRIVATE,
mayInstantiate=false,
diff --git a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/protocols/internal/InternalSearchOperation.java b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/protocols/internal/InternalSearchOperation.java
index f6d43c2..8b0240a 100644
--- a/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/protocols/internal/InternalSearchOperation.java
+++ b/opendj-sdk/opendj3-server-dev/src/server/org/opends/server/protocols/internal/InternalSearchOperation.java
@@ -30,7 +30,6 @@
import java.util.List;
import java.util.Set;
-import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.DereferenceAliasesPolicy;
import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.api.ClientConnection;
@@ -61,74 +60,6 @@
/** The set of search references returned for this search. */
private List<SearchResultReference> referenceList;
-
-
- /**
- * Creates a new internal search operation with the provided
- * information.
- *
- * @param internalConnection The internal client connection with
- * which this internal search operation
- * is associated.
- * @param operationID The operation ID for this internal
- * search.
- * @param messageID The message ID for this internal
- * search.
- * @param requestControls The set of request controls for this
- * internal search.
- * @param rawBaseDN The raw base DN for this internal
- * search.
- * @param scope The scope for this internal search.
- * @param derefPolicy The alias dereferencing policy for
- * this internal search.
- * @param sizeLimit The size limit for this internal
- * search.
- * @param timeLimit The time limit for this internal
- * search.
- * @param typesOnly The typesOnly flag for this internal
- * search.
- * @param rawFilter The raw filter for this internal
- * search.
- * @param attributes The names of the requested attributes
- * for this internal search.
- * @param searchListener The internal search listener that
- * should be used to process the
- * results, or <CODE>null</CODE> if
- * they should be collected internally.
- */
- public InternalSearchOperation(
- ClientConnection internalConnection,
- long operationID, int messageID,
- List<Control> requestControls, ByteString rawBaseDN,
- SearchScope scope, DereferenceAliasesPolicy derefPolicy,
- int sizeLimit, int timeLimit, boolean typesOnly,
- RawFilter rawFilter, Set<String> attributes,
- InternalSearchListener searchListener)
- {
- super(internalConnection, operationID, messageID, requestControls,
- rawBaseDN, scope, derefPolicy, sizeLimit, timeLimit,
- typesOnly, rawFilter, attributes);
-
-
-
-
- if (searchListener == null)
- {
- this.searchListener = null;
- this.entryList = new LinkedList<SearchResultEntry>();
- this.referenceList = new LinkedList<SearchResultReference>();
- }
- else
- {
- this.searchListener = searchListener;
- this.entryList = null;
- this.referenceList = null;
- }
-
- setInternalOperation(true);
- }
-
-
/**
* Creates a new internal search operation with the provided information.
*
@@ -176,7 +107,6 @@
searchListener);
}
- // TODO JNR remove??
private InternalSearchOperation(
ClientConnection internalConnection,
long operationID, int messageID,
diff --git a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/core/ModifyOperationTestCase.java b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/core/ModifyOperationTestCase.java
index 2d62168..d72fed8 100644
--- a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/core/ModifyOperationTestCase.java
+++ b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/core/ModifyOperationTestCase.java
@@ -34,7 +34,6 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.ByteString;
-import org.forgerock.opendj.ldap.DereferenceAliasesPolicy;
import org.forgerock.opendj.ldap.ModificationType;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
@@ -45,11 +44,11 @@
import org.opends.server.plugins.UpdatePreOpPlugin;
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.protocols.internal.InternalSearchOperation;
+import org.opends.server.protocols.internal.SearchRequest;
import org.opends.server.protocols.ldap.BindRequestProtocolOp;
import org.opends.server.protocols.ldap.BindResponseProtocolOp;
import org.opends.server.protocols.ldap.LDAPAttribute;
import org.opends.server.protocols.ldap.LDAPControl;
-import org.opends.server.protocols.ldap.LDAPFilter;
import org.opends.server.protocols.ldap.LDAPMessage;
import org.opends.server.protocols.ldap.LDAPModification;
import org.opends.server.protocols.ldap.ModifyRequestProtocolOp;
@@ -81,6 +80,7 @@
import static org.opends.server.TestCaseUtils.*;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
+import static org.opends.server.protocols.internal.Requests.*;
import static org.opends.server.protocols.ldap.LDAPConstants.*;
import static org.opends.server.util.CollectionUtils.*;
import static org.testng.Assert.*;
@@ -1343,8 +1343,7 @@
* @throws Exception If an unexpected problem occurs.
*/
@Test(dataProvider = "baseDNs")
- public void testSuccessReplaceExistingWithNew(String baseDN)
- throws Exception
+ public void testSuccessReplaceExistingWithNew(String baseDN) throws Exception
{
TestCaseUtils.addEntry(
"dn: uid=test.user," + baseDN,
@@ -1392,24 +1391,14 @@
"userPassword: password",
"mail: foo");
+ String dn = "uid=test.user," + baseDN;
LDAPAttribute attr = newLDAPAttribute("uid", "test.user");
- ModifyOperation modifyOperation = processModify("uid=test.user," + baseDN, replace(attr));
+ ModifyOperation modifyOperation = processModify(dn, replace(attr));
assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS);
retrieveSuccessfulOperationElements(modifyOperation);
- InternalSearchOperation searchOperation =
- new InternalSearchOperation(
- getRootConnection(), nextOperationID(), nextMessageID(),
- new ArrayList<Control>(),
- ByteString.valueOf("uid=test.user," + baseDN),
- SearchScope.WHOLE_SUBTREE,
- DereferenceAliasesPolicy.NEVER,
- Integer.MAX_VALUE,
- Integer.MAX_VALUE,
- false,
- LDAPFilter.decode("(uid=test.user)"),
- null, null);
- searchOperation.run();
+ SearchRequest request = newSearchRequest(dn, SearchScope.WHOLE_SUBTREE, "(uid=test.user)");
+ InternalSearchOperation searchOperation = getRootConnection().processSearch(request);
assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS);
assertEquals(searchOperation.getEntriesSent(), 1);
@@ -1447,27 +1436,14 @@
assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS);
retrieveSuccessfulOperationElements(modifyOperation);
- InternalSearchOperation searchOperation =
- new InternalSearchOperation(
- getRootConnection(), nextOperationID(), nextMessageID(),
- new ArrayList<Control>(),
- ByteString.valueOf(baseDN),
- SearchScope.WHOLE_SUBTREE,
- DereferenceAliasesPolicy.NEVER,
- Integer.MAX_VALUE,
- Integer.MAX_VALUE,
- false,
- LDAPFilter.decode("(cn=Test User)"),
- null, null);
- searchOperation.run();
+ SearchRequest request = newSearchRequest(baseDN, SearchScope.WHOLE_SUBTREE, "(cn=Test User)");
+ InternalSearchOperation searchOperation = getRootConnection().processSearch(request);
assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS);
assertEquals(searchOperation.getEntriesSent(), 1);
assertEquals(searchOperation.getErrorMessage().length(), 0);
}
-
-
/**
* Tests the ability to perform a modification that deletes one value of an
* attribute containing two values, the values are the same but the attribute
@@ -1476,8 +1452,7 @@
* @throws Exception If an unexpected problem occurs.
*/
@Test(dataProvider = "baseDNs")
- public void testSuccessDeleteAttributeWithOption(String baseDN)
- throws Exception
+ public void testSuccessDeleteAttributeWithOption(String baseDN) throws Exception
{
TestCaseUtils.addEntry(
"dn: uid=test.user," + baseDN,
@@ -1500,19 +1475,8 @@
assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS);
retrieveSuccessfulOperationElements(modifyOperation);
- InternalSearchOperation searchOperation =
- new InternalSearchOperation(
- getRootConnection(), nextOperationID(), nextMessageID(),
- new ArrayList<Control>(),
- ByteString.valueOf(baseDN),
- SearchScope.WHOLE_SUBTREE,
- DereferenceAliasesPolicy.NEVER,
- Integer.MAX_VALUE,
- Integer.MAX_VALUE,
- false,
- LDAPFilter.decode("(givenName;lang-de=X)"),
- null, null);
- searchOperation.run();
+ SearchRequest request = newSearchRequest(baseDN, SearchScope.WHOLE_SUBTREE, "(givenName;lang-de=X)");
+ InternalSearchOperation searchOperation = getRootConnection().processSearch(request);
assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS);
assertEquals(searchOperation.getEntriesSent(), 1);
diff --git a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/core/SearchOperationTestCase.java b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/core/SearchOperationTestCase.java
index 37632e4..2af2dcd 100644
--- a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/core/SearchOperationTestCase.java
+++ b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/core/SearchOperationTestCase.java
@@ -54,6 +54,7 @@
import static org.assertj.core.api.Assertions.*;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
+import static org.opends.server.protocols.internal.Requests.*;
import static org.opends.server.util.ServerConstants.*;
import static org.testng.Assert.*;
@@ -174,20 +175,7 @@
@Override
protected Operation[] createTestOperations() throws Exception
{
- return new Operation[]
- {
- new SearchOperationBasis(
- getRootConnection(), nextOperationID(), nextMessageID(),
- new ArrayList<Control>(),
- ByteString.valueOf(BASE),
- SearchScope.WHOLE_SUBTREE,
- DereferenceAliasesPolicy.NEVER,
- -1,
- -1,
- false,
- LDAPFilter.objectClassPresent(),
- null)
- };
+ return new Operation[0];
}
/**
@@ -209,13 +197,8 @@
// assertEquals(InvocationCounterPlugin.getPostResponseCount(), 1);
}
- private Entry searchInternalForSingleEntry(
- InternalSearchOperation searchOperation)
+ private Entry getSingleEntry(InternalSearchOperation searchOperation)
{
- InvocationCounterPlugin.resetAllCounters();
-
- searchOperation.run();
-
assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS);
assertEquals(searchOperation.getEntriesSent(), 1);
assertEquals(searchOperation.getErrorMessage().length(), 0);
@@ -326,8 +309,8 @@
{
InvocationCounterPlugin.resetAllCounters();
- InternalSearchOperation searchOperation = newInternalSearchOperation(LDAPFilter.objectClassPresent());
- searchOperation.run();
+ SearchRequest request = newSearchRequest(DN.valueOf(BASE), SearchScope.WHOLE_SUBTREE);
+ InternalSearchOperation searchOperation = getRootConnection().processSearch(request);
assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS);
assertEquals(searchOperation.getEntriesSent(), 4);
assertEquals(searchOperation.getReferencesSent(), 2);
@@ -339,9 +322,8 @@
@Test
public void testSearchInternalUnspecifiedAttributes() throws Exception
{
- InternalSearchOperation searchOperation =
- newInternalSearchOperation(LDAPFilter.decode("(objectclass=inetorgperson)"));
- Entry resultEntry = searchInternalForSingleEntry(searchOperation);
+ InternalSearchOperation searchOperation = newInternalSearchOperation("(objectclass=inetorgperson)");
+ Entry resultEntry = getSingleEntry(searchOperation);
assertEquals(resultEntry.getObjectClasses(), testEntry.getObjectClasses());
@@ -353,23 +335,14 @@
}
@Test
- public void testSearchInternalUnspecifiedAttributesOmitValues()
- throws Exception
+ public void testSearchInternalUnspecifiedAttributesOmitValues() throws Exception
{
- InternalSearchOperation searchOperation =
- new InternalSearchOperation(
- getRootConnection(), nextOperationID(), nextMessageID(),
- new ArrayList<Control>(),
- ByteString.valueOf(BASE),
- SearchScope.WHOLE_SUBTREE,
- DereferenceAliasesPolicy.NEVER,
- Integer.MAX_VALUE,
- Integer.MAX_VALUE,
- true,
- LDAPFilter.decode("(objectclass=inetorgperson)"),
- null, null);
-
- Entry resultEntry = searchInternalForSingleEntry(searchOperation);
+ InvocationCounterPlugin.resetAllCounters();
+ SearchRequest request = Requests.newSearchRequest(BASE, SearchScope.WHOLE_SUBTREE, "(objectclass=inetorgperson)")
+ .setTimeLimit(Integer.MAX_VALUE)
+ .setSizeLimit(Integer.MAX_VALUE)
+ .setTypesOnly(true);
+ Entry resultEntry = getSingleEntry(getRootConnection().processSearch(request));
assertEquals(resultEntry.getObjectClasses().size(), 0);
@@ -381,9 +354,8 @@
@Test
public void testSearchInternalAllOperationalAttributes() throws Exception
{
- InternalSearchOperation searchOperation =
- newInternalSearchOperation(LDAPFilter.decode("(objectclass=inetorgperson)"), "+");
- Entry resultEntry = searchInternalForSingleEntry(searchOperation);
+ InternalSearchOperation searchOperation = newInternalSearchOperation("(objectclass=inetorgperson)", "+");
+ Entry resultEntry = getSingleEntry(searchOperation);
assertEquals(resultEntry.getObjectClasses().size(), 0);
assertEquals(resultEntry.getUserAttributes().size(), 0);
@@ -391,12 +363,10 @@
}
@Test
- public void testSearchInternalAllUserAndOperationalAttributes()
- throws Exception
+ public void testSearchInternalAllUserAndOperationalAttributes() throws Exception
{
- InternalSearchOperation searchOperation =
- newInternalSearchOperation(LDAPFilter.decode("(objectclass=inetorgperson)"), "*", "+");
- Entry resultEntry = searchInternalForSingleEntry(searchOperation);
+ InternalSearchOperation searchOperation = newInternalSearchOperation("(objectclass=inetorgperson)", "*", "+");
+ Entry resultEntry = getSingleEntry(searchOperation);
assertEquals(resultEntry.getObjectClasses(), testEntry.getObjectClasses());
assertTrue(resultEntry.getOperationalAttributes().size() > 0);
@@ -407,12 +377,11 @@
}
@Test
- public void testSearchInternalAllUserAttributesPlusSelectedOperational()
- throws Exception
+ public void testSearchInternalAllUserAttributesPlusSelectedOperational() throws Exception
{
InternalSearchOperation searchOperation =
- newInternalSearchOperation(LDAPFilter.decode("(objectclass=inetorgperson)"), "*", "createtimestamp");
- Entry resultEntry = searchInternalForSingleEntry(searchOperation);
+ newInternalSearchOperation("(objectclass=inetorgperson)", "*", "createtimestamp");
+ Entry resultEntry = getSingleEntry(searchOperation);
assertEquals(resultEntry.getObjectClasses(), testEntry.getObjectClasses());
@@ -424,27 +393,23 @@
}
@Test
- public void testSearchInternalSelectedAttributes()
- throws Exception
+ public void testSearchInternalSelectedAttributes() throws Exception
{
InternalSearchOperation searchOperation =
- newInternalSearchOperation(LDAPFilter.decode("(objectclass=inetorgperson)"), "uid", "createtimestamp");
- Entry resultEntry = searchInternalForSingleEntry(searchOperation);
+ newInternalSearchOperation("(objectclass=inetorgperson)", "uid", "createtimestamp");
+ Entry resultEntry = getSingleEntry(searchOperation);
assertEquals(resultEntry.getObjectClasses().size(), 0);
assertEquals(resultEntry.getUserAttributes().size(), 1);
assertEquals(resultEntry.getOperationalAttributes().size(), 1);
}
- private InternalSearchOperation newInternalSearchOperation(LDAPFilter filter, String... attributes)
+ private InternalSearchOperation newInternalSearchOperation(String filter, String... attributes) throws Exception
{
- return new InternalSearchOperation(
- getRootConnection(), nextOperationID(), nextMessageID(),
- new ArrayList<Control>(),
- ByteString.valueOf(BASE),
- SearchScope.WHOLE_SUBTREE,
- DereferenceAliasesPolicy.NEVER, Integer.MAX_VALUE, Integer.MAX_VALUE, false,
- filter, new LinkedHashSet<String>(Arrays.asList(attributes)), null);
+ InvocationCounterPlugin.resetAllCounters();
+ SearchRequest request = newSearchRequest(BASE, SearchScope.WHOLE_SUBTREE, filter)
+ .addAttribute(attributes);
+ return getRootConnection().processSearch(request);
}
@Test
@@ -721,9 +686,8 @@
{
InvocationCounterPlugin.resetAllCounters();
- InternalSearchOperation searchOperation =
- newInternalSearchOperation(LDAPFilter.decode("(objectclass=inetorgperson)"));
- searchOperation.run();
+ SearchRequest request = newSearchRequest(BASE, SearchScope.WHOLE_SUBTREE, "(objectclass=inetorgperson)");
+ InternalSearchOperation searchOperation = getRootConnection().processSearch(request);
assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS);
assertEquals(searchOperation.getReferencesSent(), 2);
@@ -753,19 +717,8 @@
{
InvocationCounterPlugin.resetAllCounters();
- InternalSearchOperation searchOperation = new InternalSearchOperation(
- getRootConnection(), nextOperationID(), nextMessageID(),
- new ArrayList<Control>(),
- ByteString.valueOf(BASE),
- SearchScope.SINGLE_LEVEL,
- DereferenceAliasesPolicy.NEVER,
- Integer.MAX_VALUE,
- Integer.MAX_VALUE,
- false,
- LDAPFilter.decode("(ou=*)"),
- null, null);
-
- searchOperation.run();
+ SearchRequest request = newSearchRequest(BASE, SearchScope.SINGLE_LEVEL, "(ou=*)");
+ InternalSearchOperation searchOperation = getRootConnection().processSearch(request);
assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS);
assertEquals(searchOperation.getReferencesSent(), 1);
@@ -785,10 +738,8 @@
{
InvocationCounterPlugin.resetAllCounters();
- InternalSearchOperation searchOperation =
- newInternalSearchOperation(LDAPFilter.decode("(objectclass=ldapsubentry)"));
- searchOperation.run();
-
+ SearchRequest request = newSearchRequest(BASE, SearchScope.WHOLE_SUBTREE, "(objectclass=ldapsubentry)");
+ InternalSearchOperation searchOperation = getRootConnection().processSearch(request);
assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS);
assertEquals(searchOperation.getEntriesSent(), 1);
assertEquals(searchOperation.getErrorMessage().length(), 0);
@@ -799,21 +750,11 @@
{
InvocationCounterPlugin.resetAllCounters();
- InternalSearchOperation searchOperation =
- new InternalSearchOperation(
- getRootConnection(), nextOperationID(), nextMessageID(),
- Collections.singletonList((Control)new SubentriesControl(true, true)),
- ByteString.valueOf(BASE),
- SearchScope.WHOLE_SUBTREE,
- DereferenceAliasesPolicy.NEVER,
- Integer.MAX_VALUE,
- Integer.MAX_VALUE,
- false,
- LDAPFilter.objectClassPresent(),
- null, null);
-
- searchOperation.run();
-
+ SearchRequest request = Requests.newSearchRequest(DN.valueOf(BASE), SearchScope.WHOLE_SUBTREE)
+ .setSizeLimit(Integer.MAX_VALUE)
+ .setTimeLimit(Integer.MAX_VALUE)
+ .addControl(new SubentriesControl(true, true));
+ InternalSearchOperation searchOperation = getRootConnection().processSearch(request);
assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS);
assertEquals(searchOperation.getEntriesSent(), 1);
assertEquals(searchOperation.getErrorMessage().length(), 0);
@@ -824,16 +765,11 @@
{
InvocationCounterPlugin.resetAllCounters();
- InternalSearchOperation searchOperation = new InternalSearchOperation(
- getRootConnection(), nextOperationID(), nextMessageID(),
- Collections.singletonList((Control) new LDAPControl(
- OID_LDUP_SUBENTRIES, true)), ByteString.valueOf(BASE),
- SearchScope.WHOLE_SUBTREE, DereferenceAliasesPolicy.NEVER,
- Integer.MAX_VALUE, Integer.MAX_VALUE, false,
- LDAPFilter.objectClassPresent(), null, null);
-
- searchOperation.run();
-
+ SearchRequest request = Requests.newSearchRequest(DN.valueOf(BASE), SearchScope.WHOLE_SUBTREE)
+ .setSizeLimit(Integer.MAX_VALUE)
+ .setTimeLimit(Integer.MAX_VALUE)
+ .addControl(new LDAPControl(OID_LDUP_SUBENTRIES, true));
+ InternalSearchOperation searchOperation = getRootConnection().processSearch(request);
assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS);
assertEquals(searchOperation.getEntriesSent(), 1);
assertEquals(searchOperation.getErrorMessage().length(), 0);
@@ -844,16 +780,16 @@
{
InvocationCounterPlugin.resetAllCounters();
- InternalSearchOperation searchOperation =
- newInternalSearchOperation(LDAPFilter.decode("(&(cn=*)(objectclass=ldapsubentry))"));
- searchOperation.run();
+ SearchRequest request1 = newSearchRequest(BASE, SearchScope.WHOLE_SUBTREE, "(&(cn=*)(objectclass=ldapsubentry))");
+ InternalSearchOperation searchOperation = getRootConnection().processSearch(request1);
assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS);
assertEquals(searchOperation.getEntriesSent(), 1);
assertEquals(searchOperation.getErrorMessage().length(), 0);
- searchOperation = newInternalSearchOperation(LDAPFilter.decode("(&(&(cn=*)(objectclass=ldapsubentry)))"));
- searchOperation.run();
+ SearchRequest request2 =
+ newSearchRequest(BASE, SearchScope.WHOLE_SUBTREE, "(&(&(cn=*)(objectclass=ldapsubentry)))");
+ searchOperation = getRootConnection().processSearch(request2);
assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS);
assertEquals(searchOperation.getEntriesSent(), 1);
@@ -865,9 +801,9 @@
{
InvocationCounterPlugin.resetAllCounters();
- InternalSearchOperation searchOperation =
- newInternalSearchOperation(LDAPFilter.decode("(|(objectclass=ldapsubentry)(objectclass=top))"));
- searchOperation.run();
+ SearchRequest request =
+ newSearchRequest(BASE, SearchScope.WHOLE_SUBTREE, "(|(objectclass=ldapsubentry)(objectclass=top))");
+ InternalSearchOperation searchOperation = getRootConnection().processSearch(request);
assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS);
assertEquals(searchOperation.getEntriesSent(), 5);
@@ -881,21 +817,8 @@
TestCaseUtils.initializeTestBackend(true);
- InternalSearchOperation searchOperation =
- new InternalSearchOperation(
- getRootConnection(), nextOperationID(), nextMessageID(),
- new ArrayList<Control>(),
- ByteString.valueOf("ou=nonexistent,o=test"),
- SearchScope.WHOLE_SUBTREE,
- DereferenceAliasesPolicy.NEVER,
- Integer.MAX_VALUE,
- Integer.MAX_VALUE,
- false,
- LDAPFilter.objectClassPresent(),
- null, null);
-
- searchOperation.run();
-
+ SearchRequest request = newSearchRequest(DN.valueOf("ou=nonexistent,o=test"), SearchScope.WHOLE_SUBTREE);
+ InternalSearchOperation searchOperation = getRootConnection().processSearch(request);
assertEquals(searchOperation.getResultCode(), ResultCode.NO_SUCH_OBJECT);
assertNotNull(searchOperation.getMatchedDN());
}
@@ -1327,20 +1250,9 @@
assertEquals(err,0);
- InternalSearchOperation searchOperation =
- new InternalSearchOperation(
- getRootConnection(), nextOperationID(), nextMessageID(),
- new ArrayList<Control>(),
- ByteString.valueOf("dc=example,dc=com"),
- SearchScope.SINGLE_LEVEL,
- DereferenceAliasesPolicy.NEVER,
- Integer.MAX_VALUE,
- Integer.MAX_VALUE,
- false,
- LDAPFilter.decode("(objectclass=organizationalUnit)"),
- null, null);
-
- searchOperation.run();
+ SearchRequest request =
+ newSearchRequest("dc=example,dc=com", SearchScope.SINGLE_LEVEL, "(objectclass=organizationalUnit)");
+ InternalSearchOperation searchOperation = getRootConnection().processSearch(request);
assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS);
assertEquals(searchOperation.getSearchEntries().size(),3);
//restore the allid threshold.
diff --git a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/protocols/internal/InternalSearchOperationTestCase.java b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/protocols/internal/InternalSearchOperationTestCase.java
index 6a47e2f..f03b2fe 100644
--- a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/protocols/internal/InternalSearchOperationTestCase.java
+++ b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/protocols/internal/InternalSearchOperationTestCase.java
@@ -26,16 +26,9 @@
*/
package org.opends.server.protocols.internal;
-import java.util.ArrayList;
-import java.util.LinkedHashSet;
-
-import org.forgerock.opendj.ldap.ByteString;
-import org.forgerock.opendj.ldap.DereferenceAliasesPolicy;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.TestCaseUtils;
-import org.opends.server.protocols.ldap.LDAPFilter;
-import org.opends.server.types.Control;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
import org.opends.server.types.SearchResultEntry;
@@ -44,6 +37,7 @@
import org.testng.annotations.Test;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
+import static org.opends.server.protocols.internal.Requests.*;
import static org.testng.Assert.*;
/**
@@ -73,17 +67,11 @@
*
* @throws Exception If an unexpected problem occurs.
*/
- @Test()
- public void testConstructor1WithoutListener()
- throws Exception
+ @Test
+ public void testConstructor1WithoutListener() throws Exception
{
- InternalClientConnection conn = getRootConnection();
- new InternalSearchOperation(conn, nextOperationID(),
- nextMessageID(), new ArrayList<Control>(),
- ByteString.empty(), SearchScope.BASE_OBJECT,
- DereferenceAliasesPolicy.NEVER, 0, 0,
- false, LDAPFilter.objectClassPresent(),
- new LinkedHashSet<String>(), null);
+ SearchRequest request = newSearchRequest(DN.rootDN(), SearchScope.BASE_OBJECT);
+ new InternalSearchOperation(getRootConnection(), nextOperationID(), nextMessageID(), request);
}
@@ -94,18 +82,11 @@
*
* @throws Exception If an unexpected problem occurs.
*/
- @Test()
- public void testConstructor1WithListener()
- throws Exception
+ @Test
+ public void testConstructor1WithListener() throws Exception
{
- InternalClientConnection conn = getRootConnection();
- new InternalSearchOperation(conn, nextOperationID(),
- nextMessageID(), new ArrayList<Control>(),
- ByteString.empty(), SearchScope.BASE_OBJECT,
- DereferenceAliasesPolicy.NEVER, 0, 0,
- false, LDAPFilter.objectClassPresent(),
- new LinkedHashSet<String>(),
- new TestInternalSearchListener());
+ SearchRequest request = newSearchRequest(DN.rootDN(), SearchScope.BASE_OBJECT);
+ new InternalSearchOperation(getRootConnection(), nextOperationID(), nextMessageID(), request, new TestInternalSearchListener());
}
@@ -116,7 +97,7 @@
*
* @throws Exception If an unexpected problem occurs.
*/
- @Test()
+ @Test
public void testGetSearchEntriesAndReferences() throws Exception
{
SearchRequest request = Requests.newSearchRequest(DN.rootDN(), SearchScope.BASE_OBJECT);
@@ -136,16 +117,9 @@
@Test()
public void testAddSearchEntryWithoutListener() throws Exception
{
- InternalClientConnection conn = getRootConnection();
+ SearchRequest request = newSearchRequest(DN.rootDN(), SearchScope.BASE_OBJECT);
InternalSearchOperation searchOperation =
- new InternalSearchOperation(conn, nextOperationID(),
- nextMessageID(),
- new ArrayList<Control>(),
- ByteString.empty(),
- SearchScope.BASE_OBJECT,
- DereferenceAliasesPolicy.NEVER, 0, 0, false,
- LDAPFilter.objectClassPresent(),
- new LinkedHashSet<String>(), null);
+ new InternalSearchOperation(getRootConnection(), nextOperationID(), nextMessageID(), request);
Entry e = TestCaseUtils.makeEntry("dn: ",
"objectClass: top",
@@ -160,21 +134,12 @@
*
* @throws Exception If an unexpected problem occurs.
*/
- @Test()
- public void testAddSearchEntryWithListener()
- throws Exception
+ @Test
+ public void testAddSearchEntryWithListener() throws Exception
{
- InternalClientConnection conn = getRootConnection();
- InternalSearchOperation searchOperation =
- new InternalSearchOperation(conn, nextOperationID(),
- nextMessageID(),
- new ArrayList<Control>(),
- ByteString.empty(),
- SearchScope.BASE_OBJECT,
- DereferenceAliasesPolicy.NEVER, 0, 0, false,
- LDAPFilter.objectClassPresent(),
- new LinkedHashSet<String>(),
- new TestInternalSearchListener());
+ SearchRequest request = newSearchRequest(DN.rootDN(), SearchScope.BASE_OBJECT);
+ InternalSearchOperation searchOperation = new InternalSearchOperation(
+ getRootConnection(), nextOperationID(), nextMessageID(), request, new TestInternalSearchListener());
Entry e = TestCaseUtils.makeEntry("dn: ",
"objectClass: top",
@@ -183,26 +148,17 @@
}
-
/**
* Tests the <CODE>addSearchReference</CODE> method without a search listener.
*
* @throws Exception If an unexpected problem occurs.
*/
- @Test()
- public void testAddSearchReferenceWithoutListener()
- throws Exception
+ @Test
+ public void testAddSearchReferenceWithoutListener() throws Exception
{
- InternalClientConnection conn = getRootConnection();
+ SearchRequest request = newSearchRequest(DN.rootDN(), SearchScope.BASE_OBJECT);
InternalSearchOperation searchOperation =
- new InternalSearchOperation(conn, nextOperationID(),
- nextMessageID(),
- new ArrayList<Control>(),
- ByteString.empty(),
- SearchScope.BASE_OBJECT,
- DereferenceAliasesPolicy.NEVER, 0, 0, false,
- LDAPFilter.objectClassPresent(),
- new LinkedHashSet<String>(), null);
+ new InternalSearchOperation(getRootConnection(), nextOperationID(), nextMessageID(), request);
SearchResultReference reference =
new SearchResultReference("ldap://server.example.com:389/");
@@ -216,21 +172,12 @@
*
* @throws Exception If an unexpected problem occurs.
*/
- @Test()
- public void testAddSearchReferenceWithListener()
- throws Exception
+ @Test
+ public void testAddSearchReferenceWithListener() throws Exception
{
- InternalClientConnection conn = getRootConnection();
- InternalSearchOperation searchOperation =
- new InternalSearchOperation(conn, nextOperationID(),
- nextMessageID(),
- new ArrayList<Control>(),
- ByteString.empty(),
- SearchScope.BASE_OBJECT,
- DereferenceAliasesPolicy.NEVER, 0, 0, false,
- LDAPFilter.objectClassPresent(),
- new LinkedHashSet<String>(),
- new TestInternalSearchListener());
+ SearchRequest request = newSearchRequest(DN.rootDN(), SearchScope.BASE_OBJECT);
+ InternalSearchOperation searchOperation = new InternalSearchOperation(
+ getRootConnection(), nextOperationID(), nextMessageID(), request, new TestInternalSearchListener());
SearchResultReference reference =
new SearchResultReference("ldap://server.example.com:389/");
diff --git a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/protocols/ldap/LDAPBinaryOptionTestCase.java b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/protocols/ldap/LDAPBinaryOptionTestCase.java
index c4239e4..2e8d5c6 100644
--- a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/protocols/ldap/LDAPBinaryOptionTestCase.java
+++ b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/protocols/ldap/LDAPBinaryOptionTestCase.java
@@ -36,21 +36,23 @@
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.DereferenceAliasesPolicy;
+import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.TestCaseUtils;
import org.opends.server.api.Backend;
import org.opends.server.core.DirectoryServer;
-import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.protocols.internal.InternalSearchOperation;
+import org.opends.server.protocols.internal.SearchRequest;
import org.opends.server.tools.LDAPModify;
import org.opends.server.tools.LDAPSearch;
import org.opends.server.types.*;
-import org.forgerock.opendj.ldap.ResultCode;
import org.opends.server.util.Base64;
import org.opends.server.util.StaticUtils;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
+import static org.opends.server.protocols.internal.InternalClientConnection.*;
+import static org.opends.server.protocols.internal.Requests.*;
import static org.testng.Assert.*;
/**
@@ -58,16 +60,16 @@
* functionality across different protocol versions of LDAP.
*/
public class LDAPBinaryOptionTestCase extends LdapTestCase {
- // Exported LDIF file.
- private File ldif = null;
- //LDIFExportConfig used for exporting entries.
- private LDIFExportConfig exportConfig = null;
- //LDIFImportConfig used for importing entries.
- private LDIFImportConfig importConfig = null;
- //Test Backend.
- private Backend backend = null;
+ /** Exported LDIF file. */
+ private File ldif;
+ /** LDIFExportConfig used for exporting entries. */
+ private LDIFExportConfig exportConfig;
+ /** LDIFImportConfig used for importing entries. */
+ private LDIFImportConfig importConfig;
+ /** Test Backend. */
+ private Backend<?> backend;
- //Constant value of userCertificate attribute.
+ /** Constant value of userCertificate attribute. */
private static final String CERT=
"MIIB5TCCAU6gAwIBAgIERloIajANBgkqhkiG9" +
"w0BAQUFADA3MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRXhhbXBs" +
@@ -195,25 +197,8 @@
"LDAPBinaryOptionTestCase.binaryAttributeAddV3"})
public void binaryAttributeSearchV3() throws Exception
{
- InternalClientConnection conn =
- InternalClientConnection.getRootConnection();
-
- InternalSearchOperation searchOperation =
- new InternalSearchOperation(
- conn,
- InternalClientConnection.nextOperationID(),
- InternalClientConnection.nextMessageID(),
- new ArrayList<Control>(),
- ByteString.valueOf("o=test"),
- SearchScope.WHOLE_SUBTREE,
- DereferenceAliasesPolicy.NEVER,
- Integer.MAX_VALUE,
- Integer.MAX_VALUE,
- false,
- LDAPFilter.decode("(uid=user.1)"),
- null, null);
-
- searchOperation.run();
+ SearchRequest request = newSearchRequest("o=test", SearchScope.WHOLE_SUBTREE, "(uid=user.1)");
+ InternalSearchOperation searchOperation = getRootConnection().processSearch(request);
assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS);
List<SearchResultEntry> entries = searchOperation.getSearchEntries();
SearchResultEntry e = entries.get(0);
@@ -222,10 +207,7 @@
Attribute a = attrs.get(0);
assertNotNull(a);
assertTrue(a.getOptions().contains("binary"));
-
- }
-
-
+ }
/**
* Test to verify a SEARCH using the ;binary transfer option using a V3
@@ -236,33 +218,18 @@
"LDAPBinaryOptionTestCase.binaryAttributeAddV3"})
public void invalidBinaryAttributeSearchV3() throws Exception
{
- InternalClientConnection conn =
- InternalClientConnection.getRootConnection();
- LinkedHashSet<String> attrs = new LinkedHashSet<String>();
- attrs.add("cn;binary");
- InternalSearchOperation searchOperation =
- new InternalSearchOperation(
- conn,
- InternalClientConnection.nextOperationID(),
- InternalClientConnection.nextMessageID(),
- new ArrayList<Control>(),
- ByteString.valueOf("o=test"),
- SearchScope.WHOLE_SUBTREE,
- DereferenceAliasesPolicy.NEVER,
- Integer.MAX_VALUE,
- Integer.MAX_VALUE,
- false,
- LDAPFilter.decode("(uid=user.1)"),
- attrs, null);
-
- searchOperation.run();
+ SearchRequest request = newSearchRequest("o=test", SearchScope.WHOLE_SUBTREE, "(uid=user.1)")
+ .setSizeLimit(Integer.MAX_VALUE)
+ .setTimeLimit(Integer.MAX_VALUE)
+ .addAttribute("cn;binary");
+ InternalSearchOperation searchOperation = getRootConnection().processSearch(request);
assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS);
List<SearchResultEntry> entries = searchOperation.getSearchEntries();
SearchResultEntry e = entries.get(0);
assertNotNull(e);
List<Attribute> list = e.getAttributes();
assertEquals(list.size(), 0);
- }
+ }
@@ -349,12 +316,13 @@
for(LDAPAttribute a:searchResultEntry.getAttributes())
{
//Shouldn't be userCertificate;binary.
- if(a.getAttributeType().equalsIgnoreCase("userCertificate"))
- certWithNoOption=true;
- else if(a.getAttributeType().equalsIgnoreCase("sn"))
+ if ("userCertificate".equalsIgnoreCase(a.getAttributeType()))
{
- List<ByteString> lVal = a.getValues();
- for(ByteString v:lVal)
+ certWithNoOption=true;
+ }
+ else if ("sn".equalsIgnoreCase(a.getAttributeType()))
+ {
+ for (ByteString v : a.getValues())
{
String val = v.toString();
if(val.equals("sn#1") || val.equals("sn#2")
@@ -365,7 +333,6 @@
else //All the values should match.
snWithMultiVal = false;
}
-
}
}
assertTrue(snWithMultiVal && certWithNoOption);
@@ -420,7 +387,7 @@
//modifies the binary option from the ldif and re-imports it.A re-export of
//the last import should have the binary option even though it wasn't
//there in the imported ldif.
- assert(ldif.exists());
+ assertTrue(ldif.exists());
importLDIF();
assertTrue(containsBinary());
//Remove the binary option and re-import it.
@@ -434,10 +401,12 @@
if(line.startsWith(userCert))
{
builder.append("userCertificate:");
- builder.append(line.substring(userCert.length()+1, line.length()));
+ builder.append(line, userCert.length()+1, line.length());
}
else
+ {
builder.append(line);
+ }
builder.append("\n");
}
buf.close();
@@ -514,7 +483,9 @@
while((line=buf.readLine())!=null)
{
if(line.startsWith("userCertificate;binary"))
+ {
found = true;
+ }
}
buf.close();
return found;
@@ -530,7 +501,9 @@
{
//Initialize necessary instance variables.
if(ldif==null)
+ {
ldif = File.createTempFile("LDAPBinaryOptionTestCase", ".ldif");
+ }
exportConfig = new LDIFExportConfig(ldif.getAbsolutePath(),
ExistingFileBehavior.OVERWRITE);
backend = DirectoryServer.getBackend("test");
diff --git a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/AttributeTypeSyntaxTest.java b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/AttributeTypeSyntaxTest.java
index 37d0e66..e04ac6b 100644
--- a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/AttributeTypeSyntaxTest.java
+++ b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/AttributeTypeSyntaxTest.java
@@ -26,24 +26,21 @@
*/
package org.opends.server.schema;
+import org.forgerock.i18n.LocalizableMessageBuilder;
+import org.forgerock.opendj.ldap.ByteString;
+import org.forgerock.opendj.ldap.ResultCode;
+import org.forgerock.opendj.ldap.SearchScope;
+import org.opends.server.TestCaseUtils;
+import org.opends.server.api.AttributeSyntax;
+import org.opends.server.core.DirectoryServer;
+import org.opends.server.protocols.internal.InternalSearchOperation;
+import org.opends.server.protocols.internal.SearchRequest;
+import org.opends.server.types.AttributeType;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
-import org.opends.server.api.AttributeSyntax;
-import org.opends.server.core.DirectoryServer;
-import org.opends.server.types.AttributeType;
-import org.forgerock.opendj.ldap.ByteString;
-import org.forgerock.i18n.LocalizableMessageBuilder;
-import java.util.ArrayList;
-import org.opends.server.TestCaseUtils;
-import org.opends.server.protocols.internal.InternalClientConnection;
-import org.opends.server.protocols.internal.InternalSearchOperation;
-import org.opends.server.protocols.ldap.LDAPFilter;
-import org.opends.server.types.Control;
-import org.forgerock.opendj.ldap.DereferenceAliasesPolicy;
-import org.forgerock.opendj.ldap.ResultCode;
-import org.forgerock.opendj.ldap.SearchScope;
-
+import static org.opends.server.protocols.internal.InternalClientConnection.*;
+import static org.opends.server.protocols.internal.Requests.*;
import static org.testng.Assert.*;
/**
@@ -145,9 +142,8 @@
*
* @throws Exception If an unexpected problem occurs.
*/
- @Test()
- public void testXAPPROXExtension()
- throws Exception
+ @Test
+ public void testXAPPROXExtension() throws Exception
{
// Create and register the approximate matching rule for testing purposes.
EqualLengthApproximateMatchingRule testApproxRule =
@@ -194,7 +190,7 @@
*
* @throws Exception In case of an error.
*/
- @Test()
+ @Test
public void testMixedEqualityAndSubstringMatchingRules() throws Exception
{
//Add an attribute with directory string syntax.
@@ -210,38 +206,21 @@
"add: objectclasses",
"objectClasses: ( gvRightsTest-oid NAME 'gvRightsTest' DESC 'Test' SUP top AUXILIARY " +
"MUST ( objectClass $ gvRights ) )");
- assertTrue(resultCode == 0);
+ assertEquals(resultCode, 0);
TestCaseUtils.initializeTestBackend(true);
//add the test entry.
TestCaseUtils.addEntry(
- "dn: cn=gvrightstest,o=test",
- "objectclass: person",
- "objectclass: gvRightsTest",
- "cn: gvrightstest",
- "sn: test",
- "gvRights: gvApplId=test2,ou=Applications,dc=bla$test2-T");
+ "dn: cn=gvrightstest,o=test",
+ "objectclass: person",
+ "objectclass: gvRightsTest",
+ "cn: gvrightstest",
+ "sn: test",
+ "gvRights: gvApplId=test2,ou=Applications,dc=bla$test2-T");
//Search for the entry using substring matching rule filter.
- InternalClientConnection conn =
- InternalClientConnection.getRootConnection();
-
- InternalSearchOperation searchOperation =
- new InternalSearchOperation(
- conn,
- InternalClientConnection.nextOperationID(),
- InternalClientConnection.nextMessageID(),
- new ArrayList<Control>(),
- ByteString.valueOf("cn=gvrightstest,o=test"),
- SearchScope.WHOLE_SUBTREE,
- DereferenceAliasesPolicy.NEVER,
- Integer.MAX_VALUE,
- Integer.MAX_VALUE,
- false,
- LDAPFilter.decode("(&(gvrights=*ApplId=test2,ou=*)" +
- "(gvrights=*test2,ou=A*))"),
- null, null);
-
- searchOperation.run();
+ String filter = "(&(gvrights=*ApplId=test2,ou=*)" + "(gvrights=*test2,ou=A*))";
+ SearchRequest request = newSearchRequest("cn=gvrightstest,o=test", SearchScope.WHOLE_SUBTREE, filter);
+ InternalSearchOperation searchOperation = getRootConnection().processSearch(request);
assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS);
assertEquals(searchOperation.getEntriesSent(), 1);
}
diff --git a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/CollationMatchingRuleTest.java b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/CollationMatchingRuleTest.java
index cae1a99..106b459 100644
--- a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/CollationMatchingRuleTest.java
+++ b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/CollationMatchingRuleTest.java
@@ -29,17 +29,13 @@
import java.util.ArrayList;
import java.util.List;
-import org.forgerock.opendj.ldap.ByteString;
-import org.forgerock.opendj.ldap.DereferenceAliasesPolicy;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.TestCaseUtils;
import org.opends.server.controls.ServerSideSortRequestControl;
import org.opends.server.controls.VLVRequestControl;
-import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.protocols.internal.InternalSearchOperation;
import org.opends.server.protocols.internal.SearchRequest;
-import org.opends.server.protocols.ldap.LDAPFilter;
import org.opends.server.tools.LDAPModify;
import org.opends.server.types.Control;
import org.opends.server.types.DN;
@@ -120,22 +116,9 @@
public void searchCollationEqualityUsingOID() throws Exception
{
//Search the collation rule with OID of en and no suffix in the filter.
- InternalClientConnection conn = getRootConnection();
-
- InternalSearchOperation searchOperation =
- new InternalSearchOperation(
- conn, nextOperationID(), nextMessageID(),
- null,
- ByteString.valueOf("uid=user,o=test"),
- SearchScope.WHOLE_SUBTREE,
- DereferenceAliasesPolicy.NEVER,
- Integer.MAX_VALUE,
- Integer.MAX_VALUE,
- false,
- LDAPFilter.decode("cn:1.3.6.1.4.1.42.2.27.9.4.34.1:=sanchez"),
- null, null);
-
- searchOperation.run();
+ SearchRequest request =
+ newSearchRequest("uid=user,o=test", SearchScope.WHOLE_SUBTREE, "cn:1.3.6.1.4.1.42.2.27.9.4.34.1:=sanchez");
+ InternalSearchOperation searchOperation = getRootConnection().processSearch(request);
assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS);
List<SearchResultEntry> entries = searchOperation.getSearchEntries();
SearchResultEntry e = entries.get(0);
@@ -154,22 +137,8 @@
{
//Search the collation rule with language tag of en and no suffix
//in the filter.
- InternalClientConnection conn = getRootConnection();
-
- InternalSearchOperation searchOperation =
- new InternalSearchOperation(
- conn, nextOperationID(), nextMessageID(),
- null,
- ByteString.valueOf("uid=user,o=test"),
- SearchScope.WHOLE_SUBTREE,
- DereferenceAliasesPolicy.NEVER,
- Integer.MAX_VALUE,
- Integer.MAX_VALUE,
- false,
- LDAPFilter.decode("cn:en:=sanchez"),
- null, null);
-
- searchOperation.run();
+ SearchRequest request = newSearchRequest("uid=user,o=test", SearchScope.WHOLE_SUBTREE, "cn:en:=sanchez");
+ InternalSearchOperation searchOperation = getRootConnection().processSearch(request);
assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS);
List<SearchResultEntry> entries = searchOperation.getSearchEntries();
SearchResultEntry e = entries.get(0);
@@ -178,7 +147,6 @@
}
-
/**
* Test to search the collation Less than matching rule using OID and suffix.
*/
@@ -187,22 +155,9 @@
public void searchCollationLTUsingOIDSuffix() throws Exception
{
//Search the collation rule with OID of es and suffix in the filter.
- InternalClientConnection conn = getRootConnection();
-
- InternalSearchOperation searchOperation =
- new InternalSearchOperation(
- conn, nextOperationID(), nextMessageID(),
- null,
- ByteString.valueOf("uid=user,o=test"),
- SearchScope.WHOLE_SUBTREE,
- DereferenceAliasesPolicy.NEVER,
- Integer.MAX_VALUE,
- Integer.MAX_VALUE,
- false,
- LDAPFilter.decode("departmentnumber:1.3.6.1.4.1.42.2.27.9.4.49.1.1:=abc120"),
- null, null);
-
- searchOperation.run();
+ String filter = "departmentnumber:1.3.6.1.4.1.42.2.27.9.4.49.1.1:=abc120";
+ SearchRequest request = newSearchRequest("uid=user,o=test", SearchScope.WHOLE_SUBTREE, filter);
+ InternalSearchOperation searchOperation = getRootConnection().processSearch(request);
assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS);
List<SearchResultEntry> entries = searchOperation.getSearchEntries();
SearchResultEntry e = entries.get(0);
@@ -221,22 +176,8 @@
public void searchCollationLTEUsingLanguageSuffix() throws Exception
{
//Search the collation rule with tag of fr and suffix in the filter.
- InternalClientConnection conn = getRootConnection();
-
- InternalSearchOperation searchOperation =
- new InternalSearchOperation(
- conn, nextOperationID(), nextMessageID(),
- null,
- ByteString.valueOf("uid=user,o=test"),
- SearchScope.WHOLE_SUBTREE,
- DereferenceAliasesPolicy.NEVER,
- Integer.MAX_VALUE,
- Integer.MAX_VALUE,
- false,
- LDAPFilter.decode("carLicense:fr.2:=ebe2"),
- null, null);
-
- searchOperation.run();
+ SearchRequest request = newSearchRequest("uid=user,o=test", SearchScope.WHOLE_SUBTREE, "carLicense:fr.2:=ebe2");
+ InternalSearchOperation searchOperation = getRootConnection().processSearch(request);
assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS);
List<SearchResultEntry> entries = searchOperation.getSearchEntries();
SearchResultEntry e = entries.get(0);
@@ -255,22 +196,8 @@
public void searchCollationGTUsingLanguage() throws Exception
{
//Search the collation rule with tag of fr in the filter.
- InternalClientConnection conn = getRootConnection();
-
- InternalSearchOperation searchOperation =
- new InternalSearchOperation(
- conn, nextOperationID(), nextMessageID(),
- null,
- ByteString.valueOf("uid=user,o=test"),
- SearchScope.WHOLE_SUBTREE,
- DereferenceAliasesPolicy.NEVER,
- Integer.MAX_VALUE,
- Integer.MAX_VALUE,
- false,
- LDAPFilter.decode("carLicense:fr.5:=ebe1"),
- null, null);
-
- searchOperation.run();
+ SearchRequest request = newSearchRequest("uid=user,o=test", SearchScope.WHOLE_SUBTREE, "carLicense:fr.5:=ebe1");
+ InternalSearchOperation searchOperation = getRootConnection().processSearch(request);
assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS);
List<SearchResultEntry> entries = searchOperation.getSearchEntries();
SearchResultEntry e = entries.get(0);
@@ -289,22 +216,9 @@
public void searchCollationGTEUsingLanguage() throws Exception
{
//Search the collation rule with tag of es and suffix in the filter.
- InternalClientConnection conn = getRootConnection();
-
- InternalSearchOperation searchOperation =
- new InternalSearchOperation(
- conn, nextOperationID(), nextMessageID(),
- null,
- ByteString.valueOf("uid=user,o=test"),
- SearchScope.WHOLE_SUBTREE,
- DereferenceAliasesPolicy.NEVER,
- Integer.MAX_VALUE,
- Integer.MAX_VALUE,
- false,
- LDAPFilter.decode("departmentnumber:es.4:=abc111"),
- null, null);
-
- searchOperation.run();
+ SearchRequest request =
+ newSearchRequest("uid=user,o=test", SearchScope.WHOLE_SUBTREE, "departmentnumber:es.4:=abc111");
+ InternalSearchOperation searchOperation = getRootConnection().processSearch(request);
assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS);
List<SearchResultEntry> entries = searchOperation.getSearchEntries();
SearchResultEntry e = entries.get(0);
@@ -326,20 +240,10 @@
*It searches for string quebec against the value of sn which is
* Qu\u00e9bec.
*/
- InternalClientConnection conn = getRootConnection();
-
- InternalSearchOperation searchOperation =
- new InternalSearchOperation(
- conn, nextOperationID(), nextMessageID(),
- null,
- ByteString.valueOf("uid=user,o=test"),
- SearchScope.WHOLE_SUBTREE,
- DereferenceAliasesPolicy.NEVER,
- Integer.MAX_VALUE,
- Integer.MAX_VALUE,
- false,
- LDAPFilter.decode("sn:en.6:=*u*bec"),
- null, null);
+ SearchRequest request = newSearchRequest("uid=user,o=test", SearchScope.WHOLE_SUBTREE, "sn:en.6:=*u*bec")
+ .setSizeLimit(Integer.MAX_VALUE)
+ .setTimeLimit(Integer.MAX_VALUE);
+ InternalSearchOperation searchOperation = getRootConnection().processSearch(request);
searchOperation.run();
assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS);
diff --git a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/LDAPSyntaxTest.java b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/LDAPSyntaxTest.java
index c9724b0..f3b6f8b 100644
--- a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/LDAPSyntaxTest.java
+++ b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/LDAPSyntaxTest.java
@@ -28,19 +28,16 @@
import java.util.ArrayList;
import java.util.Iterator;
-import java.util.LinkedHashSet;
import java.util.List;
import org.forgerock.opendj.ldap.ByteString;
-import org.forgerock.opendj.ldap.DereferenceAliasesPolicy;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.TestCaseUtils;
import org.opends.server.api.AttributeSyntax;
import org.opends.server.core.AddOperation;
-import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.protocols.internal.InternalSearchOperation;
-import org.opends.server.protocols.ldap.LDAPFilter;
+import org.opends.server.protocols.internal.SearchRequest;
import org.opends.server.types.Attribute;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
@@ -49,6 +46,7 @@
import org.testng.annotations.Test;
import static org.opends.server.protocols.internal.InternalClientConnection.*;
+import static org.opends.server.protocols.internal.Requests.*;
import static org.testng.Assert.*;
/**
@@ -158,7 +156,7 @@
/**
* Tests whether an implemented syntax can't be substituted by another.
*/
- @Test()
+ @Test
public void testSubstitutionSyntaxForInvalidSubstitution() throws Exception
{
try
@@ -217,33 +215,17 @@
*
* @throws java.lang.Exception
*/
- @Test()
+ @Test
public void testSubstitutionSyntaxSearch() throws Exception
{
try
{
addSubtitutionSyntax();
- InternalClientConnection conn =
- InternalClientConnection.getRootConnection();
- LinkedHashSet<String> attrList = new LinkedHashSet<String>();
- attrList.add("ldapsyntaxes");
- InternalSearchOperation searchOperation =
- new InternalSearchOperation(
- conn,
- InternalClientConnection.nextOperationID(),
- InternalClientConnection.nextMessageID(),
- null,
- ByteString.valueOf("cn=schema"),
- SearchScope.WHOLE_SUBTREE,
- DereferenceAliasesPolicy.NEVER,
- Integer.MAX_VALUE,
- Integer.MAX_VALUE,
- false,
- LDAPFilter.decode("objectclass=ldapsubentry"),
- attrList, null);
+ SearchRequest request = newSearchRequest("cn=schema", SearchScope.WHOLE_SUBTREE, "objectclass=ldapsubentry")
+ .addAttribute("ldapsyntaxes");
+ InternalSearchOperation searchOperation = getRootConnection().processSearch(request);
- searchOperation.run();
assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS);
List<SearchResultEntry> entries = searchOperation.getSearchEntries();
SearchResultEntry e = entries.get(0);
@@ -283,7 +265,7 @@
*
* @throws java.lang.Exception
*/
- @Test()
+ @Test
public void testSubsitutionSyntaxAddValues() throws Exception
{
try
@@ -324,7 +306,7 @@
*
* @throws java.lang.Exception
*/
- @Test()
+ @Test
public void testRegexSyntaxAddValues() throws Exception
{
try
@@ -366,7 +348,7 @@
*
* @throws java.lang.Exception
*/
- @Test()
+ @Test
public void testRegexSyntaxSearch() throws Exception
{
try
@@ -382,25 +364,9 @@
"sn: xyz",
"test-attr-regex: host:0.0.0");
- InternalClientConnection conn =
- InternalClientConnection.getRootConnection();
-
- InternalSearchOperation searchOperation =
- new InternalSearchOperation(
- conn,
- InternalClientConnection.nextOperationID(),
- InternalClientConnection.nextMessageID(),
- null,
- ByteString.valueOf("cn=test,o=test"),
- SearchScope.WHOLE_SUBTREE,
- DereferenceAliasesPolicy.NEVER,
- Integer.MAX_VALUE,
- Integer.MAX_VALUE,
- false,
- LDAPFilter.decode("test-attr-regex=host:0.0.0"),
- null, null);
-
- searchOperation.run();
+ SearchRequest request =
+ newSearchRequest("cn=test,o=test", SearchScope.WHOLE_SUBTREE, "test-attr-regex=host:0.0.0");
+ InternalSearchOperation searchOperation = getRootConnection().processSearch(request);
assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS);
List<SearchResultEntry> entries = searchOperation.getSearchEntries();
SearchResultEntry e = entries.get(0);
@@ -413,15 +379,13 @@
}
}
-
-
- /**
+ /**
* Tests whether it is possible to add values after an enum syntax
* has been added.
*
* @throws java.lang.Exception
*/
- @Test()
+ @Test
public void testEnumSyntaxAddValues() throws Exception
{
try
@@ -460,10 +424,8 @@
/**
* Tests the equality-based search using enum syntax.
- *
- * @throws java.lang.Exception
*/
- @Test()
+ @Test
public void testEnumSyntaxEqualitySearch() throws Exception
{
try
@@ -479,25 +441,8 @@
"sn: xyz",
"test-attr-enum: wednesday");
- InternalClientConnection conn =
- InternalClientConnection.getRootConnection();
-
- InternalSearchOperation searchOperation =
- new InternalSearchOperation(
- conn,
- InternalClientConnection.nextOperationID(),
- InternalClientConnection.nextMessageID(),
- null,
- ByteString.valueOf("cn=test,o=test"),
- SearchScope.WHOLE_SUBTREE,
- DereferenceAliasesPolicy.NEVER,
- Integer.MAX_VALUE,
- Integer.MAX_VALUE,
- false,
- LDAPFilter.decode("test-attr-enum=wednesday"),
- null, null);
-
- searchOperation.run();
+ SearchRequest request = newSearchRequest("cn=test,o=test", SearchScope.WHOLE_SUBTREE, "test-attr-enum=wednesday");
+ InternalSearchOperation searchOperation = getRootConnection().processSearch(request);
assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS);
List<SearchResultEntry> entries = searchOperation.getSearchEntries();
SearchResultEntry e = entries.get(0);
@@ -514,10 +459,8 @@
/**
* Tests the ordering-based search using enum syntax.
- *
- * @throws java.lang.Exception
*/
- @Test()
+ @Test
public void testEnumSyntaxOrderingSearch() throws Exception
{
try
@@ -547,25 +490,8 @@
"sn: xyz",
"test-attr-enum: tuesday");
- InternalClientConnection conn =
- InternalClientConnection.getRootConnection();
-
- InternalSearchOperation searchOperation =
- new InternalSearchOperation(
- conn,
- InternalClientConnection.nextOperationID(),
- InternalClientConnection.nextMessageID(),
- null,
- ByteString.valueOf("o=test"),
- SearchScope.WHOLE_SUBTREE,
- DereferenceAliasesPolicy.NEVER,
- Integer.MAX_VALUE,
- Integer.MAX_VALUE,
- false,
- LDAPFilter.decode("test-attr-enum>=tuesday"),
- null, null);
-
- searchOperation.run();
+ SearchRequest request = newSearchRequest("o=test", SearchScope.WHOLE_SUBTREE, "test-attr-enum>=tuesday");
+ InternalSearchOperation searchOperation = getRootConnection().processSearch(request);
assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS);
List<SearchResultEntry> entries = searchOperation.getSearchEntries();
SearchResultEntry e = entries.get(0);
diff --git a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/StringPrepProfileTestCase.java b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/StringPrepProfileTestCase.java
index ea98dc8..19119a3 100644
--- a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/StringPrepProfileTestCase.java
+++ b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/StringPrepProfileTestCase.java
@@ -31,27 +31,27 @@
import org.forgerock.opendj.ldap.Assertion;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ConditionResult;
-import org.forgerock.opendj.ldap.DereferenceAliasesPolicy;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.opends.server.TestCaseUtils;
import org.opends.server.api.MatchingRule;
-import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.protocols.internal.InternalSearchOperation;
-import org.opends.server.protocols.ldap.LDAPFilter;
+import org.opends.server.protocols.internal.SearchRequest;
import org.opends.server.types.SearchResultEntry;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
+import static org.opends.server.protocols.internal.InternalClientConnection.*;
+import static org.opends.server.protocols.internal.Requests.*;
import static org.testng.Assert.*;
/**
* This Test Class tests various matching rules for their compatibility
* against RFC 4517,4518 and 3454.
*/
-public final class StringPrepProfileTestCase
- extends SchemaTestCase
+@SuppressWarnings("javadoc")
+public final class StringPrepProfileTestCase extends SchemaTestCase
{
/**
* Ensures that the Directory Server is running before executing the
@@ -59,15 +59,14 @@
*
* @throws Exception If an unexpected problem occurs.
*/
- @BeforeClass()
- public void startServer()
- throws Exception
+ @BeforeClass
+ public void startServer() throws Exception
{
TestCaseUtils.startServer();
}
- //Adds an entry for test.
+ /** Adds an entry for test. */
private void addEntry() throws Exception
{
TestCaseUtils.clearJEBackend(true, "userRoot", "dc=example,dc=com");
@@ -86,33 +85,17 @@
* DN and searching for it using the filter containing a combining sequence
* and acute accent.
*/
- @Test()
+ @Test
public void testUnicodeSearch() throws Exception
{
try
{
addEntry();
- InternalClientConnection conn =
- InternalClientConnection.getRootConnection();
+ SearchRequest request =
+ newSearchRequest("dc= example,dc=com", SearchScope.WHOLE_SUBTREE, "&(cn=Jos\u0065\u0301)(sn=This is a test)");
+ InternalSearchOperation searchOperation = getRootConnection().processSearch(request);
- InternalSearchOperation searchOperation =
- new InternalSearchOperation(
- conn,
- InternalClientConnection.nextOperationID(),
- InternalClientConnection.nextMessageID(),
- null,
- ByteString.valueOf("dc= example,dc=com"),
- SearchScope.WHOLE_SUBTREE,
- DereferenceAliasesPolicy.NEVER,
- Integer.MAX_VALUE,
- Integer.MAX_VALUE,
- false,
- //The filter uses a combining sequence e and acute accent.
- LDAPFilter.decode("&(cn=Jos\u0065\u0301)(sn=This is a test)"),
- null, null);
-
- searchOperation.run();
assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS);
List<SearchResultEntry> entries = searchOperation.getSearchEntries();
//No results expected for jdk 5.
@@ -146,7 +129,7 @@
}
- //Generates data for case exact matching rules.
+ /** Generates data for case exact matching rules. */
@DataProvider(name="exactRuleData")
private Object[][] createExactRuleData()
{
@@ -180,7 +163,7 @@
}
- //Generates data for case ignore matching rules.
+ /** Generates data for case ignore matching rules. */
@DataProvider(name="caseFoldRuleData")
private Object[][] createIgnoreRuleData()
{
diff --git a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/TimeBasedMatchingRuleTest.java b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/TimeBasedMatchingRuleTest.java
index af1633b..490d1c1 100644
--- a/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/TimeBasedMatchingRuleTest.java
+++ b/opendj-sdk/opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/schema/TimeBasedMatchingRuleTest.java
@@ -36,9 +36,8 @@
import org.opends.server.TestCaseUtils;
import org.opends.server.api.MatchingRule;
import org.opends.server.core.DirectoryServer;
-import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.protocols.internal.InternalSearchOperation;
-import org.opends.server.protocols.ldap.LDAPFilter;
+import org.opends.server.protocols.internal.SearchRequest;
import org.opends.server.types.DN;
import org.opends.server.types.SearchResultEntry;
import org.opends.server.util.TimeThread;
@@ -46,6 +45,8 @@
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
+import static org.opends.server.protocols.internal.InternalClientConnection.*;
+import static org.opends.server.protocols.internal.Requests.*;
import static org.opends.server.schema.GeneralizedTimeSyntax.*;
import static org.opends.server.schema.SchemaConstants.*;
import static org.testng.Assert.*;
@@ -122,25 +123,10 @@
try
{
populateEntries();
- InternalClientConnection conn =
- InternalClientConnection.getRootConnection();
- InternalSearchOperation searchOperation =
- new InternalSearchOperation(
- conn,
- InternalClientConnection.nextOperationID(),
- InternalClientConnection.nextMessageID(),
- null,
- ByteString.valueOf("dc=example,dc=com"),
- SearchScope.WHOLE_SUBTREE,
- DereferenceAliasesPolicy.NEVER,
- Integer.MAX_VALUE,
- Integer.MAX_VALUE,
- false,
- LDAPFilter.decode(TIME_ATTR+":"+EXT_OMR_RELATIVE_TIME_LT_OID+":=-60m"), //
- null, null);
-
- searchOperation.run();
+ String filter = TIME_ATTR + ":" + EXT_OMR_RELATIVE_TIME_LT_OID + ":=-60m";
+ SearchRequest request = newSearchRequest("dc=example,dc=com", SearchScope.WHOLE_SUBTREE, filter);
+ InternalSearchOperation searchOperation = getRootConnection().processSearch(request);
assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS);
List<SearchResultEntry> entries = searchOperation.getSearchEntries();
assertTrue(dnFoundInEntryList(entries,user1,user2));
@@ -162,25 +148,10 @@
try
{
populateEntries();
- InternalClientConnection conn =
- InternalClientConnection.getRootConnection();
- InternalSearchOperation searchOperation =
- new InternalSearchOperation(
- conn,
- InternalClientConnection.nextOperationID(),
- InternalClientConnection.nextMessageID(),
- null,
- ByteString.valueOf("dc=example,dc=com"),
- SearchScope.WHOLE_SUBTREE,
- DereferenceAliasesPolicy.NEVER,
- Integer.MAX_VALUE,
- Integer.MAX_VALUE,
- false,
- LDAPFilter.decode(TIME_ATTR+":"+EXT_OMR_RELATIVE_TIME_LT_OID+":=1d"),
- null, null);
-
- searchOperation.run();
+ String filter = TIME_ATTR + ":" + EXT_OMR_RELATIVE_TIME_LT_OID + ":=1d";
+ SearchRequest request = newSearchRequest("dc=example,dc=com", SearchScope.WHOLE_SUBTREE, filter);
+ InternalSearchOperation searchOperation = getRootConnection().processSearch(request);
assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS);
List<SearchResultEntry> entries = searchOperation.getSearchEntries();
assertTrue(entries.size() == 4 && dnFoundInEntryList(entries,user1,user2,user3,user5));
@@ -193,7 +164,7 @@
- /**
+ /**
* Test to search using the greater-than relative time matching rule for expired events.
*/
@Test()
@@ -202,25 +173,10 @@
try
{
populateEntries();
- InternalClientConnection conn =
- InternalClientConnection.getRootConnection();
- InternalSearchOperation searchOperation =
- new InternalSearchOperation(
- conn,
- InternalClientConnection.nextOperationID(),
- InternalClientConnection.nextMessageID(),
- null,
- ByteString.valueOf("dc=example,dc=com"),
- SearchScope.WHOLE_SUBTREE,
- DereferenceAliasesPolicy.NEVER,
- Integer.MAX_VALUE,
- Integer.MAX_VALUE,
- false,
- LDAPFilter.decode(TIME_ATTR+":"+EXT_OMR_RELATIVE_TIME_GT_OID+":=-1h"),
- null, null);
-
- searchOperation.run();
+ String filter = TIME_ATTR + ":" + EXT_OMR_RELATIVE_TIME_GT_OID + ":=-1h";
+ SearchRequest request = newSearchRequest("dc=example,dc=com", SearchScope.WHOLE_SUBTREE, filter);
+ InternalSearchOperation searchOperation = getRootConnection().processSearch(request);
assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS);
List<SearchResultEntry> entries = searchOperation.getSearchEntries();
Assertions.assertThat(entries).hasSize(3);
@@ -243,25 +199,10 @@
try
{
populateEntries();
- InternalClientConnection conn =
- InternalClientConnection.getRootConnection();
- InternalSearchOperation searchOperation =
- new InternalSearchOperation(
- conn,
- InternalClientConnection.nextOperationID(),
- InternalClientConnection.nextMessageID(),
- null,
- ByteString.valueOf("dc=example,dc=com"),
- SearchScope.WHOLE_SUBTREE,
- DereferenceAliasesPolicy.NEVER,
- Integer.MAX_VALUE,
- Integer.MAX_VALUE,
- false,
- LDAPFilter.decode(TIME_ATTR+":"+EXT_OMR_RELATIVE_TIME_GT_OID+":=0s"),
- null, null);
-
- searchOperation.run();
+ String filter = TIME_ATTR + ":" + EXT_OMR_RELATIVE_TIME_GT_OID + ":=0s";
+ SearchRequest request = newSearchRequest("dc=example,dc=com", SearchScope.WHOLE_SUBTREE, filter);
+ InternalSearchOperation searchOperation = getRootConnection().processSearch(request);
assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS);
List<SearchResultEntry> entries = searchOperation.getSearchEntries();
assertTrue(entries.size()==2 && dnFoundInEntryList(entries,user3,user4));
@@ -286,25 +227,11 @@
try
{
populateEntries();
- InternalClientConnection conn =
- InternalClientConnection.getRootConnection();
- String assertion = "01D11M";
- InternalSearchOperation searchOperation =
- new InternalSearchOperation(
- conn,
- InternalClientConnection.nextOperationID(),
- InternalClientConnection.nextMessageID(),
- null,
- ByteString.valueOf("dc=example,dc=com"),
- SearchScope.WHOLE_SUBTREE,
- DereferenceAliasesPolicy.NEVER,
- Integer.MAX_VALUE,
- Integer.MAX_VALUE,
- false,
- LDAPFilter.decode(DATE_ATTR+":"+EXT_PARTIAL_DATE_TIME_OID+":="+assertion),
- null,null);
- searchOperation.run();
+ String assertion = "01D11M";
+ String filter = DATE_ATTR + ":" + EXT_PARTIAL_DATE_TIME_OID + ":=" + assertion;
+ SearchRequest request = newSearchRequest("dc=example,dc=com", SearchScope.WHOLE_SUBTREE, filter);
+ InternalSearchOperation searchOperation = getRootConnection().processSearch(request);
assertEquals(searchOperation.getResultCode(), ResultCode.SUCCESS);
List<SearchResultEntry> entries = searchOperation.getSearchEntries();
assertTrue(entries.size()==1 && dnFoundInEntryList(entries,user6));
--
Gitblit v1.10.0