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();
}
}
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);
}
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;
}
Aggregations