Search in sources :

Example 6 with DefaultURLConnector

use of aQute.bnd.deployer.http.DefaultURLConnector in project bnd by bndtools.

the class CachingUriResourceHandlerTest method testUseCached.

public static void testUseCached() throws Exception {
    File cached = IO.getFile("testdata/httpcache/4/http%3A%2F%2Flocalhost%3A18083%2Fbundles/dummybundle.jar");
    long cacheTimestamp = cached.lastModified();
    CachingUriResourceHandle handle = new CachingUriResourceHandle(new URI("http://localhost:18083/bundles/dummybundle.jar"), IO.getFile("testdata/httpcache/4"), new DefaultURLConnector(), EXPECTED_SHA);
    NanoHTTPD httpd = new NanoHTTPD(18083, IO.getFile("testdata/http"));
    try {
        File result = handle.request();
        assertEquals(cached, result);
        assertEquals("File timestamp should NOT change", cacheTimestamp, result.lastModified());
    } finally {
        httpd.stop();
    }
}
Also used : NanoHTTPD(test.lib.NanoHTTPD) File(java.io.File) URI(java.net.URI) DefaultURLConnector(aQute.bnd.deployer.http.DefaultURLConnector)

Example 7 with DefaultURLConnector

use of aQute.bnd.deployer.http.DefaultURLConnector in project bnd by bndtools.

the class CachingUriResourceHandlerTest method testUseCacheWhenRemoteUnavailable.

public static void testUseCacheWhenRemoteUnavailable() throws Exception {
    File cached = IO.getFile("testdata/httpcache/7/http%3A%2F%2Flocalhost%3A18083%2Fbundles/dummybundle.jar");
    CachingUriResourceHandle handle = new CachingUriResourceHandle(new URI("http://localhost:18083/bundles/dummybundle.jar"), IO.getFile("testdata/httpcache/7"), new DefaultURLConnector(), (String) null);
    // whoops where's the server...
    File result = handle.request();
    assertEquals(cached, result);
}
Also used : File(java.io.File) URI(java.net.URI) DefaultURLConnector(aQute.bnd.deployer.http.DefaultURLConnector)

Example 8 with DefaultURLConnector

use of aQute.bnd.deployer.http.DefaultURLConnector in project bnd by bndtools.

the class AbstractIndexedRepo method getConnector.

/**
	 * @return the class to use for URL connections. It's retrieved from the
	 *         registry under the URLConnector class, or it will be the
	 *         DefaultURLConnector if the former was not found.
	 */
private URLConnector getConnector() {
    URLConnector connector;
    synchronized (this) {
        connector = registry != null ? registry.getPlugin(URLConnector.class) : null;
    }
    if (connector == null) {
        DefaultURLConnector defaultConnector = new DefaultURLConnector();
        defaultConnector.setRegistry(registry);
        connector = defaultConnector;
    }
    return connector;
}
Also used : DefaultURLConnector(aQute.bnd.deployer.http.DefaultURLConnector) URLConnector(aQute.bnd.service.url.URLConnector) DefaultURLConnector(aQute.bnd.deployer.http.DefaultURLConnector)

Aggregations

DefaultURLConnector (aQute.bnd.deployer.http.DefaultURLConnector)8 File (java.io.File)7 URI (java.net.URI)7 NanoHTTPD (test.lib.NanoHTTPD)4 URLConnector (aQute.bnd.service.url.URLConnector)1 IOException (java.io.IOException)1 List (java.util.List)1