Search in sources :

Example 6 with BndEditModel

use of aQute.bnd.build.model.BndEditModel 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 7 with BndEditModel

use of aQute.bnd.build.model.BndEditModel 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)

Example 8 with BndEditModel

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

the class BndrunResolveContextTest method testResolveSystemCapabilitiesExtra.

public static void testResolveSystemCapabilitiesExtra() {
    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);
    runModel.genericSet("-runsystemcapabilities", "osgi.extender;osgi.extender=foobar;version:Version=1.0");
    BndrunResolveContext context = new BndrunResolveContext(runModel, registry, log);
    Requirement req = new CapReqBuilder("osgi.extender").addDirective("filter", "(&(osgi.extender=foobar)(version>=1.0))").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)

Example 9 with BndEditModel

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

the class BndrunResolveContextTest method testResolveSystemBundleAlias.

public static void testResolveSystemBundleAlias() {
    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.wiring.host").addDirective("filter", "(osgi.wiring.host=system.bundle)").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)

Example 10 with BndEditModel

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

the class BndrunResolveContextTest method testJREPackageNotResolved.

public static void testJREPackageNotResolved() {
    MockRegistry registry = new MockRegistry();
    registry.addPlugin(createRepo(IO.getFile("testdata/repo3.index.xml")));
    BndEditModel runModel = new BndEditModel();
    runModel.setRunFw("org.apache.felix.framework");
    // javax.annotation added in Java 6
    runModel.setEE(EE.J2SE_1_5);
    BndrunResolveContext context = new BndrunResolveContext(runModel, registry, log);
    Requirement req = CapReqBuilder.createPackageRequirement("javax.annotation", null).buildSyntheticRequirement();
    List<Capability> providers = context.findProviders(req);
    assertEquals(0, providers.size());
}
Also used : 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