Package org.apache.commons.httpclient

Examples of org.apache.commons.httpclient.NameValuePair


        // create destination parent
        testClient.createNode(HTTP_BASE_URL + testPath + "/dest", props);

        // move the src? nodes
        List<NameValuePair> nvPairs = new ArrayList<NameValuePair>();
        nvPairs.add(new NameValuePair(SlingPostConstants.RP_OPERATION,
            SlingPostConstants.OPERATION_MOVE));
        nvPairs.add(new NameValuePair(SlingPostConstants.RP_DEST, testPath
            + "/dest/"));
        nvPairs.add(new NameValuePair(SlingPostConstants.RP_APPLY_TO, "test/*"));
        // we expect success
        assertPostStatus(testRoot, HttpServletResponse.SC_OK, nvPairs,
            "Expecting Move Success");

        // assert existence of the src?/text properties
View Full Code Here


    assertFalse(jsonObj.getBoolean("jcr:isCheckedOut"));


    //2. try an update with the :autoCheckout value set to false
        List<NameValuePair> postParams = new ArrayList<NameValuePair>();
        postParams.add(new NameValuePair(SlingPostConstants.RP_OPERATION,
                    SlingPostConstants.OPERATION_IMPORT));
        postParams.add(new NameValuePair(SlingPostConstants.RP_CONTENT_TYPE, "json"));
        postParams.add(new NameValuePair(SlingPostConstants.RP_CHECKIN, "true"));
        postParams.add(new NameValuePair(SlingPostConstants.RP_REPLACE_PROPERTIES, "true"));
        postParams.add(new NameValuePair(SlingPostConstants.RP_AUTO_CHECKOUT, "false"));
        postParams.add(new NameValuePair(SlingPostConstants.RP_CONTENT, "{ \"abc\": \"def2\" }"));
        assertPostStatus(importedNodeUrl, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, postParams, "Expected error from VersionException");

    //3. now try an update with the :autoCheckout value set to true
        postParams.clear();
        postParams.add(new NameValuePair(SlingPostConstants.RP_OPERATION,
        SlingPostConstants.OPERATION_IMPORT));
    postParams.add(new NameValuePair(SlingPostConstants.RP_CONTENT_TYPE, "json"));
    postParams.add(new NameValuePair(SlingPostConstants.RP_CHECKIN, "true"));
    postParams.add(new NameValuePair(SlingPostConstants.RP_REPLACE_PROPERTIES, "true"));
    postParams.add(new NameValuePair(SlingPostConstants.RP_AUTO_CHECKOUT, "true"));
    postParams.add(new NameValuePair(SlingPostConstants.RP_CONTENT, "{ \"abc\": \"def2\" }"));
    postParams.add(new NameValuePair(":http-equiv-accept", "application/json,*/*;q=0.9"));
        HttpMethod post = assertPostStatus(importedNodeUrl, HttpServletResponse.SC_CREATED, postParams, "Expected 201 status");
       
        String responseBodyAsString = post.getResponseBodyAsString();
    JSONObject responseJSON = new JSONObject(responseBodyAsString);
        JSONArray changes = responseJSON.getJSONArray("changes");
View Full Code Here

        Map<String, String> props = new HashMap<String, String>();
        String testNode = testClient.createNode(HTTP_BASE_URL + testPath, props);
        urlsToDelete.add(testNode);

    List<NameValuePair> postParams = new ArrayList<NameValuePair>();
    postParams.add(new NameValuePair(SlingPostConstants.RP_OPERATION, SlingPostConstants.OPERATION_IMPORT));
    postParams.add(new NameValuePair(SlingPostConstants.RP_NODE_NAME, "exactNodeName*"));
        String jsonContent = getStreamAsString(getClass().getResourceAsStream("/integration-test/servlets/post/testimport.json"));
    postParams.add(new NameValuePair(SlingPostConstants.RP_CONTENT, jsonContent));
    postParams.add(new NameValuePair(SlingPostConstants.RP_CONTENT_TYPE, "json"));
    postParams.add(new NameValuePair(SlingPostConstants.RP_REDIRECT_TO, SERVLET_CONTEXT + testPath + "/*"));

        //expect a 500 status since the name is invalid
        String location = HTTP_BASE_URL + testPath;
    assertPostStatus(location, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, postParams, null);
    }
View Full Code Here


        //try to create the same node again, since same name siblings are not allowed an error should be
        // thrown
    List<NameValuePair> postParams = new ArrayList<NameValuePair>();
    postParams.add(new NameValuePair(SlingPostConstants.RP_NODE_NAME, testNodeName));
    //expect a 500 status since the name is not unique
    String postUrl = location.substring(0, location.lastIndexOf('/'));
    assertPostStatus(postUrl + SlingPostConstants.DEFAULT_CREATE_SUFFIX, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, postParams, null);
    }
View Full Code Here

        if (testUserId != null) {
            //remove the test user if it exists.
            String postUrl = HTTP_BASE_URL + "/system/userManager/user/" + testUserId + ".delete.html";
            List<NameValuePair> postParams = new ArrayList<NameValuePair>();
          //SLING-1635 the sudo cookie messes up the user delete, so clear it out before deleting the test user
            postParams.add(new NameValuePair("sudo", "-"));
            assertAuthenticatedAdminPostStatus(postUrl, HttpServletResponse.SC_OK, postParams, null);
        }
        super.tearDown();
    }
View Full Code Here

    @Test
    @Category(JackrabbitOnly.class)
    // TODO: fails on Oak
    public void testValidatingCorrectFormCredentials() throws Exception {
        List<NameValuePair> params = new ArrayList<NameValuePair>();
        params.add(new NameValuePair("j_username", "admin"));
        params.add(new NameValuePair("j_password", "admin"));
        params.add(new NameValuePair("j_validate", "true"));
        HttpMethod post = H.assertPostStatus(HttpTest.HTTP_BASE_URL + "/j_security_check", HttpServletResponse.SC_OK,
                params, null);
        assertTrue(post.getResponseBodyAsString().length() == 0);

        List<NameValuePair> params2 = new ArrayList<NameValuePair>();
        params2.add(new NameValuePair("j_validate", "true"));
        HttpMethod post2 = H.assertPostStatus(HttpTest.HTTP_BASE_URL + "/j_security_check", HttpServletResponse.SC_OK,
                params2, null);
        assertTrue(post2.getResponseBodyAsString().length() == 0);
    }
View Full Code Here

    }

    @Test
    public void testValidatingCorrectHttpBasicCredentials() throws Exception {
        List<NameValuePair> params = new ArrayList<NameValuePair>();
        params.add(new NameValuePair("j_validate", "true"));
        HttpMethod post = H.assertPostStatus(HttpTest.HTTP_BASE_URL + "/j_security_check", HttpServletResponse.SC_OK,
                params, null);
        assertTrue(post.getResponseBodyAsString().length() == 0);

        HttpMethod get = H.assertHttpStatus(HttpTest.HTTP_BASE_URL + "/?j_validate=true", HttpServletResponse.SC_OK);
View Full Code Here

    }

    @Test
    public void testValidatingIncorrectCredentials() throws Exception {
        List<NameValuePair> params = new ArrayList<NameValuePair>();
        params.add(new NameValuePair("j_username", "garbage"));
        params.add(new NameValuePair("j_password", "garbage"));
        params.add(new NameValuePair("j_validate", "true"));
        HttpMethod post = H.assertPostStatus(HttpTest.HTTP_BASE_URL + "/j_security_check",
                HttpServletResponse.SC_FORBIDDEN, params, null);
        assertNotNull(post.getResponseHeader("X-Reason"));
    }
View Full Code Here

    }

    @Test
    public void testValidatingIncorrectCookie() throws Exception {
        List<NameValuePair> params = new ArrayList<NameValuePair>();
        params.add(new NameValuePair("j_validate", "true"));

        List<Header> headers = new ArrayList<Header>();
        headers.add(new Header("Cookie", "sling.formauth=garbage"));

        HttpMethod post = assertPostStatus(HttpTest.HTTP_BASE_URL + "/j_security_check",
View Full Code Here

        Credentials defaultcreds = new UsernamePasswordCredentials("garbage", "garbage");
        H.getHttpClient().getState()
                .setCredentials(new AuthScope(url.getHost(), url.getPort(), AuthScope.ANY_REALM), defaultcreds);

        List<NameValuePair> params = new ArrayList<NameValuePair>();
        params.add(new NameValuePair("j_validate", "true"));
        HttpMethod post = H.assertPostStatus(HttpTest.HTTP_BASE_URL + "/j_security_check",
                HttpServletResponse.SC_FORBIDDEN, params, null);
        assertXReason(post);

        HttpMethod get = H.assertHttpStatus(HttpTest.HTTP_BASE_URL + "/?j_validate=true",
View Full Code Here

TOP

Related Classes of org.apache.commons.httpclient.NameValuePair

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.