Package org.apache.sling.commons.json

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


        // Execute tests from the failingtests bundle and verify response
        final Request r = getRequestBuilder().buildPostRequest(JUNIT_SERVLET_PATH
                + "/org.apache.sling.testing.samples.failingtests.json").withCredentials(getServerUsername(), getServerPassword());
        getRequestExecutor().execute(r).assertStatus(200);
       
        final JSONArray json = new JSONArray(new JSONTokener((getRequestExecutor().getContent())));
       
        assertEquals(
                "initializationError(org.apache.sling.testing.samples.failingtests.EmptyTest): No runnable methods",
                getFailure(json, "org.apache.sling.testing.samples.failingtests.EmptyTest")
        );
View Full Code Here


                "org.apache.sling.junit.scriptable.ScriptableTestsProvider",
                null,
                "json"
                );
        executor.assertContentType("application/json");
        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);
View Full Code Here

                testParameters.getTestClassesSelector(),
                testParameters.getTestMethodSelector(),
                "json"
                );
        executor.assertContentType("application/json");
        final JSONArray json = new JSONArray(new JSONTokener((executor.getContent())));

        // Response contains an array of objects identified by
        // their INFO_TYPE, extract the tests
        // based on this vlaue
        for(int i = 0 ; i < json.length(); i++) {
View Full Code Here

        final Map<String, String> options = new HashMap<String, String>();
        options.put("forceReload", "true");
        final RequestExecutor executor = testClient.runTests(testPackageOrClassName, null, "json", options);
        executor.assertContentType("application/json");
        String content = executor.getContent();
        final JSONArray json = new JSONArray(new JSONTokener(content));

        for(int i = 0 ; i < json.length(); i++) {
            final JSONObject obj = json.getJSONObject(i);
            if("test".equals(obj.getString("INFO_TYPE"))) {
                r.testCount++;
View Full Code Here

     * @param string The comma delimited text.
     * @return A JSONArray of JSONObjects.
     * @throws JSONException
     */
    public static JSONArray toJSONArray(String string) throws JSONException {
        return toJSONArray(new JSONTokener(string));
    }
View Full Code Here

     * @return A JSONArray of JSONObjects.
     * @throws JSONException
     */
    public static JSONArray toJSONArray(JSONArray names, String string)
            throws JSONException {
        return toJSONArray(names, new JSONTokener(string));
    }
View Full Code Here

     * @param text The text to check.
     * @throws JSONException If the text is not valid.
     */
    public static void validate(final String text)
    throws JSONException {
        validate(new JSONTokener(text));
    }
View Full Code Here

     * @return A JSONObject
     * @throws JSONException
     */
    public static JSONObject toJSONObject(String string) throws JSONException {
        JSONObject o = new JSONObject();
        JSONTokener x = new JSONTokener(string);
        while (x.more()) {
            String name = Cookie.unescape(x.nextTo('='));
            x.next('=');
            o.put(name, Cookie.unescape(x.nextTo(';')));
            x.next();
        }
        return o;
    }
View Full Code Here

     */
    public static JSONObject toJSONObject(String string) throws JSONException {
        String         n;
        JSONObject     o = new JSONObject();
        Object         v;
        JSONTokener x = new JSONTokener(string);
        o.put("name", x.nextTo('='));
        x.next('=');
        o.put("value", x.nextTo(';'));
        x.next();
        while (x.more()) {
            n = unescape(x.nextTo("=;"));
            if (x.next() != '=') {
                if (n.equals("secure")) {
                    v = Boolean.TRUE;
                } else {
                    throw x.syntaxError("Missing '=' in cookie parameter.");
                }
            } else {
                v = unescape(x.nextTo(';'));
                x.next();
            }
            o.put(n, v);
        }
        return o;
    }
View Full Code Here

TOP

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

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.