Examples of RequestExecutor


Examples of com.couchace.core.internal.RequestExecutor

    @BeforeClass
    public void beforeClass() throws Exception {
        server = new MockCouchServer();
        database = server.database("unit-tests");
        requestExecutor = new RequestExecutor(database);
    }
View Full Code Here

Examples of com.couchace.core.internal.RequestExecutor

    @BeforeClass
    public void beforeClass() throws Exception {
        server = new MockCouchServer();
        database = server.database("unit-tests");
        requestExecutor = new RequestExecutor(database);
    }
View Full Code Here

Examples of com.google.code.http4j.RequestExecutor

    return this;
  }
 
  protected Response submit(Request request, Metrics parentMetrics) throws InterruptedException,
      IOException, URISyntaxException {
    RequestExecutor executor = new BasicRequestExecutor(connectionManager, cookieCache, responseParser);
    Response response = executor.execute(request);
    LOGGER.debug("Metrics for {} : \r\n{}", request.getURI(), response.getMetrics());
    response.getMetrics().setParentMetrics(parentMetrics);
    return postProcess(request, response);
  }
View Full Code Here

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

    public static final String JSON_KEY_STATE = "state";
    public static final String CONSOLE_BUNDLES_PATH = "/system/console/bundles";
   
    public WebconsoleClient(String slingServerUrl, String username, String password) {
        this.builder = new RequestBuilder(slingServerUrl);
        this.executor = new RequestExecutor(new DefaultHttpClient());
        this.username = username;
        this.password = password;
    }
View Full Code Here

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

    public SlingClient(String slingServerUrl, String username, String password) {
        this.slingServerUrl = slingServerUrl;
        this.username = username;
        this.password = password;
        builder = new RequestBuilder(slingServerUrl);
        executor = new RequestExecutor(new DefaultHttpClient());
    }
View Full Code Here

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

    @Test
    public void testDefault() throws Exception{
        RequestBuilder rb = new RequestBuilder(ServerConfiguration.getServerUrl());
        // Add Sling POST options
        RequestExecutor result = executor.execute(
                rb.buildGetRequest("/mdc","foo","bar"));

        JSONObject jb = new JSONObject(result.getContent());
        assertEquals("/mdc", jb.getString("req.requestURI"));
        assertEquals("foo=bar", jb.getString("req.queryString"));
        assertEquals(ServerConfiguration.getServerUrl() + "/mdc", jb.getString("req.requestURL"));
        log.info("Response  {}",result.getContent());
    }
View Full Code Here

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

        cookie.setPath("/");
        cookie.setDomain("localhost");
        httpClient.getCookieStore().addCookie(cookie);

        //Execute request
        RequestExecutor result = executor.execute(
                rb.buildGetRequest("/mdc", "mdc-test-param", "foo-test-param", "ignored-param", "ignored-value")
                        .withHeader("X-Forwarded-For", "foo-forwarded-for")
                        .withHeader("mdc-test-header", "foo-test-header")
        );

        JSONObject jb = new JSONObject(result.getContent());
        log.info("Response  {}",result.getContent());

        assertEquals("/mdc", jb.getString("req.requestURI"));
        assertEquals(ServerConfiguration.getServerUrl() + "/mdc", jb.getString("req.requestURL"));
        assertEquals("foo-forwarded-for", jb.getString("req.xForwardedFor"));
        assertEquals("foo-test-header", jb.getString("mdc-test-header"));
View Full Code Here

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

    public RequestExecutor runTests(String testClassesSelector, String testMethodSelector, String extension, Map<String, String> requestOptions)
    throws ClientProtocolException, IOException {
        final RequestBuilder builder = new RequestBuilder(junitServletUrl);

        // Optionally let the client to consume the response entity
        final RequestExecutor executor = new RequestExecutor(new DefaultHttpClient()) {
            @Override
            protected void consumeEntity() throws ParseException, IOException {
                if(consumeContent) {
                    super.consumeEntity();
                }
            }
        };
       
        // Build path for POST request to execute the tests
       
        // Test classes selector
        subpath = new StringBuilder();
        if(!junitServletUrl.endsWith(SLASH)) {
            subpath.append(SLASH);
        }
        subpath.append(testClassesSelector);
       
        // Test method selector
        if(testMethodSelector != null && testMethodSelector.length() > 0) {
            subpath.append("/");
            subpath.append(testMethodSelector);
        }
       
        // Extension
        if(!extension.startsWith(DOT)) {
            subpath.append(DOT);
        }
        subpath.append(extension);

        // Request options if any
        final List<NameValuePair> opt = new ArrayList<NameValuePair>();
        if(requestOptions != null) {
            for(Map.Entry<String, String> e : requestOptions.entrySet()) {
                opt.add(new BasicNameValuePair(e.getKey(), e.getValue()));
            }
        }
       
        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);

        return executor;
    }
View Full Code Here

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

        MultipartEntity entity = new MultipartEntity();
        entity.addPart("sling:resourceType", new StringBody("validation/test/resourceType1"));
        entity.addPart("field1", new StringBody("HelloWorld"));
        entity.addPart("field2", new StringBody("30.01.1988"));
        entity.addPart(SlingPostConstants.RP_OPERATION, new StringBody("validation"));
        RequestExecutor re = getRequestExecutor().execute(getRequestBuilder().buildPostRequest
                ("/validation/testing/fakeFolder1/resource").withEntity(entity)).assertStatus(200);
        JSONObject jsonResponse = new JSONObject(re.getContent());
        assertTrue(jsonResponse.getBoolean("valid"));
    }
View Full Code Here

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

    public void testInvalidRequestModel1() throws IOException, JSONException {
        MultipartEntity entity = new MultipartEntity();
        entity.addPart("sling:resourceType", new StringBody("validation/test/resourceType1"));
        entity.addPart("field1", new StringBody("Hello World"));
        entity.addPart(SlingPostConstants.RP_OPERATION, new StringBody("validation"));
        RequestExecutor re = getRequestExecutor().execute(getRequestBuilder().buildPostRequest
                ("/validation/testing/fakeFolder1/resource").withEntity(entity)).assertStatus(200);
        String content = re.getContent();
        JSONObject jsonResponse = new JSONObject(content);
        assertFalse(jsonResponse.getBoolean("valid"));
    }
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.