Search in sources :

Example 16 with Resolver

use of org.osgi.service.resolver.Resolver in project bnd by bndtools.

the class ResolveTest method testSimpleResolve.

/**
	 * This is a basic test of resolving. This test is paired with
	 * {@link #testResolveWithDistro()}. If you change the resources, make sure
	 * this is done in the same way. The {@link #testResolveWithDistro()} has a
	 * negative check while this one checks positive.
	 */
public void testSimpleResolve() {
    MockRegistry registry = new MockRegistry();
    registry.addPlugin(createRepo(IO.getFile("testdata/repo3.index.xml")));
    BndEditModel model = new BndEditModel();
    model.setRunFw("org.apache.felix.framework");
    List<Requirement> requires = new ArrayList<Requirement>();
    CapReqBuilder capReq = CapReqBuilder.createBundleRequirement("org.apache.felix.gogo.shell", "[0,1)");
    requires.add(capReq.buildSyntheticRequirement());
    model.setRunRequires(requires);
    BndrunResolveContext context = new BndrunResolveContext(model, registry, log);
    Resolver resolver = new BndResolver(new ResolverLogger(4));
    try {
        Map<Resource, List<Wire>> resolved = resolver.resolve(context);
        Set<Resource> resources = resolved.keySet();
        Resource resource = getResource(resources, "org.apache.felix.gogo.runtime", "0.10");
        assertNotNull(resource);
    } catch (ResolutionException e) {
        fail("Resolve failed");
    }
}
Also used : CapReqBuilder(aQute.bnd.osgi.resource.CapReqBuilder) Resolver(org.osgi.service.resolver.Resolver) MockRegistry(test.lib.MockRegistry) ArrayList(java.util.ArrayList) Resource(org.osgi.resource.Resource) ResolutionException(org.osgi.service.resolver.ResolutionException) Requirement(org.osgi.resource.Requirement) ArrayList(java.util.ArrayList) List(java.util.List) BndEditModel(aQute.bnd.build.model.BndEditModel)

Aggregations

Resolver (org.osgi.service.resolver.Resolver)16 ArrayList (java.util.ArrayList)12 Resource (org.osgi.resource.Resource)12 Requirement (org.osgi.resource.Requirement)11 List (java.util.List)10 Repository (org.osgi.service.repository.Repository)7 BndEditModel (aQute.bnd.build.model.BndEditModel)6 MockRegistry (test.lib.MockRegistry)6 CapReqBuilder (aQute.bnd.osgi.resource.CapReqBuilder)5 Capability (org.osgi.resource.Capability)5 ResolutionException (org.osgi.service.resolver.ResolutionException)5 Collection (java.util.Collection)4 Processor (aQute.bnd.osgi.Processor)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 Wire (org.osgi.resource.Wire)3 Parameters (aQute.bnd.header.Parameters)2 IdentityCapability (aQute.bnd.osgi.resource.ResourceUtils.IdentityCapability)2 InfoRepository (aQute.bnd.service.repository.InfoRepository)2 BndResolver (biz.aQute.resolve.BndResolver)2