Search in sources :

Example 1 with HttpClient

use of aQute.bnd.http.HttpClient in project bnd by bndtools.

the class P2IndexerTest method testRefresh.

public void testRefresh() throws Exception {
    HttpClient client = new HttpClient();
    client.setCache(IO.getFile(tmp, "cache"));
    try (P2Indexer p2 = new P2Indexer(new Slf4jReporter(P2IndexerTest.class), tmp, client, new URI("http://macbadge-updates.s3.amazonaws.com"), "test")) {
        assertEquals(1, p2.versions("name.njbartlett.eclipse.macbadge").size());
        p2.refresh();
        assertEquals(1, p2.versions("name.njbartlett.eclipse.macbadge").size());
    }
}
Also used : HttpClient(aQute.bnd.http.HttpClient) Slf4jReporter(aQute.libg.reporter.slf4j.Slf4jReporter) URI(java.net.URI)

Example 2 with HttpClient

use of aQute.bnd.http.HttpClient in project bnd by bndtools.

the class OSGiRepositoryTest method testPolling.

public void testPolling(Workspace workspace) throws Exception {
    try (OSGiRepository r = new OSGiRepository()) {
        Map<String, String> map = new HashMap<>();
        map.put("locations", fnx.getBaseURI("/repo/minir5.xml").toString());
        map.put("cache", cache.getPath());
        map.put("max.stale", "10000");
        map.put("name", "test");
        map.put("poll.time", "1");
        r.setProperties(map);
        Processor p = new Processor();
        HttpClient httpClient = new HttpClient();
        httpClient.setCache(cache);
        httpClient.setRegistry(p);
        p.addBasicPlugin(httpClient);
        p.setBase(ws);
        p.addBasicPlugin(workspace);
        r.setRegistry(p);
        final AtomicReference<RepositoryPlugin> refreshed = new AtomicReference<>();
        p.addBasicPlugin(new RepositoryListenerPlugin() {

            @Override
            public void repositoryRefreshed(RepositoryPlugin repository) {
                refreshed.set(repository);
            }

            @Override
            public void repositoriesRefreshed() {
            // TODO Auto-generated method stub
            }

            @Override
            public void bundleRemoved(RepositoryPlugin repository, Jar jar, File file) {
            // TODO Auto-generated method stub
            }

            @Override
            public void bundleAdded(RepositoryPlugin repository, Jar jar, File file) {
            // TODO Auto-generated method stub
            }
        });
        File file = r.get("dummybundle", new Version("0"), null);
        assertNotNull(file);
        // not stale, default name
        assertNull(r.title(new Object[0]));
        System.out.println("1");
        Thread.sleep(3000);
        System.out.println("2");
        assertEquals(null, refreshed.get());
        System.out.println("3");
        // update the index file
        File index = IO.getFile(remote, "minir5.xml");
        long time = index.lastModified();
        String s = IO.collect(index);
        // change the sha
        s += " ";
        IO.store(s, index);
        System.out.println("5 " + index + " " + (index.lastModified() - time));
        // give the poller a chance
        Thread.sleep(3000);
        System.out.println("6");
        assertEquals(r, refreshed.get());
        assertEquals("test [stale]", r.title(new Object[0]));
        System.out.println(r.tooltip(new Object[0]));
    }
}
Also used : Processor(aQute.bnd.osgi.Processor) RepositoryListenerPlugin(aQute.bnd.service.RepositoryListenerPlugin) HashMap(java.util.HashMap) RepositoryPlugin(aQute.bnd.service.RepositoryPlugin) AtomicReference(java.util.concurrent.atomic.AtomicReference) Version(aQute.bnd.version.Version) HttpClient(aQute.bnd.http.HttpClient) Jar(aQute.bnd.osgi.Jar) File(java.io.File)

Example 3 with HttpClient

use of aQute.bnd.http.HttpClient in project bnd by bndtools.

the class OSGiIndexTest method testIndex.

public void testIndex() throws Exception {
    HttpClient client = new HttpClient();
    client.setCache(tmp);
    OSGiIndex oi = getIndex(client);
    List<String> list = oi.getBridge().list("osgi.enroute.*");
    assertNotNull(list);
    assertEquals(32, list.size());
    oi = getIndex(client);
    list = oi.getBridge().list("osgi.enroute.*");
    assertNotNull(list);
    assertEquals(32, list.size());
    System.out.println(list);
    SortedSet<Version> versions = oi.getBridge().versions("osgi.enroute.rest.simple.provider");
    assertEquals(1, versions.size());
    System.out.println(versions);
    File f = new File(tmp, "f");
    Promise<File> promise = oi.get("osgi.enroute.rest.simple.provider", new Version("2.0.2.201509211431"), f);
    assertNotNull(promise);
    File value = promise.getValue();
    assertEquals(value, f);
    promise = oi.get("osgi.enroute.rest.simple.provider", new Version("2.0.2.201509211431"), f);
    assertNotNull(promise);
}
Also used : Version(aQute.bnd.version.Version) HttpClient(aQute.bnd.http.HttpClient) File(java.io.File)

Example 4 with HttpClient

use of aQute.bnd.http.HttpClient in project bnd by bndtools.

the class MavenRepoTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    tmpName = "generated/tmp/test/" + getName();
    local = IO.getFile(tmpName + "/local");
    remote = IO.getFile(tmpName + "/remote");
    reporter.setTrace(true);
    Config config = new Config();
    fnx = new FakeNexus(config, remote);
    fnx.start();
    IO.delete(remote);
    IO.delete(local);
    IO.copy(IO.getFile("testresources/mavenrepo"), remote);
    remote.mkdirs();
    local.mkdirs();
    repo = MavenBackingRepository.create(fnx.getBaseURI() + "/repo/", reporter, local, new HttpClient());
    storage = new MavenRepository(local, "fnexus", this.repo, this.repo, null, null, null);
}
Also used : Config(aQute.http.testservers.HttpTestServer.Config) HttpClient(aQute.bnd.http.HttpClient)

Example 5 with HttpClient

use of aQute.bnd.http.HttpClient in project bnd by bndtools.

the class NexusTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    tmpName = "generated/tmp/test/" + getName();
    local = IO.getFile(tmpName + "/local");
    reporter.setTrace(true);
    Config config = new Config();
    IO.delete(local);
    local.mkdirs();
    HttpClient httpClient = new HttpClient();
    httpClient.addURLConnectionHandler(new BasicAuthentication("deployment", "deployment123", Workspace.log));
    repo = new MavenRemoteRepository(local, httpClient, "http://localhost:8081/nexus/content/repositories/snapshots/", reporter);
}
Also used : Config(aQute.http.testservers.HttpTestServer.Config) HttpClient(aQute.bnd.http.HttpClient) BasicAuthentication(aQute.bnd.url.BasicAuthentication)

Aggregations

HttpClient (aQute.bnd.http.HttpClient)47 TaggedData (aQute.bnd.service.url.TaggedData)18 Processor (aQute.bnd.osgi.Processor)14 File (java.io.File)14 URI (java.net.URI)9 HashMap (java.util.HashMap)7 ProgressPlugin (aQute.bnd.service.progress.ProgressPlugin)6 Version (aQute.bnd.version.Version)6 IOException (java.io.IOException)6 URL (java.net.URL)6 ConnectionSettings (aQute.bnd.connection.settings.ConnectionSettings)5 Workspace (aQute.bnd.build.Workspace)4 ServerDTO (aQute.bnd.connection.settings.ServerDTO)4 RepositoryPlugin (aQute.bnd.service.RepositoryPlugin)4 Config (aQute.http.testservers.HttpTestServer.Config)4 Resource (org.osgi.resource.Resource)4 Jar (aQute.bnd.osgi.Jar)3 Slf4jReporter (aQute.libg.reporter.slf4j.Slf4jReporter)3 MavenRepository (aQute.maven.provider.MavenRepository)3 AtomicReference (java.util.concurrent.atomic.AtomicReference)3