Search in sources :

Example 6 with TransactionSpecificationRequestControl

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

the class TransactionExtendedOperationHandlerTestCase method testAbortedTransaction.

/**
 * Provides a test case for a transaction that is aborted rather than
 * committed.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testAbortedTransaction() throws Exception {
    final TestUnsolicitedNotificationHandler unsolicitedNotificationHandler = new TestUnsolicitedNotificationHandler();
    final LDAPConnectionOptions connectionOptions = new LDAPConnectionOptions();
    connectionOptions.setUnsolicitedNotificationHandler(unsolicitedNotificationHandler);
    final InMemoryDirectoryServer ds = getTestDS(true, true);
    final LDAPConnection conn = ds.getConnection(connectionOptions);
    assertEquals(unsolicitedNotificationHandler.getNotificationCount(), 0);
    ds.assertEntryExists("dc=example,dc=com");
    ds.assertEntryExists("ou=People,dc=example,dc=com");
    ds.assertEntryExists("uid=test.user,ou=People,dc=example,dc=com");
    ds.assertEntryMissing("ou=test,dc=example,dc=com");
    ds.assertEntryMissing("uid=test.user,ou=test,dc=example,dc=com");
    final StartTransactionExtendedResult startTxnResult = (StartTransactionExtendedResult) conn.processExtendedOperation(new StartTransactionExtendedRequest());
    assertResultCodeEquals(startTxnResult, ResultCode.SUCCESS);
    final ASN1OctetString txnID = startTxnResult.getTransactionID();
    assertNotNull(txnID);
    final TransactionSpecificationRequestControl txnControl = new TransactionSpecificationRequestControl(txnID);
    ds.assertEntryExists("dc=example,dc=com");
    ds.assertEntryExists("ou=People,dc=example,dc=com");
    ds.assertEntryExists("uid=test.user,ou=People,dc=example,dc=com");
    ds.assertEntryMissing("ou=test,dc=example,dc=com");
    ds.assertEntryMissing("uid=test.user,ou=test,dc=example,dc=com");
    final AddRequest addRequest = new AddRequest("dn: ou=test,dc=example,dc=com", "objectClass: top", "objectClass: organizationalUnit", "ou: test");
    addRequest.setControls(txnControl);
    assertResultCodeEquals(conn, addRequest, ResultCode.SUCCESS);
    ds.assertEntryExists("dc=example,dc=com");
    ds.assertEntryExists("ou=People,dc=example,dc=com");
    ds.assertEntryExists("uid=test.user,ou=People,dc=example,dc=com");
    ds.assertEntryMissing("ou=test,dc=example,dc=com");
    ds.assertEntryMissing("uid=test.user,ou=test,dc=example,dc=com");
    final ModifyRequest modifyRequest = new ModifyRequest("dn: uid=test.user,ou=People,dc=example,dc=com", "changeType: modify", "replace: description", "description: foo");
    modifyRequest.setControls(txnControl);
    assertResultCodeEquals(conn, modifyRequest, ResultCode.SUCCESS);
    ds.assertEntryExists("dc=example,dc=com");
    ds.assertEntryExists("ou=People,dc=example,dc=com");
    ds.assertEntryExists("uid=test.user,ou=People,dc=example,dc=com");
    ds.assertEntryMissing("ou=test,dc=example,dc=com");
    ds.assertEntryMissing("uid=test.user,ou=test,dc=example,dc=com");
    final ModifyDNRequest modifyDNRequest = new ModifyDNRequest("uid=test.user,ou=People,dc=example,dc=com", "uid=test.user", false, "ou=test,dc=example,dc=com");
    modifyDNRequest.setControls(txnControl);
    assertResultCodeEquals(conn, modifyDNRequest, ResultCode.SUCCESS);
    ds.assertEntryExists("dc=example,dc=com");
    ds.assertEntryExists("ou=People,dc=example,dc=com");
    ds.assertEntryExists("uid=test.user,ou=People,dc=example,dc=com");
    ds.assertEntryMissing("ou=test,dc=example,dc=com");
    ds.assertEntryMissing("uid=test.user,ou=test,dc=example,dc=com");
    final DeleteRequest deleteRequest = new DeleteRequest("ou=People,dc=example,dc=com");
    deleteRequest.setControls(txnControl);
    assertResultCodeEquals(conn, deleteRequest, ResultCode.SUCCESS);
    ds.assertEntryExists("dc=example,dc=com");
    ds.assertEntryExists("ou=People,dc=example,dc=com");
    ds.assertEntryExists("uid=test.user,ou=People,dc=example,dc=com");
    ds.assertEntryMissing("ou=test,dc=example,dc=com");
    ds.assertEntryMissing("uid=test.user,ou=test,dc=example,dc=com");
    final EndTransactionExtendedResult endTxnResult = (EndTransactionExtendedResult) conn.processExtendedOperation(new EndTransactionExtendedRequest(txnID, false));
    assertResultCodeEquals(endTxnResult, ResultCode.SUCCESS);
    assertTrue(endTxnResult.getFailedOpMessageID() < 0);
    assertNotNull(endTxnResult.getOperationResponseControls());
    assertTrue(endTxnResult.getOperationResponseControls().isEmpty());
    ds.assertEntryExists("dc=example,dc=com");
    ds.assertEntryExists("ou=People,dc=example,dc=com");
    ds.assertEntryExists("uid=test.user,ou=People,dc=example,dc=com");
    ds.assertEntryMissing("ou=test,dc=example,dc=com");
    ds.assertEntryMissing("uid=test.user,ou=test,dc=example,dc=com");
    conn.close();
    assertEquals(unsolicitedNotificationHandler.getNotificationCount(), 0);
}
Also used : LDAPConnectionOptions(com.unboundid.ldap.sdk.LDAPConnectionOptions) ASN1OctetString(com.unboundid.asn1.ASN1OctetString) EndTransactionExtendedRequest(com.unboundid.ldap.sdk.extensions.EndTransactionExtendedRequest) LDAPConnection(com.unboundid.ldap.sdk.LDAPConnection) ModifyRequest(com.unboundid.ldap.sdk.ModifyRequest) AddRequest(com.unboundid.ldap.sdk.AddRequest) ModifyDNRequest(com.unboundid.ldap.sdk.ModifyDNRequest) StartTransactionExtendedResult(com.unboundid.ldap.sdk.extensions.StartTransactionExtendedResult) StartTransactionExtendedRequest(com.unboundid.ldap.sdk.extensions.StartTransactionExtendedRequest) DeleteRequest(com.unboundid.ldap.sdk.DeleteRequest) EndTransactionExtendedResult(com.unboundid.ldap.sdk.extensions.EndTransactionExtendedResult) TestUnsolicitedNotificationHandler(com.unboundid.ldap.sdk.TestUnsolicitedNotificationHandler) TransactionSpecificationRequestControl(com.unboundid.ldap.sdk.controls.TransactionSpecificationRequestControl) Test(org.testng.annotations.Test)

Example 7 with TransactionSpecificationRequestControl

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

the class TransactionExtendedOperationHandlerTestCase method testSuccessfulTransaction.

/**
 * Provides a test case for a completely successful transaction.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testSuccessfulTransaction() throws Exception {
    final TestUnsolicitedNotificationHandler unsolicitedNotificationHandler = new TestUnsolicitedNotificationHandler();
    final LDAPConnectionOptions connectionOptions = new LDAPConnectionOptions();
    connectionOptions.setUnsolicitedNotificationHandler(unsolicitedNotificationHandler);
    final InMemoryDirectoryServer ds = getTestDS(true, true);
    final LDAPConnection conn = ds.getConnection(connectionOptions);
    assertEquals(unsolicitedNotificationHandler.getNotificationCount(), 0);
    ds.assertEntryExists("dc=example,dc=com");
    ds.assertEntryExists("ou=People,dc=example,dc=com");
    ds.assertEntryExists("uid=test.user,ou=People,dc=example,dc=com");
    ds.assertEntryMissing("ou=test,dc=example,dc=com");
    ds.assertEntryMissing("uid=test.user,ou=test,dc=example,dc=com");
    final StartTransactionExtendedResult startTxnResult = (StartTransactionExtendedResult) conn.processExtendedOperation(new StartTransactionExtendedRequest());
    assertResultCodeEquals(startTxnResult, ResultCode.SUCCESS);
    final ASN1OctetString txnID = startTxnResult.getTransactionID();
    assertNotNull(txnID);
    final TransactionSpecificationRequestControl txnControl = new TransactionSpecificationRequestControl(txnID);
    ds.assertEntryExists("dc=example,dc=com");
    ds.assertEntryExists("ou=People,dc=example,dc=com");
    ds.assertEntryExists("uid=test.user,ou=People,dc=example,dc=com");
    ds.assertEntryMissing("ou=test,dc=example,dc=com");
    ds.assertEntryMissing("uid=test.user,ou=test,dc=example,dc=com");
    final AddRequest addRequest = new AddRequest("dn: ou=test,dc=example,dc=com", "objectClass: top", "objectClass: organizationalUnit", "ou: test");
    addRequest.setControls(txnControl);
    assertResultCodeEquals(conn, addRequest, ResultCode.SUCCESS);
    ds.assertEntryExists("dc=example,dc=com");
    ds.assertEntryExists("ou=People,dc=example,dc=com");
    ds.assertEntryExists("uid=test.user,ou=People,dc=example,dc=com");
    ds.assertEntryMissing("ou=test,dc=example,dc=com");
    ds.assertEntryMissing("uid=test.user,ou=test,dc=example,dc=com");
    final ModifyRequest modifyRequest = new ModifyRequest("dn: uid=test.user,ou=People,dc=example,dc=com", "changeType: modify", "replace: description", "description: foo");
    modifyRequest.setControls(txnControl);
    assertResultCodeEquals(conn, modifyRequest, ResultCode.SUCCESS);
    ds.assertEntryExists("dc=example,dc=com");
    ds.assertEntryExists("ou=People,dc=example,dc=com");
    ds.assertEntryExists("uid=test.user,ou=People,dc=example,dc=com");
    ds.assertEntryMissing("ou=test,dc=example,dc=com");
    ds.assertEntryMissing("uid=test.user,ou=test,dc=example,dc=com");
    final ModifyDNRequest modifyDNRequest = new ModifyDNRequest("uid=test.user,ou=People,dc=example,dc=com", "uid=test.user", false, "ou=test,dc=example,dc=com");
    modifyDNRequest.setControls(txnControl);
    assertResultCodeEquals(conn, modifyDNRequest, ResultCode.SUCCESS);
    ds.assertEntryExists("dc=example,dc=com");
    ds.assertEntryExists("ou=People,dc=example,dc=com");
    ds.assertEntryExists("uid=test.user,ou=People,dc=example,dc=com");
    ds.assertEntryMissing("ou=test,dc=example,dc=com");
    ds.assertEntryMissing("uid=test.user,ou=test,dc=example,dc=com");
    final DeleteRequest deleteRequest = new DeleteRequest("ou=People,dc=example,dc=com");
    deleteRequest.setControls(txnControl);
    assertResultCodeEquals(conn, deleteRequest, ResultCode.SUCCESS);
    ds.assertEntryExists("dc=example,dc=com");
    ds.assertEntryExists("ou=People,dc=example,dc=com");
    ds.assertEntryExists("uid=test.user,ou=People,dc=example,dc=com");
    ds.assertEntryMissing("ou=test,dc=example,dc=com");
    ds.assertEntryMissing("uid=test.user,ou=test,dc=example,dc=com");
    final EndTransactionExtendedResult endTxnResult = (EndTransactionExtendedResult) conn.processExtendedOperation(new EndTransactionExtendedRequest(txnID, true));
    assertResultCodeEquals(endTxnResult, ResultCode.SUCCESS);
    assertTrue(endTxnResult.getFailedOpMessageID() < 0);
    assertNotNull(endTxnResult.getOperationResponseControls());
    assertTrue(endTxnResult.getOperationResponseControls().isEmpty());
    ds.assertEntryExists("dc=example,dc=com");
    ds.assertEntryExists("ou=test,dc=example,dc=com");
    ds.assertEntryExists("uid=test.user,ou=test,dc=example,dc=com");
    ds.assertEntryMissing("ou=People,dc=example,dc=com");
    ds.assertEntryMissing("uid=test.user,ou=People,dc=example,dc=com");
    conn.close();
    assertEquals(unsolicitedNotificationHandler.getNotificationCount(), 0);
}
Also used : LDAPConnectionOptions(com.unboundid.ldap.sdk.LDAPConnectionOptions) ASN1OctetString(com.unboundid.asn1.ASN1OctetString) EndTransactionExtendedRequest(com.unboundid.ldap.sdk.extensions.EndTransactionExtendedRequest) LDAPConnection(com.unboundid.ldap.sdk.LDAPConnection) ModifyRequest(com.unboundid.ldap.sdk.ModifyRequest) AddRequest(com.unboundid.ldap.sdk.AddRequest) ModifyDNRequest(com.unboundid.ldap.sdk.ModifyDNRequest) StartTransactionExtendedResult(com.unboundid.ldap.sdk.extensions.StartTransactionExtendedResult) StartTransactionExtendedRequest(com.unboundid.ldap.sdk.extensions.StartTransactionExtendedRequest) DeleteRequest(com.unboundid.ldap.sdk.DeleteRequest) EndTransactionExtendedResult(com.unboundid.ldap.sdk.extensions.EndTransactionExtendedResult) TestUnsolicitedNotificationHandler(com.unboundid.ldap.sdk.TestUnsolicitedNotificationHandler) TransactionSpecificationRequestControl(com.unboundid.ldap.sdk.controls.TransactionSpecificationRequestControl) Test(org.testng.annotations.Test)

Example 8 with TransactionSpecificationRequestControl

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

the class TransactionExtendedOperationHandlerTestCase method testTransactionControlWithMismatchedTransactionID.

/**
 * Tests the behavior when trying to use the transaction specification request
 * control with a transaction ID that differs from the ID of the associated
 * transaction.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testTransactionControlWithMismatchedTransactionID() throws Exception {
    final TestUnsolicitedNotificationHandler unsolicitedNotificationHandler = new TestUnsolicitedNotificationHandler();
    final LDAPConnectionOptions connectionOptions = new LDAPConnectionOptions();
    connectionOptions.setUnsolicitedNotificationHandler(unsolicitedNotificationHandler);
    final InMemoryDirectoryServer ds = getTestDS(true, true);
    final LDAPConnection conn = ds.getConnection(connectionOptions);
    assertEquals(unsolicitedNotificationHandler.getNotificationCount(), 0);
    final StartTransactionExtendedResult startTxnResult = (StartTransactionExtendedResult) conn.processExtendedOperation(new StartTransactionExtendedRequest());
    assertResultCodeEquals(startTxnResult, ResultCode.SUCCESS);
    final ASN1OctetString txnID = startTxnResult.getTransactionID();
    assertNotNull(txnID);
    final ASN1OctetString wrongTxnID = new ASN1OctetString(txnID.stringValue() + "-wrong");
    final TransactionSpecificationRequestControl wrongTxnControl = new TransactionSpecificationRequestControl(wrongTxnID);
    final AddRequest addRequest = new AddRequest("dn: ou=test,dc=example,dc=com", "objectClass: top", "objectClass: organizationalUnit", "ou: test");
    addRequest.setControls(wrongTxnControl);
    assertResultCodeEquals(conn, addRequest, ResultCode.UNAVAILABLE_CRITICAL_EXTENSION);
    conn.close();
    assertEquals(unsolicitedNotificationHandler.getNotificationCount(), 1);
}
Also used : LDAPConnectionOptions(com.unboundid.ldap.sdk.LDAPConnectionOptions) ASN1OctetString(com.unboundid.asn1.ASN1OctetString) AddRequest(com.unboundid.ldap.sdk.AddRequest) StartTransactionExtendedResult(com.unboundid.ldap.sdk.extensions.StartTransactionExtendedResult) StartTransactionExtendedRequest(com.unboundid.ldap.sdk.extensions.StartTransactionExtendedRequest) LDAPConnection(com.unboundid.ldap.sdk.LDAPConnection) TestUnsolicitedNotificationHandler(com.unboundid.ldap.sdk.TestUnsolicitedNotificationHandler) TransactionSpecificationRequestControl(com.unboundid.ldap.sdk.controls.TransactionSpecificationRequestControl) Test(org.testng.annotations.Test)

Example 9 with TransactionSpecificationRequestControl

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

the class TransactionExtendedOperationHandlerTestCase method testFailedDeleteInTransaction.

/**
 * Provides a test case for a transaction in which a delete operation fails
 * after other operations that should have succeeded.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testFailedDeleteInTransaction() throws Exception {
    final TestUnsolicitedNotificationHandler unsolicitedNotificationHandler = new TestUnsolicitedNotificationHandler();
    final LDAPConnectionOptions connectionOptions = new LDAPConnectionOptions();
    connectionOptions.setUnsolicitedNotificationHandler(unsolicitedNotificationHandler);
    final InMemoryDirectoryServer ds = getTestDS(true, true);
    final LDAPConnection conn = ds.getConnection(connectionOptions);
    assertEquals(unsolicitedNotificationHandler.getNotificationCount(), 0);
    ds.assertEntryExists("dc=example,dc=com");
    ds.assertEntryExists("ou=People,dc=example,dc=com");
    ds.assertEntryExists("uid=test.user,ou=People,dc=example,dc=com");
    ds.assertEntryMissing("ou=test,dc=example,dc=com");
    ds.assertEntryMissing("uid=test.user,ou=test,dc=example,dc=com");
    final StartTransactionExtendedResult startTxnResult = (StartTransactionExtendedResult) conn.processExtendedOperation(new StartTransactionExtendedRequest());
    assertResultCodeEquals(startTxnResult, ResultCode.SUCCESS);
    final ASN1OctetString txnID = startTxnResult.getTransactionID();
    assertNotNull(txnID);
    final TransactionSpecificationRequestControl txnControl = new TransactionSpecificationRequestControl(txnID);
    final AddRequest addRequest = new AddRequest("dn: ou=test,dc=example,dc=com", "objectClass: top", "objectClass: organizationalUnit", "ou: test");
    addRequest.setControls(txnControl);
    assertResultCodeEquals(conn, addRequest, ResultCode.SUCCESS);
    final DeleteRequest deleteRequest = new DeleteRequest("ou=People,dc=example,dc=com");
    deleteRequest.setControls(txnControl);
    assertResultCodeEquals(conn, deleteRequest, ResultCode.SUCCESS);
    final EndTransactionExtendedResult endTxnResult = (EndTransactionExtendedResult) conn.processExtendedOperation(new EndTransactionExtendedRequest(txnID, true));
    assertResultCodeEquals(endTxnResult, ResultCode.NOT_ALLOWED_ON_NONLEAF);
    assertTrue(endTxnResult.getFailedOpMessageID() > 0);
    assertEquals(endTxnResult.getFailedOpMessageID(), deleteRequest.getLastMessageID());
    assertNotNull(endTxnResult.getOperationResponseControls());
    assertTrue(endTxnResult.getOperationResponseControls().isEmpty());
    ds.assertEntryExists("dc=example,dc=com");
    ds.assertEntryExists("ou=People,dc=example,dc=com");
    ds.assertEntryExists("uid=test.user,ou=People,dc=example,dc=com");
    ds.assertEntryMissing("ou=test,dc=example,dc=com");
    ds.assertEntryMissing("uid=test.user,ou=test,dc=example,dc=com");
    conn.close();
    assertEquals(unsolicitedNotificationHandler.getNotificationCount(), 0);
}
Also used : LDAPConnectionOptions(com.unboundid.ldap.sdk.LDAPConnectionOptions) ASN1OctetString(com.unboundid.asn1.ASN1OctetString) AddRequest(com.unboundid.ldap.sdk.AddRequest) StartTransactionExtendedResult(com.unboundid.ldap.sdk.extensions.StartTransactionExtendedResult) StartTransactionExtendedRequest(com.unboundid.ldap.sdk.extensions.StartTransactionExtendedRequest) EndTransactionExtendedRequest(com.unboundid.ldap.sdk.extensions.EndTransactionExtendedRequest) LDAPConnection(com.unboundid.ldap.sdk.LDAPConnection) DeleteRequest(com.unboundid.ldap.sdk.DeleteRequest) EndTransactionExtendedResult(com.unboundid.ldap.sdk.extensions.EndTransactionExtendedResult) TestUnsolicitedNotificationHandler(com.unboundid.ldap.sdk.TestUnsolicitedNotificationHandler) TransactionSpecificationRequestControl(com.unboundid.ldap.sdk.controls.TransactionSpecificationRequestControl) Test(org.testng.annotations.Test)

Example 10 with TransactionSpecificationRequestControl

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

the class ExampleUsagesTestCase method testStartTransactionExtendedRequestExample.

/**
 * Tests the example in the {@code StartTransactionExtendedRequest} class.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testStartTransactionExtendedRequestExample() throws Exception {
    /* ----- BEGIN PRE-EXAMPLE SETUP ----- */
    final InMemoryDirectoryServer ds = getTestDS(true, false);
    final LDAPConnection connection = ds.getConnection();
    connection.add("dn: cn=first,dc=example,dc=com", "objectClass: top", "objectClass: person", "cn: first", "sn: first");
    connection.add("dn: cn=second,dc=example,dc=com", "objectClass: top", "objectClass: person", "cn: second", "sn: second");
    /* ----- BEGIN EXAMPLE CODE ----- */
    // Use the start transaction extended operation to begin a transaction.
    StartTransactionExtendedResult startTxnResult;
    try {
        startTxnResult = (StartTransactionExtendedResult) connection.processExtendedOperation(new StartTransactionExtendedRequest());
    // This doesn't necessarily mean that the operation was successful, since
    // some kinds of extended operations return non-success results under
    // normal conditions.
    } catch (LDAPException le) {
        // For an extended operation, this generally means that a problem was
        // encountered while trying to send the request or read the result.
        startTxnResult = new StartTransactionExtendedResult(new ExtendedResult(le));
    }
    LDAPTestUtils.assertResultCodeEquals(startTxnResult, ResultCode.SUCCESS);
    ASN1OctetString txnID = startTxnResult.getTransactionID();
    // At this point, we have a transaction available for use.  If any problem
    // arises, we want to ensure that the transaction is aborted, so create a
    // try block to process the operations and a finally block to commit or
    // abort the transaction.
    boolean commit = false;
    try {
        // Create and process a modify operation to update a first entry as part
        // of the transaction.  Make sure to include the transaction specification
        // control in the request to indicate that it should be part of the
        // transaction.
        ModifyRequest firstModifyRequest = new ModifyRequest("cn=first,dc=example,dc=com", new Modification(ModificationType.REPLACE, "description", "first"));
        firstModifyRequest.addControl(new TransactionSpecificationRequestControl(txnID));
        LDAPResult firstModifyResult;
        try {
            firstModifyResult = connection.modify(firstModifyRequest);
        } catch (LDAPException le) {
            firstModifyResult = le.toLDAPResult();
        }
        LDAPTestUtils.assertResultCodeEquals(firstModifyResult, ResultCode.SUCCESS);
        // Perform a second modify operation as part of the transaction.
        ModifyRequest secondModifyRequest = new ModifyRequest("cn=second,dc=example,dc=com", new Modification(ModificationType.REPLACE, "description", "second"));
        secondModifyRequest.addControl(new TransactionSpecificationRequestControl(txnID));
        LDAPResult secondModifyResult;
        try {
            secondModifyResult = connection.modify(secondModifyRequest);
        } catch (LDAPException le) {
            secondModifyResult = le.toLDAPResult();
        }
        LDAPTestUtils.assertResultCodeEquals(secondModifyResult, ResultCode.SUCCESS);
        // If we've gotten here, then all writes have been processed successfully
        // and we can indicate that the transaction should be committed rather
        // than aborted.
        commit = true;
    } finally {
        // Commit or abort the transaction.
        EndTransactionExtendedResult endTxnResult;
        try {
            endTxnResult = (EndTransactionExtendedResult) connection.processExtendedOperation(new EndTransactionExtendedRequest(txnID, commit));
        } catch (LDAPException le) {
            endTxnResult = new EndTransactionExtendedResult(new ExtendedResult(le));
        }
        LDAPTestUtils.assertResultCodeEquals(endTxnResult, ResultCode.SUCCESS);
    }
    /* ----- END EXAMPLE CODE ----- */
    /* ----- BEGIN POST-EXAMPLE CLEANUP ----- */
    connection.close();
    assertTrue(commit);
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) Modification(com.unboundid.ldap.sdk.Modification) InMemoryDirectoryServer(com.unboundid.ldap.listener.InMemoryDirectoryServer) LDAPResult(com.unboundid.ldap.sdk.LDAPResult) LDAPConnection(com.unboundid.ldap.sdk.LDAPConnection) ModifyRequest(com.unboundid.ldap.sdk.ModifyRequest) LDAPException(com.unboundid.ldap.sdk.LDAPException) ExtendedResult(com.unboundid.ldap.sdk.ExtendedResult) TransactionSpecificationRequestControl(com.unboundid.ldap.sdk.controls.TransactionSpecificationRequestControl) Test(org.testng.annotations.Test)

Aggregations

ASN1OctetString (com.unboundid.asn1.ASN1OctetString)16 TransactionSpecificationRequestControl (com.unboundid.ldap.sdk.controls.TransactionSpecificationRequestControl)16 LDAPConnection (com.unboundid.ldap.sdk.LDAPConnection)14 Test (org.testng.annotations.Test)14 AddRequest (com.unboundid.ldap.sdk.AddRequest)12 LDAPConnectionOptions (com.unboundid.ldap.sdk.LDAPConnectionOptions)10 TestUnsolicitedNotificationHandler (com.unboundid.ldap.sdk.TestUnsolicitedNotificationHandler)10 StartTransactionExtendedRequest (com.unboundid.ldap.sdk.extensions.StartTransactionExtendedRequest)10 StartTransactionExtendedResult (com.unboundid.ldap.sdk.extensions.StartTransactionExtendedResult)10 ModifyRequest (com.unboundid.ldap.sdk.ModifyRequest)9 EndTransactionExtendedRequest (com.unboundid.ldap.sdk.extensions.EndTransactionExtendedRequest)9 EndTransactionExtendedResult (com.unboundid.ldap.sdk.extensions.EndTransactionExtendedResult)8 DeleteRequest (com.unboundid.ldap.sdk.DeleteRequest)6 ModifyDNRequest (com.unboundid.ldap.sdk.ModifyDNRequest)6 Control (com.unboundid.ldap.sdk.Control)5 PostReadRequestControl (com.unboundid.ldap.sdk.controls.PostReadRequestControl)5 ExtendedResult (com.unboundid.ldap.sdk.ExtendedResult)3 LDAPException (com.unboundid.ldap.sdk.LDAPException)3 Modification (com.unboundid.ldap.sdk.Modification)3 PreReadRequestControl (com.unboundid.ldap.sdk.controls.PreReadRequestControl)3