Search in sources :

Example 11 with TaggedData

use of aQute.bnd.service.url.TaggedData in project bnd by bndtools.

the class HttpConnectorTest method testConnectWithUserPassAndTag.

public static void testConnectWithUserPassAndTag() throws Exception {
    HttpBasicAuthURLConnector connector = new HttpBasicAuthURLConnector();
    Map<String, String> config = new HashMap<String, String>();
    config.put("configs", "testdata/http_auth.properties");
    connector.setProperties(config);
    TaggedData data = connector.connectTagged(new URL(getUrl(true) + "securebundles/dummybundle.jar"), EXPECTED_ETAG);
    assertNull("Data should be null because resource not modified", data);
}
Also used : HashMap(java.util.HashMap) TaggedData(aQute.bnd.service.url.TaggedData) URL(java.net.URL)

Example 12 with TaggedData

use of aQute.bnd.service.url.TaggedData in project bnd by bndtools.

the class HttpConnectorTest method testConnectTagged.

public static void testConnectTagged() throws Exception {
    DefaultURLConnector connector = new DefaultURLConnector();
    TaggedData data = connector.connectTagged(new URL(getUrl(true) + "bundles/dummybundle.jar"));
    assertNotNull("Data should be non-null because ETag not provided", data);
    data.getInputStream().close();
    assertEquals("ETag is incorrect", EXPECTED_ETAG, data.getTag());
}
Also used : TaggedData(aQute.bnd.service.url.TaggedData) URL(java.net.URL)

Example 13 with TaggedData

use of aQute.bnd.service.url.TaggedData in project bnd by bndtools.

the class HttpConnectorTest method testConnectTaggedHTTPS.

public static void testConnectTaggedHTTPS() throws Exception {
    DefaultURLConnector connector = new DefaultURLConnector();
    Map<String, String> config = new HashMap<String, String>();
    config.put(HttpsUtil.PROP_DISABLE_SERVER_CERT_VERIFY, "true");
    connector.setProperties(config);
    TaggedData data = connector.connectTagged(new URL(getUrl(false) + "bundles/dummybundle.jar"));
    assertNotNull(data);
    data.getInputStream().close();
}
Also used : HashMap(java.util.HashMap) TaggedData(aQute.bnd.service.url.TaggedData) URL(java.net.URL)

Example 14 with TaggedData

use of aQute.bnd.service.url.TaggedData in project bnd by bndtools.

the class HttpClientTest method testRedirectURL.

public void testRedirectURL() throws Exception {
    try (HttpClient hc = new HttpClient()) {
        HttpsVerification httpsVerification = new HttpsVerification(httpsServer.getCertificateChain(), false, hc.getReporter());
        hc.addURLConnectionHandler(httpsVerification);
        URI uri = httpsServer.getBaseURI("get");
        URL go = httpServer.getBaseURI("xlocation").toURL();
        TaggedData tag = hc.build().maxRedirects(3).get(TaggedData.class).headers("XLocation", uri.toString()).go(go);
        assertNotNull(tag);
        assertEquals(200, tag.getResponseCode());
    }
}
Also used : HttpsVerification(aQute.bnd.url.HttpsVerification) HttpClient(aQute.bnd.http.HttpClient) TaggedData(aQute.bnd.service.url.TaggedData) URI(java.net.URI) URL(java.net.URL)

Example 15 with TaggedData

use of aQute.bnd.service.url.TaggedData in project bnd by bndtools.

the class HttpClientTest method testNotModifiedEtag.

public void testNotModifiedEtag() throws Exception {
    try (HttpClient hc = new HttpClient()) {
        TaggedData data = hc.build().get(TaggedData.class).ifNoneMatch("1234").go(httpServer.getBaseURI("etag/1234/0"));
        assertNotNull(data);
        assertEquals("1234", data.getTag());
        assertEquals(HttpURLConnection.HTTP_NOT_MODIFIED, data.getResponseCode());
    }
}
Also used : HttpClient(aQute.bnd.http.HttpClient) TaggedData(aQute.bnd.service.url.TaggedData)

Aggregations

TaggedData (aQute.bnd.service.url.TaggedData)35 HttpClient (aQute.bnd.http.HttpClient)18 URL (java.net.URL)15 File (java.io.File)7 IOException (java.io.IOException)6 Processor (aQute.bnd.osgi.Processor)5 URISyntaxException (java.net.URISyntaxException)4 ConnectionSettings (aQute.bnd.connection.settings.ConnectionSettings)3 ServerDTO (aQute.bnd.connection.settings.ServerDTO)3 ProgressPlugin (aQute.bnd.service.progress.ProgressPlugin)3 FileNotFoundException (java.io.FileNotFoundException)3 URI (java.net.URI)3 ProxyDTO (aQute.bnd.connection.settings.ProxyDTO)2 HttpRequestException (aQute.bnd.http.HttpRequestException)2 Info (aQute.bnd.http.URLCache.Info)2 InputStream (java.io.InputStream)2 HttpURLConnection (java.net.HttpURLConnection)2 SocketTimeoutException (java.net.SocketTimeoutException)2 URLConnection (java.net.URLConnection)2 HashMap (java.util.HashMap)2