Search in sources :

Example 96 with Resource

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

the class PomRepositoryTest method testBndPomRepoURI.

public void testBndPomRepoURI() throws Exception {
    final BndPomRepository bpr = new BndPomRepository();
    Workspace w = Workspace.createStandaloneWorkspace(new Processor(), tmp.toURI());
    w.setBase(tmp);
    bpr.setRegistry(w);
    Map<String, String> config = new HashMap<>();
    config.put("pom", "https://repo1.maven.org/maven2/org/apache/felix/org.apache.felix.gogo.shell/0.12.0/org.apache.felix.gogo.shell-0.12.0.pom");
    config.put("snapshotUrls", "https://repo1.maven.org/maven2/");
    config.put("releaseUrls", "https://repo1.maven.org/maven2/");
    config.put("name", "test");
    bpr.setProperties(config);
    List<String> list = bpr.list(null);
    assertNotNull(list);
    assertEquals(1, list.size());
    RequirementBuilder builder = bpr.newRequirementBuilder("osgi.identity");
    builder.addDirective("filter", "(osgi.identity=org.apache.felix.gogo.runtime)");
    Promise<Collection<Resource>> providers = bpr.findProviders(builder.buildExpression());
    Collection<Resource> resources = providers.getValue();
    assertFalse(resources.isEmpty());
    assertEquals(1, resources.size());
}
Also used : Processor(aQute.bnd.osgi.Processor) HashMap(java.util.HashMap) Resource(org.osgi.resource.Resource) Collection(java.util.Collection) RequirementBuilder(org.osgi.service.repository.RequirementBuilder) Workspace(aQute.bnd.build.Workspace)

Example 97 with Resource

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

the class PomRepositoryTest method testRepository.

public void testRepository() throws Exception {
    MavenRepository repo = getRepo();
    Revision revision = Revision.valueOf("bcel:bcel:5.1");
    PomRepository pom = new PomRepository(repo, client, location).revisions(Collections.singleton(revision));
    assertTrue(location.isFile());
    try (XMLResourceParser xp = new XMLResourceParser(location)) {
        List<Resource> parse = xp.parse();
        assertEquals(parse.size(), pom.getResources().size());
    }
}
Also used : MavenRepository(aQute.maven.provider.MavenRepository) Revision(aQute.maven.api.Revision) Resource(org.osgi.resource.Resource) XMLResourceParser(aQute.bnd.osgi.repository.XMLResourceParser)

Example 98 with Resource

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

the class PomRepositoryTest method testSearchRepoMultipleConfigurationsDontBreak.

public void testSearchRepoMultipleConfigurationsDontBreak() throws Exception {
    Workspace w = Workspace.createStandaloneWorkspace(new Processor(), tmp.toURI());
    w.setBase(tmp);
    BndPomRepository mcsrBnd320 = new BndPomRepository();
    mcsrBnd320.setRegistry(w);
    Map<String, String> config = new HashMap<>();
    config.put("query", "q=g:biz.aQute.bnd+a:biz.aQute.bnd+AND+v:3.2.0");
    config.put("name", "bnd320");
    mcsrBnd320.setProperties(config);
    BndPomRepository mcsrBnd330 = new BndPomRepository();
    mcsrBnd330.setRegistry(w);
    config = new HashMap<>();
    config.put("query", "q=g:biz.aQute.bnd+a:biz.aQute.bnd+AND+v:3.3.0");
    config.put("name", "bnd330");
    mcsrBnd330.setProperties(config);
    List<String> list320 = mcsrBnd320.list(null);
    assertNotNull(list320);
    assertEquals(1, list320.size());
    List<String> list330 = mcsrBnd330.list(null);
    assertNotNull(list330);
    assertEquals(1, list330.size());
    // check the first repo to make sure it's there.
    RequirementBuilder builder = mcsrBnd320.newRequirementBuilder("osgi.identity");
    builder.addDirective("filter", "(&(osgi.identity=biz.aQute.bnd)(version>=3.2.0)(!(version>=3.3.0)))");
    Promise<Collection<Resource>> providers = mcsrBnd320.findProviders(builder.buildExpression());
    Collection<Resource> resources = providers.getValue();
    assertFalse(resources.isEmpty());
    assertEquals(1, resources.size());
    // make sure it's not in the second repo, otherwise the caches are
    // messed up.
    providers = mcsrBnd330.findProviders(builder.buildExpression());
    resources = providers.getValue();
    assertTrue(resources.isEmpty());
    assertEquals(0, resources.size());
}
Also used : Processor(aQute.bnd.osgi.Processor) HashMap(java.util.HashMap) Resource(org.osgi.resource.Resource) RequirementBuilder(org.osgi.service.repository.RequirementBuilder) Collection(java.util.Collection) Workspace(aQute.bnd.build.Workspace)

Example 99 with Resource

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

the class PomRepositoryTest method assertAllBndCap.

void assertAllBndCap(Map<Archive, Resource> value) {
    for (Resource resource : value.values()) {
        List<Capability> capabilities = resource.getCapabilities(IdentityNamespace.IDENTITY_NAMESPACE);
        assertNotNull(capabilities);
        assertEquals(1, capabilities.size());
        capabilities = resource.getCapabilities("bnd.info");
        Capability c = capabilities.get(0);
        String a = (String) c.getAttributes().get("name");
        Archive archive = Archive.valueOf(a);
        assertNotNull(archive);
    }
}
Also used : Archive(aQute.maven.api.Archive) Capability(org.osgi.resource.Capability) Resource(org.osgi.resource.Resource)

Example 100 with Resource

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

the class TestObrCapReqParsing method testObrContentReqs.

public static void testObrContentReqs() throws Exception {
    FileInputStream stream = new FileInputStream("testdata/fullobr.xml");
    URI baseUri = new File("testdata").toURI();
    List<Resource> resources = parseIndex(stream, baseUri);
    assertEquals(7, resources.size());
    // Check package imports of emf.minimal 2.7.0
    List<Requirement> pkgReqs = resources.get(0).getRequirements("osgi.wiring.package");
    assertNotNull(pkgReqs);
    assertEquals(20, pkgReqs.size());
    // Check mandatory/optional and filters
    assertNull(pkgReqs.get(0).getDirectives().get("resolution"));
    assertEquals("optional", pkgReqs.get(5).getDirectives().get("resolution"));
    assertEquals("(&(osgi.wiring.package=javax.crypto)(version>=0.0.0))", pkgReqs.get(0).getDirectives().get("filter"));
    // Check service requires of felix.shell
    List<Requirement> svcReqs = resources.get(4).getRequirements("osgi.service");
    assertNotNull(svcReqs);
    assertEquals(2, svcReqs.size());
    assertEquals("(osgi.service=org.osgi.service.startlevel.StartLevel)", svcReqs.get(0).getDirectives().get("filter"));
    assertEquals("(osgi.service=org.osgi.service.packageadmin.PackageAdmin)", svcReqs.get(1).getDirectives().get("filter"));
}
Also used : Requirement(org.osgi.resource.Requirement) Resource(org.osgi.resource.Resource) URI(java.net.URI) File(java.io.File) FileInputStream(java.io.FileInputStream)

Aggregations

Resource (org.osgi.resource.Resource)197 Requirement (org.osgi.resource.Requirement)62 Capability (org.osgi.resource.Capability)61 ArrayList (java.util.ArrayList)54 List (java.util.List)37 HashMap (java.util.HashMap)31 File (java.io.File)27 Collection (java.util.Collection)24 ResourceBuilder (aQute.bnd.osgi.resource.ResourceBuilder)23 Wire (org.osgi.resource.Wire)22 Map (java.util.Map)21 CapReqBuilder (aQute.bnd.osgi.resource.CapReqBuilder)18 URI (java.net.URI)18 BndEditModel (aQute.bnd.build.model.BndEditModel)15 HashSet (java.util.HashSet)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