@Test
public void testWritePrivileges_defaults() throws Exception {

    final File tempDir = new File(testBaseDir, "testWritePrivileges_defaults");
    final File fromRepoDir = new File(tempDir, "fromRepo/segmentstore");
    final File toRepoDir = new File(tempDir, "toRepo/segmentstore");
    final File exportedXml = new File(tempDir, "exported.xml");
    TestUtil.prepareRepo(fromRepoDir, session -> {
        final URL aemPrivileges = getClass().getResource("/aem_privileges.xml");
        TestUtil.installPrivilegesFromURL(session, aemPrivileges);
    });
    if (exportedXml.exists()) {
        exportedXml.delete();
    }
    TestUtil.withReadOnlyFixture(fromRepoDir, session -> {
        final Workspace workspace = session.getWorkspace();
        final PrivilegeManager privilegeManager = ((JackrabbitWorkspace) workspace).getPrivilegeManager();
        assertNotNull("crx:replicate should be imported",
                privilegeManager.getPrivilege("crx:replicate"));
        assertNotNull("cq:storeUGC should be imported",
                privilegeManager.getPrivilege("cq:storeUGC"));
        PrivilegeXmlExporter.writePrivileges(() -> new OutputStreamWriter(
                        new FileOutputStream(exportedXml)),
                session, null, true);
    });
    TestUtil.prepareRepo(toRepoDir, session -> {
        final URL exportedUrl = exportedXml.toURL();
        resultNothing1((URL url) -> TestUtil.installPrivilegesWithIndivResults(session, url)).apply(exportedUrl);
    });
    TestUtil.withReadOnlyFixture(toRepoDir, session -> {
        final Workspace workspace = session.getWorkspace();
        final PrivilegeManager privilegeManager = ((JackrabbitWorkspace) workspace).getPrivilegeManager();
        assertNotNull("crx:replicate should be imported",
                privilegeManager.getPrivilege("crx:replicate"));
    });
}