Search in sources :

Example 16 with BndEditModel

use of aQute.bnd.build.model.BndEditModel in project bnd by bndtools.

the class BndrunResolveContextTest method testInputRequirementsAsMandatoryResource.

public static void testInputRequirementsAsMandatoryResource() {
    MockRegistry registry = new MockRegistry();
    registry.addPlugin(createRepo(IO.getFile("testdata/repo3.index.xml")));
    BndEditModel runModel = new BndEditModel();
    runModel.setRunFw("org.apache.felix.framework");
    Requirement req = new CapReqBuilder("osgi.identity").addDirective("filter", "(osgi.identity=org.apache.felix.gogo.command)").buildSyntheticRequirement();
    runModel.setRunRequires(Collections.singletonList(req));
    BndrunResolveContext context = new BndrunResolveContext(runModel, registry, log);
    context.init();
    assertEquals(IO.getFile("testdata/repo3/org.apache.felix.framework-4.0.2.jar").toURI(), findContentURI(context.getFramework()));
    Collection<Resource> mandRes = context.getMandatoryResources();
    assertEquals(1, mandRes.size());
    Resource resource = mandRes.iterator().next();
    assertNotNull(resource);
    IdentityCapability ic = ResourceUtils.getIdentityCapability(resource);
    assertNotNull(ic);
    assertEquals("<<INITIAL>>", ic.osgi_identity());
}
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) IdentityCapability(aQute.bnd.osgi.resource.ResourceUtils.IdentityCapability)

Example 17 with BndEditModel

use of aQute.bnd.build.model.BndEditModel in project bnd by bndtools.

the class BndrunResolveContextTest method testProviderPreference.

public static void testProviderPreference() {
    Requirement req = new CapReqBuilder("osgi.wiring.package").addDirective("filter", "(osgi.wiring.package=org.apache.felix.gogo.api)").buildSyntheticRequirement();
    MockRegistry registry;
    BndrunResolveContext context;
    List<Capability> providers;
    Resource resource;
    // First try it with repo1 first
    registry = new MockRegistry();
    registry.addPlugin(createRepo(IO.getFile("testdata/repo1.index.xml")));
    registry.addPlugin(createRepo(IO.getFile("testdata/repo2.index.xml")));
    context = new BndrunResolveContext(new BndEditModel(), registry, log);
    providers = context.findProviders(req);
    assertEquals(2, providers.size());
    resource = providers.get(0).getResource();
    assertEquals(IO.getFile("testdata/repo1/org.apache.felix.gogo.runtime-0.10.0.jar").toURI(), findContentURI(resource));
    resource = providers.get(1).getResource();
    assertEquals(IO.getFile("testdata/repo2/org.apache.felix.gogo.runtime-0.10.0.jar").toURI(), findContentURI(resource));
    // Now try it with repo2 first
    registry = new MockRegistry();
    registry.addPlugin(createRepo(IO.getFile("testdata/repo2.index.xml")));
    registry.addPlugin(createRepo(IO.getFile("testdata/repo1.index.xml")));
    context = new BndrunResolveContext(new BndEditModel(), registry, log);
    providers = context.findProviders(req);
    assertEquals(2, providers.size());
    resource = providers.get(0).getResource();
    assertEquals(IO.getFile("testdata/repo2/org.apache.felix.gogo.runtime-0.10.0.jar").toURI(), findContentURI(resource));
    resource = providers.get(1).getResource();
    assertEquals(IO.getFile("testdata/repo1/org.apache.felix.gogo.runtime-0.10.0.jar").toURI(), findContentURI(resource));
}
Also used : CapReqBuilder(aQute.bnd.osgi.resource.CapReqBuilder) Requirement(org.osgi.resource.Requirement) Capability(org.osgi.resource.Capability) IdentityCapability(aQute.bnd.osgi.resource.ResourceUtils.IdentityCapability) MockRegistry(test.lib.MockRegistry) Resource(org.osgi.resource.Resource) BndEditModel(aQute.bnd.build.model.BndEditModel)

Example 18 with BndEditModel

use of aQute.bnd.build.model.BndEditModel in project bnd by bndtools.

the class BndrunResolveContextTest method testResolverHookFiltersResultWithBlacklistAndVersionRange2.

public static void testResolverHookFiltersResultWithBlacklistAndVersionRange2() {
    MockRegistry registry = new MockRegistry();
    registry.addPlugin(createRepo(new File("testdata/osgi.cmpn-4.3.0.index.xml")));
    registry.addPlugin(createRepo(new File("testdata/org.apache.felix.framework-4.0.2.index.xml")));
    // Add a hook that removes all capabilities from resource with id
    // "osgi.cmpn"
    HashMap<String, String> blacklistProp = new HashMap<String, String>();
    BndEditModel runModel = new BndEditModel();
    ArrayList<Requirement> blacklistlist = new ArrayList<Requirement>();
    blacklistlist.add(CapReqBuilder.createSimpleRequirement("osgi.identity", "osgi.cmpn", "[4.0.0,4.4.0)").buildSyntheticRequirement());
    runModel.setRunBlacklist(blacklistlist);
    runModel.setRunFw("org.apache.felix.framework");
    Requirement requirement = new CapReqBuilder("osgi.wiring.package").addDirective("filter", "(&(osgi.wiring.package=org.osgi.util.tracker)(version>=1.5)(!(version>=1.6)))").buildSyntheticRequirement();
    BndrunResolveContext context = new BndrunResolveContext(runModel, registry, log);
    List<Capability> providers = context.findProviders(requirement);
    assertEquals(1, providers.size());
    assertEquals(new File("testdata/org.apache.felix.framework-4.0.2.jar").toURI(), findContentURI(providers.get(0).getResource()));
}
Also used : CapReqBuilder(aQute.bnd.osgi.resource.CapReqBuilder) Capability(org.osgi.resource.Capability) IdentityCapability(aQute.bnd.osgi.resource.ResourceUtils.IdentityCapability) HashMap(java.util.HashMap) MockRegistry(test.lib.MockRegistry) ArrayList(java.util.ArrayList) Requirement(org.osgi.resource.Requirement) File(java.io.File) BndEditModel(aQute.bnd.build.model.BndEditModel)

Example 19 with BndEditModel

use of aQute.bnd.build.model.BndEditModel in project bnd by bndtools.

the class BndrunResolveContextTest method testResolverHookFiltersResultWithBlacklistAndVersionRange1.

public static void testResolverHookFiltersResultWithBlacklistAndVersionRange1() {
    MockRegistry registry = new MockRegistry();
    registry.addPlugin(createRepo(new File("testdata/osgi.cmpn-4.3.0.index.xml")));
    registry.addPlugin(createRepo(new File("testdata/org.apache.felix.framework-4.0.2.index.xml")));
    // Add a hook that removes all capabilities from resource with id
    // "osgi.cmpn"
    HashMap<String, String> blacklistProp = new HashMap<String, String>();
    BndEditModel runModel = new BndEditModel();
    ArrayList<Requirement> blacklistlist = new ArrayList<Requirement>();
    blacklistlist.add(CapReqBuilder.createSimpleRequirement("osgi.identity", "osgi.cmpn", "[4.0.0,4.3.0)").buildSyntheticRequirement());
    runModel.setRunBlacklist(blacklistlist);
    runModel.setRunFw("org.apache.felix.framework");
    Requirement requirement = new CapReqBuilder("osgi.wiring.package").addDirective("filter", "(&(osgi.wiring.package=org.osgi.util.tracker)(version>=1.5)(!(version>=1.6)))").buildSyntheticRequirement();
    BndrunResolveContext context = new BndrunResolveContext(runModel, registry, log);
    List<Capability> providers = context.findProviders(requirement);
    assertEquals(2, providers.size());
    assertEquals(new File("testdata/org.apache.felix.framework-4.0.2.jar").toURI(), findContentURI(providers.get(0).getResource()));
    assertEquals(new File("testdata/osgi.cmpn-4.3.0.jar").toURI(), findContentURI(providers.get(1).getResource()));
}
Also used : CapReqBuilder(aQute.bnd.osgi.resource.CapReqBuilder) Capability(org.osgi.resource.Capability) IdentityCapability(aQute.bnd.osgi.resource.ResourceUtils.IdentityCapability) HashMap(java.util.HashMap) MockRegistry(test.lib.MockRegistry) ArrayList(java.util.ArrayList) Requirement(org.osgi.resource.Requirement) File(java.io.File) BndEditModel(aQute.bnd.build.model.BndEditModel)

Example 20 with BndEditModel

use of aQute.bnd.build.model.BndEditModel in project bnd by bndtools.

the class BndrunResolveContextTest method testEERequirementResolvesFramework.

public static void testEERequirementResolvesFramework() {
    MockRegistry registry = new MockRegistry();
    registry.addPlugin(createRepo(IO.getFile("testdata/repo3.index.xml")));
    BndEditModel runModel = new BndEditModel();
    runModel.setRunFw("org.apache.felix.framework");
    runModel.setEE(EE.JavaSE_1_6);
    BndrunResolveContext context = new BndrunResolveContext(runModel, registry, log);
    Requirement req = new CapReqBuilder("osgi.ee").addDirective("filter", "(osgi.ee=J2SE-1.5)").buildSyntheticRequirement();
    List<Capability> providers = context.findProviders(req);
    assertEquals(1, providers.size());
    assertEquals(IO.getFile("testdata/repo3/org.apache.felix.framework-4.0.2.jar").toURI(), findContentURI(providers.get(0).getResource()));
}
Also used : CapReqBuilder(aQute.bnd.osgi.resource.CapReqBuilder) Requirement(org.osgi.resource.Requirement) Capability(org.osgi.resource.Capability) IdentityCapability(aQute.bnd.osgi.resource.ResourceUtils.IdentityCapability) MockRegistry(test.lib.MockRegistry) BndEditModel(aQute.bnd.build.model.BndEditModel)

Aggregations

BndEditModel (aQute.bnd.build.model.BndEditModel)55 Requirement (org.osgi.resource.Requirement)35 MockRegistry (test.lib.MockRegistry)34 CapReqBuilder (aQute.bnd.osgi.resource.CapReqBuilder)32 IdentityCapability (aQute.bnd.osgi.resource.ResourceUtils.IdentityCapability)25 Capability (org.osgi.resource.Capability)25 File (java.io.File)15 Resource (org.osgi.resource.Resource)15 ArrayList (java.util.ArrayList)12 Document (aQute.bnd.properties.Document)8 List (java.util.List)7 Workspace (aQute.bnd.build.Workspace)6 Resolver (org.osgi.service.resolver.Resolver)6 ExportedPackage (aQute.bnd.build.model.clauses.ExportedPackage)5 VersionedClause (aQute.bnd.build.model.clauses.VersionedClause)5 IOException (java.io.IOException)5 HashMap (java.util.HashMap)5 IFile (org.eclipse.core.resources.IFile)4 CoreException (org.eclipse.core.runtime.CoreException)4 ResolutionException (org.osgi.service.resolver.ResolutionException)4