Package org.apache.sling.commons.json

Examples of org.apache.sling.commons.json.JSONObject.optString()


    assertEquals(1, jsonObject.length());
   
    JSONObject aceObject = jsonObject.optJSONObject(testUserId);
    assertNotNull(aceObject);
   
    assertEquals(testUserId, aceObject.optString("principal"));
   
    JSONArray grantedArray = aceObject.getJSONArray("granted");
    assertNotNull(grantedArray);
    Set<String> grantedPrivilegeNames = new HashSet<String>();
    for (int i=0; i < grantedArray.length(); i++) {
View Full Code Here


    JSONObject aceObject = jsonObject.optJSONObject(testUserId);
    assertNotNull(aceObject);
   
    assertEquals(0, aceObject.getInt("order"));

    String principalString = aceObject.optString("principal");
    assertEquals(testUserId, principalString);
   
    JSONArray grantedArray = aceObject.optJSONArray("granted");
    assertNotNull(grantedArray);
    assertEquals("jcr:read", grantedArray.getString(0));
View Full Code Here

    if (addGroupAce) {
      aceObject = jsonObject.optJSONObject(testGroupId);
      assertNotNull(aceObject);
     
      principalString = aceObject.optString("principal");
      assertEquals(testGroupId, principalString);

            assertEquals(1, aceObject.getInt("order"));

      grantedArray = aceObject.optJSONArray("granted");
View Full Code Here

        request.setResource(contentResource);

        queryPackagerServlet.doPost(request, response);

        final JSONObject actual = new JSONObject(response.getOutput().toString());
        assertEquals("success", actual.optString("status", "error"));
    }


    @Test
    public void testDoPost_preview() throws Exception {
View Full Code Here

        queryPackagerServlet.doPost(request, response);
        String tmp = response.getOutput().toString();
        final JSONObject actual = new JSONObject(tmp);

        assertEquals("preview", actual.optString("status", "error"));
    }

    @Test
    public void testDoPost_error() throws Exception {
        final String resourcePath = "/etc/acs-commons/packages/query-packager-test/jcr:content";
View Full Code Here

        request.setResource(contentResource);

        queryPackagerServlet.doPost(request, response);

        final JSONObject actual = new JSONObject(response.getOutput().toString());
        assertEquals("error", actual.optString("status", "success"));
    }


    private class SuccessMockResourceResolver extends MockResourceResolver {
        final List<Resource> results;
View Full Code Here

        request.setResource(contentResource);

        aclPackagerServlet.doPost(request, response);

        final JSONObject actual = new JSONObject(response.getOutput().toString());
        assertEquals("success", actual.optString("status", "error"));
    }


    @Test
    public void testDoPost_preview() throws Exception {
View Full Code Here

        aclPackagerServlet.doPost(request, response);
        String tmp = response.getOutput().toString();
        System.out.println(tmp);
        final JSONObject actual = new JSONObject(tmp);

        assertEquals("preview", actual.optString("status", "error"));
    }

    @Test
    public void testDoPost_error() throws Exception {
        final String resourcePath = "/etc/acs-commons/packages/acl-packager-test/jcr:content";
View Full Code Here

        request.setResource(contentResource);

        aclPackagerServlet.doPost(request, response);

        final JSONObject actual = new JSONObject(response.getOutput().toString());
        assertEquals("error", actual.optString("status", "success"));
    }


    private class SuccessMockResourceResolver extends MockResourceResolver {
        final List<Resource> results;
View Full Code Here

        }

        try {
            final JSONObject jsonData = new JSONObject(requestData);

            final String incomingFormName = jsonData.optString(KEY_FORM_NAME);

            // Double-check the form names; only inject matching forms
            if (StringUtils.equals(incomingFormName, formName)) {
                final JSONObject incomingJsonForm = jsonData.optJSONObject(KEY_FORM);
                if (incomingJsonForm != null) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.