public void testImportCheckinNodes()

in src/main/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/post/PostServletImportTest.java [241:302]


    public void testImportCheckinNodes() throws IOException, JsonException {
        final String testPath = TEST_BASE_PATH;
        Map<String, String> props = new HashMap<String, String>();
        String testNode = testClient.createNode(HTTP_BASE_URL + testPath, props);
        urlsToDelete.add(testNode);

        props.clear();
        props.put(SlingPostConstants.RP_OPERATION, SlingPostConstants.OPERATION_IMPORT);

        String testNodeName = "testNode_" + String.valueOf(random.nextInt());
        props.put(SlingPostConstants.RP_NODE_NAME_HINT, testNodeName);
        testFile = getTestFile(getClass().getResourceAsStream("/integration-test/servlets/post/testimport3.json"));
        props.put(SlingPostConstants.RP_CONTENT_TYPE, "json");
        props.put(SlingPostConstants.RP_REDIRECT_TO, SERVLET_CONTEXT + testPath + "/*");
        props.put(SlingPostConstants.RP_CHECKIN, "true");
        String importedNodeUrl = testClient.createNode(
                HTTP_BASE_URL + testPath,
                new NameValuePairList(props),
                null,
                true,
                testFile,
                SlingPostConstants.RP_CONTENT_FILE,
                null);

        // assert content at new location
        String content = getContent(importedNodeUrl + ".json", CONTENT_TYPE_JSON);

        JsonObject jsonObj = JsonUtil.parseObject(content);
        assertNotNull(jsonObj);

        // assert that the versionable node is checked in.
        assertFalse(jsonObj.getBoolean("jcr:isCheckedOut"));

        // now try with the checkin value set to false
        testFile.delete();
        props.clear();
        props.put(SlingPostConstants.RP_OPERATION, SlingPostConstants.OPERATION_IMPORT);

        String testNodeName2 = "testNode_" + String.valueOf(random.nextInt());
        props.put(SlingPostConstants.RP_NODE_NAME_HINT, testNodeName2);
        testFile = getTestFile(getClass().getResourceAsStream("/integration-test/servlets/post/testimport3.json"));
        props.put(SlingPostConstants.RP_CONTENT_TYPE, "json");
        props.put(SlingPostConstants.RP_REDIRECT_TO, SERVLET_CONTEXT + testPath + "/*");
        props.put(SlingPostConstants.RP_CHECKIN, "false");
        String importedNodeUrl2 = testClient.createNode(
                HTTP_BASE_URL + testPath,
                new NameValuePairList(props),
                null,
                true,
                testFile,
                SlingPostConstants.RP_CONTENT_FILE,
                null);

        // assert content at new location
        String content2 = getContent(importedNodeUrl2 + ".json", CONTENT_TYPE_JSON);

        JsonObject jsonObj2 = JsonUtil.parseObject(content2);
        assertNotNull(jsonObj2);

        // assert that the versionable node is checked in.
        assertTrue(jsonObj2.getBoolean("jcr:isCheckedOut"));
    }