Search in sources :

Example 6 with Repository

use of org.osgi.service.repository.Repository in project bnd by bndtools.

the class ResolveTest method testenRouteGuard.

/**
	 * The enRoute base guard resolved but is missing bundles, the runbundles do
	 * not run
	 */
public void testenRouteGuard() throws Exception {
    MockRegistry registry = new MockRegistry();
    Repository repo = createRepo(IO.getFile("testdata/enroute/index.xml"));
    registry.addPlugin(repo);
    List<Requirement> reqs = CapReqBuilder.getRequirementsFrom(new Parameters("osgi.wiring.package;filter:='(osgi.wiring.package=org.osgi.service.async)'"));
    Collection<Capability> pack = repo.findProviders(reqs).get(reqs.get(0));
    assertEquals(2, pack.size());
    ResourceBuilder b = new ResourceBuilder();
    File guard = IO.getFile("testdata/enroute/osgi.enroute.base.guard.jar");
    Domain manifest = Domain.domain(guard);
    b.addManifest(manifest);
    Repository resourceRepository = new ResourcesRepository(b.build());
    registry.addPlugin(resourceRepository);
    Processor model = new Processor();
    model.setRunfw("org.eclipse.osgi");
    model.setRunblacklist("osgi.identity;filter:='(osgi.identity=osgi.enroute.base.api)',osgi.identity;filter:='(osgi.identity=osgi.cmpn)',osgi.identity;filter:='(osgi.identity=osgi.core)");
    model.setRunRequires("osgi.identity;filter:='(osgi.identity=osgi.enroute.base.guard)'");
    model.setRunee("JavaSE-1.8");
    try {
        BndrunResolveContext context = new BndrunResolveContext(model, null, registry, log);
        Resolver resolver = new BndResolver(new ResolverLogger(4));
        Map<Resource, List<Wire>> resolved = resolver.resolve(context);
        Set<Resource> resources = resolved.keySet();
    } catch (ResolutionException e) {
        String msg = e.getMessage().replaceAll("\\[caused by:", "\n->");
        System.out.println(msg);
        fail(msg);
    }
}
Also used : ResourceBuilder(aQute.bnd.osgi.resource.ResourceBuilder) Parameters(aQute.bnd.header.Parameters) Processor(aQute.bnd.osgi.Processor) Capability(org.osgi.resource.Capability) Resolver(org.osgi.service.resolver.Resolver) MockRegistry(test.lib.MockRegistry) Resource(org.osgi.resource.Resource) ResolutionException(org.osgi.service.resolver.ResolutionException) Requirement(org.osgi.resource.Requirement) Repository(org.osgi.service.repository.Repository) ResourcesRepository(aQute.bnd.osgi.repository.ResourcesRepository) ArrayList(java.util.ArrayList) List(java.util.List) Domain(aQute.bnd.osgi.Domain) File(java.io.File) ResourcesRepository(aQute.bnd.osgi.repository.ResourcesRepository)

Example 7 with Repository

use of org.osgi.service.repository.Repository in project bnd by bndtools.

the class StandaloneTest method testExtraAttribs.

public void testExtraAttribs() throws Exception {
    File f = IO.getFile("testdata/standalone/attribs.bndrun");
    Run run = Run.createRun(null, f);
    List<Repository> repositories = run.getWorkspace().getPlugins(Repository.class);
    assertEquals(1, repositories.size());
    assertTrue(repositories.get(0) instanceof OSGiRepository);
    OSGiRepository f0 = (OSGiRepository) repositories.get(0);
    assertEquals("foo", f0.getName());
    assertEquals("http://example.org/index.xml", f0.getLocation());
    File cacheDir = IO.getFile(System.getProperty("user.home") + "/.custom_cache_dir");
    assertEquals(cacheDir, f0.getRoot());
}
Also used : OSGiRepository(aQute.bnd.repository.osgi.OSGiRepository) Repository(org.osgi.service.repository.Repository) OSGiRepository(aQute.bnd.repository.osgi.OSGiRepository) Run(aQute.bnd.build.Run) File(java.io.File)

Example 8 with Repository

use of org.osgi.service.repository.Repository in project bnd by bndtools.

the class StandaloneTest method testStandalone.

public void testStandalone() throws Exception {
    File f = IO.getFile("testdata/standalone/simple.bndrun");
    Run run = Run.createRun(null, f);
    List<Repository> repositories = run.getWorkspace().getPlugins(Repository.class);
    assertEquals(1, repositories.size());
    assertTrue(repositories.get(0) instanceof OSGiRepository);
    OSGiRepository f0 = (OSGiRepository) repositories.get(0);
    assertEquals("foo", f0.getName());
    assertEquals("http://example.org/index.xml", f0.getLocation());
}
Also used : OSGiRepository(aQute.bnd.repository.osgi.OSGiRepository) Repository(org.osgi.service.repository.Repository) OSGiRepository(aQute.bnd.repository.osgi.OSGiRepository) Run(aQute.bnd.build.Run) File(java.io.File)

Example 9 with Repository

use of org.osgi.service.repository.Repository in project bnd by bndtools.

the class JpmRepoTest method testUnresolved.

public void testUnresolved() throws ResolutionException {
    Repository repo = ws.getPlugin(Repository.class);
    BndEditModel model = new BndEditModel();
    model.setRunFw("org.apache.felix.framework");
    List<Requirement> requires = new ArrayList<Requirement>();
    CapReqBuilder capReq = CapReqBuilder.createBundleRequirement("org.apache.felix.webconsole", "[4,5)");
    requires.add(capReq.buildSyntheticRequirement());
    Map<Requirement, Collection<Capability>> shell = repo.findProviders(requires);
    assertNotNull(shell);
    assertEquals(1, shell.size());
    model.setRunRequires(requires);
    BndrunResolveContext context = new BndrunResolveContext(model, ws, log);
    Resolver resolver = new BndResolver(new org.apache.felix.resolver.Logger(4));
    try {
        Map<Resource, List<Wire>> resolved = resolver.resolve(context);
        fail("Resolve did not fail");
    } catch (ResolutionException e) {
        assertEquals(1, e.getUnresolvedRequirements().size());
        ResolutionException augmented = ResolveProcess.augment(context, e);
        assertEquals(2, augmented.getUnresolvedRequirements().size());
    }
}
Also used : CapReqBuilder(aQute.bnd.osgi.resource.CapReqBuilder) BndResolver(biz.aQute.resolve.BndResolver) Resolver(org.osgi.service.resolver.Resolver) ArrayList(java.util.ArrayList) Resource(org.osgi.resource.Resource) ResolutionException(org.osgi.service.resolver.ResolutionException) Requirement(org.osgi.resource.Requirement) InfoRepository(aQute.bnd.service.repository.InfoRepository) Repository(org.osgi.service.repository.Repository) BndrunResolveContext(biz.aQute.resolve.BndrunResolveContext) Collection(java.util.Collection) ArrayList(java.util.ArrayList) List(java.util.List) BndResolver(biz.aQute.resolve.BndResolver) BndEditModel(aQute.bnd.build.model.BndEditModel)

Example 10 with Repository

use of org.osgi.service.repository.Repository in project bnd by bndtools.

the class GenericResolveContextResolveTest method testSimpleResolve.

/**
	 * Simple basic resolve. We use a small index with gogo + framework and then
	 * try to see if we can resolve the runtime from the shell requirement.
	 * 
	 * @throws Exception
	 */
public void testSimpleResolve() throws Exception {
    Repository repository = createRepo(IO.getFile("testdata/repo3.index.xml"));
    GenericResolveContext grc = new GenericResolveContext(logger);
    grc.setLevel(2);
    grc.addRepository(repository);
    grc.addFramework("org.apache.felix.framework", null);
    grc.addEE(EE.JavaSE_1_7);
    grc.addRequireBundle("org.apache.felix.gogo.shell", new VersionRange("[0,1]"));
    grc.done();
    Resolver resolver = new BndResolver(new ResolverLogger(4));
    Set<Resource> resources = resolver.resolve(grc).keySet();
    assertNotNull(getResource(resources, "org.apache.felix.gogo.runtime", "0.10"));
}
Also used : Repository(org.osgi.service.repository.Repository) Resolver(org.osgi.service.resolver.Resolver) Resource(org.osgi.resource.Resource) VersionRange(aQute.bnd.version.VersionRange)

Aggregations

Repository (org.osgi.service.repository.Repository)35 Requirement (org.osgi.resource.Requirement)18 Capability (org.osgi.resource.Capability)16 ArrayList (java.util.ArrayList)11 Collection (java.util.Collection)11 CapReqBuilder (aQute.bnd.osgi.resource.CapReqBuilder)9 File (java.io.File)9 Resource (org.osgi.resource.Resource)8 Run (aQute.bnd.build.Run)5 OSGiRepository (aQute.bnd.repository.osgi.OSGiRepository)5 List (java.util.List)5 Resolver (org.osgi.service.resolver.Resolver)5 BndEditModel (aQute.bnd.build.model.BndEditModel)4 ResourcesRepository (aQute.bnd.osgi.repository.ResourcesRepository)4 Processor (aQute.bnd.osgi.Processor)3 IdentityCapability (aQute.bnd.osgi.resource.ResourceUtils.IdentityCapability)3 RepositoryPlugin (aQute.bnd.service.RepositoryPlugin)3 InfoRepository (aQute.bnd.service.repository.InfoRepository)3 WorkspaceR5Repository (bndtools.central.WorkspaceR5Repository)3 Map (java.util.Map)3