Package org.apache.sling.testing.tools.http

Examples of org.apache.sling.testing.tools.http.Request


    private static final String JSON_SELECTOR = ".json";
    private static final String REPLICATION_ROOT_PATH = "/libs/sling/replication";

    private static String assertPostResourceWithParameters(SlingInstance slingInstance,
                                                           int status, String path, String... parameters) throws IOException {
        Request request = slingInstance.getRequestBuilder().buildPostRequest(path);

        if (parameters != null) {
            assertEquals(0, parameters.length % 2);
            List<NameValuePair> valuePairList = new ArrayList<NameValuePair>();

            for (int i = 0; i < parameters.length; i += 2) {
                valuePairList.add(new BasicNameValuePair(parameters[i], parameters[i + 1]));
            }
            UrlEncodedFormEntity entity = new UrlEncodedFormEntity(valuePairList);
            request.withEntity(entity);
        }

        return slingInstance.getRequestExecutor().execute(
                request.withCredentials(slingInstance.getServerUsername(), slingInstance.getServerPassword())
        ).assertStatus(status).getContent();
    }
View Full Code Here


        ).assertStatus(status).getContent();
    }

    private static String assertPostResource(SlingInstance slingInstance,
                                             int status, String path, byte[] bytes) throws IOException {
        Request request = slingInstance.getRequestBuilder().buildPostRequest(path);

        if (bytes != null) {

            ByteArrayEntity entity = new ByteArrayEntity(bytes);
            request.withEntity(entity);
        }

        return slingInstance.getRequestExecutor().execute(
                request.withCredentials(slingInstance.getServerUsername(), slingInstance.getServerPassword())
        ).assertStatus(status).getContent();
    }
View Full Code Here

            }
        }
       
        log.info("Executing test remotely, path={} JUnit servlet URL={}",
                subpath, junitServletUrl);
        final Request r = builder
        .buildPostRequest(subpath.toString())
        .withCredentials(username, password)
        .withCustomizer(requestCustomizer)
        .withEntity(new UrlEncodedFormEntity(opt));
        executor.execute(r).assertStatus(200);
View Full Code Here

   
    @Test
    public void testFailures() throws Exception{
       
        // 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())));
       
View Full Code Here

TOP

Related Classes of org.apache.sling.testing.tools.http.Request

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.