Search in sources :

Example 1 with ChangeLogEntry

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

the class InMemoryRequestHandler method addDeleteChangeLogEntry.

/**
 * Creates a changelog entry from the information in the provided delete
 * request and adds it to the server changelog.
 *
 * @param  e        The entry to be deleted.
 * @param  authzDN  The authorization DN for the change.
 */
private void addDeleteChangeLogEntry(@NotNull final Entry e, @NotNull final DN authzDN) {
    // If the changelog is disabled, then don't do anything.
    if (maxChangelogEntries <= 0) {
        return;
    }
    final long changeNumber = lastChangeNumber.incrementAndGet();
    final LDIFDeleteChangeRecord changeRecord = new LDIFDeleteChangeRecord(e.getDN());
    // Create the changelog entry.
    try {
        final ChangeLogEntry cle = ChangeLogEntry.constructChangeLogEntry(changeNumber, changeRecord);
        // Add a set of deleted entry attributes, which is simply an LDIF-encoded
        // representation of the entry, excluding the first line since it contains
        // the DN.
        final StringBuilder deletedEntryAttrsBuffer = new StringBuilder();
        final String[] ldifLines = e.toLDIF(0);
        for (int i = 1; i < ldifLines.length; i++) {
            deletedEntryAttrsBuffer.append(ldifLines[i]);
            deletedEntryAttrsBuffer.append(StaticUtils.EOL);
        }
        final Entry copy = cle.duplicate();
        copy.addAttribute(ChangeLogEntry.ATTR_DELETED_ENTRY_ATTRS, deletedEntryAttrsBuffer.toString());
        addChangeLogEntry(new ChangeLogEntry(copy), authzDN);
    } catch (final LDAPException le) {
        // This should never happen.
        Debug.debugException(le);
    }
}
Also used : ChangeLogEntry(com.unboundid.ldap.sdk.ChangeLogEntry) SearchResultEntry(com.unboundid.ldap.sdk.SearchResultEntry) Entry(com.unboundid.ldap.sdk.Entry) ReadOnlyEntry(com.unboundid.ldap.sdk.ReadOnlyEntry) LDAPException(com.unboundid.ldap.sdk.LDAPException) ChangeLogEntry(com.unboundid.ldap.sdk.ChangeLogEntry) ASN1OctetString(com.unboundid.asn1.ASN1OctetString) LDIFDeleteChangeRecord(com.unboundid.ldif.LDIFDeleteChangeRecord)

Example 2 with ChangeLogEntry

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

the class ChangelogEntryIntermediateResponseTestCase method testEntryResponseWithUnboundIDChangelogEntry.

/**
 * Provides generic coverage for a changelog entry intermediate response.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testEntryResponseWithUnboundIDChangelogEntry() throws Exception {
    final StringBuilder changes = new StringBuilder();
    changes.append("objectClass: top").append(StaticUtils.EOL);
    changes.append("objectClass: domain").append(StaticUtils.EOL);
    changes.append("dc: example").append(StaticUtils.EOL);
    final ChangeLogEntry e = new UnboundIDChangeLogEntry(new Entry("dn: changeNumber=1,cn=changelog", "objectClass: top", "objectClass: changeLogEntry", "changeNumber: 1", "targetDN: dc=example,dc=com", "changeType: add", "changes:: " + Base64.encode(changes.toString())));
    final String serverID = CryptoHelper.getRandomUUID().toString();
    final ASN1OctetString resumeToken = new ASN1OctetString("foo");
    ChangelogEntryIntermediateResponse ir = new ChangelogEntryIntermediateResponse(e, serverID, resumeToken, new Control("1.2.3.4"), new Control("5.6.7.8"));
    ir = new ChangelogEntryIntermediateResponse(ir);
    assertNotNull(ir);
    assertNotNull(ir.getChangeLogEntry());
    assertEquals(ir.getChangeLogEntry(), e);
    assertNotNull(ir.getServerID());
    assertEquals(ir.getServerID(), serverID);
    assertNotNull(ir.getResumeToken());
    assertTrue(Arrays.equals(ir.getResumeToken().getValue(), resumeToken.getValue()));
    assertNotNull(ir.getIntermediateResponseName());
    assertNotNull(ir.valueToString());
    assertNotNull(ir.toString());
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) Entry(com.unboundid.ldap.sdk.Entry) ChangeLogEntry(com.unboundid.ldap.sdk.ChangeLogEntry) UnboundIDChangeLogEntry(com.unboundid.ldap.sdk.unboundidds.UnboundIDChangeLogEntry) Control(com.unboundid.ldap.sdk.Control) UnboundIDChangeLogEntry(com.unboundid.ldap.sdk.unboundidds.UnboundIDChangeLogEntry) ChangeLogEntry(com.unboundid.ldap.sdk.ChangeLogEntry) UnboundIDChangeLogEntry(com.unboundid.ldap.sdk.unboundidds.UnboundIDChangeLogEntry) ASN1OctetString(com.unboundid.asn1.ASN1OctetString) Test(org.testng.annotations.Test)

Example 3 with ChangeLogEntry

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

the class ChangelogEntryIntermediateResponseTestCase method testEntryResponseWithGenericChangelogEntry.

/**
 * Provides generic coverage for a changelog entry intermediate response.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testEntryResponseWithGenericChangelogEntry() throws Exception {
    final StringBuilder changes = new StringBuilder();
    changes.append("objectClass: top").append(StaticUtils.EOL);
    changes.append("objectClass: domain").append(StaticUtils.EOL);
    changes.append("dc: example").append(StaticUtils.EOL);
    final ChangeLogEntry e = new ChangeLogEntry(new Entry("dn: changeNumber=1,cn=changelog", "objectClass: top", "objectClass: changeLogEntry", "changeNumber: 1", "targetDN: dc=example,dc=com", "changeType: add", "changes:: " + Base64.encode(changes.toString())));
    final String serverID = CryptoHelper.getRandomUUID().toString();
    final ASN1OctetString resumeToken = new ASN1OctetString("foo");
    ChangelogEntryIntermediateResponse ir = new ChangelogEntryIntermediateResponse(e, serverID, resumeToken, new Control("1.2.3.4"), new Control("5.6.7.8"));
    ir = new ChangelogEntryIntermediateResponse(ir);
    assertNotNull(ir);
    assertNotNull(ir.getChangeLogEntry());
    assertEquals(ir.getChangeLogEntry(), e);
    assertNotNull(ir.getServerID());
    assertEquals(ir.getServerID(), serverID);
    assertNotNull(ir.getResumeToken());
    assertTrue(Arrays.equals(ir.getResumeToken().getValue(), resumeToken.getValue()));
    assertNotNull(ir.getIntermediateResponseName());
    assertNotNull(ir.valueToString());
    assertNotNull(ir.toString());
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) Entry(com.unboundid.ldap.sdk.Entry) ChangeLogEntry(com.unboundid.ldap.sdk.ChangeLogEntry) UnboundIDChangeLogEntry(com.unboundid.ldap.sdk.unboundidds.UnboundIDChangeLogEntry) Control(com.unboundid.ldap.sdk.Control) ChangeLogEntry(com.unboundid.ldap.sdk.ChangeLogEntry) UnboundIDChangeLogEntry(com.unboundid.ldap.sdk.unboundidds.UnboundIDChangeLogEntry) ASN1OctetString(com.unboundid.asn1.ASN1OctetString) Test(org.testng.annotations.Test)

Example 4 with ChangeLogEntry

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

the class DefaultChangelogEntryListenerTestCase method testHandleChangelogEntry.

/**
 * Provides test coverage for the {@code handleChangelogEntry} method.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testHandleChangelogEntry() throws Exception {
    final StringBuilder changes = new StringBuilder();
    changes.append("objectClass: top").append(StaticUtils.EOL);
    changes.append("objectClass: domain").append(StaticUtils.EOL);
    changes.append("dc: example").append(StaticUtils.EOL);
    final ChangeLogEntry e = new ChangeLogEntry(new Entry("dn: changeNumber=1,cn=changelog", "objectClass: top", "objectClass: changeLogEntry", "changeNumber: 1", "targetDN: dc=example,dc=com", "changeType: add", "changes:: " + Base64.encode(changes.toString())));
    final String serverID = CryptoHelper.getRandomUUID().toString();
    final ASN1OctetString resumeToken = new ASN1OctetString("foo");
    ChangelogEntryIntermediateResponse ir = new ChangelogEntryIntermediateResponse(e, serverID, resumeToken, new Control("1.2.3.4"), new Control("5.6.7.8"));
    ir = new ChangelogEntryIntermediateResponse(ir);
    final GetChangelogBatchExtendedRequest r = new GetChangelogBatchExtendedRequest(new EndOfChangelogStartingPoint(), 100, 300000L);
    final DefaultChangelogEntryListener l = new DefaultChangelogEntryListener(r);
    l.handleChangelogEntry(ir);
    assertNotNull(l.getEntryList());
    assertFalse(l.getEntryList().isEmpty());
    assertEquals(l.getEntryList().size(), 1);
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) Entry(com.unboundid.ldap.sdk.Entry) ChangeLogEntry(com.unboundid.ldap.sdk.ChangeLogEntry) Control(com.unboundid.ldap.sdk.Control) ChangeLogEntry(com.unboundid.ldap.sdk.ChangeLogEntry) ASN1OctetString(com.unboundid.asn1.ASN1OctetString) Test(org.testng.annotations.Test)

Example 5 with ChangeLogEntry

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

the class InMemoryDirectoryServerChangeLogTestCase method testChangeLogOperations.

/**
 * Provides test coverage to ensure that basic operations result in valid
 * changelog entries.
 *
 * @throws  Exception  If an unexpected problem occurs.
 */
@Test()
public void testChangeLogOperations() throws Exception {
    final InMemoryDirectoryServerConfig cfg = new InMemoryDirectoryServerConfig("dc=example,dc=com");
    cfg.setMaxChangeLogEntries(5);
    final InMemoryDirectoryServer ds = new InMemoryDirectoryServer(cfg);
    ds.startListening();
    final LDAPConnection conn = ds.getConnection();
    try {
        // Test the directory server methods used for counting entries.
        assertEquals(ds.countEntries(), 0);
        assertEquals(ds.countEntries(false), 0);
        assertEquals(ds.countEntries(true), 1);
        assertEquals(ds.countEntriesBelow("dc=example,dc=com"), 0);
        assertEquals(ds.countEntriesBelow("cn=changelog"), 1);
        assertEquals(ds.countEntriesBelow("changeNumber=1,cn=changelog"), 0);
        // Ensure that the changelog attributes are present in the root DSE.
        assertValueExists(conn, "", "changeLog", "cn=changelog");
        assertValueExists(conn, "", "firstChangeNumber", "0");
        assertValueExists(conn, "", "lastChangeNumber", "0");
        // Ensure that the changelog base entry exists.
        assertEntryExists(conn, "cn=changelog");
        // Add an entry to the server and verify that a changelog entry is created
        // for it.
        conn.add(generateDomainEntry("example", "dc=com"));
        assertValueExists(conn, "", "changeLog", "cn=changelog");
        assertValueExists(conn, "", "firstChangeNumber", "1");
        assertValueExists(conn, "", "lastChangeNumber", "1");
        assertEntryExists(conn, "cn=changelog");
        assertEntryExists(conn, "changeNumber=1,cn=changelog");
        assertAttributeExists(conn, "changeNumber=1,cn=changelog", "entryDN", "entryUUID", "creatorsName", "createTimestamp", "modifiersName", "modifyTimestamp", "subschemaSubentry");
        ChangeLogEntry changeLogEntry = new ChangeLogEntry(conn.getEntry("changeNumber=1,cn=changelog"));
        assertNotNull(changeLogEntry);
        assertEquals(changeLogEntry.getChangeNumber(), 1L);
        assertEquals(new DN(changeLogEntry.getTargetDN()), new DN("dc=example,dc=com"));
        assertEquals(changeLogEntry.getChangeType(), ChangeType.ADD);
        assertNotNull(changeLogEntry.getAddAttributes());
        assertTrue(changeLogEntry.getAddAttributes().contains(new Attribute("objectClass", "top", "domain")));
        assertTrue(changeLogEntry.getAddAttributes().contains(new Attribute("dc", "example")));
        // Add a second entry to the server and verify that a changelog entry is
        // created for it as well.
        conn.add(generateOrgUnitEntry("People", "dc=example,dc=com"));
        assertValueExists(conn, "", "changeLog", "cn=changelog");
        assertValueExists(conn, "", "firstChangeNumber", "1");
        assertValueExists(conn, "", "lastChangeNumber", "2");
        assertEntryExists(conn, "cn=changelog");
        assertEntryExists(conn, "changeNumber=1,cn=changelog");
        assertEntryExists(conn, "changeNumber=2,cn=changelog");
        assertAttributeExists(conn, "changeNumber=2,cn=changelog", "entryDN", "entryUUID", "creatorsName", "createTimestamp", "modifiersName", "modifyTimestamp", "subschemaSubentry");
        changeLogEntry = new ChangeLogEntry(conn.getEntry("changeNumber=2,cn=changelog"));
        assertNotNull(changeLogEntry);
        assertEquals(changeLogEntry.getChangeNumber(), 2L);
        assertEquals(new DN(changeLogEntry.getTargetDN()), new DN("ou=People,dc=example,dc=com"));
        assertEquals(changeLogEntry.getChangeType(), ChangeType.ADD);
        assertNotNull(changeLogEntry.getAddAttributes());
        assertTrue(changeLogEntry.getAddAttributes().contains(new Attribute("objectClass", "top", "organizationalUnit")));
        assertTrue(changeLogEntry.getAddAttributes().contains(new Attribute("ou", "People")));
        // Add a third entry to the server and verify that a changelog entry is
        // created for it as well.
        conn.add(generateUserEntry("test.user", "ou=People,dc=example,dc=com", "Test", "User", "password"));
        assertValueExists(conn, "", "changeLog", "cn=changelog");
        assertValueExists(conn, "", "firstChangeNumber", "1");
        assertValueExists(conn, "", "lastChangeNumber", "3");
        assertEntryExists(conn, "cn=changelog");
        assertEntryExists(conn, "changeNumber=1,cn=changelog");
        assertEntryExists(conn, "changeNumber=2,cn=changelog");
        assertEntryExists(conn, "changeNumber=3,cn=changelog");
        assertAttributeExists(conn, "changeNumber=3,cn=changelog", "entryDN", "entryUUID", "creatorsName", "createTimestamp", "modifiersName", "modifyTimestamp", "subschemaSubentry");
        changeLogEntry = new ChangeLogEntry(conn.getEntry("changeNumber=3,cn=changelog"));
        assertNotNull(changeLogEntry);
        assertEquals(changeLogEntry.getChangeNumber(), 3L);
        assertEquals(new DN(changeLogEntry.getTargetDN()), new DN("uid=test.user,ou=People,dc=example,dc=com"));
        assertEquals(changeLogEntry.getChangeType(), ChangeType.ADD);
        assertNotNull(changeLogEntry.getAddAttributes());
        assertTrue(changeLogEntry.getAddAttributes().contains(new Attribute("objectClass", "top", "person", "organizationalPerson", "inetOrgPerson")));
        assertTrue(changeLogEntry.getAddAttributes().contains(new Attribute("uid", "test.user")));
        assertTrue(changeLogEntry.getAddAttributes().contains(new Attribute("givenName", "Test")));
        assertTrue(changeLogEntry.getAddAttributes().contains(new Attribute("sn", "User")));
        assertTrue(changeLogEntry.getAddAttributes().contains(new Attribute("cn", "Test User")));
        assertTrue(changeLogEntry.getAddAttributes().contains(new Attribute("userPassword", "password")));
        // Modify the user entry and verify that a changelog record is created
        // for it.
        conn.modify("dn: uid=test.user,ou=People,dc=example,dc=com", "changetype: modify", "replace: description", "description: foo");
        assertValueExists(conn, "", "changeLog", "cn=changelog");
        assertValueExists(conn, "", "firstChangeNumber", "1");
        assertValueExists(conn, "", "lastChangeNumber", "4");
        assertEntryExists(conn, "cn=changelog");
        assertEntryExists(conn, "changeNumber=1,cn=changelog");
        assertEntryExists(conn, "changeNumber=2,cn=changelog");
        assertEntryExists(conn, "changeNumber=3,cn=changelog");
        assertEntryExists(conn, "changeNumber=4,cn=changelog");
        assertAttributeExists(conn, "changeNumber=4,cn=changelog", "entryDN", "entryUUID", "creatorsName", "createTimestamp", "modifiersName", "modifyTimestamp", "subschemaSubentry");
        changeLogEntry = new ChangeLogEntry(conn.getEntry("changeNumber=4,cn=changelog"));
        assertNotNull(changeLogEntry);
        assertEquals(changeLogEntry.getChangeNumber(), 4L);
        assertEquals(new DN(changeLogEntry.getTargetDN()), new DN("uid=test.user,ou=People,dc=example,dc=com"));
        assertEquals(changeLogEntry.getChangeType(), ChangeType.MODIFY);
        assertNull(changeLogEntry.getAddAttributes());
        assertNotNull(changeLogEntry.getModifications());
        assertTrue(changeLogEntry.getModifications().contains(new Modification(ModificationType.REPLACE, "description", "foo")));
        // Test the directory server methods used for counting entries.
        assertEquals(ds.countEntries(), 3);
        assertEquals(ds.countEntries(false), 3);
        assertEquals(ds.countEntries(true), 8);
        assertEquals(ds.countEntriesBelow("dc=example,dc=com"), 3);
        assertEquals(ds.countEntriesBelow("ou=People,dc=example,dc=com"), 2);
        assertEquals(ds.countEntriesBelow("uid=test.user,ou=People,dc=example,dc=com"), 1);
        assertEquals(ds.countEntriesBelow("cn=missing,dc=example,dc=com"), 0);
        assertEquals(ds.countEntriesBelow("cn=changelog"), 5);
        assertEquals(ds.countEntriesBelow("changeNumber=1,cn=changelog"), 1);
        assertEquals(ds.countEntriesBelow("changeNumber=5,cn=changelog"), 0);
        // Rename the organizationalUnit entry and verify that another changelog
        // record was created for it.  In this case, only one changelog entry
        // should be created even though two entries are impacted.
        conn.modifyDN("ou=People,dc=example,dc=com", "ou=Users", true);
        assertValueExists(conn, "", "changeLog", "cn=changelog");
        assertValueExists(conn, "", "firstChangeNumber", "1");
        assertValueExists(conn, "", "lastChangeNumber", "5");
        assertEntryExists(conn, "cn=changelog");
        assertEntryExists(conn, "changeNumber=1,cn=changelog");
        assertEntryExists(conn, "changeNumber=2,cn=changelog");
        assertEntryExists(conn, "changeNumber=3,cn=changelog");
        assertEntryExists(conn, "changeNumber=4,cn=changelog");
        assertEntryExists(conn, "changeNumber=5,cn=changelog");
        assertAttributeExists(conn, "changeNumber=5,cn=changelog", "entryDN", "entryUUID", "creatorsName", "createTimestamp", "modifiersName", "modifyTimestamp", "subschemaSubentry");
        changeLogEntry = new ChangeLogEntry(conn.getEntry("changeNumber=5,cn=changelog"));
        assertNotNull(changeLogEntry);
        assertEquals(changeLogEntry.getChangeNumber(), 5L);
        assertEquals(new DN(changeLogEntry.getTargetDN()), new DN("ou=People,dc=example,dc=com"));
        assertEquals(changeLogEntry.getChangeType(), ChangeType.MODIFY_DN);
        assertNull(changeLogEntry.getAddAttributes());
        assertNull(changeLogEntry.getModifications());
        assertEquals(new RDN(changeLogEntry.getNewRDN()), new RDN("ou=Users"));
        assertTrue(changeLogEntry.deleteOldRDN());
        assertEquals(new DN(changeLogEntry.getNewDN()), new DN("ou=Users,dc=example,dc=com"));
        // Delete the user entry and verify that a changelog entry was created
        // for the delete.  At this point, we have hit the changelog entry limit
        // and an old entry should have been removed.
        conn.delete("uid=test.user,ou=Users,dc=example,dc=com");
        assertValueExists(conn, "", "changeLog", "cn=changelog");
        assertValueExists(conn, "", "firstChangeNumber", "2");
        assertValueExists(conn, "", "lastChangeNumber", "6");
        assertEntryExists(conn, "cn=changelog");
        assertEntryMissing(conn, "changeNumber=1,cn=changelog");
        assertEntryExists(conn, "changeNumber=2,cn=changelog");
        assertEntryExists(conn, "changeNumber=3,cn=changelog");
        assertEntryExists(conn, "changeNumber=4,cn=changelog");
        assertEntryExists(conn, "changeNumber=5,cn=changelog");
        assertEntryExists(conn, "changeNumber=6,cn=changelog");
        assertAttributeExists(conn, "changeNumber=6,cn=changelog", "entryDN", "entryUUID", "creatorsName", "createTimestamp", "modifiersName", "modifyTimestamp", "subschemaSubentry");
        changeLogEntry = new ChangeLogEntry(conn.getEntry("changeNumber=6,cn=changelog"));
        assertNotNull(changeLogEntry);
        assertEquals(changeLogEntry.getChangeNumber(), 6L);
        assertEquals(new DN(changeLogEntry.getTargetDN()), new DN("uid=test.user,ou=Users,dc=example,dc=com"));
        assertEquals(changeLogEntry.getChangeType(), ChangeType.DELETE);
        assertNull(changeLogEntry.getAddAttributes());
        assertNull(changeLogEntry.getModifications());
        assertNotNull(changeLogEntry.getDeletedEntryAttributes());
        assertTrue(changeLogEntry.getDeletedEntryAttributes().contains(new Attribute("objectClass", "top", "person", "organizationalPerson", "inetOrgPerson")));
        assertTrue(changeLogEntry.getDeletedEntryAttributes().contains(new Attribute("uid", "test.user")));
        assertTrue(changeLogEntry.getDeletedEntryAttributes().contains(new Attribute("givenName", "Test")));
        assertTrue(changeLogEntry.getDeletedEntryAttributes().contains(new Attribute("sn", "User")));
        assertTrue(changeLogEntry.getDeletedEntryAttributes().contains(new Attribute("cn", "Test User")));
        assertTrue(changeLogEntry.getDeletedEntryAttributes().contains(new Attribute("userPassword", "password")));
        // Perform a subtree delete from the base and verify that two new
        // changelog entries are created (one for each entry removed, in
        // descending hierarchical order).
        final DeleteRequest deleteRequest = new DeleteRequest("dc=example,dc=com");
        deleteRequest.addControl(new SubtreeDeleteRequestControl());
        conn.delete(deleteRequest);
        assertValueExists(conn, "", "changeLog", "cn=changelog");
        assertValueExists(conn, "", "firstChangeNumber", "4");
        assertValueExists(conn, "", "lastChangeNumber", "8");
        assertEntryExists(conn, "cn=changelog");
        assertEntryMissing(conn, "changeNumber=1,cn=changelog");
        assertEntryMissing(conn, "changeNumber=2,cn=changelog");
        assertEntryMissing(conn, "changeNumber=3,cn=changelog");
        assertEntryExists(conn, "changeNumber=4,cn=changelog");
        assertEntryExists(conn, "changeNumber=5,cn=changelog");
        assertEntryExists(conn, "changeNumber=6,cn=changelog");
        assertEntryExists(conn, "changeNumber=7,cn=changelog");
        assertEntryExists(conn, "changeNumber=8,cn=changelog");
        assertAttributeExists(conn, "changeNumber=7,cn=changelog", "entryDN", "entryUUID", "creatorsName", "createTimestamp", "modifiersName", "modifyTimestamp", "subschemaSubentry");
        changeLogEntry = new ChangeLogEntry(conn.getEntry("changeNumber=7,cn=changelog"));
        assertNotNull(changeLogEntry);
        assertEquals(changeLogEntry.getChangeNumber(), 7L);
        assertEquals(new DN(changeLogEntry.getTargetDN()), new DN("ou=Users,dc=example,dc=com"));
        assertEquals(changeLogEntry.getChangeType(), ChangeType.DELETE);
        assertNull(changeLogEntry.getAddAttributes());
        assertNull(changeLogEntry.getModifications());
        assertNotNull(changeLogEntry.getDeletedEntryAttributes());
        assertTrue(changeLogEntry.getDeletedEntryAttributes().contains(new Attribute("objectClass", "top", "organizationalUnit")));
        assertTrue(changeLogEntry.getDeletedEntryAttributes().contains(new Attribute("ou", "Users")));
        assertAttributeExists(conn, "changeNumber=8,cn=changelog", "entryDN", "entryUUID", "creatorsName", "createTimestamp", "modifiersName", "modifyTimestamp", "subschemaSubentry");
        changeLogEntry = new ChangeLogEntry(conn.getEntry("changeNumber=8,cn=changelog"));
        assertNotNull(changeLogEntry);
        assertEquals(changeLogEntry.getChangeNumber(), 8L);
        assertEquals(new DN(changeLogEntry.getTargetDN()), new DN("dc=example,dc=com"));
        assertEquals(changeLogEntry.getChangeType(), ChangeType.DELETE);
        assertNull(changeLogEntry.getAddAttributes());
        assertNull(changeLogEntry.getModifications());
        assertNotNull(changeLogEntry.getDeletedEntryAttributes());
        assertTrue(changeLogEntry.getDeletedEntryAttributes().contains(new Attribute("objectClass", "top", "domain")));
        assertTrue(changeLogEntry.getDeletedEntryAttributes().contains(new Attribute("dc", "example")));
    } finally {
        conn.close();
        ds.shutDown(true);
    }
}
Also used : Modification(com.unboundid.ldap.sdk.Modification) Attribute(com.unboundid.ldap.sdk.Attribute) ChangeLogEntry(com.unboundid.ldap.sdk.ChangeLogEntry) RDN(com.unboundid.ldap.sdk.RDN) DN(com.unboundid.ldap.sdk.DN) LDAPConnection(com.unboundid.ldap.sdk.LDAPConnection) RDN(com.unboundid.ldap.sdk.RDN) DeleteRequest(com.unboundid.ldap.sdk.DeleteRequest) SubtreeDeleteRequestControl(com.unboundid.ldap.sdk.controls.SubtreeDeleteRequestControl) Test(org.testng.annotations.Test)

Aggregations

ChangeLogEntry (com.unboundid.ldap.sdk.ChangeLogEntry)21 Entry (com.unboundid.ldap.sdk.Entry)20 Test (org.testng.annotations.Test)19 DN (com.unboundid.ldap.sdk.DN)13 RDN (com.unboundid.ldap.sdk.RDN)13 Attribute (com.unboundid.ldap.sdk.Attribute)11 ASN1OctetString (com.unboundid.asn1.ASN1OctetString)7 Control (com.unboundid.ldap.sdk.Control)6 Modification (com.unboundid.ldap.sdk.Modification)6 LDIFModifyChangeRecord (com.unboundid.ldif.LDIFModifyChangeRecord)5 LDIFDeleteChangeRecord (com.unboundid.ldif.LDIFDeleteChangeRecord)3 LDAPResult (com.unboundid.ldap.sdk.LDAPResult)2 ReadOnlyEntry (com.unboundid.ldap.sdk.ReadOnlyEntry)2 SearchResultEntry (com.unboundid.ldap.sdk.SearchResultEntry)2 UnboundIDChangeLogEntry (com.unboundid.ldap.sdk.unboundidds.UnboundIDChangeLogEntry)2 LDIFAddChangeRecord (com.unboundid.ldif.LDIFAddChangeRecord)2 LDIFModifyDNChangeRecord (com.unboundid.ldif.LDIFModifyDNChangeRecord)2 DeleteRequest (com.unboundid.ldap.sdk.DeleteRequest)1 LDAPConnection (com.unboundid.ldap.sdk.LDAPConnection)1 LDAPException (com.unboundid.ldap.sdk.LDAPException)1