Search in sources :

Example 6 with Processor

use of aQute.bnd.osgi.Processor in project bnd by bndtools.

the class OSGiRepositoryTest method testPolling.

public void testPolling() throws Exception {
    Processor p = new Processor();
    testPolling(Workspace.createStandaloneWorkspace(p, ws.toURI()));
}
Also used : Processor(aQute.bnd.osgi.Processor)

Example 7 with Processor

use of aQute.bnd.osgi.Processor in project bnd by bndtools.

the class P2RepositoryTest method testSimple.

public void testSimple() throws Exception {
    try (P2Repository p2r = new P2Repository()) {
        Workspace w = Workspace.createStandaloneWorkspace(new Processor(), tmp.toURI());
        w.setBase(tmp);
        p2r.setRegistry(w);
        Map<String, String> config = new HashMap<>();
        config.put("url", "https://dl.bintray.com/bndtools/bndtools/latest/");
        config.put("name", "test");
        p2r.setProperties(config);
        List<String> list = p2r.list(null);
        assertNotNull(list);
        assertTrue(list.size() > 1);
    }
}
Also used : Processor(aQute.bnd.osgi.Processor) HashMap(java.util.HashMap) Workspace(aQute.bnd.build.Workspace)

Example 8 with Processor

use of aQute.bnd.osgi.Processor 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 9 with Processor

use of aQute.bnd.osgi.Processor in project bnd by bndtools.

the class MavenBndRepoTest method config.

void config(Map<String, String> override) throws Exception {
    Map<String, String> config = new HashMap<>();
    config.put("local", tmpName + "/local");
    config.put("index", tmpName + "/index");
    config.put("releaseUrl", fnx.getBaseURI() + "/repo/");
    if (override != null)
        config.putAll(override);
    reporter = new Processor();
    reporter.addBasicPlugin(new ProgressPlugin() {

        @Override
        public Task startTask(final String name, int size) {
            System.out.println("Starting " + name);
            return new Task() {

                @Override
                public void worked(int units) {
                    System.out.println("Worked " + name + " " + units);
                }

                @Override
                public void done(String message, Throwable e) {
                    System.out.println("Done " + name + " " + message + " " + e);
                }

                @Override
                public boolean isCanceled() {
                    return false;
                }
            };
        }
    });
    HttpClient client = new HttpClient();
    client.setRegistry(reporter);
    Executor executor = Executors.newCachedThreadPool();
    reporter.addBasicPlugin(client);
    reporter.setTrace(true);
    repo = new MavenBndRepository();
    repo.setReporter(reporter);
    repo.setRegistry(reporter);
    repo.setProperties(config);
}
Also used : Processor(aQute.bnd.osgi.Processor) Executor(java.util.concurrent.Executor) HashMap(java.util.HashMap) ProgressPlugin(aQute.bnd.service.progress.ProgressPlugin) HttpClient(aQute.bnd.http.HttpClient)

Example 10 with Processor

use of aQute.bnd.osgi.Processor in project bnd by bndtools.

the class DistroCommandTest method testResolveAgainstDistro.

public void testResolveAgainstDistro() throws Exception {
    bnd bnd = new bnd();
    CommandLine cmdline = new CommandLine(null);
    List<String> remoteArgs = new ArrayList<>();
    RemoteOptions remoteOptions = cmdline.getOptions(RemoteOptions.class, remoteArgs);
    File distro = new File("generated/tmp/test.distro.jar");
    List<String> distroArgs = new ArrayList<>();
    distroArgs.add("-o");
    distroArgs.add(distro.getPath());
    distroArgs.add("test.distro");
    distroArgs.add("1.0.0");
    DistroOptions distroOptions = cmdline.getOptions(DistroOptions.class, distroArgs);
    new RemoteCommand(bnd, remoteOptions)._distro(distroOptions);
    assertTrue(distro.exists());
    ResolveProcess process = new ResolveProcess();
    ResolverLogger logger = new ResolverLogger();
    MockRegistry registry = new MockRegistry();
    Processor model = new Processor();
    model.setProperty("-distro", distro.getAbsolutePath() + ";version=file");
    model.setProperty("-runfw", "org.eclipse.osgi");
    model.setProperty("-runrequires", "osgi.wiring.package;filter:='(osgi.wiring.package=com.liferay.dynamic.data.mapping.taglib.servlet.taglib)'");
    Map<Resource, List<Wire>> requiredResources = process.resolveRequired(model, null, registry, new BndResolver(logger), Collections.<ResolutionCallback>emptyList(), logger);
    assertEquals(1, requiredResources.size());
}
Also used : Processor(aQute.bnd.osgi.Processor) ResolverLogger(biz.aQute.resolve.ResolverLogger) RemoteOptions(aQute.bnd.main.RemoteCommand.RemoteOptions) ArrayList(java.util.ArrayList) MockRegistry(aQute.bnd.main.testlib.MockRegistry) Resource(org.osgi.resource.Resource) CommandLine(aQute.lib.getopt.CommandLine) DistroOptions(aQute.bnd.main.RemoteCommand.DistroOptions) ResolveProcess(biz.aQute.resolve.ResolveProcess) ArrayList(java.util.ArrayList) List(java.util.List) BndResolver(biz.aQute.resolve.BndResolver) File(java.io.File)

Aggregations

Processor (aQute.bnd.osgi.Processor)185 HashMap (java.util.HashMap)43 File (java.io.File)37 Macro (aQute.bnd.osgi.Macro)29 Workspace (aQute.bnd.build.Workspace)27 Jar (aQute.bnd.osgi.Jar)17 HttpClient (aQute.bnd.http.HttpClient)14 Baseline (aQute.bnd.differ.Baseline)12 DiffPluginImpl (aQute.bnd.differ.DiffPluginImpl)12 BundleInfo (aQute.bnd.differ.Baseline.BundleInfo)10 IOException (java.io.IOException)10 Resource (org.osgi.resource.Resource)10 Info (aQute.bnd.differ.Baseline.Info)8 Version (aQute.bnd.version.Version)8 ArrayList (java.util.ArrayList)8 List (java.util.List)7 ProgressPlugin (aQute.bnd.service.progress.ProgressPlugin)6 Collection (java.util.Collection)6 Properties (java.util.Properties)6 Parameters (aQute.bnd.header.Parameters)5