Search in sources :

Example 1 with RequirementBuilder

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

the class PomRepositoryTest method testMultipleRevisions.

public void testMultipleRevisions() throws Exception {
    BndPomRepository mcsr = new BndPomRepository();
    Workspace w = Workspace.createStandaloneWorkspace(new Processor(), tmp.toURI());
    w.setBase(tmp);
    mcsr.setRegistry(w);
    File local = new File(tmp, "m2-repository");
    local.mkdirs();
    Map<String, String> config = new HashMap<>();
    config.put("name", "test-dependencies");
    String revisions = Strings.join(new String[] { "biz.aQute.bnd:biz.aQute.junit:3.3.0", "biz.aQute.bnd:biz.aQute.launcher:3.3.0", "biz.aQute.bnd:biz.aQute.remote.launcher:3.3.0", "biz.aQute.bnd:biz.aQute.tester:3.3.0" });
    config.put("revision", revisions);
    config.put("snapshotUrls", "https://repo1.maven.org/maven2/");
    config.put("releaseUrls", "https://repo1.maven.org/maven2/");
    config.put("local", local.getAbsolutePath());
    config.put("transitive", "true");
    mcsr.setProperties(config);
    List<String> list = mcsr.list(null);
    assertNotNull(list);
    assertEquals(4, list.size());
    RequirementBuilder builder = mcsr.newRequirementBuilder("osgi.identity");
    builder.addAttribute("filter", "(osgi.identity=biz.aQute.tester)");
    Promise<Collection<Resource>> providers = mcsr.findProviders(builder.buildExpression());
    Collection<Resource> resources = providers.getValue();
    assertFalse(resources.isEmpty());
}
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) File(java.io.File) Workspace(aQute.bnd.build.Workspace)

Example 2 with RequirementBuilder

use of org.osgi.service.repository.RequirementBuilder 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 3 with RequirementBuilder

use of org.osgi.service.repository.RequirementBuilder 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 4 with RequirementBuilder

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

the class PomRepositoryTest method testMultiplePomFiles.

public void testMultiplePomFiles() throws Exception {
    BndPomRepository mcsr = new BndPomRepository();
    Workspace w = Workspace.createStandaloneWorkspace(new Processor(), tmp.toURI());
    w.setBase(tmp);
    mcsr.setRegistry(w);
    File local = new File(tmp, "m2-repository");
    local.mkdirs();
    Map<String, String> config = new HashMap<>();
    config.put("name", "test-dependencies");
    String pomFiles = Strings.join(new String[] { "testdata/pomrepo/simple.xml", "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("pom", pomFiles);
    config.put("snapshotUrls", "https://repo1.maven.org/maven2/");
    config.put("releaseUrls", "https://repo1.maven.org/maven2/");
    config.put("local", local.getAbsolutePath());
    mcsr.setProperties(config);
    List<String> list = mcsr.list(null);
    assertNotNull(list);
    assertEquals(2, list.size());
    RequirementBuilder builder = mcsr.newRequirementBuilder("osgi.identity");
    builder.addAttribute("filter", "(osgi.identity=org.apache.felix.gogo.shell)");
    Promise<Collection<Resource>> providers = mcsr.findProviders(builder.buildExpression());
    Collection<Resource> resources = providers.getValue();
    assertFalse(resources.isEmpty());
    builder = mcsr.newRequirementBuilder("osgi.identity");
    builder.addAttribute("filter", "(osgi.identity=osgi.core)");
    providers = mcsr.findProviders(builder.buildExpression());
    resources = providers.getValue();
    assertFalse(resources.isEmpty());
}
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) File(java.io.File) Workspace(aQute.bnd.build.Workspace)

Aggregations

Workspace (aQute.bnd.build.Workspace)4 Processor (aQute.bnd.osgi.Processor)4 Collection (java.util.Collection)4 HashMap (java.util.HashMap)4 Resource (org.osgi.resource.Resource)4 RequirementBuilder (org.osgi.service.repository.RequirementBuilder)4 File (java.io.File)2