Search in sources :

Example 86 with Resource

use of org.osgi.resource.Resource in project bnd by bndtools.

the class ProjectResolverTest method add.

private void add(ResourcesRepository fr, File file) throws Exception {
    ResourceBuilder rb = new ResourceBuilder();
    rb.addFile(file, file.toURI());
    Resource resource = rb.build();
    fr.add(resource);
}
Also used : ResourceBuilder(aQute.bnd.osgi.resource.ResourceBuilder) Resource(org.osgi.resource.Resource) EmbeddedResource(aQute.bnd.osgi.EmbeddedResource)

Example 87 with Resource

use of org.osgi.resource.Resource in project bnd by bndtools.

the class ResolveProcessTest method testBigNastyResolveRequired.

public void testBigNastyResolveRequired() throws ResolutionException, MalformedURLException, URISyntaxException {
    ResolveProcess process = new ResolveProcess();
    ResolverLogger logger = new ResolverLogger();
    MockRegistry registry = new MockRegistry();
    registry.addPlugin(getIndex("testdata/repo7/index.xml"));
    registry.addPlugin(getIndex("testdata/repo7/index-aries.xml"));
    registry.addPlugin(getIndex("testdata/repo7/index-gemini.xml"));
    registry.addPlugin(getIndex("testdata/repo7/index-local.xml"));
    Processor model = new Processor();
    model.setProperty("-runfw", "org.apache.felix.framework");
    model.setProperty("-runrequires", "osgi.extender;filter:='(osgi.extender=osgi.component)'");
    Map<Resource, List<Wire>> requiredResources = process.resolveRequired(model, null, registry, new BndResolver(logger), Collections.<ResolutionCallback>emptyList(), logger);
    Collection<Resource> optionalResources = process.getOptionalResources();
    assertEquals(1, requiredResources.size());
    assertEquals(13, optionalResources.size());
    SortedSet<Resource> set = new TreeSet<Resource>(new ResourceComparator());
    set.addAll(optionalResources);
    Iterator<Resource> it = set.iterator();
    checkOptionalResource(process, it.next(), "org.apache.felix.configadmin", parseVersion("1.8.2"), "org.osgi.service.cm");
    checkOptionalResource(process, it.next(), "org.apache.felix.configadmin", parseVersion("1.8.8"), "org.osgi.service.cm");
    checkOptionalResource(process, it.next(), "org.apache.felix.gogo.command", parseVersion("0.12.0"), "org.osgi.service.log");
    checkOptionalResource(process, it.next(), "org.apache.felix.gogo.runtime", parseVersion("0.10.0"), "org.apache.felix.service.command");
    checkOptionalResource(process, it.next(), "org.apache.felix.log", parseVersion("1.0.1"), "org.osgi.service.log");
    checkOptionalResource(process, it.next(), "org.apache.felix.metatype", parseVersion("1.0.4"), "org.osgi.service.metatype");
    checkOptionalResource(process, it.next(), "org.apache.felix.metatype", parseVersion("1.1.0"), "org.osgi.service.metatype");
    checkOptionalResource(process, it.next(), "org.apache.felix.shell", parseVersion("1.4.2"), "org.osgi.service.log", "org.apache.felix.shell");
    checkOptionalResource(process, it.next(), "org.eclipse.osgi.services", parseVersion("3.1.200.v20070605"), "org.osgi.service.cm", "org.osgi.service.log", "org.osgi.service.metatype");
    checkOptionalResource(process, it.next(), "org.ops4j.pax.logging.pax-logging-api", parseVersion("1.4.0"), "org.osgi.service.log");
    checkOptionalResource(process, it.next(), "osgi.cmpn", parseVersion("4.3.1.201210102024"), "org.osgi.service.cm", "org.osgi.service.log", "org.osgi.service.metatype");
    checkOptionalResource(process, it.next(), "osgi.cmpn", parseVersion("5.0.0.201305092017"), "org.osgi.service.cm", "org.osgi.service.log", "org.osgi.service.metatype");
    checkOptionalResource(process, it.next(), "osgi.enterprise", parseVersion("4.2.0.201003190513"), "org.osgi.service.cm", "org.osgi.service.log", "org.osgi.service.metatype");
}
Also used : Processor(aQute.bnd.osgi.Processor) MockRegistry(test.lib.MockRegistry) Resource(org.osgi.resource.Resource) TreeSet(java.util.TreeSet) List(java.util.List)

Example 88 with Resource

use of org.osgi.resource.Resource in project bnd by bndtools.

the class ValidatorTest method testValidatingResourcesWithDocumentaryAttributes.

public void testValidatingResourcesWithDocumentaryAttributes() throws Exception {
    try (ResolverValidator validator = new ResolverValidator()) {
        ResourceBuilder system = new ResourceBuilder();
        system.addEE(EE.JavaSE_1_8);
        system.addManifest(OSGI_CORE.R6_0_0.getManifest());
        validator.setSystem(system.build());
        validator.setTrace(true);
        ResourcesRepository repository = new ResourcesRepository();
        ResourceBuilder builder = new ResourceBuilder();
        File file = IO.getFile("testdata/osgi.cmpn-4.3.0.jar");
        builder.addFile(file, file.toURI());
        repository.add(builder.build());
        builder = new ResourceBuilder();
        file = IO.getFile("testdata/org.apache.felix.framework-4.0.0.jar");
        builder.addFile(file, file.toURI());
        repository.add(builder.build());
        List<Resource> resources = repository.getResources();
        validator.validateResources(repository, resources);
        assertTrue(validator.check());
    }
}
Also used : ResourceBuilder(aQute.bnd.osgi.resource.ResourceBuilder) Resource(org.osgi.resource.Resource) File(java.io.File) ResourcesRepository(aQute.bnd.osgi.repository.ResourcesRepository)

Example 89 with Resource

use of org.osgi.resource.Resource 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 90 with Resource

use of org.osgi.resource.Resource in project bnd by bndtools.

the class BndrunResolveContextTest method testBlacklistFramework.

/**
	 * See if we can reject the 4.0.2 framework, which should normally be
	 * selected because it is the highest (this is tested later).
	 */
public static void testBlacklistFramework() {
    MockRegistry registry = new MockRegistry();
    registry.addPlugin(createRepo(IO.getFile("testdata/org.apache.felix.framework-4.0.0.index.xml")));
    registry.addPlugin(createRepo(IO.getFile("testdata/org.apache.felix.framework-4.0.2.index.xml")));
    BndEditModel model = new BndEditModel();
    model.setRunFw("org.apache.felix.framework;version='[4,4.1)'");
    Requirement blacklist = new CapReqBuilder("osgi.identity").addDirective("filter", "(&(osgi.identity=org.apache.felix.framework)(version>=4.0.1))").buildSyntheticRequirement();
    model.setRunBlacklist(Arrays.asList(blacklist));
    BndrunResolveContext context = new BndrunResolveContext(model, registry, log);
    context.init();
    Resource framework = context.getFramework();
    assertNotNull(framework);
    assertEquals(IO.getFile("testdata/org.apache.felix.framework-4.0.0.jar").toURI(), findContentURI(framework));
}
Also used : CapReqBuilder(aQute.bnd.osgi.resource.CapReqBuilder) Requirement(org.osgi.resource.Requirement) MockRegistry(test.lib.MockRegistry) Resource(org.osgi.resource.Resource) BndEditModel(aQute.bnd.build.model.BndEditModel)

Aggregations

Resource (org.osgi.resource.Resource)201 Capability (org.osgi.resource.Capability)62 Requirement (org.osgi.resource.Requirement)62 ArrayList (java.util.ArrayList)57 List (java.util.List)39 HashMap (java.util.HashMap)32 File (java.io.File)27 Collection (java.util.Collection)24 Wire (org.osgi.resource.Wire)24 ResourceBuilder (aQute.bnd.osgi.resource.ResourceBuilder)23 Map (java.util.Map)22 CapReqBuilder (aQute.bnd.osgi.resource.CapReqBuilder)18 URI (java.net.URI)18 HashSet (java.util.HashSet)18 BndEditModel (aQute.bnd.build.model.BndEditModel)15 MockRegistry (test.lib.MockRegistry)15 Version (org.osgi.framework.Version)14 BundleRevision (org.osgi.framework.wiring.BundleRevision)14 Repository (org.osgi.service.repository.Repository)14 IdentityCapability (aQute.bnd.osgi.resource.ResourceUtils.IdentityCapability)13