public RequestExecutor runTests()

in src/main/java/org/apache/sling/junit/remote/httpclient/RemoteTestHttpClient.java [84:137]


    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;
    }