void installBundle()

in src/main/java/org/apache/sling/testing/teleporter/client/TeleporterHttpClient.java [149:173]


    void installBundle(InputStream bundle, String bundleSymbolicName, int webConsoleReadyTimeoutSeconds) throws MalformedURLException, IOException {
        // Equivalent of
        // curl -u admin:admin -F action=install -Fbundlestart=1 -Fbundlefile=@somefile.jar http://localhost:8080/system/console/bundles
        final String url = baseUrl + "/system/console/bundles";
        final String contentType = "application/octet-stream";
        final HttpURLConnection c = setHttpTimeouts((HttpURLConnection)new URL(url).openConnection());
        
        waitForStatus(url, 200, webConsoleReadyTimeoutSeconds * 1000);
        
        try {
            setConnectionCredentials(c);
            new MultipartAdapter(c, CHARSET)
            .parameter("action", "install")
            .parameter("bundlestart", "1")
            .file("bundlefile", bundleSymbolicName + ".jar", contentType, bundle)
            .close();
            final int status = c.getResponseCode();
            if(status != 302) {
                throw new IOException("Got status code " + status + " for " + url);
            }
            log.debug("POST request to install bundle {} successful", bundleSymbolicName);
        } finally {
            cleanup(c);
        }
    }