// Read the entry back to get its history operational attribute.
DN dn = DN.decode("uid=user.1," + TEST_ROOT_DN_STRING);
Entry entry = DirectoryServer.getEntry(dn);
List<Attribute> attrs = EntryHistorical.getHistoricalAttr(entry);
Attribute before = attrs.get(0);
// Check that encoding and decoding preserves the history information.
EntryHistorical hist = EntryHistorical.newInstanceFromEntry(entry);
Attribute after = hist.encodeAndPurge();
assertEquals(hist.getLastPurgedValuesCount(),0);
assertEquals(after, before);
LDAPReplicationDomain domain = MultimasterReplication.findDomain(
DN.decode("uid=user.1," + TEST_ROOT_DN_STRING), null);
Thread.sleep(1000);
args[9] = TestCaseUtils.createTempFile(
"dn: uid=user.1," + TEST_ROOT_DN_STRING,
"changetype: modify",
"replace: displayName",
"displayName: 3",
"-"
);
assertEquals(LDAPModify.mainModify(args, false, null, System.err), 0);
long testPurgeDelayInMillisec = 1000; // 1 sec
// Read the entry back to get its history operational attribute.
entry = DirectoryServer.getEntry(dn);
hist = EntryHistorical.newInstanceFromEntry(entry);
hist.setPurgeDelay(testPurgeDelayInMillisec);
after = hist.encodeAndPurge();
// The purge time is not done so the hist attribute should be not empty
assertTrue(!after.isEmpty());
// Now wait for the purge time to be done
Thread.sleep(testPurgeDelayInMillisec + 200);
// Read the entry back to get its history operational attribute.
// The hist attribute should now be empty since purged
entry = DirectoryServer.getEntry(dn);
hist = EntryHistorical.newInstanceFromEntry(entry);
hist.setPurgeDelay(testPurgeDelayInMillisec);
after = hist.encodeAndPurge();
assertTrue(after.isEmpty());
assertEquals(hist.getLastPurgedValuesCount(),11);
}