use of aQute.bnd.http.HttpClient in project bnd by bndtools.
the class HttpClientTest method testRedirect.
public void testRedirect() throws Exception {
try (HttpClient hc = new HttpClient()) {
TaggedData tag = hc.build().get(TaggedData.class).go(httpServer.getBaseURI("redirect/3/200"));
assertNotNull(tag);
assertEquals(200, tag.getResponseCode());
}
}
use of aQute.bnd.http.HttpClient in project bnd by bndtools.
the class HttpClientTest method testMultipleProgressPlugins.
public void testMultipleProgressPlugins() throws Exception {
final long deadline = System.currentTimeMillis() + 1000L;
try (HttpClient hc = new HttpClient()) {
Processor p = new Processor();
final int[] counts = new int[2];
counts[0] = counts[1] = 0;
p.addBasicPlugin(new ProgressPlugin() {
@Override
public Task startTask(String name, int size) {
return new Task() {
@Override
public void worked(int units) {
counts[0]++;
}
@Override
public void done(String message, Throwable e) {
counts[0]++;
}
@Override
public boolean isCanceled() {
return false;
}
};
}
});
p.addBasicPlugin(new ProgressPlugin() {
@Override
public Task startTask(String name, int size) {
return new Task() {
@Override
public void worked(int units) {
counts[1]++;
}
@Override
public void done(String message, Throwable e) {
counts[1]++;
}
@Override
public boolean isCanceled() {
return false;
}
};
}
});
hc.setRegistry(p);
String text = hc.build().get(String.class).go(httpServer.getBaseURI("get"));
assertNotNull(text);
assertTrue(counts[0] > 0);
assertEquals(counts[0], counts[1]);
}
}
use of aQute.bnd.http.HttpClient in project bnd by bndtools.
the class HttpClientTest method testETag.
public void testETag() throws Exception {
try (HttpClient hc = new HttpClient()) {
TaggedData data = hc.build().get(TaggedData.class).go(httpServer.getBaseURI("etag/1234/0"));
assertNotNull(data);
assertEquals("1234", data.getTag());
}
}
use of aQute.bnd.http.HttpClient in project bnd by bndtools.
the class P2Repository method getP2Index0.
P2Indexer getP2Index0() {
this.workspace = registry.getPlugin(Workspace.class);
HttpClient client = registry.getPlugin(HttpClient.class);
URI url = config.url();
if (url == null)
throw new IllegalArgumentException("For a p2 repository you must set the url parameter to the repository");
try {
name = config.name(client.toName(url));
File location = workspace.getFile(config.location("cnf/cache/p2-" + name));
IO.mkdirs(location);
File indexFile = new File(location, "index.xml.gz");
return new P2Indexer(reporter, location, client, url, name);
} catch (Exception e) {
throw Exceptions.duck(e);
}
}
use of aQute.bnd.http.HttpClient in project bnd by bndtools.
the class BndPomRepository method init.
public synchronized void init() {
try {
if (inited)
return;
inited = true;
Workspace workspace = registry.getPlugin(Workspace.class);
HttpClient client = registry.getPlugin(HttpClient.class);
File localRepo = IO.getFile(configuration.local(MAVEN_REPO_LOCAL));
File location = workspace.getFile(getLocation());
List<MavenBackingRepository> release = MavenBackingRepository.create(configuration.releaseUrls(), reporter, localRepo, client);
List<MavenBackingRepository> snapshot = MavenBackingRepository.create(configuration.snapshotUrls(), reporter, localRepo, client);
MavenRepository repository = new MavenRepository(localRepo, name, release, snapshot, Processor.getExecutor(), reporter, null);
boolean transitive = configuration.transitive(true);
if (pomFiles != null) {
repoImpl = new PomRepository(repository, client, location, transitive).uris(pomFiles);
} else if (revisions != null) {
repoImpl = new PomRepository(repository, client, location, transitive).revisions(revisions);
} else if (query != null) {
repoImpl = new SearchRepository(repository, location, query, queryUrl, workspace, client, transitive);
} else {
repository.close();
throw new IllegalStateException("We have neither a pom, revision, or query set!");
}
bridge = new BridgeRepository(repoImpl);
} catch (Exception e) {
throw Exceptions.duck(e);
}
}
Aggregations