Package org.apache.sling.commons.json

Examples of org.apache.sling.commons.json.JSONObject


        assertTrue(importedNodeUrl.endsWith("/nodeName"));

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

    JSONObject jsonObj = new JSONObject(content);
    assertNotNull(jsonObj);

    //assert the imported content is there.
        String expectedJsonContent = getStreamAsString(getClass().getResourceAsStream("/integration-test/servlets/post/importresults.json"));
    assertExpectedJSON(new JSONObject(expectedJsonContent), jsonObj);
    }
View Full Code Here


            testFile, SlingPostConstants.RP_CONTENT_FILE, null);

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

    JSONObject jsonObj = new JSONObject(content);
    assertNotNull(jsonObj);

    //assert the imported content is there.
        String expectedJsonContent = getStreamAsString(getClass().getResourceAsStream("/integration-test/servlets/post/testimportzip.json"));
    assertExpectedJSON(new JSONObject(expectedJsonContent), jsonObj);
    }
View Full Code Here

            testFile, SlingPostConstants.RP_CONTENT_FILE, null);

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

    JSONObject jsonObj = new JSONObject(content);
    assertNotNull(jsonObj);

    //assert the imported content is there.
        String expectedJsonContent = getStreamAsString(getClass().getResourceAsStream("/integration-test/servlets/post/testimportzip.json"));
    assertExpectedJSON(new JSONObject(expectedJsonContent), jsonObj);
    }
View Full Code Here

            testFile, SlingPostConstants.RP_CONTENT_FILE, null);

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

    JSONObject jsonObj = new JSONObject(content);
    assertNotNull(jsonObj);

    //assert the imported content is there.
        String expectedJsonContent = getStreamAsString(getClass().getResourceAsStream("/integration-test/servlets/post/importresults.json"));
    assertExpectedJSON(new JSONObject(expectedJsonContent), jsonObj);
    }
View Full Code Here

        String location = testClient.createNode(HTTP_BASE_URL + testPath, props);

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

    JSONObject jsonObj = new JSONObject(content);
    assertNotNull(jsonObj);

    //assert the imported content is there.
        String expectedJsonContent = getStreamAsString(getClass().getResourceAsStream("/integration-test/servlets/post/importresults.json"));
    assertExpectedJSON(new JSONObject(expectedJsonContent), jsonObj);

      assertHttpStatus(location + DEFAULT_EXT, HttpServletResponse.SC_OK,
                "POST must redirect to created resource (" + location + ")");
        assertTrue("Node (" + location + ") must have exact name",
                !location.endsWith("/*"));
 
View Full Code Here

        String importedNodeUrl = testClient.createNode(HTTP_BASE_URL + testPath, props);

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

    JSONObject jsonObj = new JSONObject(content);
    assertNotNull(jsonObj);

    //assert the imported content is there.
    assertExpectedJSON(new JSONObject(jsonContent), jsonObj);
    }
View Full Code Here

        final JSONArray json = new JSONArray(new JSONTokener((executor.getContent())));
       
        int testsCount = 0;
        final List<String> failures = new ArrayList<String>();
        for(int i = 0 ; i < json.length(); i++) {
            final JSONObject obj = json.getJSONObject(i);
            if("test".equals(obj.getString("INFO_TYPE"))) {
                testsCount++;
                if(obj.has("failure")) {
                    failures.add(obj.get("failure").toString());
                }
            }
        }
       
        final int expectedTests = 1;
View Full Code Here

    @Override
    protected void doSend(HttpServletResponse response) throws IOException {
        response.setContentType("application/json");
        PrintWriter printWriter = response.getWriter();
        JSONObject jsonResponse = new JSONObject();
        boolean validationError = false;
        if (validationResult != null) {
            try {
                jsonResponse.put("valid", validationResult.isValid());
                for (Map.Entry<String, List<String>> entry : validationResult.getFailureMessages().entrySet()) {
                    jsonResponse.put(entry.getKey(), entry.getValue());
                }
            } catch (JSONException e) {
                LOG.error("JSON error during response send operation.", e);
            }
        } else {
            validationError = true;
        }
        printWriter.write(jsonResponse.toString());
        if (validationError) {
            response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
        }
    }
View Full Code Here

                    RequestDispatcherOptions options = new RequestDispatcherOptions();
                    options.setReplaceSelectors(" ");
                    request.getRequestDispatcher(request.getResource(), options).forward(request, response);
                } else {
                    response.setContentType("application/json");
                    JSONObject json = new JSONObject();
                    try {
                        json.put("success", false);
                        JSONObject messages = new JSONObject();
                        for (Map.Entry<String, List<String>> entry : vr.getFailureMessages().entrySet()) {
                            String key = entry.getKey();
                            JSONArray errors = new JSONArray();
                            for (String message : entry.getValue()) {
                                errors.put(message);
                            }
                            messages.put(key, errors);
                        }
                        json.put("messages", messages);
                        response.getWriter().print(json.toString());
                        response.setStatus(400);
                    } catch (JSONException e) {
View Full Code Here

    public static final String GET_CONFIG_PATH = "/testing/GetConfigServlet.tidy.json/" + CONFIG_PID;
    public static final String CONFIG_PROP = "servletresolver.cacheSize";
   
    public void testCacheDisabled() throws Exception {
        final String content = getContent(HTTP_BASE_URL + GET_CONFIG_PATH, CONTENT_TYPE_JSON);
        final JSONObject json = new JSONObject(content);
        final int cacheSize = json.getJSONObject("properties").getInt(CONFIG_PROP);
        if(cacheSize != 0) {
            fail(
                    "ServletResolver cache size should be set to zero for testing, current value=" + cacheSize
                    + " *** THIS MIGHT CAUSE MANY OTHER TESTS TO FAIL!! ***"
                    + " (" + CONFIG_PID + "/" + CONFIG_PROP + ")"
View Full Code Here

TOP

Related Classes of org.apache.sling.commons.json.JSONObject

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.