@Test
public void testWriteNodetypesByName() throws Exception {

    final File tempDir = new File(testBaseDir, "testWriteNodetypesByName");
    final File fromRepoDir = new File(tempDir, "fromRepo/segmentstore");
    final File toRepoDir = new File(tempDir, "toRepo/segmentstore");
    final File exportedCnd = new File(tempDir, "exported.cnd");
    TestUtil.prepareRepo(fromRepoDir, session -> {
        final URL slingNodetypes = getClass().getResource("/sling_nodetypes.cnd");
        TestUtil.installCndFromURL(session, slingNodetypes);
    });
    if (exportedCnd.exists()) {
        exportedCnd.delete();
    }
    TestUtil.withReadOnlyFixture(fromRepoDir, session -> {
        final Workspace workspace = session.getWorkspace();
        NodeTypeManager ntManager = workspace.getNodeTypeManager();
        assertTrue("sling:Folder should be imported",
                ntManager.hasNodeType("sling:Folder"));
        assertTrue("sling:OrderedFolder should be imported",
                ntManager.hasNodeType("sling:OrderedFolder"));
        new CndExporter.Builder().build()
                .writeNodetypes(exportedCnd, session, Collections.singletonList("sling:Folder"));
    });
    TestUtil.prepareRepo(toRepoDir, session -> {
        final URL exportedUrl = exportedCnd.toURL();
        TestUtil.installCndFromURL(session, exportedUrl);
    });
    TestUtil.withReadOnlyFixture(toRepoDir, session -> {
        final Workspace workspace = session.getWorkspace();
        NodeTypeManager ntManager = workspace.getNodeTypeManager();
        assertTrue("sling:Folder should be imported",
                ntManager.hasNodeType("sling:Folder"));
        assertFalse("sling:OrderedFolder should NOT be imported",
                ntManager.hasNodeType("sling:OrderedFolder"));
    });
}