Package org.apache.sling.commons.testing.integration

Examples of org.apache.sling.commons.testing.integration.NameValuePairList


        NamespaceContext ctx = new SimpleNamespaceContext(m);
        XMLUnit.setXpathNamespaceContext(ctx);


        final NameValuePairList props = new NameValuePairList();
        props.add("a", "");
        props.add("jcr:mixinTypes", "mix:referenceable");

        firstCreatedNodeUrl = testClient.createNode(postUrl + SlingPostConstants.DEFAULT_CREATE_SUFFIX, props, null, false);
        firstUuid = getProperty(firstCreatedNodeUrl, "jcr:uuid");
        firstPath = getPath(firstCreatedNodeUrl);
View Full Code Here


        secondUuid = getProperty(secondCreatedNodeUrl, "jcr:uuid");
        secondPath = getPath(secondCreatedNodeUrl);
    }

    public void testReferenceTypesCreatedFromUuids() throws Exception {
        final NameValuePairList props = new NameValuePairList();
        props.add("r", firstUuid);
        props.add("r@TypeHint", "Reference");
        props.add("w", firstUuid);
        props.add("w@TypeHint", "WeakReference");
        props.add("rs", firstUuid);
        props.add("rs", secondUuid);
        props.add("rs@TypeHint", "Reference[]");
        props.add("ws", firstUuid);
        props.add("ws", secondUuid);
        props.add("ws@TypeHint", "WeakReference[]");
        final String referencingNodeUrl = testClient.createNode(postUrl + SlingPostConstants.DEFAULT_CREATE_SUFFIX,
                props, null, false);

        verifyReferences(referencingNodeUrl);
    }
View Full Code Here

        verifyReferences(referencingNodeUrl);
    }

    public void testReferenceTypesCreatedFromPath() throws Exception {
        final NameValuePairList props = new NameValuePairList();
        props.add("r", firstPath);
        props.add("r@TypeHint", "Reference");
        props.add("w", firstPath);
        props.add("w@TypeHint", "WeakReference");
        props.add("rs", firstPath);
        props.add("rs", secondPath);
        props.add("rs@TypeHint", "Reference[]");
        props.add("ws", firstPath);
        props.add("ws", secondPath);
        props.add("ws@TypeHint", "WeakReference[]");
        final String referencingNodeUrl = testClient.createNode(postUrl + SlingPostConstants.DEFAULT_CREATE_SUFFIX,
                props, null, false);

        verifyReferences(referencingNodeUrl);
    }
View Full Code Here

        super.setUp();
        postUrl = HTTP_BASE_URL + TEST_BASE_PATH + "/" + System.currentTimeMillis();
    }

    public void testPatch() throws Exception {
        final NameValuePairList props = new NameValuePairList();
       
        // 1. create multi-value property
        props.add("prop@TypeHint", "String[]");
        props.add("prop", "alpha");
        props.add("prop", "beta");
        props.add("prop", "beta");
        props.add("prop", "gamma");
        props.add("prop", "epsilon"); // make sure both epsilons are kept, as they are not touched
        props.add("prop", "epsilon"); // by the patch operations below
       
        String location = testClient.createNode(postUrl + SlingPostConstants.DEFAULT_CREATE_SUFFIX,
                props, null, false);
        props.clear();
       
        // 2. update mv prop through Patch method
        props.add("prop@Patch", "true");
        //props.add("prop@TypeHint", "String[]");
        props.add("prop", "-beta")// remove all betas
        props.add("prop", "+delta"); // add one delta
        props.add("prop", "+alpha"); // already exists, do not add a second alpha
       
        testClient.createNode(location, props, null, false);
        String content = getContent(location + ".json", CONTENT_TYPE_JSON);
        assertJavascript("true", content, "out.println(data.prop.length == 5)");
        assertJavascript("alpha", content, "out.println(data.prop[0])");
View Full Code Here

        assertJavascript("epsilon", content, "out.println(data.prop[3])");
        assertJavascript("delta", content, "out.println(data.prop[4])");
    }

    public void testInvalidPatch() throws Exception {
        final NameValuePairList props = new NameValuePairList();
       
        // 1. create multi-value property
        props.add("prop@TypeHint", "String[]");
        props.add("prop", "alpha");
        props.add("prop", "beta");
        props.add("prop", "gamma");
        props.add("prop", "delta");
       
        String location = testClient.createNode(postUrl + SlingPostConstants.DEFAULT_CREATE_SUFFIX,
                props, null, false);
        props.clear();
       
        // 2. update mv prop through Patch method
        // but use only invalid values
        props.add("prop@Patch", "true");
        props.add("prop", "wrong");
        props.add("prop", "#noop");
       
        testClient.createNode(location, props, null, false);
        String content = getContent(location + ".json", CONTENT_TYPE_JSON);
        assertJavascript("true", content, "out.println(data.prop.length == 4)");
        assertJavascript("alpha", content, "out.println(data.prop[0])");
View Full Code Here

      testUserId = H.createTestUser();

      //2. Create node as admin (OK)
        // curl -F:nameHint=node -FpropOne=propOneValue1 -FpropOne=propOneValue2 -FpropTwo=propTwoValue http://admin:admin@localhost:8080/test/
        final String createTestNodeUrl = postUrl + SlingPostConstants.DEFAULT_CREATE_SUFFIX;
        NameValuePairList clientNodeProperties = new NameValuePairList();
        clientNodeProperties.add(SlingPostConstants.RP_NODE_NAME_HINT, testName.getMethodName());
        clientNodeProperties.add("propOne", "propOneValue1");
        clientNodeProperties.add("propOne", "propOneValue2");
        clientNodeProperties.add("propTwo", "propTwoValue");
      String testNodeUrl = H.getTestClient().createNode(createTestNodeUrl, clientNodeProperties, null, false);

        String content = H.getContent(testNodeUrl + ".json", HttpTest.CONTENT_TYPE_JSON);
        JSONObject json = new JSONObject(content);
        Object propOneObj = json.opt("propOne");
View Full Code Here

        content = getContent(createdNodeUrl + ".json", CONTENT_TYPE_JSON);

        assertJavascript("undefined", content, "out.println(\"\" + data.a)");

        // check array
        NameValuePairList params = new NameValuePairList();
        params.add("x", "1");
        params.add("x", "2");
        params.add("x", "3");

        testClient.createNode(createdNodeUrl, params, null, false);
        content = getContent(createdNodeUrl + ".json", CONTENT_TYPE_JSON);

        assertJavascript("123", content, "out.println(data.x)");

        // check array with empty value
        params = new NameValuePairList();
        params.add("x", "1");
        params.add("x", "");
        params.add("x", "3");

        testClient.createNode(createdNodeUrl, params, null, false);
        content = getContent(createdNodeUrl + ".json", CONTENT_TYPE_JSON);

        assertJavascript("3.0", content, "out.println(data.x.length)");
        assertJavascript("1", content, "out.println(data.x[0])");
        assertJavascript("", content, "out.println(data.x[1])");
        assertJavascript("3", content, "out.println(data.x[2])");

        // check array with empty value and ignore blanks
        params = new NameValuePairList();
        params.add("x", "1");
        params.add("x", "");
        params.add("x", "3");
        params.add("x@IgnoreBlanks", "true");

        testClient.createNode(createdNodeUrl, params, null, false);
        content = getContent(createdNodeUrl + ".json", CONTENT_TYPE_JSON);

        assertJavascript("2.0", content, "out.println(data.x.length)");
View Full Code Here

        testFile = getTestFile(getClass().getResourceAsStream("/integration-test/servlets/post/testimport2.json"));
        props.put(SlingPostConstants.RP_CONTENT_TYPE, "json");
        props.put(SlingPostConstants.RP_REDIRECT_TO, SERVLET_CONTEXT + testPath + "/*");
        props.put(SlingPostConstants.RP_REPLACE, "true");
        String importedNodeUrl2 = testClient.createNode(HTTP_BASE_URL + testPath, new NameValuePairList(props), null, true,
            testFile, SlingPostConstants.RP_CONTENT_FILE, null);

        //the new node should have the same path as the replaced node
        assertEquals(importedNodeUrl, importedNodeUrl2);

View Full Code Here

        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 = new JSONObject(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);

View Full Code Here

        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);

View Full Code Here

TOP

Related Classes of org.apache.sling.commons.testing.integration.NameValuePairList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.