Search in sources :

Example 1 with PostReadRequestControl

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

the class InMemoryDirectoryServerLDAPInterfaceTestCase method testModifyDN.

/**
 * Provides test coverage for the methods that can be used to process modify
 * DN operations.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testModifyDN() throws Exception {
    ds.restoreSnapshot(snapshot);
    ds.add("dn: ou=Users,dc=example,dc=com", "objectClass: top", "objectClass: organizationalUnit", "ou: Users");
    // Test the method that takes a DN, new RDN, and deleteOldRDN flag.
    LDAPResult modifyDNResult = ds.modifyDN("uid=test.user,ou=People,dc=example,dc=com", "uid=test.2", true);
    assertNotNull(modifyDNResult);
    assertEquals(modifyDNResult.getResultCode(), ResultCode.SUCCESS);
    // Test the method that takes a DN, new RDN, deleteOldRDN flag and a new
    // superior DN.
    modifyDNResult = ds.modifyDN("uid=test.2,ou=People,dc=example,dc=com", "uid=test.2", false, "ou=Users,dc=example,dc=com");
    assertNotNull(modifyDNResult);
    assertEquals(modifyDNResult.getResultCode(), ResultCode.SUCCESS);
    // Test the method that takes a modify DN request, with controls.
    final ModifyDNRequest modifyDNRequest = new ModifyDNRequest("uid=test.2,ou=Users,dc=example,dc=com", "uid=test.3", true);
    modifyDNRequest.addControl(new PreReadRequestControl("*", "+"));
    modifyDNRequest.addControl(new PostReadRequestControl("*", "+"));
    modifyDNResult = ds.modifyDN(modifyDNRequest);
    assertNotNull(modifyDNResult);
    assertEquals(modifyDNResult.getResultCode(), ResultCode.SUCCESS);
    assertTrue(modifyDNResult.hasResponseControl(PreReadResponseControl.PRE_READ_RESPONSE_OID));
    final PreReadResponseControl preReadResponse = PreReadResponseControl.get(modifyDNResult);
    assertNotNull(preReadResponse);
    assertTrue(preReadResponse.getEntry().hasAttributeValue("uid", "test.2"));
    assertTrue(modifyDNResult.hasResponseControl(PostReadResponseControl.POST_READ_RESPONSE_OID));
    final PostReadResponseControl postReadResponse = PostReadResponseControl.get(modifyDNResult);
    assertNotNull(postReadResponse);
    assertTrue(postReadResponse.getEntry().hasAttributeValue("uid", "test.3"));
    // Test the method that takes a read-only modify DN request.
    final ReadOnlyModifyDNRequest readOnlyModifyDNRequest = new ModifyDNRequest("uid=test.3,ou=Users,dc=example,dc=com", "uid=test.4", true);
    modifyDNResult = ds.modifyDN(readOnlyModifyDNRequest);
    assertNotNull(modifyDNResult);
    assertEquals(modifyDNResult.getResultCode(), ResultCode.SUCCESS);
}
Also used : ReadOnlyModifyDNRequest(com.unboundid.ldap.sdk.ReadOnlyModifyDNRequest) ModifyDNRequest(com.unboundid.ldap.sdk.ModifyDNRequest) ReadOnlyModifyDNRequest(com.unboundid.ldap.sdk.ReadOnlyModifyDNRequest) PreReadResponseControl(com.unboundid.ldap.sdk.controls.PreReadResponseControl) LDAPResult(com.unboundid.ldap.sdk.LDAPResult) PreReadRequestControl(com.unboundid.ldap.sdk.controls.PreReadRequestControl) PostReadResponseControl(com.unboundid.ldap.sdk.controls.PostReadResponseControl) PostReadRequestControl(com.unboundid.ldap.sdk.controls.PostReadRequestControl) Test(org.testng.annotations.Test)

Example 2 with PostReadRequestControl

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

the class TransactionExtendedOperationHandlerTestCase method testTransactionWithControls.

/**
 * Provides a test case for a completely successful transaction that includes
 * request and response controls for the associated operations.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testTransactionWithControls() 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");
    final PostReadRequestControl postReadRequestControl = new PostReadRequestControl("*", "+");
    addRequest.setControls(txnControl, postReadRequestControl);
    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");
    final PreReadRequestControl preReadRequestControl = new PreReadRequestControl("*", "+");
    modifyRequest.setControls(txnControl, preReadRequestControl, postReadRequestControl);
    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, preReadRequestControl, postReadRequestControl);
    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, preReadRequestControl);
    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());
    assertFalse(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");
    final Control[] addControls = endTxnResult.getOperationResponseControls(addRequest.getLastMessageID());
    assertNotNull(addControls);
    assertEquals(addControls.length, 1);
    assertTrue(addControls[0] instanceof PostReadResponseControl);
    final Control[] modifyControls = endTxnResult.getOperationResponseControls(modifyRequest.getLastMessageID());
    assertNotNull(modifyControls);
    assertEquals(modifyControls.length, 2);
    assertTrue(modifyControls[0] instanceof PreReadResponseControl);
    assertTrue(modifyControls[1] instanceof PostReadResponseControl);
    final Control[] modifyDNControls = endTxnResult.getOperationResponseControls(modifyDNRequest.getLastMessageID());
    assertNotNull(modifyDNControls);
    assertEquals(modifyDNControls.length, 2);
    assertTrue(modifyDNControls[0] instanceof PreReadResponseControl);
    assertTrue(modifyDNControls[1] instanceof PostReadResponseControl);
    final Control[] deleteControls = endTxnResult.getOperationResponseControls(deleteRequest.getLastMessageID());
    assertNotNull(deleteControls);
    assertEquals(deleteControls.length, 1);
    assertTrue(deleteControls[0] instanceof PreReadResponseControl);
    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) PreReadRequestControl(com.unboundid.ldap.sdk.controls.PreReadRequestControl) AddRequest(com.unboundid.ldap.sdk.AddRequest) ModifyDNRequest(com.unboundid.ldap.sdk.ModifyDNRequest) PostReadResponseControl(com.unboundid.ldap.sdk.controls.PostReadResponseControl) TransactionSpecificationRequestControl(com.unboundid.ldap.sdk.controls.TransactionSpecificationRequestControl) Control(com.unboundid.ldap.sdk.Control) PreReadResponseControl(com.unboundid.ldap.sdk.controls.PreReadResponseControl) PostReadRequestControl(com.unboundid.ldap.sdk.controls.PostReadRequestControl) PreReadRequestControl(com.unboundid.ldap.sdk.controls.PreReadRequestControl) PreReadResponseControl(com.unboundid.ldap.sdk.controls.PreReadResponseControl) StartTransactionExtendedResult(com.unboundid.ldap.sdk.extensions.StartTransactionExtendedResult) StartTransactionExtendedRequest(com.unboundid.ldap.sdk.extensions.StartTransactionExtendedRequest) PostReadResponseControl(com.unboundid.ldap.sdk.controls.PostReadResponseControl) PostReadRequestControl(com.unboundid.ldap.sdk.controls.PostReadRequestControl) 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 3 with PostReadRequestControl

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

the class LDAPConnectionTestCase method testModifyWithPostReadControl.

/**
 * Provides test coverage for the ability to process a modify operation which
 * includes the post-read control.
 * <BR><BR>
 * Access to a Directory Server instance is required for complete processing.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testModifyWithPostReadControl() throws Exception {
    if (!isDirectoryInstanceAvailable()) {
        return;
    }
    LDAPConnection c = new LDAPConnection();
    c.connect(getTestHost(), getTestPort(), getTestBindDN(), getTestBindPassword());
    c.add(new LDAPEntry(new Entry(getTestBaseDN(), getBaseEntryAttributes())));
    c.add(new LDAPEntry(new Entry("dn: ou=test," + getTestBaseDN(), "objectClass: top", "objectClass: organizationalUnit", "ou: test")));
    LDAPConstraints constraints = new LDAPConstraints();
    constraints.setServerControls(new LDAPControl(new PostReadRequestControl("description")));
    LDAPModification mod = new LDAPModification(LDAPModification.REPLACE, new LDAPAttribute("description", "foo"));
    c.modify("ou=test," + getTestBaseDN(), mod, constraints);
    LDAPControl[] responseControls = c.getResponseControls();
    assertNotNull(responseControls);
    assertEquals(responseControls.length, 1);
    PostReadResponseControl postReadResponse = new PostReadResponseControl(responseControls[0].getID(), false, new ASN1OctetString(responseControls[0].getValue()));
    Entry e = postReadResponse.getEntry();
    assertNotNull(e);
    assertTrue(e.hasAttributeValue("description", "foo"));
    c.delete("ou=test," + getTestBaseDN());
    c.delete(getTestBaseDN());
    c.disconnect();
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) Entry(com.unboundid.ldap.sdk.Entry) PostReadResponseControl(com.unboundid.ldap.sdk.controls.PostReadResponseControl) PostReadRequestControl(com.unboundid.ldap.sdk.controls.PostReadRequestControl) Test(org.testng.annotations.Test)

Example 4 with PostReadRequestControl

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

the class StartTransactionExtendedRequestTestCase method testCommitTransaction.

/**
 * Tests the process of creating a transaction, including multiple operations
 * as part of that transaction, and then committing it.
 * <BR><BR>
 * Access to a Directory Server instance is required for complete processing.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testCommitTransaction() throws Exception {
    if (!isDirectoryInstanceAvailable()) {
        return;
    }
    LDAPConnection conn = getAdminConnection();
    RootDSE rootDSE = conn.getRootDSE();
    if ((rootDSE == null) || (!rootDSE.supportsExtendedOperation(StartTransactionExtendedRequest.START_TRANSACTION_REQUEST_OID))) {
        conn.close();
        return;
    }
    StartTransactionExtendedResult startTxnResult = (StartTransactionExtendedResult) conn.processExtendedOperation(new StartTransactionExtendedRequest());
    assertEquals(startTxnResult.getResultCode(), ResultCode.SUCCESS);
    ASN1OctetString txnID = startTxnResult.getTransactionID();
    assertNotNull(txnID);
    assertNotNull(startTxnResult.toString());
    Control[] controls = { new TransactionSpecificationRequestControl(txnID), new PostReadRequestControl(true) };
    AddRequest addRequest = new AddRequest(getTestBaseDN(), getBaseEntryAttributes(), controls);
    conn.add(addRequest);
    Modification[] mods = { new Modification(ModificationType.REPLACE, "description", "foo") };
    ModifyRequest modifyRequest = new ModifyRequest(getTestBaseDN(), mods, controls);
    conn.modify(modifyRequest);
    EndTransactionExtendedResult endTxnResult = (EndTransactionExtendedResult) conn.processExtendedOperation(new EndTransactionExtendedRequest(txnID, true));
    assertEquals(endTxnResult.getResultCode(), ResultCode.SUCCESS);
    assertNotNull(endTxnResult.getOperationResponseControls());
    assertFalse(endTxnResult.getOperationResponseControls().isEmpty());
    assertNotNull(endTxnResult.toString());
    conn.delete(getTestBaseDN());
    conn.close();
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) Modification(com.unboundid.ldap.sdk.Modification) LDAPConnection(com.unboundid.ldap.sdk.LDAPConnection) ModifyRequest(com.unboundid.ldap.sdk.ModifyRequest) RootDSE(com.unboundid.ldap.sdk.RootDSE) AddRequest(com.unboundid.ldap.sdk.AddRequest) TransactionSpecificationRequestControl(com.unboundid.ldap.sdk.controls.TransactionSpecificationRequestControl) Control(com.unboundid.ldap.sdk.Control) PostReadRequestControl(com.unboundid.ldap.sdk.controls.PostReadRequestControl) PostReadRequestControl(com.unboundid.ldap.sdk.controls.PostReadRequestControl) TransactionSpecificationRequestControl(com.unboundid.ldap.sdk.controls.TransactionSpecificationRequestControl) Test(org.testng.annotations.Test)

Example 5 with PostReadRequestControl

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

the class InMemoryDirectoryControlsTestCase method testReadEntryControls.

/**
 * Provides test coverage for the pre-read and post-read controls.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testReadEntryControls() throws Exception {
    final InMemoryDirectoryServer ds = getTestDS(true, true);
    final LDAPConnection conn = ds.getConnection();
    conn.add("dn: ou=Users,dc=example,dc=com", "objectClass: top", "objectClass: organizationalUnit", "ou: Users");
    final PreReadRequestControl preReadUserAttrs = new PreReadRequestControl();
    final PreReadRequestControl preReadAllAttrs = new PreReadRequestControl("*", "+");
    final PreReadRequestControl preReadSpecifiedAttrs = new PreReadRequestControl("objectClass", "cn", "entryUUID");
    final PostReadRequestControl postReadUserAttrs = new PostReadRequestControl();
    final PostReadRequestControl postReadAllAttrs = new PostReadRequestControl("*", "+");
    final PostReadRequestControl postReadSpecifiedAttrs = new PostReadRequestControl("objectClass", "cn", "entryUUID");
    // Test an add with a post-read control that should return all user
    // attributes.
    AddRequest addRequest = new AddRequest(generateUserEntry("test.1", "ou=People,dc=example,dc=com", "Test", "1", "password", new Attribute("description", "foo")));
    addRequest.setControls(postReadUserAttrs);
    LDAPResult addResult = conn.add(addRequest);
    assertEquals(addResult.getResultCode(), ResultCode.SUCCESS);
    PostReadResponseControl postReadResponse = PostReadResponseControl.get(addResult);
    assertNotNull(postReadResponse);
    Entry postReadEntry = postReadResponse.getEntry();
    assertEquals(postReadEntry.getParsedDN(), new DN("uid=test.1,ou=People,dc=example,dc=com"));
    assertTrue(postReadEntry.hasAttributeValue("objectClass", "top"));
    assertTrue(postReadEntry.hasAttributeValue("objectClass", "inetOrgPerson"));
    assertTrue(postReadEntry.hasAttributeValue("cn", "Test 1"));
    assertTrue(postReadEntry.hasAttributeValue("uid", "test.1"));
    assertTrue(postReadEntry.hasAttributeValue("givenName", "Test"));
    assertTrue(postReadEntry.hasAttributeValue("sn", "1"));
    assertTrue(postReadEntry.hasAttributeValue("userPassword", "password"));
    assertTrue(postReadEntry.hasAttributeValue("description", "foo"));
    assertFalse(postReadEntry.hasAttribute("entryDN"));
    assertFalse(postReadEntry.hasAttribute("entryUUID"));
    assertFalse(postReadEntry.hasAttribute("creatorsName"));
    assertFalse(postReadEntry.hasAttribute("createTimestamp"));
    assertFalse(postReadEntry.hasAttribute("modifiersName"));
    assertFalse(postReadEntry.hasAttribute("modifyTimestamp"));
    assertFalse(postReadEntry.hasAttribute("subschemaSubentry"));
    // Test an add with a post-read control that should return all user and
    // operational attributes.
    addRequest = new AddRequest(generateUserEntry("test.2", "ou=People,dc=example,dc=com", "Test", "2", "password", new Attribute("description", "foo")));
    addRequest.setControls(postReadAllAttrs);
    addResult = conn.add(addRequest);
    assertEquals(addResult.getResultCode(), ResultCode.SUCCESS);
    postReadResponse = PostReadResponseControl.get(addResult);
    assertNotNull(postReadResponse);
    postReadEntry = postReadResponse.getEntry();
    assertEquals(postReadEntry.getParsedDN(), new DN("uid=test.2,ou=People,dc=example,dc=com"));
    assertTrue(postReadEntry.hasAttributeValue("objectClass", "top"));
    assertTrue(postReadEntry.hasAttributeValue("objectClass", "inetOrgPerson"));
    assertTrue(postReadEntry.hasAttributeValue("cn", "Test 2"));
    assertTrue(postReadEntry.hasAttributeValue("uid", "test.2"));
    assertTrue(postReadEntry.hasAttributeValue("givenName", "Test"));
    assertTrue(postReadEntry.hasAttributeValue("sn", "2"));
    assertTrue(postReadEntry.hasAttributeValue("userPassword", "password"));
    assertTrue(postReadEntry.hasAttributeValue("description", "foo"));
    assertTrue(postReadEntry.hasAttribute("entryDN"));
    assertTrue(postReadEntry.hasAttribute("entryUUID"));
    assertTrue(postReadEntry.hasAttribute("creatorsName"));
    assertTrue(postReadEntry.hasAttribute("createTimestamp"));
    assertTrue(postReadEntry.hasAttribute("modifiersName"));
    assertTrue(postReadEntry.hasAttribute("modifyTimestamp"));
    assertTrue(postReadEntry.hasAttribute("subschemaSubentry"));
    // Test an add with a post-read control that should return only a specified
    // set of attributes.
    addRequest = new AddRequest(generateUserEntry("test.3", "ou=People,dc=example,dc=com", "Test", "3", "password", new Attribute("description", "foo")));
    addRequest.setControls(postReadSpecifiedAttrs);
    addResult = conn.add(addRequest);
    assertEquals(addResult.getResultCode(), ResultCode.SUCCESS);
    postReadResponse = PostReadResponseControl.get(addResult);
    assertNotNull(postReadResponse);
    postReadEntry = postReadResponse.getEntry();
    assertEquals(postReadEntry.getParsedDN(), new DN("uid=test.3,ou=People,dc=example,dc=com"));
    assertTrue(postReadEntry.hasAttributeValue("objectClass", "top"));
    assertTrue(postReadEntry.hasAttributeValue("objectClass", "inetOrgPerson"));
    assertTrue(postReadEntry.hasAttributeValue("cn", "Test 3"));
    assertFalse(postReadEntry.hasAttribute("uid"));
    assertFalse(postReadEntry.hasAttribute("givenName"));
    assertFalse(postReadEntry.hasAttribute("sn"));
    assertFalse(postReadEntry.hasAttribute("userPassword"));
    assertFalse(postReadEntry.hasAttribute("description"));
    assertFalse(postReadEntry.hasAttribute("entryDN"));
    assertTrue(postReadEntry.hasAttribute("entryUUID"));
    assertFalse(postReadEntry.hasAttribute("creatorsName"));
    assertFalse(postReadEntry.hasAttribute("createTimestamp"));
    assertFalse(postReadEntry.hasAttribute("modifiersName"));
    assertFalse(postReadEntry.hasAttribute("modifyTimestamp"));
    assertFalse(postReadEntry.hasAttribute("subschemaSubentry"));
    // Test a modify with pre-read and post-read controls that should return all
    // user attributes.
    ModifyRequest modifyRequest = new ModifyRequest("dn: uid=test.1,ou=People,dc=example,dc=com", "changetype: modify", "replace: description", "description: bar");
    modifyRequest.setControls(preReadUserAttrs, postReadUserAttrs);
    LDAPResult modifyResult = conn.modify(modifyRequest);
    assertEquals(modifyResult.getResultCode(), ResultCode.SUCCESS);
    PreReadResponseControl preReadResponse = PreReadResponseControl.get(modifyResult);
    assertNotNull(preReadResponse);
    Entry preReadEntry = preReadResponse.getEntry();
    assertEquals(preReadEntry.getParsedDN(), new DN("uid=test.1,ou=People,dc=example,dc=com"));
    assertTrue(preReadEntry.hasAttributeValue("objectClass", "top"));
    assertTrue(preReadEntry.hasAttributeValue("objectClass", "inetOrgPerson"));
    assertTrue(preReadEntry.hasAttributeValue("cn", "Test 1"));
    assertTrue(preReadEntry.hasAttributeValue("uid", "test.1"));
    assertTrue(preReadEntry.hasAttributeValue("givenName", "Test"));
    assertTrue(preReadEntry.hasAttributeValue("sn", "1"));
    assertTrue(preReadEntry.hasAttributeValue("userPassword", "password"));
    assertTrue(preReadEntry.hasAttributeValue("description", "foo"));
    assertFalse(preReadEntry.hasAttribute("entryDN"));
    assertFalse(preReadEntry.hasAttribute("entryUUID"));
    assertFalse(preReadEntry.hasAttribute("creatorsName"));
    assertFalse(preReadEntry.hasAttribute("createTimestamp"));
    assertFalse(preReadEntry.hasAttribute("modifiersName"));
    assertFalse(preReadEntry.hasAttribute("modifyTimestamp"));
    assertFalse(preReadEntry.hasAttribute("subschemaSubentry"));
    postReadResponse = PostReadResponseControl.get(modifyResult);
    assertNotNull(postReadResponse);
    postReadEntry = postReadResponse.getEntry();
    assertEquals(postReadEntry.getParsedDN(), new DN("uid=test.1,ou=People,dc=example,dc=com"));
    assertTrue(postReadEntry.hasAttributeValue("objectClass", "top"));
    assertTrue(postReadEntry.hasAttributeValue("objectClass", "inetOrgPerson"));
    assertTrue(postReadEntry.hasAttributeValue("cn", "Test 1"));
    assertTrue(postReadEntry.hasAttributeValue("uid", "test.1"));
    assertTrue(postReadEntry.hasAttributeValue("givenName", "Test"));
    assertTrue(postReadEntry.hasAttributeValue("sn", "1"));
    assertTrue(postReadEntry.hasAttributeValue("userPassword", "password"));
    assertTrue(postReadEntry.hasAttributeValue("description", "bar"));
    assertFalse(postReadEntry.hasAttribute("entryDN"));
    assertFalse(postReadEntry.hasAttribute("entryUUID"));
    assertFalse(postReadEntry.hasAttribute("creatorsName"));
    assertFalse(postReadEntry.hasAttribute("createTimestamp"));
    assertFalse(postReadEntry.hasAttribute("modifiersName"));
    assertFalse(postReadEntry.hasAttribute("modifyTimestamp"));
    assertFalse(postReadEntry.hasAttribute("subschemaSubentry"));
    // Test a modify with pre-read and post-read controls that should return all
    // user and operational attributes.  Sleep before processing the modify so
    // that we can ensure that the pre-read and post-read versions of the entry
    // will have different modifyTimestamp values.
    Thread.sleep(20L);
    modifyRequest = new ModifyRequest("dn: uid=test.2,ou=People,dc=example,dc=com", "changetype: modify", "replace: description", "description: bar");
    modifyRequest.setControls(preReadAllAttrs, postReadAllAttrs);
    modifyResult = conn.modify(modifyRequest);
    assertEquals(modifyResult.getResultCode(), ResultCode.SUCCESS);
    preReadResponse = PreReadResponseControl.get(modifyResult);
    assertNotNull(preReadResponse);
    preReadEntry = preReadResponse.getEntry();
    assertEquals(preReadEntry.getParsedDN(), new DN("uid=test.2,ou=People,dc=example,dc=com"));
    assertTrue(preReadEntry.hasAttributeValue("objectClass", "top"));
    assertTrue(preReadEntry.hasAttributeValue("objectClass", "inetOrgPerson"));
    assertTrue(preReadEntry.hasAttributeValue("cn", "Test 2"));
    assertTrue(preReadEntry.hasAttributeValue("uid", "test.2"));
    assertTrue(preReadEntry.hasAttributeValue("givenName", "Test"));
    assertTrue(preReadEntry.hasAttributeValue("sn", "2"));
    assertTrue(preReadEntry.hasAttributeValue("userPassword", "password"));
    assertTrue(preReadEntry.hasAttributeValue("description", "foo"));
    assertTrue(preReadEntry.hasAttribute("entryDN"));
    assertTrue(preReadEntry.hasAttribute("entryUUID"));
    assertTrue(preReadEntry.hasAttribute("creatorsName"));
    assertTrue(preReadEntry.hasAttribute("createTimestamp"));
    assertTrue(preReadEntry.hasAttribute("modifiersName"));
    assertTrue(preReadEntry.hasAttribute("modifyTimestamp"));
    assertTrue(preReadEntry.hasAttribute("subschemaSubentry"));
    postReadResponse = PostReadResponseControl.get(modifyResult);
    assertNotNull(postReadResponse);
    postReadEntry = postReadResponse.getEntry();
    assertEquals(postReadEntry.getParsedDN(), new DN("uid=test.2,ou=People,dc=example,dc=com"));
    assertTrue(postReadEntry.hasAttributeValue("objectClass", "top"));
    assertTrue(postReadEntry.hasAttributeValue("objectClass", "inetOrgPerson"));
    assertTrue(postReadEntry.hasAttributeValue("cn", "Test 2"));
    assertTrue(postReadEntry.hasAttributeValue("uid", "test.2"));
    assertTrue(postReadEntry.hasAttributeValue("givenName", "Test"));
    assertTrue(postReadEntry.hasAttributeValue("sn", "2"));
    assertTrue(postReadEntry.hasAttributeValue("userPassword", "password"));
    assertTrue(postReadEntry.hasAttributeValue("description", "bar"));
    assertTrue(postReadEntry.hasAttribute("entryDN"));
    assertTrue(postReadEntry.hasAttribute("entryUUID"));
    assertTrue(postReadEntry.hasAttribute("creatorsName"));
    assertTrue(postReadEntry.hasAttribute("createTimestamp"));
    assertTrue(postReadEntry.hasAttribute("modifiersName"));
    assertTrue(postReadEntry.hasAttribute("modifyTimestamp"));
    assertTrue(postReadEntry.hasAttribute("subschemaSubentry"));
    final Date preReadModifyTimestamp = preReadEntry.getAttributeValueAsDate("modifyTimestamp");
    final Date postReadModifyTimestamp = postReadEntry.getAttributeValueAsDate("modifyTimestamp");
    assertNotNull(preReadModifyTimestamp);
    assertNotNull(postReadModifyTimestamp);
    assertFalse(preReadModifyTimestamp.equals(postReadModifyTimestamp));
    // Test a modify with pre-read and post-read controls that should return
    // only a specified set of attributes.
    modifyRequest = new ModifyRequest("dn: uid=test.3,ou=People,dc=example,dc=com", "changetype: modify", "replace: description", "description: bar");
    modifyRequest.setControls(preReadSpecifiedAttrs, postReadSpecifiedAttrs);
    modifyResult = conn.modify(modifyRequest);
    assertEquals(modifyResult.getResultCode(), ResultCode.SUCCESS);
    preReadResponse = PreReadResponseControl.get(modifyResult);
    assertNotNull(preReadResponse);
    preReadEntry = preReadResponse.getEntry();
    assertEquals(preReadEntry.getParsedDN(), new DN("uid=test.3,ou=People,dc=example,dc=com"));
    assertTrue(preReadEntry.hasAttributeValue("objectClass", "top"));
    assertTrue(preReadEntry.hasAttributeValue("objectClass", "inetOrgPerson"));
    assertTrue(preReadEntry.hasAttributeValue("cn", "Test 3"));
    assertFalse(preReadEntry.hasAttributeValue("uid", "test.3"));
    assertFalse(preReadEntry.hasAttributeValue("givenName", "Test"));
    assertFalse(preReadEntry.hasAttributeValue("sn", "3"));
    assertFalse(preReadEntry.hasAttributeValue("userPassword", "password"));
    assertFalse(preReadEntry.hasAttributeValue("description", "foo"));
    assertFalse(preReadEntry.hasAttribute("entryDN"));
    assertTrue(preReadEntry.hasAttribute("entryUUID"));
    assertFalse(preReadEntry.hasAttribute("creatorsName"));
    assertFalse(preReadEntry.hasAttribute("createTimestamp"));
    assertFalse(preReadEntry.hasAttribute("modifiersName"));
    assertFalse(preReadEntry.hasAttribute("modifyTimestamp"));
    assertFalse(preReadEntry.hasAttribute("subschemaSubentry"));
    postReadResponse = PostReadResponseControl.get(modifyResult);
    assertNotNull(postReadResponse);
    postReadEntry = postReadResponse.getEntry();
    assertEquals(postReadEntry.getParsedDN(), new DN("uid=test.3,ou=People,dc=example,dc=com"));
    assertTrue(postReadEntry.hasAttributeValue("objectClass", "top"));
    assertTrue(postReadEntry.hasAttributeValue("objectClass", "inetOrgPerson"));
    assertTrue(postReadEntry.hasAttributeValue("cn", "Test 3"));
    assertFalse(postReadEntry.hasAttributeValue("uid", "test.3"));
    assertFalse(postReadEntry.hasAttributeValue("givenName", "Test"));
    assertFalse(postReadEntry.hasAttributeValue("sn", "3"));
    assertFalse(postReadEntry.hasAttributeValue("userPassword", "password"));
    assertFalse(postReadEntry.hasAttributeValue("description", "bar"));
    assertFalse(postReadEntry.hasAttribute("entryDN"));
    assertTrue(postReadEntry.hasAttribute("entryUUID"));
    assertFalse(postReadEntry.hasAttribute("creatorsName"));
    assertFalse(postReadEntry.hasAttribute("createTimestamp"));
    assertFalse(postReadEntry.hasAttribute("modifiersName"));
    assertFalse(postReadEntry.hasAttribute("modifyTimestamp"));
    assertFalse(postReadEntry.hasAttribute("subschemaSubentry"));
    // Test a modify DN with pre-read and post-read controls that should return
    // all user attributes.
    ModifyDNRequest modifyDNRequest = new ModifyDNRequest("uid=test.1,ou=People,dc=example,dc=com", "cn=Test 1", false);
    modifyDNRequest.setControls(preReadUserAttrs, postReadUserAttrs);
    LDAPResult modifyDNResult = conn.modifyDN(modifyDNRequest);
    assertEquals(modifyDNResult.getResultCode(), ResultCode.SUCCESS);
    preReadResponse = PreReadResponseControl.get(modifyDNResult);
    assertNotNull(preReadResponse);
    preReadEntry = preReadResponse.getEntry();
    assertEquals(preReadEntry.getParsedDN(), new DN("uid=test.1,ou=People,dc=example,dc=com"));
    assertTrue(preReadEntry.hasAttributeValue("objectClass", "top"));
    assertTrue(preReadEntry.hasAttributeValue("objectClass", "inetOrgPerson"));
    assertTrue(preReadEntry.hasAttributeValue("cn", "Test 1"));
    assertTrue(preReadEntry.hasAttributeValue("uid", "test.1"));
    assertTrue(preReadEntry.hasAttributeValue("givenName", "Test"));
    assertTrue(preReadEntry.hasAttributeValue("sn", "1"));
    assertTrue(preReadEntry.hasAttributeValue("userPassword", "password"));
    assertTrue(preReadEntry.hasAttributeValue("description", "bar"));
    assertFalse(preReadEntry.hasAttribute("entryDN"));
    assertFalse(preReadEntry.hasAttribute("entryUUID"));
    assertFalse(preReadEntry.hasAttribute("creatorsName"));
    assertFalse(preReadEntry.hasAttribute("createTimestamp"));
    assertFalse(preReadEntry.hasAttribute("modifiersName"));
    assertFalse(preReadEntry.hasAttribute("modifyTimestamp"));
    assertFalse(preReadEntry.hasAttribute("subschemaSubentry"));
    postReadResponse = PostReadResponseControl.get(modifyDNResult);
    assertNotNull(postReadResponse);
    postReadEntry = postReadResponse.getEntry();
    assertEquals(postReadEntry.getParsedDN(), new DN("cn=Test 1,ou=People,dc=example,dc=com"));
    assertTrue(postReadEntry.hasAttributeValue("objectClass", "top"));
    assertTrue(postReadEntry.hasAttributeValue("objectClass", "inetOrgPerson"));
    assertTrue(postReadEntry.hasAttributeValue("cn", "Test 1"));
    assertTrue(postReadEntry.hasAttributeValue("uid", "test.1"));
    assertTrue(postReadEntry.hasAttributeValue("givenName", "Test"));
    assertTrue(postReadEntry.hasAttributeValue("sn", "1"));
    assertTrue(postReadEntry.hasAttributeValue("userPassword", "password"));
    assertTrue(postReadEntry.hasAttributeValue("description", "bar"));
    assertFalse(postReadEntry.hasAttribute("entryDN"));
    assertFalse(postReadEntry.hasAttribute("entryUUID"));
    assertFalse(postReadEntry.hasAttribute("creatorsName"));
    assertFalse(postReadEntry.hasAttribute("createTimestamp"));
    assertFalse(postReadEntry.hasAttribute("modifiersName"));
    assertFalse(postReadEntry.hasAttribute("modifyTimestamp"));
    assertFalse(postReadEntry.hasAttribute("subschemaSubentry"));
    // Test a modify DN with pre-read and post-read controls that should return
    // all user and operational attributes.
    modifyDNRequest = new ModifyDNRequest("uid=test.2,ou=People,dc=example,dc=com", "uid=test.two", true);
    modifyDNRequest.setControls(preReadAllAttrs, postReadAllAttrs);
    modifyDNResult = conn.modifyDN(modifyDNRequest);
    assertEquals(modifyDNResult.getResultCode(), ResultCode.SUCCESS);
    preReadResponse = PreReadResponseControl.get(modifyDNResult);
    assertNotNull(preReadResponse);
    preReadEntry = preReadResponse.getEntry();
    assertEquals(preReadEntry.getParsedDN(), new DN("uid=test.2,ou=People,dc=example,dc=com"));
    assertTrue(preReadEntry.hasAttributeValue("objectClass", "top"));
    assertTrue(preReadEntry.hasAttributeValue("objectClass", "inetOrgPerson"));
    assertTrue(preReadEntry.hasAttributeValue("cn", "Test 2"));
    assertTrue(preReadEntry.hasAttributeValue("uid", "test.2"));
    assertFalse(preReadEntry.hasAttributeValue("uid", "test.two"));
    assertTrue(preReadEntry.hasAttributeValue("givenName", "Test"));
    assertTrue(preReadEntry.hasAttributeValue("sn", "2"));
    assertTrue(preReadEntry.hasAttributeValue("userPassword", "password"));
    assertTrue(preReadEntry.hasAttributeValue("description", "bar"));
    assertTrue(preReadEntry.hasAttribute("entryDN"));
    assertTrue(preReadEntry.hasAttribute("entryUUID"));
    assertTrue(preReadEntry.hasAttribute("creatorsName"));
    assertTrue(preReadEntry.hasAttribute("createTimestamp"));
    assertTrue(preReadEntry.hasAttribute("modifiersName"));
    assertTrue(preReadEntry.hasAttribute("modifyTimestamp"));
    assertTrue(preReadEntry.hasAttribute("subschemaSubentry"));
    postReadResponse = PostReadResponseControl.get(modifyDNResult);
    assertNotNull(postReadResponse);
    postReadEntry = postReadResponse.getEntry();
    assertEquals(postReadEntry.getParsedDN(), new DN("uid=test.two,ou=People,dc=example,dc=com"));
    assertTrue(postReadEntry.hasAttributeValue("objectClass", "top"));
    assertTrue(postReadEntry.hasAttributeValue("objectClass", "inetOrgPerson"));
    assertTrue(postReadEntry.hasAttributeValue("cn", "Test 2"));
    assertFalse(postReadEntry.hasAttributeValue("uid", "test.2"));
    assertTrue(postReadEntry.hasAttributeValue("uid", "test.two"));
    assertTrue(postReadEntry.hasAttributeValue("givenName", "Test"));
    assertTrue(postReadEntry.hasAttributeValue("sn", "2"));
    assertTrue(postReadEntry.hasAttributeValue("userPassword", "password"));
    assertTrue(postReadEntry.hasAttributeValue("description", "bar"));
    assertTrue(postReadEntry.hasAttribute("entryDN"));
    assertTrue(postReadEntry.hasAttribute("entryUUID"));
    assertTrue(postReadEntry.hasAttribute("creatorsName"));
    assertTrue(postReadEntry.hasAttribute("createTimestamp"));
    assertTrue(postReadEntry.hasAttribute("modifiersName"));
    assertTrue(postReadEntry.hasAttribute("modifyTimestamp"));
    assertTrue(postReadEntry.hasAttribute("subschemaSubentry"));
    // Test a modify DN with pre-read and post-read controls that should return
    // only a specified set of attributes.
    modifyDNRequest = new ModifyDNRequest("uid=test.3,ou=People,dc=example,dc=com", "uid=test.3", true, "ou=Users,dc=example,dc=com");
    modifyDNRequest.setControls(preReadSpecifiedAttrs, postReadSpecifiedAttrs);
    modifyDNResult = conn.modifyDN(modifyDNRequest);
    assertEquals(modifyDNResult.getResultCode(), ResultCode.SUCCESS);
    preReadResponse = PreReadResponseControl.get(modifyDNResult);
    assertNotNull(preReadResponse);
    preReadEntry = preReadResponse.getEntry();
    assertEquals(preReadEntry.getParsedDN(), new DN("uid=test.3,ou=People,dc=example,dc=com"));
    assertTrue(preReadEntry.hasAttributeValue("objectClass", "top"));
    assertTrue(preReadEntry.hasAttributeValue("objectClass", "inetOrgPerson"));
    assertTrue(preReadEntry.hasAttributeValue("cn", "Test 3"));
    assertFalse(preReadEntry.hasAttribute("uid"));
    assertFalse(preReadEntry.hasAttribute("givenName"));
    assertFalse(preReadEntry.hasAttribute("sn"));
    assertFalse(preReadEntry.hasAttribute("userPassword"));
    assertFalse(preReadEntry.hasAttribute("description"));
    assertFalse(preReadEntry.hasAttribute("entryDN"));
    assertTrue(preReadEntry.hasAttribute("entryUUID"));
    assertFalse(preReadEntry.hasAttribute("creatorsName"));
    assertFalse(preReadEntry.hasAttribute("createTimestamp"));
    assertFalse(preReadEntry.hasAttribute("modifiersName"));
    assertFalse(preReadEntry.hasAttribute("modifyTimestamp"));
    assertFalse(preReadEntry.hasAttribute("subschemaSubentry"));
    postReadResponse = PostReadResponseControl.get(modifyDNResult);
    assertNotNull(postReadResponse);
    postReadEntry = postReadResponse.getEntry();
    assertEquals(postReadEntry.getParsedDN(), new DN("uid=test.3,ou=Users,dc=example,dc=com"));
    assertTrue(postReadEntry.hasAttributeValue("objectClass", "top"));
    assertTrue(postReadEntry.hasAttributeValue("objectClass", "inetOrgPerson"));
    assertTrue(postReadEntry.hasAttributeValue("cn", "Test 3"));
    assertFalse(postReadEntry.hasAttribute("uid"));
    assertFalse(postReadEntry.hasAttribute("givenName"));
    assertFalse(postReadEntry.hasAttribute("sn"));
    assertFalse(postReadEntry.hasAttribute("userPassword"));
    assertFalse(postReadEntry.hasAttribute("description"));
    assertFalse(postReadEntry.hasAttribute("entryDN"));
    assertTrue(postReadEntry.hasAttribute("entryUUID"));
    assertFalse(postReadEntry.hasAttribute("creatorsName"));
    assertFalse(postReadEntry.hasAttribute("createTimestamp"));
    assertFalse(postReadEntry.hasAttribute("modifiersName"));
    assertFalse(postReadEntry.hasAttribute("modifyTimestamp"));
    assertFalse(postReadEntry.hasAttribute("subschemaSubentry"));
    // Test a delete with a pre-read control that should return all user
    // attributes.
    DeleteRequest deleteRequest = new DeleteRequest("cn=Test 1,ou=People,dc=example,dc=com");
    deleteRequest.setControls(preReadUserAttrs);
    LDAPResult deleteResult = conn.delete(deleteRequest);
    assertEquals(deleteResult.getResultCode(), ResultCode.SUCCESS);
    preReadResponse = PreReadResponseControl.get(deleteResult);
    assertNotNull(preReadResponse);
    preReadEntry = preReadResponse.getEntry();
    assertEquals(preReadEntry.getParsedDN(), new DN("cn=Test 1,ou=People,dc=example,dc=com"));
    assertTrue(preReadEntry.hasAttributeValue("objectClass", "top"));
    assertTrue(preReadEntry.hasAttributeValue("objectClass", "inetOrgPerson"));
    assertTrue(preReadEntry.hasAttributeValue("cn", "Test 1"));
    assertTrue(preReadEntry.hasAttributeValue("uid", "test.1"));
    assertTrue(preReadEntry.hasAttributeValue("givenName", "Test"));
    assertTrue(preReadEntry.hasAttributeValue("sn", "1"));
    assertTrue(preReadEntry.hasAttributeValue("userPassword", "password"));
    assertTrue(preReadEntry.hasAttributeValue("description", "bar"));
    assertFalse(preReadEntry.hasAttribute("entryDN"));
    assertFalse(preReadEntry.hasAttribute("entryUUID"));
    assertFalse(preReadEntry.hasAttribute("creatorsName"));
    assertFalse(preReadEntry.hasAttribute("createTimestamp"));
    assertFalse(preReadEntry.hasAttribute("modifiersName"));
    assertFalse(preReadEntry.hasAttribute("modifyTimestamp"));
    assertFalse(preReadEntry.hasAttribute("subschemaSubentry"));
    // Test a delete with a pre-read control that should return all user and
    // operational attributes.
    deleteRequest = new DeleteRequest("uid=test.two,ou=People,dc=example,dc=com");
    deleteRequest.setControls(preReadAllAttrs);
    deleteResult = conn.delete(deleteRequest);
    assertEquals(deleteResult.getResultCode(), ResultCode.SUCCESS);
    preReadResponse = PreReadResponseControl.get(deleteResult);
    assertNotNull(preReadResponse);
    preReadEntry = preReadResponse.getEntry();
    assertEquals(preReadEntry.getParsedDN(), new DN("uid=test.two,ou=People,dc=example,dc=com"));
    assertTrue(preReadEntry.hasAttributeValue("objectClass", "top"));
    assertTrue(preReadEntry.hasAttributeValue("objectClass", "inetOrgPerson"));
    assertTrue(preReadEntry.hasAttributeValue("cn", "Test 2"));
    assertFalse(preReadEntry.hasAttributeValue("uid", "test.2"));
    assertTrue(preReadEntry.hasAttributeValue("uid", "test.two"));
    assertTrue(preReadEntry.hasAttributeValue("givenName", "Test"));
    assertTrue(preReadEntry.hasAttributeValue("sn", "2"));
    assertTrue(preReadEntry.hasAttributeValue("userPassword", "password"));
    assertTrue(preReadEntry.hasAttributeValue("description", "bar"));
    assertTrue(preReadEntry.hasAttribute("entryDN"));
    assertTrue(preReadEntry.hasAttribute("entryUUID"));
    assertTrue(preReadEntry.hasAttribute("creatorsName"));
    assertTrue(preReadEntry.hasAttribute("createTimestamp"));
    assertTrue(preReadEntry.hasAttribute("modifiersName"));
    assertTrue(preReadEntry.hasAttribute("modifyTimestamp"));
    assertTrue(preReadEntry.hasAttribute("subschemaSubentry"));
    // Test a delete with a pre-read control that should return only a specified
    // set of attributes.
    deleteRequest = new DeleteRequest("uid=test.3,ou=Users,dc=example,dc=com");
    deleteRequest.setControls(preReadSpecifiedAttrs);
    deleteResult = conn.delete(deleteRequest);
    assertEquals(deleteResult.getResultCode(), ResultCode.SUCCESS);
    preReadResponse = PreReadResponseControl.get(deleteResult);
    assertNotNull(preReadResponse);
    preReadEntry = preReadResponse.getEntry();
    assertEquals(preReadEntry.getParsedDN(), new DN("uid=test.3,ou=Users,dc=example,dc=com"));
    assertTrue(preReadEntry.hasAttributeValue("objectClass", "top"));
    assertTrue(preReadEntry.hasAttributeValue("objectClass", "inetOrgPerson"));
    assertTrue(preReadEntry.hasAttributeValue("cn", "Test 3"));
    assertFalse(preReadEntry.hasAttribute("uid"));
    assertFalse(preReadEntry.hasAttribute("givenName"));
    assertFalse(preReadEntry.hasAttribute("sn"));
    assertFalse(preReadEntry.hasAttribute("userPassword"));
    assertFalse(preReadEntry.hasAttribute("description"));
    assertFalse(preReadEntry.hasAttribute("entryDN"));
    assertTrue(preReadEntry.hasAttribute("entryUUID"));
    assertFalse(preReadEntry.hasAttribute("creatorsName"));
    assertFalse(preReadEntry.hasAttribute("createTimestamp"));
    assertFalse(preReadEntry.hasAttribute("modifiersName"));
    assertFalse(preReadEntry.hasAttribute("modifyTimestamp"));
    assertFalse(preReadEntry.hasAttribute("subschemaSubentry"));
    conn.close();
}
Also used : Attribute(com.unboundid.ldap.sdk.Attribute) LDAPResult(com.unboundid.ldap.sdk.LDAPResult) DN(com.unboundid.ldap.sdk.DN) LDAPConnection(com.unboundid.ldap.sdk.LDAPConnection) ModifyRequest(com.unboundid.ldap.sdk.ModifyRequest) PreReadRequestControl(com.unboundid.ldap.sdk.controls.PreReadRequestControl) Date(java.util.Date) AddRequest(com.unboundid.ldap.sdk.AddRequest) ModifyDNRequest(com.unboundid.ldap.sdk.ModifyDNRequest) Entry(com.unboundid.ldap.sdk.Entry) SearchResultEntry(com.unboundid.ldap.sdk.SearchResultEntry) PreReadResponseControl(com.unboundid.ldap.sdk.controls.PreReadResponseControl) PostReadResponseControl(com.unboundid.ldap.sdk.controls.PostReadResponseControl) PostReadRequestControl(com.unboundid.ldap.sdk.controls.PostReadRequestControl) DeleteRequest(com.unboundid.ldap.sdk.DeleteRequest) Test(org.testng.annotations.Test)

Aggregations

PostReadRequestControl (com.unboundid.ldap.sdk.controls.PostReadRequestControl)13 Test (org.testng.annotations.Test)9 PreReadRequestControl (com.unboundid.ldap.sdk.controls.PreReadRequestControl)8 PostReadResponseControl (com.unboundid.ldap.sdk.controls.PostReadResponseControl)7 ASN1OctetString (com.unboundid.asn1.ASN1OctetString)6 Control (com.unboundid.ldap.sdk.Control)6 LDAPConnection (com.unboundid.ldap.sdk.LDAPConnection)6 AddRequest (com.unboundid.ldap.sdk.AddRequest)5 ModifyRequest (com.unboundid.ldap.sdk.ModifyRequest)5 AssertionRequestControl (com.unboundid.ldap.sdk.controls.AssertionRequestControl)5 Entry (com.unboundid.ldap.sdk.Entry)4 LDAPResult (com.unboundid.ldap.sdk.LDAPResult)4 PermissiveModifyRequestControl (com.unboundid.ldap.sdk.controls.PermissiveModifyRequestControl)4 LDAPException (com.unboundid.ldap.sdk.LDAPException)3 Modification (com.unboundid.ldap.sdk.Modification)3 ModifyDNRequest (com.unboundid.ldap.sdk.ModifyDNRequest)3 SearchResultEntry (com.unboundid.ldap.sdk.SearchResultEntry)3 PreReadResponseControl (com.unboundid.ldap.sdk.controls.PreReadResponseControl)3 ArrayList (java.util.ArrayList)3 Attribute (com.unboundid.ldap.sdk.Attribute)2