@Test
public void testWriteNodetypesWithBuiltins() throws Exception {

    final File tempDir = new File(testBaseDir, "testWriteNodetypesWithBuiltins");
    final File fromRepoDir = new File(tempDir, "fromRepo/segmentstore");
    final File explicitTypesCnd = new File(tempDir, "explicitTypes.cnd");
    final File allTypesCnd = new File(tempDir, "allTypes.cnd");
    TestUtil.prepareRepo(fromRepoDir, session -> {
        final URL slingNodetypes = getClass().getResource("/sling_nodetypes.cnd");
        TestUtil.installCndFromURL(session, slingNodetypes);
    });
    if (explicitTypesCnd.exists()) {
        explicitTypesCnd.delete();
    }
    if (allTypesCnd.exists()) {
        allTypesCnd.delete();
    }
    TestUtil.withReadOnlyFixture(fromRepoDir, session -> {
        new CndExporter.Builder().withIncludeBuiltins(true).build()
                .writeNodetypes(explicitTypesCnd, session, Arrays.asList("sling:Folder", "nt:folder"));
        try (Scanner scanner = new Scanner(explicitTypesCnd, StandardCharsets.UTF_8.name())) {
            assertNull("nt:query should not be defined", scanner.findWithinHorizon("\\[nt:query]", 0));
        }
        try (Scanner scanner = new Scanner(explicitTypesCnd, StandardCharsets.UTF_8.name())) {
            assertNull("sling:OrderedFolder should not be defined", scanner.findWithinHorizon("\\[sling:OrderedFolder]", 0));
        }
        try (Scanner scanner = new Scanner(explicitTypesCnd, StandardCharsets.UTF_8.name())) {
            assertNotNull("nt:folder should be defined", scanner.findWithinHorizon("\\[nt:folder]", 0));
        }
        try (Scanner scanner = new Scanner(explicitTypesCnd, StandardCharsets.UTF_8.name())) {
            assertNotNull("sling:Folder should be defined", scanner.findWithinHorizon("\\[sling:Folder]", 0));
        }
    });
}