private void testSpecificNodeType()

in src/main/java/org/apache/sling/launchpad/webapp/integrationtest/NodeTypeBasedRenderingTest.java [49:82]


    private void testSpecificNodeType(String nodeType, String ... moreProperties) throws IOException {
        // Create test node of specified type
        testClient.mkdirs(HTTP_BASE_URL, TEST_PATH);
        final Map<String, String> props = new HashMap<String, String>();
        props.put("jcr:primaryType", nodeType);
        
        if(moreProperties != null) {
            for(int i=0; i < moreProperties.length; i+=2) {
                props.put(moreProperties[i], moreProperties[i+1]);
            }
        }
        
        final String testNodePath = TEST_PATH + "/test_" + counter.incrementAndGet();
        testNodeUrl = testClient.createNode(HTTP_BASE_URL + testNodePath, props);
        toDelete.add(testNodeUrl);
        
        {
            // No script -> default rendering
            final String content = getContent(testNodeUrl + ".html", CONTENT_TYPE_HTML);
            assertContains(content, "dumped by HtmlRenderer");
        }
        
        {
            // With script -> custom rendering based on mapping of JCR
            // node type to Sling resource type
            final String scriptPath = "/apps/" + nodeType.replaceAll(":", "/");
            testClient.mkdirs(HTTP_BASE_URL, scriptPath);
            toDelete.add(uploadTestScript(scriptPath, "nodetype-and-path.esp", "html.esp"));
            final String content = getContent(testNodeUrl + ".html", CONTENT_TYPE_HTML);
            assertContains(content, "RENDERED BY nodetype-and-path.esp");
            assertContains(content, "TYPE " + nodeType);
            assertContains(content, "PATH " + testNodePath);
        }
    }