@Test
public void testWithExisting() throws Exception {

    final File targetFile = new File(testOutDir, "testWithExisting.xml");
    final File writeBack = new File(testOutDir, "testWithExisting_writeback");
    if (targetFile.exists()) {
        targetFile.delete();
    }
    if (writeBack.exists()) {
        FileUtils.deleteDirectory(writeBack);
    }
    OakMachine.Builder builder = TestUtil.fromPlan(obj()
            .key("jcrNamespaces", arr(JcrNs.create("foo", "http://adamcin.net/foo")))
            .key("jcrPrivileges", arr("foo:canBar"))
            .get());
    WebsterPrivilegesTarget target = new WebsterPrivilegesTarget(targetFile);
    target.setArchive(new FileArchive(new File("src/test/resources/filevault/onePrivRef")), writeBack);
    builder.build().initAndInspect(target::perform);
    assertFileNotContains(targetFile, "<privileges/>");
    assertFileContains(targetFile, "name=\"foo:canBar\"");
    OakMachine.Builder builderWithAbstract = TestUtil.fromPlan(obj()
            .key("jcrNamespaces", arr(JcrNs.create("foo", "http://adamcin.net/foo")))
            .key("jcrPrivileges", key("foo:canBar", key("abstract", true)))
            .get());
    WebsterPrivilegesTarget targetWithAbstract = new WebsterPrivilegesTarget(targetFile);
    targetWithAbstract.setArchive(new FileArchive(new File("src/test/resources/filevault/onePrivRef")), writeBack);
    builderWithAbstract.build().initAndInspect(targetWithAbstract::perform);
    assertFileNotContains(targetFile, "<privileges/>");
    assertFileContains(targetFile, "name=\"foo:canBar\"");
    assertFileContains(targetFile, "abstract=\"true\"");
}