Search in sources :

Example 6 with AsyncRequestID

use of com.unboundid.ldap.sdk.AsyncRequestID in project ldapsdk by pingidentity.

the class AccessLogRequestHandlerTestCase method testAbandon.

/**
 * Provides test coverage for an abandon.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testAbandon() throws Exception {
    logHandler.clear();
    final LDAPConnection conn = new LDAPConnection("127.0.0.1", successPort);
    // The CONNECT message.
    waitForCount(1);
    logHandler.clear();
    final AsyncRequestID requestID = InternalSDKHelper.createAsyncRequestID(1, conn);
    conn.abandon(requestID);
    waitForCount(1);
    final String[] messages = logHandler.getMessages(true);
    final String message = messages[0];
    assertTrue(message.contains(" ABANDON REQUEST "), message);
    assertTrue(message.contains(" idToAbandon=1"), message);
    conn.close();
    // The DISCONNECT message.
    waitForCount(1);
    logHandler.clear();
}
Also used : AsyncRequestID(com.unboundid.ldap.sdk.AsyncRequestID) LDAPConnection(com.unboundid.ldap.sdk.LDAPConnection) Test(org.testng.annotations.Test)

Example 7 with AsyncRequestID

use of com.unboundid.ldap.sdk.AsyncRequestID in project ldapsdk by pingidentity.

the class LDAPConnection method abandon.

/**
 * Sends a request to abandon the provided search operation.
 *
 * @param  searchResults  The search results object for the search to abandon.
 *
 * @throws  LDAPException  If a problem occurs while sending the request.
 */
public void abandon(@NotNull final LDAPSearchResults searchResults) throws LDAPException {
    try {
        final AsyncRequestID requestID = searchResults.getAsyncRequestID();
        if (requestID != null) {
            searchResults.setAbandoned();
            conn.abandon(requestID);
        } else {
            // This should never happen.
            throw new LDAPException("The search request has not been sent to the server", LDAPException.PARAM_ERROR);
        }
    } catch (final com.unboundid.ldap.sdk.LDAPException le) {
        Debug.debugException(le);
        throw new LDAPException(le);
    }
}
Also used : AsyncRequestID(com.unboundid.ldap.sdk.AsyncRequestID)

Aggregations

AsyncRequestID (com.unboundid.ldap.sdk.AsyncRequestID)7 Test (org.testng.annotations.Test)6 LDAPConnection (com.unboundid.ldap.sdk.LDAPConnection)5 InMemoryDirectoryServer (com.unboundid.ldap.listener.InMemoryDirectoryServer)2 Modification (com.unboundid.ldap.sdk.Modification)2 SearchRequest (com.unboundid.ldap.sdk.SearchRequest)2 TestAsyncListener (com.unboundid.ldap.sdk.TestAsyncListener)2 ExtendedResult (com.unboundid.ldap.sdk.ExtendedResult)1 LDAPException (com.unboundid.ldap.sdk.LDAPException)1 LDAPResult (com.unboundid.ldap.sdk.LDAPResult)1 ModifyRequest (com.unboundid.ldap.sdk.ModifyRequest)1 CancelExtendedRequest (com.unboundid.ldap.sdk.extensions.CancelExtendedRequest)1 JSONObject (com.unboundid.util.json.JSONObject)1