}
public void testWriteFileWithChanges() throws RepositoryException, NotExecutableException {
PathResolver resolver = (SessionImpl) superuser;
FileSystem fs = createFileSystem();
RetentionRegistryImpl re = new RetentionRegistryImpl((SessionImpl) superuser, fs);
String childN3Path = childN3.getPath();
try {
retentionMgr.removeRetentionPolicy(childNPath);
retentionMgr.removeHold(childNPath, retentionMgr.getHolds(childNPath)[0]);
superuser.save();
retentionMgr.setRetentionPolicy(childN3Path, getApplicableRetentionPolicy("retentionOnChild2"));
retentionMgr.addHold(childNPath, "holdOnChild", false);
superuser.save();
// write the changes to the fs
re.close();
// create a new dummy registry again.
re = new RetentionRegistryImpl((SessionImpl) superuser, fs);
// test holds
assertTrue(re.hasEffectiveHold(resolver.getQPath(childNPath), false));
assertTrue(re.hasEffectiveHold(resolver.getQPath(childNPath), true));
assertTrue(re.hasEffectiveHold(resolver.getQPath(childN3Path), true));
assertFalse(re.hasEffectiveHold(resolver.getQPath(childN3Path), false));
assertFalse(re.hasEffectiveHold(resolver.getQPath(childN3Path + "/child"), false));
assertFalse(re.hasEffectiveHold(resolver.getQPath(childN3Path + "/child"), true));
// test policies
assertTrue(re.hasEffectiveRetention(resolver.getQPath(childN3Path), false));
assertTrue(re.hasEffectiveRetention(resolver.getQPath(childN3Path + "/child"), true));
assertFalse(re.hasEffectiveRetention(resolver.getQPath(childN3Path + "/child/more"), true));
assertFalse(re.hasEffectiveRetention(resolver.getQPath(childNPath), true));
assertFalse(re.hasEffectiveRetention(resolver.getQPath(childNPath), false));
} finally {
re.close();
// remove the extra policy that is not cleared upon teardown
if (retentionMgr.getRetentionPolicy(childN3Path) != null) {
retentionMgr.removeRetentionPolicy(childN3.getPath());
}
superuser.save();